Ejemplo n.º 1
0
 /**
  * @brief generates the VEVENT/VTODO/VJOURNAL with UTC dates
  * @param array $event
  * @return string
  */
 private static function generateEvent($event)
 {
     $object = OC_VObject::parse($event['calendardata']);
     if (!$object) {
         return false;
     }
     $sharedAccessClassPermissions = OC_Calendar_Object::getAccessClassPermissions($object);
     if (OC_Calendar_Object::getowner($event['id']) !== OCP\User::getUser()) {
         if (!($sharedAccessClassPermissions & OCP\PERMISSION_READ)) {
             return '';
         }
     }
     $object = OC_Calendar_Object::cleanByAccessClass($event['id'], $object);
     if ($object->VEVENT) {
         $dtstart = $object->VEVENT->DTSTART;
         $start_dt = $dtstart->getDateTime();
         $dtend = OC_Calendar_Object::getDTEndFromVEvent($object->VEVENT);
         $end_dt = $dtend->getDateTime();
         if ($dtstart->getDateType() !== Sabre\VObject\Property\DateTime::DATE) {
             $start_dt->setTimezone(new DateTimeZone('UTC'));
             $end_dt->setTimezone(new DateTimeZone('UTC'));
             $object->VEVENT->setDateTime('DTSTART', $start_dt, Sabre\VObject\Property\DateTime::UTC);
             $object->VEVENT->setDateTime('DTEND', $end_dt, Sabre\VObject\Property\DateTime::UTC);
         }
         return $object->VEVENT->serialize();
     }
     if ($object->VTODO) {
         return $object->VTODO->serialize();
     }
     if ($object->VJOURNAL) {
         return $object->VJOURNAL->serialize();
     }
     return '';
 }
Ejemplo n.º 2
0
 /**
  * Returns a list of ACE's for this node.
  *
  * Each ACE has the following properties:
  *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  *     currently the only supported privileges
  *   * 'principal', a url to the principal who owns the node
  *   * 'protected' (optional), indicating that this ACE is not allowed to
  *      be updated.
  *
  * @return array
  */
 public function getACL()
 {
     $readprincipal = $this->getOwner();
     $writeprincipal = $this->getOwner();
     $createprincipal = $this->getOwner();
     $deleteprincipal = $this->getOwner();
     $uid = OCA\Contacts\Addressbook::extractUserID($this->getOwner());
     $readWriteACL = array(array('privilege' => '{DAV:}read', 'principal' => 'principals/' . OCP\User::getUser(), 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => 'principals/' . OCP\User::getUser(), 'protected' => true));
     if ($uid != OCP\USER::getUser()) {
         $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $this->addressBookInfo['id']);
         if ($sharedAddressbook) {
             if ($sharedAddressbook['permissions'] & OCP\PERMISSION_CREATE && $sharedAddressbook['permissions'] & OCP\PERMISSION_UPDATE && $sharedAddressbook['permissions'] & OCP\PERMISSION_DELETE) {
                 return $readWriteACL;
             }
             if ($sharedAddressbook['permissions'] & OCP\PERMISSION_CREATE) {
                 $createprincipal = 'principals/' . OCP\USER::getUser();
             }
             if ($sharedAddressbook['permissions'] & OCP\PERMISSION_READ) {
                 $readprincipal = 'principals/' . OCP\USER::getUser();
             }
             if ($sharedAddressbook['permissions'] & OCP\PERMISSION_UPDATE) {
                 $writeprincipal = 'principals/' . OCP\USER::getUser();
             }
             if ($sharedAddressbook['permissions'] & OCP\PERMISSION_DELETE) {
                 $deleteprincipal = 'principals/' . OCP\USER::getUser();
             }
         }
     } else {
         return parent::getACL();
     }
     return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write-content', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}bind', 'principal' => $createprincipal, 'protected' => true), array('privilege' => '{DAV:}unbind', 'principal' => $deleteprincipal, 'protected' => true));
 }
