当前位置: 首页>>代码示例>>PHP>>正文


PHP OC_Calendar_Calendar类代码示例

本文整理汇总了PHP中OC_Calendar_Calendar的典型用法代码示例。如果您正苦于以下问题:PHP OC_Calendar_Calendar类的具体用法?PHP OC_Calendar_Calendar怎么用?PHP OC_Calendar_Calendar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OC_Calendar_Calendar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testBasic

 function testBasic()
 {
     $uid = uniqid();
     $this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array());
     OC_User::setUserId($uid);
     $calId1 = OC_Calendar_Calendar::addCalendar($uid, 'test');
     $all = OC_Calendar_Calendar::allCalendars($uid);
     $this->assertEquals(count($all), 1);
     $this->assertEquals($all[0]['id'], $calId1);
     $this->assertEquals($all[0]['displayname'], 'test');
     $this->assertEquals($all[0]['uri'], 'test');
     $this->assertEquals($uid, $all[0]['userid']);
     $calId2 = OC_Calendar_Calendar::addCalendar($uid, 'test');
     $this->assertNotEquals($calId1, $calId2);
     $all = OC_Calendar_Calendar::allCalendars($uid);
     $this->assertEquals(count($all), 2);
     $this->assertEquals($all[1]['id'], $calId2);
     $this->assertEquals($all[1]['displayname'], 'test');
     $this->assertEquals($all[1]['uri'], 'test1');
     //$cal1=OC_Calendar_Calendar::find($calId1);
     //$this->assertEquals($cal1,$all[0]);
     OC_Calendar_Calendar::deleteCalendar($calId1);
     OC_Calendar_Calendar::deleteCalendar($calId2);
     $this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array());
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:25,代码来源:calendar.php

示例2: import

 function import()
 {
     switch ($this->appinfo->version) {
         default:
             // All versions of the app have had the same db structure, so all can use the same import function
             $query = $this->content->prepare('SELECT * FROM `calendar_calendars` WHERE `userid` = ?');
             $results = $query->execute(array($this->olduid));
             $idmap = array();
             while ($row = $results->fetchRow()) {
                 // Import each calendar
                 $calendarquery = OCP\DB::prepare('INSERT INTO `*PREFIX*calendar_calendars` (`userid`,`displayname`,`uri`,`ctag`,`calendarorder`,`calendarcolor`,`timezone`,`components`) VALUES(?,?,?,?,?,?,?,?)');
                 $calendarquery->execute(array($this->uid, $row['displayname'], $row['uri'], $row['ctag'], $row['calendarorder'], $row['calendarcolor'], $row['timezone'], $row['components']));
                 // Map the id
                 $idmap[$row['id']] = OCP\DB::insertid('*PREFIX*calendar_calendars');
                 // Make the calendar active
                 OC_Calendar_Calendar::setCalendarActive($idmap[$row['id']], true);
             }
             // Now tags
             foreach ($idmap as $oldid => $newid) {
                 $query = $this->content->prepare('SELECT * FROM `calendar_objects` WHERE `calendarid` = ?');
                 $results = $query->execute(array($oldid));
                 while ($row = $results->fetchRow()) {
                     // Import the objects
                     $objectquery = OCP\DB::prepare('INSERT INTO `*PREFIX*calendar_objects` (`calendarid`,`objecttype`,`startdate`,`enddate`,`repeating`,`summary`,`calendardata`,`uri`,`lastmodified`) VALUES(?,?,?,?,?,?,?,?,?)');
                     $objectquery->execute(array($newid, $row['objecttype'], $row['startdate'], $row['enddate'], $row['repeating'], $row['summary'], $row['calendardata'], $row['uri'], $row['lastmodified']));
                 }
             }
             // All done!
             break;
     }
     return true;
 }
开发者ID:amin-hedayati,项目名称:calendar-rework,代码行数:32,代码来源:migrate.php

