Ejemplo n.º 1
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.º 2
0
 function search($query)
 {
     $addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1);
     // 		if(count($calendars)==0 || !OCP\App::isEnabled('contacts')){
     // 			//return false;
     // 		}
     // NOTE: Does the following do anything
     $results = array();
     $searchquery = array();
     if (substr_count($query, ' ') > 0) {
         $searchquery = explode(' ', $query);
     } else {
         $searchquery[] = $query;
     }
     $l = new OC_l10n('contacts');
     foreach ($addressbooks as $addressbook) {
         $vcards = OC_Contacts_VCard::all($addressbook['id']);
         foreach ($vcards as $vcard) {
             if (substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0) {
                 $link = OCP\Util::linkTo('contacts', 'index.php') . '?id=' . urlencode($vcard['id']);
                 $results[] = new OC_Search_Result($vcard['fullname'], '', $link, $l->t('Contact'));
                 //$name,$text,$link,$type
             }
         }
     }
     return $results;
 }
Ejemplo n.º 3
0
 /**
  * Returns a list of calendars for a principal.
  *
  * Every project is an array with the following keys:
  *  * id, a unique id that will be used by other functions to modify the
  *	calendar. This can be the same as the uri or a database key.
  *  * uri, which the basename of the uri with which the calendar is
  *	accessed.
  *  * principalUri. The owner of the calendar. Almost always the same as
  *	principalUri passed to this method.
  *
  * Furthermore it can contain webdav properties in clark notation. A very
  * common one is '{DAV:}displayname'.
  *
  * @param string $principalUri
  * @return array
  */
 public function getCalendarsForUser($principalUri)
 {
     $raw = OC_Calendar_Calendar::allCalendarsWherePrincipalURIIs($principalUri);
     $calendars = array();
     foreach ($raw as $row) {
         $components = explode(',', $row['components']);
         if ($row['userid'] != OCP\USER::getUser()) {
             $row['uri'] = $row['uri'] . '_shared_by_' . $row['userid'];
         }
         $calendar = array('id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => 'principals/' . $row['userid'], '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $row['ctag'] ? $row['ctag'] : '0', '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet($components));
         foreach ($this->propertyMap as $xmlName => $dbName) {
             $calendar[$xmlName] = $row[$dbName];
         }
         $calendars[] = $calendar;
     }
     if (\OCP\App::isEnabled('contacts')) {
         $ctag = 0;
         $app = new \OCA\Contacts\App();
         $addressBooks = $app->getAddressBooksForUser();
         foreach ($addressBooks as $addressBook) {
             $tmp = $addressBook->lastModified();
             if (!is_null($tmp)) {
                 $ctag = max($ctag, $tmp);
             }
         }
         $calendars[] = array('id' => 'contact_birthdays', 'uri' => 'contact_birthdays', '{DAV:}displayname' => (string) OC_Calendar_App::$l10n->t('Contact birthdays'), 'principaluri' => 'principals/contact_birthdays', '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $ctag, '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT')));
     }
     return $calendars;
 }
Ejemplo n.º 4
0
 public static function getCalenderSources($parameters)
 {
     $base_url = OCP\Util::linkTo('calendar', 'ajax/events.php') . '?calendar_id=';
     foreach (OC_Contacts_Addressbook::all(OCP\USER::getUser()) as $addressbook) {
         $parameters['sources'][] = array('url' => $base_url . 'birthday_' . $addressbook['id'], 'backgroundColor' => '#cccccc', 'borderColor' => '#888', 'textColor' => 'black', 'cache' => true, 'editable' => false);
     }
 }
Ejemplo n.º 5
0
function importFeed($feedurl, $folderid, $feedtitle)
{
    global $eventSource;
    global $l;
    $feedmapper = new OCA\News\FeedMapper();
    $feedid = $feedmapper->findIdFromUrl($feedurl);
    if ($feedid === null) {
        $feed = OCA\News\Utils::slimFetch($feedurl);
        if ($feed !== null) {
            $feed->setTitle($feedtitle);
            //we want the title of the feed to be the one from the opml file
            $feedid = $feedmapper->save($feed, $folderid);
            $itemmapper = new OCA\News\ItemMapper(OCP\USER::getUser());
            $unreadItemsCount = $itemmapper->countAllStatus($feedid, OCA\News\StatusFlag::UNREAD);
            $tmpl_listfeed = new OCP\Template("news", "part.listfeed");
            $tmpl_listfeed->assign('feed', $feed);
            $tmpl_listfeed->assign('unreadItemsCount', $unreadItemsCount);
            $listfeed = $tmpl_listfeed->fetchPage();
            $eventSource->send('progress', array('data' => array('type' => 'feed', 'folderid' => $folderid, 'listfeed' => $listfeed)));
        }
    } else {
        OCP\Util::writeLog('news', 'ajax/importopml.php: This feed is already here: ' . $feedurl, OCP\Util::WARN);
        return true;
    }
    if ($feed === null || !$feedid) {
        OCP\Util::writeLog('news', 'ajax/importopml.php: Error adding feed: ' . $feedurl, OCP\Util::ERROR);
        return false;
    }
    return true;
}
Ejemplo n.º 6
0
 function search($query)
 {
     $stmt = OCP\DB::prepare('SELECT * FROM `*PREFIX*gallery_albums` WHERE `uid_owner` = ? AND `album_name` LIKE ?');
     $result = $stmt->execute(array(OCP\USER::getUser(), '%' . $query . '%'));
     $results = array();
     while ($row = $result->fetchRow()) {
         $results[] = new OC_Search_Result($row['album_name'], '', OCP\Util::linkTo('gallery', 'index.php') . '?view=' . $row['album_name'], (string) $l->t('Galleries'));
     }
     return $results;
 }
Ejemplo n.º 7
0
function check_dir_exists($current_dir, $dir)
{
    $owner = OCP\USER::getUser();
    $path = OCP\Config::getSystemValue("datadirectory") . '/' . $owner . '/reader';
    $path .= $current_dir . $dir;
    if (!is_dir($path)) {
        mkdir($path, 0777, true);
        return true;
    } else {
        return true;
    }
}
Ejemplo n.º 8
0
 /**
  * Returns the list of addressbooks for a specific user.
  *
  * @param string $principaluri
  * @return array
  */
 public function getAddressBooksForUser($principaluri)
 {
     $data = OC_Contacts_Addressbook::allWherePrincipalURIIs($principaluri);
     $addressbooks = array();
     foreach ($data as $i) {
         if ($i['userid'] != OCP\USER::getUser()) {
             $i['uri'] = $i['uri'] . '_shared_by_' . $i['userid'];
         }
         $addressbooks[] = array('id' => $i['id'], 'uri' => $i['uri'], 'principaluri' => 'principals/' . $i['userid'], '{DAV:}displayname' => $i['displayname'], '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => $i['description'], '{http://calendarserver.org/ns/}getctag' => $i['ctag']);
     }
     return $addressbooks;
 }
Ejemplo n.º 9
0
 function search($query)
 {
     $calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), true);
     if (count($calendars) == 0 || !OCP\App::isEnabled('calendar')) {
         //return false;
     }
     $results = array();
     $searchquery = array();
     if (substr_count($query, ' ') > 0) {
         $searchquery = explode(' ', $query);
     } else {
         $searchquery[] = $query;
     }
     $user_timezone = OC_Calendar_App::getTimezone();
     $l = new OC_l10n('calendar');
     foreach ($calendars as $calendar) {
         $objects = OC_Calendar_Object::all($calendar['id']);
         foreach ($objects as $object) {
             if ($object['objecttype'] != 'VEVENT') {
                 continue;
             }
             if (substr_count(strtolower($object['summary']), strtolower($query)) > 0) {
                 $calendardata = OC_VObject::parse($object['calendardata']);
                 $vevent = $calendardata->VEVENT;
                 $dtstart = $vevent->DTSTART;
                 $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
                 $start_dt = $dtstart->getDateTime();
                 $start_dt->setTimezone(new DateTimeZone($user_timezone));
                 $end_dt = $dtend->getDateTime();
                 $end_dt->setTimezone(new DateTimeZone($user_timezone));
                 if ($dtstart->getDateType() == Sabre\VObject\Property\DateTime::DATE) {
                     $end_dt->modify('-1 sec');
                     if ($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')) {
                         $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y');
                     } else {
                         $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');
                     }
                 } else {
                     $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i');
                 }
                 $link = OCP\Util::linkTo('calendar', 'index.php') . '?showevent=' . urlencode($object['id']);
                 $results[] = new OC_Search_Result($object['summary'], $info, $link, (string) $l->t('Cal.'));
                 //$name,$text,$link,$type
             }
         }
     }
     return $results;
 }
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()) {
         $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.º 11
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 = OCA\Contacts\Addressbook::extractUserID($this->getOwner());
     if ($uid != OCP\USER::getUser()) {
         $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $this->addressBookInfo['id']);
         if ($sharedAddressbook && $sharedAddressbook['permissions'] & OCP\PERMISSION_READ) {
             $readprincipal = 'principals/' . OCP\USER::getUser();
         }
         if ($sharedAddressbook && $sharedAddressbook['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));
 }
Ejemplo n.º 12
0
 /**
  * Returns a list of calendars for a principal.
  *
  * Every project is an array with the following keys:
  *  * id, a unique id that will be used by other functions to modify the
  *	calendar. This can be the same as the uri or a database key.
  *  * uri, which the basename of the uri with which the calendar is
  *	accessed.
  *  * principalUri. The owner of the calendar. Almost always the same as
  *	principalUri passed to this method.
  *
  * Furthermore it can contain webdav properties in clark notation. A very
  * common one is '{DAV:}displayname'.
  *
  * @param string $principalUri
  * @return array
  */
 public function getCalendarsForUser($principalUri)
 {
     $raw = OC_Calendar_Calendar::allCalendarsWherePrincipalURIIs($principalUri);
     $calendars = array();
     foreach ($raw as $row) {
         $components = explode(',', $row['components']);
         if ($row['userid'] != OCP\USER::getUser()) {
             $row['uri'] = $row['uri'] . '_shared_by_' . $row['userid'];
         }
         $calendar = array('id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => 'principals/' . $row['userid'], '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $row['ctag'] ? $row['ctag'] : '0', '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet($components));
         foreach ($this->propertyMap as $xmlName => $dbName) {
             $calendar[$xmlName] = $row[$dbName];
         }
         $calendars[] = $calendar;
     }
     return $calendars;
 }
Ejemplo n.º 13
0
 public static function createCategories($appUrl, $categories)
 {
     $token = uniqid();
     OC_Util::setupFS(OCP\USER::getUser());
     self::addToken($token, $appUrl, $categories);
     foreach (explode(',', $categories) as $category) {
         //TODO: input checking on $category
         $scopePathParts = array('remoteStorage', $category);
         for ($i = 0; $i <= count($scopePathParts); $i++) {
             $thisPath = '/' . implode('/', array_slice($scopePathParts, 0, $i));
             if (!OC_Filesystem::file_exists($thisPath)) {
                 OC_Filesystem::mkdir($thisPath);
             }
         }
     }
     return base64_encode('remoteStorage:' . $token);
 }
Ejemplo n.º 14
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()) {
         $object = OC_VObject::parse($this->objectData['calendardata']);
         $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $this->calendarInfo['id']);
         $sharedAccessClassPermissions = OC_Calendar_App::getAccessClassPermissions($object->VEVENT->CLASS->value);
         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.º 15
0
 private function getBookmarks()
 {
     $filters = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_bookmarks_tags", "");
     // default value doesnt work if empty
     if (empty($filters)) {
         $filters = $this->getDefaultValue("tags");
     }
     $filters = explode(',', $filters);
     $params = array(OCP\USER::getUser());
     $sql = "SELECT *, (SELECT GROUP_CONCAT(`tag`) from `*PREFIX*bookmarks_tags` WHERE `bookmark_id` = `b`.`id`) as `tags`\n\t\t\t\tFROM `*PREFIX*bookmarks` `b`\n\t\t\t\tWHERE `user_id` = ? ";
     // filter clause
     $sql .= " AND\texists (SELECT `id` FROM  `*PREFIX*bookmarks_tags`\n\t\t\t`t2` WHERE `t2`.`bookmark_id` = `b`.`id` AND ( `tag` = ? " . str_repeat(' OR `tag` = ? ', count($filters) - 1) . " ) ) ";
     $params = array_merge($params, $filters);
     $sql .= " ORDER BY lastmodified DESC ";
     $query = OCP\DB::prepare($sql);
     $results = $query->execute($params)->fetchAll();
     $this->bookmarks = $results;
 }
Ejemplo n.º 16
0
 function search($query)
 {
     if (!OCP\App::isEnabled('news')) {
         return array();
     }
     $feedMapper = new OCA\News\FeedMapper(OCP\USER::getUser());
     $results = array();
     if ($feedMapper->feedCount() > 0) {
         $allFeeds = $feedMapper->findAll();
         $l = new OC_l10n('news');
         foreach ($allFeeds as $feed) {
             if (substr_count(strtolower($feed['title']), strtolower($query)) > 0) {
                 $link = OCP\Util::linkTo('news', 'index.php') . '?feedid=' . urlencode($feed['id']);
                 $results[] = new OC_Search_Result($feed['title'], '', $link, (string) $l->t('News'));
             }
         }
     }
     return $results;
 }
Ejemplo n.º 17
0
 function search($query)
 {
     $addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1);
     if (count($addressbooks) == 0 || !OCP\App::isEnabled('contacts')) {
         return array();
     }
     $results = array();
     $l = new OC_l10n('contacts');
     foreach ($addressbooks as $addressbook) {
         $vcards = OC_Contacts_VCard::all($addressbook['id']);
         foreach ($vcards as $vcard) {
             if (substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0) {
                 $link = OCP\Util::linkTo('contacts', 'index.php') . '&id=' . urlencode($vcard['id']);
                 $results[] = new OC_Search_Result($vcard['fullname'], '', $link, (string) $l->t('Contact'));
                 //$name,$text,$link,$type
             }
         }
     }
     return $results;
 }
Ejemplo n.º 18
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 = \Sabre\VObject\Reader::read($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.º 19
0
function bailOut($msg)
{
    OCP\JSON::error(array('data' => array('message' => $msg)));
    OCP\Util::writeLog('contacts', 'ajax/categories/delete.php: ' . $msg, OCP\Util::DEBUG);
    exit;
}
function debug($msg)
{
    OCP\Util::writeLog('contacts', 'ajax/categories/delete.php: ' . $msg, OCP\Util::DEBUG);
}
$categories = isset($_POST['categories']) ? $_POST['categories'] : null;
if (is_null($categories)) {
    bailOut(OC_Contacts_App::$l10n->t('No categories selected for deletion.'));
}
debug(print_r($categories, true));
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser());
if (count($addressbooks) == 0) {
    bailOut(OC_Contacts_App::$l10n->t('No address books found.'));
}
$addressbookids = array();
foreach ($addressbooks as $addressbook) {
    $addressbookids[] = $addressbook['id'];
}
$contacts = OC_Contacts_VCard::all($addressbookids);
if (count($contacts) == 0) {
    bailOut(OC_Contacts_App::$l10n->t('No contacts found.'));
}
$cards = array();
foreach ($contacts as $contact) {
    $cards[] = array($contact['id'], $contact['carddata']);
}
Ejemplo n.º 20
0
					<label class="bold"><?php 
p($l->t('Primary CalDAV address'));
?>
</label>
					<input id="primarycaldav" type="text" value="<?php 
print_unescaped(OCP\Util::linkToRemote('caldav'));
?>
" style="width:90%" readonly>
				</li>
				<li>
					<label class="bold"><?php 
p($l->t('iOS/OS X CalDAV address'));
?>
</label>
					<input id="ioscaldav" type="text" value="<?php 
print_unescaped(OCP\Util::linkToRemote('caldav'));
?>
principals/<?php 
p(urlencode(OCP\USER::getUser()));
?>
/" style="width:90%" readonly>
				</li>
			</ul>
		</div>
	</div>
	<!-- End of settings -->
</div>
<div id="app-content">
	<div id="fullcalendar"><div id="loading" class="icon-loading"></div></div>
	<div id="dialog_holder"></div>
</div>
Ejemplo n.º 21
0
<?php

require_once OC::$APPSROOT . '/apps/files_sharing/lib_share.php';
OCP\JSON::checkAppEnabled('files_sharing');
OCP\JSON::checkLoggedIn();
$userDirectory = '/' . OCP\USER::getUser() . '/files';
$sources = explode(';', $_POST['sources']);
$uid_shared_with = $_POST['uid_shared_with'];
$permissions = $_POST['permissions'];
foreach ($sources as $source) {
    $file = OC_FileCache::get($source);
    $path = ltrim($source, '/');
    $source = $userDirectory . $source;
    // Check if the file exists or if the file is being reshared
    if ($source && $file['encrypted'] == false && (OC_FILESYSTEM::file_exists($path) && OC_FILESYSTEM::is_readable($path) || OC_Share::getSource($source))) {
        try {
            $shared = new OC_Share($source, $uid_shared_with, $permissions);
            // If this is a private link, return the token
            if ($uid_shared_with == OC_Share::PUBLICLINK) {
                OCP\JSON::success(array('data' => $shared->getToken()));
            } else {
                OCP\JSON::success();
            }
        } catch (Exception $exception) {
            OCP\Util::writeLog('files_sharing', 'Unexpected Error : ' . $exception->getMessage(), OCP\Util::ERROR);
            OCP\JSON::error(array('data' => array('message' => $exception->getMessage())));
        }
    } else {
        if ($file['encrypted'] == true) {
            OCP\JSON::error(array('data' => array('message' => 'Encrypted files cannot be shared')));
        } else {
Ejemplo n.º 22
0
<?php

$tmpl = new OCP\Template('contacts', 'settings');
$tmpl->assign('addressbooks', OC_Contacts_Addressbook::all(OCP\USER::getUser()));
$tmpl->printPage();
Ejemplo n.º 23
0
 /**
  * @brief Remove all properties which should not be exported for the AccessClass Confidential
  * @param string $id Event ID
  * @param Sabre_VObject $vobject Sabre VObject
  * @return object
  */
 public static function cleanByAccessClass($id, $vobject)
 {
     // Do not clean your own calendar
     if (OC_Calendar_Object::getowner($id) === OCP\USER::getUser()) {
         return $vobject;
     }
     if (isset($vobject->VEVENT)) {
         $velement = $vobject->VEVENT;
     } elseif (isset($vobject->VJOURNAL)) {
         $velement = $vobject->VJOURNAL;
     } elseif (isset($vobject->VTODO)) {
         $velement = $vobject->VTODO;
     }
     if (isset($velement->CLASS) && $velement->CLASS->value == 'CONFIDENTIAL') {
         foreach ($velement->children as &$property) {
             switch ($property->name) {
                 case 'CREATED':
                 case 'DTSTART':
                 case 'RRULE':
                 case 'DURATION':
                 case 'DTEND':
                 case 'CLASS':
                 case 'UID':
                     break;
                 case 'SUMMARY':
                     $property->value = OC_Calendar_App::$l10n->t('Busy');
                     break;
                 default:
                     $velement->__unset($property->name);
                     unset($property);
                     break;
             }
         }
     }
     return $vobject;
 }
Ejemplo n.º 24
0
<?php

/**
 * Copyright (c) 2011 Bart Visscher <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
$tmpl = new OCP\Template('calendar', 'settings');
$timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', '');
$tmpl->assign('timezone', $timezone);
$tmpl->assign('timezones', DateTimeZone::listIdentifiers());
$tmpl->assign('calendars', OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()), false);
OCP\Util::addscript('calendar', 'settings');
$tmpl->printPage();
Ejemplo n.º 25
0
<?php

require_once __DIR__ . '/bootstrap.php';
OCP\App::addNavigationEntry(array('id' => 'contacts_index', 'order' => 10, 'href' => OCP\Util::linkTo('contacts', 'index.php'), 'icon' => OCP\Util::imagePath('contacts', 'contacts.svg'), 'name' => OC_L10N::get('contacts')->t('Contacts')));
OCP\Util::addscript('contacts', 'loader');
OC_Search::registerProvider('OCA\\Contacts\\SearchProvider');
if (OCP\User::isLoggedIn()) {
    foreach (OCA\Contacts\Addressbook::all(OCP\USER::getUser()) as $addressbook) {
        OCP\Contacts::registerAddressBook(new OCA\Contacts\AddressbookProvider($addressbook['id']));
    }
}
Ejemplo n.º 26
0
 /**
  * @brief generates the output for an event which will be readable for our js
  * @param (mixed) $event - event object / array
  * @param (int) $start - DateTime object of start
  * @param (int) $end - DateTime object of end
  * @return (array) $output - readable output
  */
 public static function generateEventOutput(array $event, $start, $end)
 {
     if (!isset($event['calendardata']) && !isset($event['vevent'])) {
         return false;
     }
     if (!isset($event['calendardata']) && isset($event['vevent'])) {
         $event['calendardata'] = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud's Internal iCal System\n" . $event['vevent']->serialize() . "END:VCALENDAR";
     }
     try {
         $object = OC_VObject::parse($event['calendardata']);
         if (!$object) {
             \OCP\Util::writeLog('calendar', __METHOD__ . ' Error parsing event: ' . print_r($event, true), \OCP\Util::DEBUG);
             return array();
         }
         $output = array();
         if ($object->name === 'VEVENT') {
             $vevent = $object;
         } elseif (isset($object->VEVENT)) {
             $vevent = $object->VEVENT;
         } else {
             \OCP\Util::writeLog('calendar', __METHOD__ . ' Object contains not event: ' . print_r($event, true), \OCP\Util::DEBUG);
             return $output;
         }
         $id = $event['id'];
         if (OC_Calendar_Object::getowner($id) !== OCP\USER::getUser()) {
             // do not show events with private or unknown access class
             if (isset($vevent->CLASS) && ($vevent->CLASS->value === 'PRIVATE' || $vevent->CLASS->value === '')) {
                 return $output;
             }
             $object = OC_Calendar_Object::cleanByAccessClass($id, $object);
         }
         $allday = $vevent->DTSTART->getDateType() == Sabre\VObject\Property\DateTime::DATE ? true : false;
         $last_modified = @$vevent->__get('LAST-MODIFIED');
         $lastmodified = $last_modified ? $last_modified->getDateTime()->format('U') : 0;
         $staticoutput = array('id' => (int) $event['id'], 'title' => !is_null($vevent->SUMMARY) && $vevent->SUMMARY->value != '' ? strtr($vevent->SUMMARY->value, array('\\,' => ',', '\\;' => ';')) : self::$l10n->t('unnamed'), 'description' => isset($vevent->DESCRIPTION) ? strtr($vevent->DESCRIPTION->value, array('\\,' => ',', '\\;' => ';')) : '', 'lastmodified' => $lastmodified, 'allDay' => $allday);
         if (OC_Calendar_Object::isrepeating($id) && OC_Calendar_Repeat::is_cached_inperiod($event['id'], $start, $end)) {
             $cachedinperiod = OC_Calendar_Repeat::get_inperiod($id, $start, $end);
             foreach ($cachedinperiod as $cachedevent) {
                 $dynamicoutput = array();
                 if ($allday) {
                     $start_dt = new DateTime($cachedevent['startdate'], new DateTimeZone('UTC'));
                     $end_dt = new DateTime($cachedevent['enddate'], new DateTimeZone('UTC'));
                     $dynamicoutput['start'] = $start_dt->format('Y-m-d');
                     $dynamicoutput['end'] = $end_dt->format('Y-m-d');
                 } else {
                     $start_dt = new DateTime($cachedevent['startdate'], new DateTimeZone('UTC'));
                     $end_dt = new DateTime($cachedevent['enddate'], new DateTimeZone('UTC'));
                     $start_dt->setTimezone(new DateTimeZone(self::$tz));
                     $end_dt->setTimezone(new DateTimeZone(self::$tz));
                     $dynamicoutput['start'] = $start_dt->format('Y-m-d H:i:s');
                     $dynamicoutput['end'] = $end_dt->format('Y-m-d H:i:s');
                 }
                 $output[] = array_merge($staticoutput, $dynamicoutput);
             }
         } else {
             if (OC_Calendar_Object::isrepeating($id) || $event['repeating'] == 1) {
                 $object->expand($start, $end);
             }
             foreach ($object->getComponents() as $singleevent) {
                 if (!$singleevent instanceof Sabre\VObject\Component\VEvent) {
                     continue;
                 }
                 $dynamicoutput = OC_Calendar_Object::generateStartEndDate($singleevent->DTSTART, OC_Calendar_Object::getDTEndFromVEvent($singleevent), $allday, self::$tz);
                 $output[] = array_merge($staticoutput, $dynamicoutput);
             }
         }
         return $output;
     } catch (Exception $e) {
         $uid = 'unknown';
         if (isset($event['uri'])) {
             $uid = $event['uri'];
         }
         \OCP\Util::writeLog('calendar', 'Event (' . $uid . ') contains invalid data: ' . $e->getMessage(), \OCP\Util::WARN);
     }
 }
Ejemplo n.º 27
0
<?php

$tmpl = new OCP\Template('user_openid', 'settings');
$identity = OCP\Config::getUserValue(OCP\USER::getUser(), 'user_openid', 'identity', '');
$tmpl->assign('identity', htmlentities($identity));
OCP\Util::addscript('user_openid', 'settings');
return $tmpl->fetchPage();
Ejemplo n.º 28
0
echo $l->t('CardDAV syncing addresses');
?>
 (<a href="http://owncloud.org/synchronisation/" target="_blank"><?php 
echo $l->t('more info');
?>
</a>)
		<dl>
		<dt><?php 
echo $l->t('Primary address (Kontact et al)');
?>
</dt>
		<dd><code><?php 
echo OCP\Util::linkToRemote('carddav');
?>
</code></dd>
		<dt><?php 
echo $l->t('iOS/OS X');
?>
</dt>
		<dd><code><?php 
echo OCP\Util::linkToRemote('carddav');
?>
principals/<?php 
echo OCP\USER::getUser();
?>
</code>/</dd>
		</dl>
		Powered by <a href="http://geonames.org/" target="_blank">geonames.org webservice</a>
	</fieldset>
</form>
Ejemplo n.º 29
0
 public static function getGalleryRoot()
 {
     return OCP\Config::getUserValue(OCP\USER::getUser(), 'gallery', 'root', '');
 }
Ejemplo n.º 30
0
<?php

OCP\JSON::checkAppEnabled('files_versions');
OCP\JSON::callCheck();
$userDirectory = "/" . OCP\USER::getUser() . "/files";
$file = $_GET['file'];
$revision = (int) $_GET['revision'];
if (OCA_Versions\Storage::isversioned($file)) {
    if (OCA_Versions\Storage::rollback($file, $revision)) {
        OCP\JSON::success(array("data" => array("revision" => $revision, "file" => $file)));
    } else {
        OCP\JSON::error(array("data" => array("message" => "Could not revert:" . $file)));
    }
}