Ejemplo n.º 3
0
 public static function log($target, $source, $mode)
 {
     $query = OCP\DB::prepare('SELECT * FROM `*PREFIX*sharing` WHERE `source` = ? AND `target` = ?');
     $info = $query->execute(array($source, $target))->fetchAll();
     $info = $info[0];
     //var_dump($info);
     $query = OCP\DB::prepare('INSERT INTO `*PREFIX*sharing_log` VALUES (?,?,?,?,?)');
     $query->execute(array($info['uid_owner'], $source, OCP\User::getUser(), time(), $mode));
     //die;
 }
Ejemplo n.º 4
0
 public static function share_user($params)
 {
     $path = $params['source'];
     $permissions = $params['permissions'];
     $with = $params['with'];
     $user = OCP\User::getUser();
     //$rw = $permissions & OC_Share::WRITE ? 'w' : 'o'; //FIXME OC_Share no longer exists, hack to check permissions
     $rw = $permissions & 1 ? 'w' : 'o';
     self::log('Shared "' . $path . '" (r' . $rw . ') with user "' . $with . '" by ' . $user);
 }
Ejemplo n.º 5
0
 public static function logout()
 {
     OCP\Config::setUserValue(OCP\User::getUser(), 'rainloop', 'rainloop-autologin-password', '');
     $sApiPath = __DIR__ . '/../app/index.php';
     if (file_exists($sApiPath)) {
         self::regRainLoopDataFunction();
         $_ENV['RAINLOOP_INCLUDE_AS_API'] = true;
         include $sApiPath;
         if (class_exists('\\RainLoop\\Api')) {
             \RainLoop\Api::LogoutCurrentLogginedUser();
         }
     }
     return true;
 }
Ejemplo n.º 6
0
function index()
{
    if (isset($_GET['fileid'])) {
        $fileIds = array($_GET['fileid']);
    } else {
        $fileIds = OCA\Search_Lucene\Indexer::getUnindexed();
    }
    $eventSource = new OC_EventSource();
    $eventSource->send('count', count($fileIds));
    $skippedDirs = explode(';', OCP\Config::getUserValue(OCP\User::getUser(), 'search_lucene', 'skipped_dirs', '.git;.svn;.CVS;.bzr'));
    foreach ($fileIds as $id) {
        $skipped = false;
        $fileStatus = OCA\Search_Lucene\Status::fromFileId($id);
        try {
            //before we start mark the file as error so we know there was a problem when the php execution dies
            $fileStatus->markError();
            $path = OC\Files\Filesystem::getPath($id);
            $eventSource->send('indexing', $path);
            foreach ($skippedDirs as $skippedDir) {
                if (strpos($path, '/' . $skippedDir . '/') !== false || strrpos($path, '/' . $skippedDir) === strlen($path) - (strlen($skippedDir) + 1)) {
                    $result = $fileStatus->markSkipped();
                    $skipped = true;
                    break;
                }
            }
            if (!$skipped) {
                if (OCA\Search_Lucene\Indexer::indexFile($path, OCP\User::getUser())) {
                    $result = $fileStatus->markIndexed();
                }
            }
            if (!$result) {
                OCP\JSON::error(array('message' => 'Could not index file.'));
                $eventSource->send('error', $path);
            }
        } catch (Exception $e) {
            //sqlite might report database locked errors when stock filescan is in progress
            //this also catches db locked exception that might come up when using sqlite
            \OCP\Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), \OCP\Util::ERROR);
            OCP\JSON::error(array('message' => 'Could not index file.'));
            $eventSource->send('error', $e->getMessage());
            //try to mark the file as new to let it reindex
            $fileStatus->markNew();
            // Add UI to trigger rescan of files with status 'E'rror?
        }
    }
    $eventSource->send('done', '');
    $eventSource->close();
}
Ejemplo n.º 7
0
function index()
{
    $fileIds = OCA\Search_Lucene\Indexer::getUnindexed();
    $eventSource = new OC_EventSource();
    $eventSource->send('count', count($fileIds));
    $skippedDirs = explode(';', OCP\Config::getUserValue(OCP\User::getUser(), 'search_lucene', 'skipped_dirs', '.git;.svn;.CVS;.bzr'));
    $query = OC_DB::prepare('INSERT INTO `*PREFIX*lucene_status` VALUES (?,?)');
    foreach ($fileIds as $id) {
        $skipped = false;
        try {
            //before we start mark the file as error so we know there was a problem when the php execution dies
            $result = $query->execute(array($id, 'E'));
            $path = OC\Files\Filesystem::getPath($id);
            $eventSource->send('indexing', $path);
            //clean jobs for indexed file
            $param = json_encode(array('path' => $path, 'user' => OCP\User::getUser()));
            $cleanjobquery = OC_DB::prepare('DELETE FROM `*PREFIX*queuedtasks` WHERE `app`=? AND `parameters`=?');
            $cleanjobquery->execute(array('search_lucene', $param));
            foreach ($skippedDirs as $skippedDir) {
                if (strpos($path, '/' . $skippedDir . '/') !== false || strrpos($path, '/' . $skippedDir) === strlen($path) - (strlen($skippedDir) + 1)) {
                    $result = $query->execute(array($id, 'S'));
                    $skipped = true;
                    break;
                }
            }
            if (!$skipped) {
                if (OCA\Search_Lucene\Indexer::indexFile($path, OCP\User::getUser())) {
                    $result = $query->execute(array($id, 'I'));
                }
            }
            if (!$result) {
                OC_JSON::error(array('message' => 'Could not index file.'));
                $eventSource->send('error', $path);
            }
        } catch (PDOException $e) {
            //sqlite might report database locked errors when stock filescan is in progress
            //this also catches db locked exception that might come up when using sqlite
            \OCP\Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), \OCP\Util::ERROR);
            OC_JSON::error(array('message' => 'Could not index file.'));
            $eventSource->send('error', $e->getMessage());
            //try to mark the file as new to let it reindex
            $query->execute(array($id, 'N'));
            // Add UI to trigger rescan of files with status 'E'rror?
        }
    }
    $eventSource->send('done', '');
    $eventSource->close();
}
Ejemplo n.º 8
0
	function __construct($widgetConf) {
		$this->id = $widgetConf['id'];
		$this->name = $widgetConf['name'];
		$this->l = OC_L10N::get('ocDashboard');
		$this->user = OCP\User::getUser();
		$this->conf = json_decode($widgetConf['conf'], true);
		$this->status = 0;
		$this->errorMsg = "";
		$this->htmlHash = "";
		$this->html = "";
		$this->interval = $widgetConf['refresh']*1000; // in seconds
		$this->icon = $widgetConf['icon'];
		$this->link = $widgetConf['link'];
		$this->cond = $widgetConf['cond'];
		$this->scripts = $widgetConf['scripts'];
		$this->styles = $widgetConf['styles'];

        //print_r(Array(OC_App::getAppPath('ocDashboard')."/l10n/widgets/".$this->id."/".OC_L10N::findLanguage().".php"));
        //$this->l->load("");
	}