示例3: getTasks

 /**
  * @NoAdminRequired
  */
 public function getTasks()
 {
     $calendars = \OC_Calendar_Calendar::allCalendars($this->userId, true);
     $user_timezone = \OC_Calendar_App::getTimezone();
     $tasks = array();
     foreach ($calendars as $calendar) {
         $calendar_tasks = \OC_Calendar_Object::all($calendar['id']);
         foreach ($calendar_tasks as $task) {
             if ($task['objecttype'] != 'VTODO') {
                 continue;
             }
             if (is_null($task['summary'])) {
                 continue;
             }
             $vtodo = Helper::parseVTODO($task['calendardata']);
             try {
                 $task_data = Helper::arrayForJSON($task['id'], $vtodo, $user_timezone);
                 $task_data['calendarid'] = $calendar['id'];
                 $task_data['calendarcolor'] = $calendar['calendarcolor'];
                 $tasks[] = $task_data;
             } catch (\Exception $e) {
                 \OCP\Util::writeLog('tasks', $e->getMessage(), \OCP\Util::ERROR);
             }
         }
     }
     $result = array('data' => array('tasks' => $tasks));
     $response = new JSONResponse();
     $response->setData($result);
     return $response;
 }
开发者ID:msbt,项目名称:tasks,代码行数:33,代码来源:taskscontroller.php

