本文整理汇总了PHP中OC_Calendar_Object::all方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Calendar_Object::all方法的具体用法?PHP OC_Calendar_Object::all怎么用?PHP OC_Calendar_Object::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Calendar_Object
的用法示例。
在下文中一共展示了OC_Calendar_Object::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: import
public function import()
{
if (!$this->isValid()) {
return false;
}
$numofcomponents = count($this->calobject->getComponents());
if ($this->overwrite) {
foreach (OC_Calendar_Object::all($this->id) as $obj) {
OC_Calendar_Object::delete($obj['id']);
}
}
foreach ($this->calobject->getComponents() as $object) {
if (!$object instanceof Sabre\VObject\Component\VEvent && !$object instanceof Sabre\VObject\Component\VJournal && !$object instanceof Sabre\VObject\Component\VTodo) {
continue;
}
if (!is_null($object->DTSTART)) {
$dtend = OC_Calendar_Object::getDTEndFromVEvent($object);
if ($object->DTEND) {
$object->DTEND->setDateTime($dtend->getDateTime(), $object->DTSTART->getDateType());
}
}
$vcalendar = $this->createVCalendar($object->serialize());
$insertid = OC_Calendar_Object::add($this->id, $vcalendar);
$this->abscount++;
if ($this->isDuplicate($insertid)) {
OC_Calendar_Object::delete($insertid);
} else {
$this->count++;
}
$this->updateProgress(intval($this->abscount / $numofcomponents * 100));
}
OC_Cache::remove($this->progresskey);
return true;
}
示例7: is_calendar_cached
/**
* @brief checks if a whole calendar is already cached
* @param (int) id - id of the calendar
* @return (bool)
*/
public static function is_calendar_cached($id)
{
$cachedevents = count(self::getCalendar($id));
$repeatingevents = 0;
$allevents = OC_Calendar_Object::all($id);
foreach ($allevents as $event) {
if ($event['repeating'] === 1) {
$repeatingevents++;
}
}
if ($cachedevents < $repeatingevents) {
return false;
} else {
return true;
}
}
示例8: getCalendarObjects
/**
* Returns all calendar objects within a calendar object.
*
* Every item contains an array with the following keys:
* * id - unique identifier which will be used for subsequent updates
* * calendardata - The iCalendar-compatible calnedar data
* * uri - a unique key which will be used to construct the uri. This can be any arbitrary string.
* * lastmodified - a timestamp of the last modification time
* * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
* ' "abcdef"')
* * calendarid - The calendarid as it was passed to this function.
*
* Note that the etag is optional, but it's highly encouraged to return for
* speed reasons.
*
* The calendardata is also optional. If it's not returned
* 'getCalendarObject' will be called later, which *is* expected to return
* calendardata.
*
* @param string $calendarId
* @return array
*/
public function getCalendarObjects($calendarId)
{
$data = array();
if ($calendarId === 'contact_birthdays') {
$app = new \OCA\Contacts\App();
$addressBooks = $app->getAddressBooksForUser();
foreach ($addressBooks as $addressBook) {
foreach ($addressBook->getChildren() as $contact) {
$vevent = $contact->getBirthdayEvent();
if (is_null($vevent)) {
continue;
}
$data[] = $this->OCAddETag(array('id' => 0, 'calendarid' => 'contact_birthdays', 'uri' => $addressBook->getBackend()->name . '::' . $addressBook->getId() . '::' . $contact->getId() . '.ics', 'lastmodified' => $contact->lastModified(), 'summary' => $vevent->SUMMARY, 'calendardata' => $vevent->serialize()));
}
}
} else {
$calendar = OC_Calendar_Calendar::find($calendarId);
$isShared = $calendar['userid'] !== OCP\USER::getUser();
foreach (OC_Calendar_Object::all($calendarId) as $row) {
if (!$isShared) {
$data[] = $this->OCAddETag($row);
} else {
if (substr_count($row['calendardata'], 'CLASS') === 0) {
$data[] = $this->OCAddETag($row);
} else {
$object = \Sabre\VObject\Reader::read($row['calendardata']);
if (!$object) {
return false;
}
$isPrivate = false;
$toCheck = array('VEVENT', 'VJOURNAL', 'VTODO');
foreach ($toCheck as $type) {
foreach ($object->select($type) as $vobject) {
if (isset($vobject->{'CLASS'}) && $vobject->{'CLASS'}->getValue() === 'PRIVATE') {
$isPrivate = true;
}
}
}
if ($isPrivate === false) {
$data[] = $this->OCAddETag($row);
}
}
}
}
}
return $data;
}
示例9: array
<?php
$installedVersionTasks = OCP\Config::getAppValue('tasks', 'installed_version');
$installedVersionTasksEnhanced = OCP\Config::getAppValue('tasks_enhanced', 'installed_version');
\OC::$CLASSPATH['OC_Calendar_Calendar'] = 'calendar/lib/calendar.php';
\OC::$CLASSPATH['OC_Calendar_Object'] = 'calendar/lib/object.php';
if (version_compare($installedVersionTasksEnhanced, '0.4.1', '<=') && version_compare($installedVersionTasks, '0.5.0', '<=')) {
try {
$stmt = \OCP\DB::prepare('SELECT * FROM `*PREFIX*clndr_calendars`');
$result = $stmt->execute();
$calendars = array();
while ($row = $result->fetchRow()) {
$calendars[] = $row;
}
foreach ($calendars as $calendar) {
$calendar_entries = \OC_Calendar_Object::all($calendar['id']);
foreach ($calendar_entries as $task) {
if ($task['objecttype'] != 'VTODO') {
continue;
}
$vcalendar = \OC_VObject::parse($task['calendardata']);
$vtodo = $vcalendar->VTODO;
$children = $vtodo->children;
$taskId = $task['id'];
$comments = $vtodo->COMMENT;
if ($comments) {
foreach ($comments as $com) {
$idx = 0;
foreach ($children as $i => &$property) {
if ($property->name == 'COMMENT' && $property['ID']->value == (int) $com['ID']->value) {
unset($vtodo->children[$idx]);
示例10: scanCategories
/**
* scan events for categories.
* @param $events VEVENTs to scan. null to check all events for the current user.
*/
public static function scanCategories($events = null)
{
if (is_null($events)) {
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
if (count($calendars) > 0) {
$events = array();
foreach ($calendars as $calendar) {
if ($calendar['userid'] === OCP\User::getUser()) {
$calendar_events = OC_Calendar_Object::all($calendar['id']);
$events = $events + $calendar_events;
}
}
}
}
if (is_array($events) && count($events) > 0) {
$vcategories = \OC::$server->getTagManager()->load('event');
$getName = function ($tag) {
return $tag['name'];
};
$tags = array_map($getName, $vcategories->getTags());
$vcategories->delete($tags);
foreach ($events as $event) {
$vobject = OC_VObject::parse($event['calendardata']);
if (!is_null($vobject)) {
$object = null;
if (isset($calendar->VEVENT)) {
$object = $calendar->VEVENT;
} else {
if (isset($calendar->VTODO)) {
$object = $calendar->VTODO;
} else {
if (isset($calendar->VJOURNAL)) {
$object = $calendar->VJOURNAL;
}
}
}
if ($object && isset($object->CATEGORIES)) {
$vcategories->addMultiple($object->CATEGORIES->getParts(), true, $event['id']);
}
}
}
}
}
示例11: foreach
*/
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
foreach ($_POST as $key => $element) {
debug('_POST: ' . $key . '=>' . print_r($element, true));
}
function bailOut($msg)
{
OCP\JSON::error(array('data' => array('message' => $msg)));
OCP\Util::writeLog('calendar', 'ajax/categories/rescan.php: ' . $msg, OCP\Util::DEBUG);
exit;
}
function debug($msg)
{
OCP\Util::writeLog('calendar', 'ajax/categories/rescan.php: ' . $msg, OCP\Util::DEBUG);
}
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
if (count($calendars) == 0) {
bailOut(OC_Calendar_App::$l10n->t('No calendars found.'));
}
$events = array();
foreach ($calendars as $calendar) {
$calendar_events = OC_Calendar_Object::all($calendar['id']);
$events = $events + $calendar_events;
}
if (count($events) == 0) {
bailOut(OC_Calendar_App::$l10n->t('No events found.'));
}
OC_Calendar_App::scanCategories($events);
$categories = OC_Calendar_App::getCategoryOptions();
OCP\JSON::success(array('data' => array('categories' => $categories)));
示例12: getCalendarObjects
/**
* Returns all calendar objects within a calendar object.
*
* Every item contains an array with the following keys:
* * id - unique identifier which will be used for subsequent updates
* * calendardata - The iCalendar-compatible calnedar data
* * uri - a unique key which will be used to construct the uri. This can be any arbitrary string.
* * lastmodified - a timestamp of the last modification time
* * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
* ' "abcdef"')
* * calendarid - The calendarid as it was passed to this function.
*
* Note that the etag is optional, but it's highly encouraged to return for
* speed reasons.
*
* The calendardata is also optional. If it's not returned
* 'getCalendarObject' will be called later, which *is* expected to return
* calendardata.
*
* @param string $calendarId
* @return array
*/
public function getCalendarObjects($calendarId)
{
$data = array();
foreach (OC_Calendar_Object::all($calendarId) as $row) {
$data[] = $this->OCAddETag($row);
}
return $data;
}
示例13: strip_tags
<?php
$token = strip_tags($_GET['t']);
$shared = OC_Calendar_Share::getElementByToken($token);
$nl = "\n\r";
if ($shared['type'] == OC_Calendar_Share::CALENDAR) {
$calendar = OC_Calendar_App::getCalendar($shared['id'], false);
$calobjects = OC_Calendar_Object::all($shared['id']);
header('Content-Type: text/Calendar');
header('Content-Disposition: inline; filename=' . $calendar['displayname'] . '.ics');
foreach ($calobjects as $calobject) {
echo $calobject['calendardata'] . $nl;
}
} elseif ($shared['type'] == OC_Calendar_Share::EVENT) {
$data = OC_Calendar_App::getEventObject($shared['id'], false);
$calendarid = $data['calendarid'];
$calendar = OC_Calendar_App::getCalendar($calendarid);
header('Content-Type: text/Calendar');
header('Content-Disposition: inline; filename=' . $data['summary'] . '.ics');
echo $data['calendardata'];
} else {
header('Error 404: Not Found');
}
示例14: getTasks
/**
* @NoAdminRequired
*/
public function getTasks($listID = 'all', $type = 'all')
{
$user_timezone = \OC_Calendar_App::getTimezone();
if ($listID == 'all') {
$calendars = \OC_Calendar_Calendar::allCalendars($this->userId, true);
} else {
$calendar = \OC_Calendar_App::getCalendar($listID, true, false);
$calendars = array($calendar);
}
$tasks = array();
$lists = array();
foreach ($calendars as $calendar) {
$calendar_entries = \OC_Calendar_Object::all($calendar['id']);
$tasks_selected = array();
foreach ($calendar_entries 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, $calendar['id']);
switch ($type) {
case 'all':
$tasks[] = $task_data;
break;
case 'init':
if (!$task_data['completed']) {
$tasks[] = $task_data;
} else {
$tasks_selected[] = $task_data;
}
break;
case 'completed':
if ($task_data['completed']) {
$tasks[] = $task_data;
}
break;
case 'uncompleted':
if (!$task_data['completed']) {
$tasks[] = $task_data;
}
break;
}
} catch (\Exception $e) {
\OCP\Util::writeLog('tasks', $e->getMessage(), \OCP\Util::ERROR);
}
}
$nrCompleted = 0;
$notLoaded = 0;
usort($tasks_selected, array($this, 'sort_completed'));
foreach ($tasks_selected as $task_selected) {
$nrCompleted++;
if ($nrCompleted > 5) {
$notLoaded++;
continue;
}
$tasks[] = $task_selected;
}
$lists[] = array('id' => $calendar['id'], 'notLoaded' => $notLoaded);
}
$result = array('data' => array('tasks' => $tasks, 'lists' => $lists));
$response = new JSONResponse();
$response->setData($result);
return $response;
}
示例15: scanCategories
/**
* scan events for categories.
* @param $events VEVENTs to scan. null to check all events for the current user.
*/
public static function scanCategories($events = null)
{
if (is_null($events)) {
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
if (count($calendars) > 0) {
$events = array();
foreach ($calendars as $calendar) {
$calendar_events = OC_Calendar_Object::all($calendar['id']);
$events = $events + $calendar_events;
}
}
}
if (is_array($events) && count($events) > 0) {
$vcategories = self::getVCategories();
$vcategories->delete($vcategories->categories());
foreach ($events as $event) {
$vobject = OC_VObject::parse($event['calendardata']);
if (!is_null($vobject)) {
self::loadCategoriesFromVCalendar($vobject);
}
}
}
}