Ejemplo n.º 9
0
 /**
  * Returns a list of ACE's for this node.
  *
  * Each ACE has the following properties:
  *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  *     currently the only supported privileges
  *   * 'principal', a url to the principal who owns the node
  *   * 'protected' (optional), indicating that this ACE is not allowed to
  *      be updated.
  *
  * @return array
  */
 public function getACL()
 {
     $readprincipal = $this->getOwner();
     $writeprincipal = $this->getOwner();
     $uid = OC_Calendar_Calendar::extractUserID($this->getOwner());
     if ($uid != OCP\USER::getUser()) {
         if ($uid === 'contact_birthdays') {
             $readprincipal = 'principals/' . OCP\User::getUser();
         } else {
             $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']);
             if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_READ) {
                 $readprincipal = 'principals/' . OCP\User::getUser();
             }
             if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_UPDATE) {
                 $writeprincipal = 'principals/' . OCP\User::getUser();
             }
         }
     }
     return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true), array('privilege' => '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true));
 }
Ejemplo n.º 10
0
 /**
  * Returns a list of ACE's for this node.
  *
  * Each ACE has the following properties:
  *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  *     currently the only supported privileges
  *   * 'principal', a url to the principal who owns the node
  *   * 'protected' (optional), indicating that this ACE is not allowed to
  *      be updated.
  *
  * @return array
  */
 public function getACL()
 {
     $readprincipal = $this->getOwner();
     $writeprincipal = $this->getOwner();
     $uid = OC_Calendar_Calendar::extractUserID($this->getOwner());
     if ($uid != OCP\USER::getUser()) {
         if ($uid === 'contact_birthdays') {
             $readprincipal = 'principals/' . OCP\User::getUser();
         } else {
             $object = OC_VObject::parse($this->objectData['calendardata']);
             $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']);
             $sharedAccessClassPermissions = OC_Calendar_Object::getAccessClassPermissions($object);
             if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_READ && $sharedAccessClassPermissions & OCP\PERMISSION_READ) {
                 $readprincipal = 'principals/' . OCP\USER::getUser();
             }
             if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\PERMISSION_UPDATE && $sharedAccessClassPermissions & OCP\PERMISSION_UPDATE) {
                 $writeprincipal = 'principals/' . OCP\USER::getUser();
             }
         }
     }
     return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true));
 }