示例4: search

 /**
  * Search for query in calendar events
  *
  * @param string $query
  * @return array list of \OCA\Calendar\Search\Event
  */
 function search($query)
 {
     $calendars = \OC_Calendar_Calendar::allCalendars(\OCP\USER::getUser(), true);
     // check if the calenar is enabled
     if (count($calendars) == 0 || !\OCP\App::isEnabled('calendar')) {
         return array();
     }
     $results = array();
     foreach ($calendars as $calendar) {
         $objects = \OC_Calendar_Object::all($calendar['id']);
         $date = strtotime($query);
         // search all calendar objects, one by one
         foreach ($objects as $object) {
             // skip non-events
             if ($object['objecttype'] != 'VEVENT') {
                 continue;
             }
             // check the event summary string
             if (stripos($object['summary'], $query) !== false) {
                 $results[] = new \OCA\Calendar\Search\Event($object);
                 continue;
             }
             // check if the event is happening on a queried date
             $range = $this->getDateRange($object);
             if ($date && $this->fallsWithin($date, $range)) {
                 $results[] = new \OCA\Calendar\Search\Event($object);
                 continue;
             }
         }
     }
     return $results;
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:38,代码来源:provider.php

示例5: deleteUser

 /**
  * @brief Deletes all calendars of a certain user
  * @param paramters parameters from postDeleteUser-Hook
  * @return array
  */
 public static function deleteUser($parameters)
 {
     $calendars = OC_Calendar_Calendar::allCalendars($parameters['uid']);
     foreach ($calendars as $calendar) {
         OC_Calendar_Calendar::deleteCalendar($calendar['id']);
     }
     return true;
 }
开发者ID:blablubli,项目名称:owncloudapps,代码行数:13,代码来源:hooks.php

示例6: getCalendars

 private function getCalendars()
 {
     $calendars = array();
     foreach (OC_Calendar_Calendar::allCalendars($this->user, true) as $cal) {
         $calendars[$cal['id']] = $cal['displayname'];
     }
     return $calendars;
 }
开发者ID:kam1katze,项目名称:ocDashboard,代码行数:8,代码来源:tasks.php

示例7: calendar

 /**
  * @brief exports a calendar and convert all times to UTC
  * @param integer $id id of the calendar
  * @return string
  */
 private static function calendar($id)
 {
     $events = OC_Calendar_Object::all($id);
     $calendar = OC_Calendar_Calendar::find($id);
     $return = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Calendar " . OCP\App::getAppVersion('calendar') . "\nX-WR-CALNAME:" . $calendar['displayname'] . "\n";
     foreach ($events as $event) {
         $return .= self::generateEvent($event);
     }
     $return .= "END:VCALENDAR";
     return $return;
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:16,代码来源:export.php

示例8: generateTarget

 /**
  * @brief Get a unique name of the item for the specified user
  * @param string Item
  * @param string|false User the item is being shared with
  * @param array|null List of similar item names already existing as shared items
  * @return string Target name
  *
  * This function needs to verify that the user does not already have an item with this name.
  * If it does generate a new name e.g. name_#
  */
 public function generateTarget($itemSource, $shareWith, $exclude = null)
 {
     $calendar = OC_Calendar_App::getCalendar($itemSource);
     $user_calendars = array();
     foreach (OC_Calendar_Calendar::allCalendars($shareWith) as $user_calendar) {
         $user_calendars[] = $user_calendar['displayname'];
     }
     $name = $calendar['userid'] . "'s " . $calendar['displayname'];
     $suffix = '';
     while (in_array($name . $suffix, $user_calendars)) {
         $suffix++;
     }
     return $name . $suffix;
 }
开发者ID:netcon-source,项目名称:apps,代码行数:24,代码来源:calendar.php

示例9: search

 /**
  * Search for query in tasks
  *
  * @param string $query
  * @return array list of \OCA\Tasks\Controller\Task
  */
 function search($query)
 {
     $calendars = \OC_Calendar_Calendar::allCalendars(\OC::$server->getUserSession()->getUser()->getUID(), true);
     $user_timezone = \OC_Calendar_App::getTimezone();
     // check if the calenar is enabled
     if (count($calendars) == 0 || !\OCP\App::isEnabled('tasks')) {
         return array();
     }
     $results = array();
     foreach ($calendars as $calendar) {
         // $calendar_entries = \OC_Calendar_Object::all($calendar['id']);
         $objects = \OC_Calendar_Object::all($calendar['id']);
         // $date = strtotime($query);
         // 	// search all calendar objects, one by one
         foreach ($objects as $object) {
             // skip non-todos
             if ($object['objecttype'] != 'VTODO') {
                 continue;
             }
             if (!($vtodo = Helper::parseVTODO($object))) {
                 continue;
             }
             $id = $object['id'];
             $calendarId = $object['calendarid'];
             // check these properties
             $properties = array('SUMMARY', 'DESCRIPTION', 'LOCATION', 'CATEGORIES');
             foreach ($properties as $property) {
                 $string = $vtodo->{$property};
                 if (stripos($string, $query) !== false) {
                     // $results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,$property,$query,$user_timezone);
                     $results[] = Helper::arrayForJSON($id, $vtodo, $user_timezone, $calendarId);
                     continue 2;
                 }
             }
             $comments = $vtodo->COMMENT;
             if ($comments) {
                 foreach ($comments as $com) {
                     if (stripos($com->getValue(), $query) !== false) {
                         // $results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,'COMMENTS',$query,$user_timezone);
                         $results[] = Helper::arrayForJSON($id, $vtodo, $user_timezone, $calendarId);
                         continue 2;
                     }
                 }
             }
         }
     }
     usort($results, array($this, 'sort_completed'));
     return $results;
 }
开发者ID:sbambach,项目名称:tasks,代码行数:55,代码来源:searchcontroller.php

示例10: search

 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;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:48,代码来源:search.php

示例11: getACL

 /**
  * 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));
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:28,代码来源:calendar.php

示例12: getACL

 /**
  * 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));
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:30,代码来源:object.php

示例13: getACL

 /**
  * 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));
 }
开发者ID:rotdrop,项目名称:calendar,代码行数:34,代码来源:object.php

示例14:

<?php

/**
 * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
 * 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();
开发者ID:omusico,项目名称:isle-web-framework,代码行数:15,代码来源:settings.php

示例15: getowner

 /**
  * @brief returns the owner of an object
  * @param integer $id
  * @return string
  */
 public static function getowner($id)
 {
     if ($id == 0) {
         return null;
     }
     $event = self::find($id);
     $cal = OC_Calendar_Calendar::find($event['calendarid']);
     if ($cal === false || is_array($cal) === false) {
         return null;
     }
     if (array_key_exists('userid', $cal)) {
         return $cal['userid'];
     } else {
         return null;
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:21,代码来源:object.php


注:本文中的OC_Calendar_Calendar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。