Ejemplo n.º 11
0
 /**
  * @brief generates the VEVENT/VTODO/VJOURNAL with UTC dates
  * @param array $event
  * @return string
  */
 private static function generateEvent($event)
 {
     $object = OC_VObject::parse($event['calendardata']);
     if (!$object) {
         return false;
     }
     $sharedAccessClassPermissions = OC_Calendar_Object::getAccessClassPermissions($object);
     if (OC_Calendar_Object::getowner($event['id']) !== OCP\User::getUser()) {
         if (!($sharedAccessClassPermissions & OCP\PERMISSION_READ)) {
             return '';
         }
     }
     $object = OC_Calendar_Object::cleanByAccessClass($event['id'], $object);
     if ($object->VEVENT) {
         return $object->VEVENT->serialize();
     }
     if ($object->VTODO) {
         return $object->VTODO->serialize();
     }
     if ($object->VJOURNAL) {
         return $object->VJOURNAL->serialize();
     }
     return '';
 }
Ejemplo n.º 12
0
<?php

/**
 * @author Björn Schießle <*****@*****.**>
 * @author Lukas Reschke <*****@*****.**>
 * @author Morris Jobke <*****@*****.**>
 *
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
\OC::$server->getSession()->close();
$trashStatus = OCA\Files_Trashbin\Trashbin::isEmpty(OCP\User::getUser());
OCP\JSON::success(array("data" => array("isEmpty" => $trashStatus)));
Ejemplo n.º 13
0
 /**
  * @brief analyses the parameter for calendar parameter and returns the objects
  * @param (string) $calendarid - calendarid
  * @param (int) $start - unixtimestamp of start
  * @param (int) $end - unixtimestamp of end
  * @return (array) $events
  */
 public static function getrequestedEvents($calendarid, $start, $end)
 {
     $events = array();
     if ($calendarid == 'shared_events') {
         $singleevents = OCP\Share::getItemsSharedWith('event', OC_Share_Backend_Event::FORMAT_EVENT);
         $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
         foreach ($singleevents as $singleevent) {
             // Skip this single event if the whole calendar is already shared with the user.
             $calendarShared = false;
             foreach ($calendars as $calendar) {
                 if ($singleevent['calendarid'] === $calendar['id']) {
                     $calendarShared = true;
                     break;
                 }
             }
             if ($calendarShared === true) {
                 continue;
             }
             $singleevent['summary'] .= ' (' . self::$l10n->t('by') . ' ' . OC_Calendar_Object::getowner($singleevent['id']) . ')';
             $events[] = $singleevent;
         }
     } else {
         if (is_numeric($calendarid)) {
             $calendar = self::getCalendar($calendarid);
             OCP\Response::enableCaching(0);
             OCP\Response::setETagHeader($calendar['ctag']);
             $events = OC_Calendar_Object::allInPeriod($calendarid, $start, $end, $calendar['userid'] !== OCP\User::getUser());
         } else {
             OCP\Util::emitHook('OC_Calendar', 'getEvents', array('calendar_id' => $calendarid, 'events' => &$events));
         }
     }
     return $events;
 }
Ejemplo n.º 14
0
OCP\App::checkAppEnabled('contacts');
$bookid = isset($_GET['bookid']) ? $_GET['bookid'] : null;
$contactid = isset($_GET['contactid']) ? $_GET['contactid'] : null;
$selectedids = isset($_GET['selectedids']) ? $_GET['selectedids'] : null;
$nl = "\n";
if (!is_null($bookid)) {
    try {
        $addressbook = OCA\Contacts\Addressbook::find($bookid);
    } catch (Exception $e) {
        OCP\JSON::error(array('data' => array('message' => $e->getMessage())));
        exit;
    }
    header('Content-Type: text/directory');
    header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $addressbook['displayname']) . '.vcf');
    $start = 0;
    $batchsize = OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'export_batch_size', 20);
    while ($cardobjects = OCA\Contacts\VCard::all($bookid, $start, $batchsize, array('carddata'))) {
        foreach ($cardobjects as $card) {
            echo $card['carddata'] . $nl;
        }
        $start += $batchsize;
    }
} elseif (!is_null($contactid)) {
    try {
        $data = OCA\Contacts\VCard::find($contactid);
    } catch (Exception $e) {
        OCP\JSON::error(array('data' => array('message' => $e->getMessage())));
        exit;
    }
    header('Content-Type: text/vcard');
    header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $data['fullname']) . '.vcf');
Ejemplo n.º 15
0
 /**
  *
  * @param string $mountPoint Mount point
  * @param string $target The new mount point
  * @param string $mountType MOUNT_TYPE_GROUP | MOUNT_TYPE_USER
  * @return bool
  */
 public static function movePersonalMountPoint($mountPoint, $target, $mountType)
 {
     $mountPoint = rtrim($mountPoint, '/');
     $user = OCP\User::getUser();
     $mountPoints = self::readData($user);
     if (!isset($mountPoints[$mountType][$user][$mountPoint])) {
         return false;
     }
     $mountPoints[$mountType][$user][$target] = $mountPoints[$mountType][$user][$mountPoint];
     // Remove old mount point
     unset($mountPoints[$mountType][$user][$mountPoint]);
     self::writeData($user, $mountPoints);
     return true;
 }
Ejemplo n.º 16
0
 public static function moveToCalendar($id, $calendarid)
 {
     $calendar = OC_Calendar_Calendar::find($calendarid);
     if ($calendar['userid'] != OCP\User::getUser()) {
         $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $calendarid);
         if (!$sharedCalendar || !($sharedCalendar['permissions'] & OCP\PERMISSION_DELETE)) {
             throw new Exception(OC_Calendar_App::$l10n->t('You do not have the permissions to add events to this calendar.'));
         }
     }
     $stmt = OCP\DB::prepare('UPDATE `*PREFIX*clndr_objects` SET `calendarid`=? WHERE `id`=?');
     $stmt->execute(array($calendarid, $id));
     OC_Calendar_Calendar::touchCalendar($calendarid);
     OCP\Util::emitHook('OC_Calendar', 'moveEvent', $id);
     return true;
 }
Ejemplo n.º 17
0
 /**
  * check if a backup from the encryption keys exists
  *
  * @return boolean
  */
 public static function backupKeysExists()
 {
     //check if encryption was enabled in the past
     $backupExists = false;
     if (OC_App::isEnabled('files_encryption') === false) {
         $view = new OC\Files\View('/' . OCP\User::getUser());
         $backupPath = '/files_encryption/keyfiles.backup';
         if ($view->is_dir($backupPath)) {
             $dircontent = $view->getDirectoryContent($backupPath);
             if (!empty($dircontent)) {
                 $backupExists = true;
             }
         }
     }
     return $backupExists;
 }
Ejemplo n.º 18
0
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 * Displays <a href="http://opensource.org/licenses/AGPL-3.0">GNU AFFERO GENERAL PUBLIC LICENSE</a>
 * @license http://opensource.org/licenses/AGPL-3.0 GNU AFFERO GENERAL PUBLIC LICENSE
 *
 */
include_once "user_otp/lib/utils.php";
$l = OC_L10N::get('settings');
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('user_otp');
OCP\JSON::callCheck();
if ($_POST && $_POST["uid"] && OC_User::isAdminUser(OCP\User::getUser())) {
    OC_JSON::checkSubAdminUser();
    $uid = $_POST["uid"];
} else {
    $uid = OCP\User::getUser();
}
// Get data
$mOtp = new MultiOtpDb(OCP\Config::getAppValue('user_otp', 'EncryptionKey', 'DefaultCliEncryptionKey'));
$mOtp->EnableVerboseLog();
//$mOtp->SetDisplayLogOption(1);
if ($_POST && $_POST["otp_action"] === "delete_otp" && $mOtp->CheckUserExists($uid)) {
    if ($mOtp->DeleteUser($uid)) {
        OCP\JSON::success(array("data" => array("message" => $l->t("OTP Changed"))));
    } else {
        OCP\JSON::error(array("data" => array("message" => $l->t("check apps folder rights"))));
    }
} else {
    if ($_POST && $_POST["otp_action"] === "send_email_otp" && $mOtp->CheckUserExists($uid)) {
        $mOtp->SetUser($uid);
        if (OCP\Config::getAppValue('user_otp', 'TokenBase32Encode', true)) {
Ejemplo n.º 19
0
<?php

// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::success(array('data' => OCP\Config::getUserValue(OCP\User::getUser(), 'tattoo', 'wallpaper', 'none')));
Ejemplo n.º 20
0
        ?>
		<div id="<?php 
        print $sc_sort;
        ?>
" class="personalblock">
			<h3>
				<img
					src="<?php 
        print OCP\Util::imagePath('storagecharts2', 'move.png');
        ?>
" />
				<?php 
        print $l->t($sc_sort_title) . ' ' . $l->t('for');
        ?>
				"<?php 
        print OC_Group::inGroup(OCP\User::getUser(), 'admin') ? $l->t('all users') : OCP\User::getDisplayName();
        ?>
"
			</h3>
			<div id="<?php 
        print substr($sc_sort, 1);
        ?>
"
				style="max-width: 100%; height: 400px; margin: 0 auto"></div>
			<script type="text/javascript">$(document).ready(function(){<?php 
        print OC_DLStChartsLoader::loadChart($sc_sort, $l);
        ?>
});</script>
		</div>
		<?php 
    }
Ejemplo n.º 21
0
    ?>
" id="requesttoken"> 
		<input type="hidden" name="appname" value="roundcube">
		<fieldset class="<?php 
    echo $cfgClass;
    ?>
" id="roundcube">
		<h2>
			<?php 
    p($l->t('RoundCube Mailaccount'));
    ?>
		</h2>
		<?php 
    $enable_auto_login = OCP\Config::getAppValue('roundcube', 'autoLogin', false);
    if (!$enable_auto_login) {
        $username = OCP\User::getUser();
        $privKey = OC_RoundCube_App::getPrivateKey($username, false);
        foreach ($mail_userdata_entries as $mail_userdata) {
            $mail_username = OC_RoundCube_App::decryptMyEntry($mail_userdata['mail_user'], $privKey);
            $mail_password = OC_RoundCube_App::decryptMyEntry($mail_userdata['mail_password'], $privKey);
            // TODO use template and add button for adding entries
            ?>
				<input type="text" id="rc_mail_username" name="rc_mail_username"
					value="<?php 
            echo $mail_username;
            ?>
" placeholder="<?php 
            p($l->t('Email Login Name'));
            ?>
" /> 
				<input type="password" id="rc_mail_password" name="rc_mail_password"
Ejemplo n.º 22
0
if (!$file) {
    OCP\JSON::error(array('error' => '404'));
}
$file = Sabre\VObject\StringUtil::convertToUTF8($file);
$import = new OC_Calendar_Import($file);
$import->setUserID(OCP\User::getUser());
$import->setTimeZone(OC_Calendar_App::$tz);
$import->enableProgressCache();
$import->setProgresskey($_POST['progresskey']);
if (!$import->isValid()) {
    OCP\JSON::error(array('error' => 'notvalid'));
    exit;
}
$newcal = false;
if ($_POST['method'] == 'new') {
    $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser());
    foreach ($calendars as $calendar) {
        if ($calendar['displayname'] == $_POST['calname']) {
            $id = $calendar['id'];
            $newcal = false;
            break;
        }
        $newcal = true;
    }
    if ($newcal) {
        $id = OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(), strip_tags($_POST['calname']), 'VEVENT,VTODO,VJOURNAL', null, 0, strip_tags($_POST['calcolor']));
        OC_Calendar_Calendar::setCalendarActive($id, 1);
    }
} else {
    $calendar = OC_Calendar_App::getCalendar($_POST['id']);
    if ($calendar['userid'] != OCP\USER::getUser()) {
Ejemplo n.º 23
0
 * @copyright 2012 Jakob Sack <*****@*****.**>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('mail');
$accounts = OCA_Mail\App::getFolders(OCP\User::getUser());
//
// TODO: error is listed within the accounts
//
if ($accounts['error']) {
    OCP\JSON::error(array('data' => array('message' => $accounts['error'])));
    exit;
}
$tmpl = new OCP\Template('mail', 'part.folders');
$tmpl->assign('accounts', $accounts);
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => $page));
Ejemplo n.º 24
0
OCP\JSON::callCheck ( );
OCP\JSON::checkLoggedIn ( );
OCP\JSON::checkAppEnabled ( 'shorty' );

try
{
	// first remove any entries already marked as 'deleted'
	$query = OCP\DB::prepare ( OC_Shorty_Query::URL_REMOVE );
	$result = $query->execute(array(':user'=>OCP\User::getUser()));
	// now comes the real list selection
//   define ('PAGE_SIZE', 100);
//   $p_offset = OC_Shorty_Type::req_argument ( 'page', OC_Shorty_Type::INTEGER, FALSE) * PAGE_SIZE;
	// pre-sort list according to user preferences
	$p_sort = OC_Shorty_Type::$SORTING[OCP\Config::getUserValue(OCP\User::getUser(),'shorty','list-sort-code','cd')];
	$param = array (
		':user'   => OCP\User::getUser ( ),
		':sort'   => $p_sort,
// 		':offset' => $p_offset,
// 		':limit'  => PAGE_SIZE,
	);
	$query = OCP\DB::prepare ( OC_Shorty_Query::URL_LIST );
	$result = $query->execute($param);
	$reply = $result->fetchAll();
	foreach (array_keys($reply) as $key) {
		if (isset($reply[$key]['id']))
		{
			// enhance all entries with the relay url
			$reply[$key]['relay']=OC_Shorty_Tools::relayUrl ( $reply[$key]['id'] );
			// make sure there is _any_ favicon contained, otherwise layout in MS-IE browser is broken...
			if (empty($reply[$key]['favicon']))
				$reply[$key]['favicon'] = OCP\Util::imagePath('shorty', 'blank.png');
<?php

\OCP\User::checkLoggedIn();
\OCP\App::checkAppEnabled('fc_mail_attachments');
\OCP\Util::addscript('fc_mail_attachments', 'utils');
\OCP\Util::addscript('fc_mail_attachments', 'account');
//OCP\Util::addstyle('fc_mail_attachments', 'style');
$user = OCP\User::getUser();
$tmpl = new OCP\Template('fc_mail_attachments', 'settings');
$query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*fc_mail_attachments` WHERE user = ?');
$results = $query->execute(array($user))->fetchAll();
if (sizeof($results)) {
    $conf = $results[0];
    $tmpl->assign('dir', $conf['dir']);
    $tmpl->assign('mail_host', $conf['mail_host']);
    $tmpl->assign('mail_port', $conf['mail_port']);
    $tmpl->assign('mail_security', $conf['mail_security']);
    $tmpl->assign('mail_user', $conf['mail_user']);
}
return $tmpl->fetchPage();
Ejemplo n.º 26
0
<?php

/**
 * Copyright (c) 2012 Thomas Tanghus <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
$catmgr = OCA\Contacts\App::getVCategories();
$categories = $catmgr->categories(OC_VCategories::FORMAT_MAP);
foreach ($categories as &$category) {
    $ids = array();
    $contacts = $catmgr->itemsForCategory($category['name'], array('tablename' => '*PREFIX*contacts_cards', 'fields' => array('id')));
    foreach ($contacts as $contact) {
        $ids[] = $contact['id'];
    }
    $category['contacts'] = $ids;
}
$favorites = $catmgr->getFavorites();
OCP\JSON::success(array('data' => array('categories' => $categories, 'favorites' => $favorites, 'shared' => OCP\Share::getItemsSharedWith('addressbook', OCA\Contacts\Share_Backend_Addressbook::FORMAT_ADDRESSBOOKS), 'lastgroup' => OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'lastgroup', 'all'), 'sortorder' => OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'groupsort', ''))));
Ejemplo n.º 27
0
			</form>
		</li>
		<li>
			<a id="newCalendar"><?php 
p($l->t('New Calendar'));
?>
</a>
		</li>
		
		<?php 
$option_calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
for ($i = 0; $i < count($option_calendars); $i++) {
    print_unescaped("<li data-id='" . OC_Util::sanitizeHTML($option_calendars[$i]['id']) . "'>");
    $tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields');
    $tmpl->assign('calendar', $option_calendars[$i]);
    if ($option_calendars[$i]['userid'] != OCP\User::getUser()) {
        $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $option_calendars[$i]['id']);
        $shared = true;
    } else {
        $shared = false;
    }
    $tmpl->assign('shared', $shared);
    $tmpl->printpage();
    print_unescaped("</li>");
}
?>
		<li id="caldav_url_entry">
			<input style="display:none;width: 78%;float: left;" type="text" id="caldav_url" title="<?php 
p($l->t("CalDav Link"));
?>
">
Ejemplo n.º 28
0
<?php

/**
 * ownCloud - Addressbook
 *
 * @author Thomas Tanghus
 * @copyright 2012 Jakob Sack <*****@*****.**>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('mail');
$account_id = isset($_GET['account_id']) ? $_GET['account_id'] : null;
$folder_id = isset($_GET['folder_id']) ? $_GET['folder_id'] : null;
$from = isset($_GET['from']) ? $_GET['from'] : null;
$count = isset($_GET['count']) ? $_GET['count'] : null;
$messages = OCA\Mail\App::getMessages(OCP\User::getUser(), $account_id, $folder_id, $from, $count);
OCP\JSON::success(array('data' => $messages));
Ejemplo n.º 29
0
 /**
  * Test connecting using the given backend configuration
  *
  * @param string $class backend class name
  * @param array $options backend configuration options
  * @return int see self::STATUS_*
  * @throws Exception
  */
 public static function getBackendStatus($class, $options, $isPersonal)
 {
     if (self::$skipTest) {
         return self::STATUS_SUCCESS;
     }
     foreach ($options as &$option) {
         $option = self::setUserVars(OCP\User::getUser(), $option);
     }
     if (class_exists($class)) {
         try {
             /** @var \OC\Files\Storage\Common $storage */
             $storage = new $class($options);
             try {
                 $result = $storage->test($isPersonal);
                 $storage->setAvailability($result);
                 if ($result) {
                     return self::STATUS_SUCCESS;
                 }
             } catch (\Exception $e) {
                 $storage->setAvailability(false);
                 throw $e;
             }
         } catch (Exception $exception) {
             \OCP\Util::logException('files_external', $exception);
             throw $exception;
         }
     }
     return self::STATUS_ERROR;
 }
Ejemplo n.º 30
0
/**
 * Copyright (c) 2012 Georg Ehrke <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
$data = $_POST['data'];
$data = explode(',', $data);
$data = end($data);
$data = base64_decode($data);
OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
$import = new OC_Calendar_Import($data);
$import->setUserID(OCP\User::getUser());
$import->setTimeZone(OC_Calendar_App::$tz);
$import->disableProgressCache();
if (!$import->isValid()) {
    OCP\JSON::error();
    exit;
}
$newcalendarname = strip_tags($import->createCalendarName());
$newid = OC_Calendar_Calendar::addCalendar(OCP\User::getUser(), $newcalendarname, 'VEVENT,VTODO,VJOURNAL', null, 0, $import->createCalendarColor());
$import->setCalendarID($newid);
$import->import();
$count = $import->getCount();
if ($count == 0) {
    OC_Calendar_Calendar::deleteCalendar($newid);
    OCP\JSON::error(array('message' => OC_Calendar_App::$l10n->t('The file contained either no events or all events are already saved in your calendar.')));
} else {
    OCP\JSON::success(array('message' => $count . ' ' . OC_Calendar_App::$l10n->t('events has been saved in the new calendar') . ' ' . $newcalendarname, 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo(OC_Calendar_Calendar::find($newid))));
}