本文整理汇总了PHP中OC_Calendar_Object类的典型用法代码示例。如果您正苦于以下问题:PHP OC_Calendar_Object类的具体用法?PHP OC_Calendar_Object怎么用?PHP OC_Calendar_Object使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OC_Calendar_Object类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateEvent
/**
* @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 '';
}
示例2: generateEvent
/**
* @brief generates the VEVENT with UTC dates
* @param array $event
* @return string
*/
private static function generateEvent($event)
{
$object = OC_VObject::parse($event['calendardata']);
if (!$object) {
return false;
}
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 '';
}
示例3: formatItems
public function formatItems($items, $format, $parameters = null)
{
$events = array();
if ($format == self::FORMAT_EVENT) {
foreach ($items as $item) {
$event = OC_Calendar_Object::find($item['item_source']);
$event['summary'] = $item['item_target'];
$event['permissions'] = $item['permissions'];
$events[] = $event;
}
}
return $events;
}
示例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: generateEvent
/**
* @brief generates the VEVENT with UTC dates
* @param array $event
* @return string
*/
private static function generateEvent($event)
{
$object = OC_VObject::parse($event['calendardata']);
$dtstart = $object->VEVENT->DTSTART;
$start_dt = $dtstart->getDateTime();
$dtend = OC_Calendar_Object::getDTEndFromVEvent($object->VEVENT);
$end_dt = $dtend->getDateTime();
if ($dtstart->getDateType() !== Sabre_VObject_Element_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();
}
示例6: 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;
}
示例7: parseVTODO
public static function parseVTODO($task)
{
$object = \Sabre\VObject\Reader::read($task['calendardata']);
if (!$object) {
return false;
}
$sharedAccessClassPermissions = \OC_Calendar_Object::getAccessClassPermissions($object);
if (\OC_Calendar_Object::getowner($task['id']) !== \OC::$server->getUserSession()->getUser()->getUID()) {
if (!($sharedAccessClassPermissions & \OCP\Constants::PERMISSION_READ)) {
return false;
}
}
$object = \OC_Calendar_Object::cleanByAccessClass($task['id'], $object);
$vtodo = $object->VTODO;
return $vtodo;
}
示例8: formatItems
public function formatItems($items, $format, $parameters = null)
{
$events = array();
if ($format == self::FORMAT_EVENT) {
foreach ($items as $item) {
$event = OC_Calendar_Object::find($item['item_source']);
if ($event == False) {
\OCP\Util::writeLog('calendar', __METHOD__ . ', Missing event: ' . $item['item_target'], \OCP\Util::DEBUG);
} else {
$event['summary'] = $item['item_target'];
$event['permissions'] = $item['permissions'];
$events[] = $event;
}
}
}
return $events;
}
示例9: 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 = 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));
}
示例10: generateEvent
/**
* @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 '';
}
示例11: __construct
/**
* Constructor
*
* @param array $data
* @return \OCA\Calendar\Search\Event
*/
public function __construct(array $data = null)
{
// set default properties
$this->id = $data['id'];
$this->name = $data['summary'];
$this->link = \OCP\Util::linkTo('calendar', 'index.php') . '?showevent=' . urlencode($data['id']);
// do calendar-specific setup
$l = new \OC_l10n('calendar');
$calendar_data = \Sabre\VObject\Reader::read($data['calendardata']);
$vevent = $calendar_data->VEVENT;
// get start time
$dtstart = $vevent->DTSTART;
$start_dt = $dtstart->getDateTime();
$start_dt->setTimezone($this->getUserTimezone());
$this->start_time = $start_dt->format('r');
// get end time
$dtend = \OC_Calendar_Object::getDTEndFromVEvent($vevent);
$end_dt = $dtend->getDateTime();
$end_dt->setTimezone($this->getUserTimezone());
$this->end_time = $end_dt->format('r');
// create text description
if (!$dtstart->hasTime()) {
$end_dt->modify('-1 sec');
if ($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')) {
$this->text = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y');
} else {
$this->text = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');
}
} else {
$this->text = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i');
}
// set last modified time
$this->modified = date('r', $data['lastmodified']);
// set repeating property
$this->repeating = (bool) $data['repeating'];
}
示例12: array
<?php
/**
* ownCloud - Addressbook
*
* @author Jakob Sack
* @copyright 2011 Jakob Sack mail@jakobsack.de
*
* 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/>.
*
*/
// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('tasks');
OCP\JSON::callCheck();
$id = $_POST['id'];
$task = OC_Calendar_App::getEventObject($id);
OC_Calendar_Object::delete($id);
OCP\JSON::success(array('data' => array('id' => $id)));
示例13: deleteComment
/**
* @NoAdminRequired
*/
public function deleteComment()
{
$taskId = $this->params('taskID');
$commentId = $this->params('commentID');
$response = new JSONResponse();
try {
$vcalendar = \OC_Calendar_App::getVCalendar($taskId);
$vtodo = $vcalendar->VTODO;
$commentIndex = $this->getCommentById($vtodo, $commentId);
$comment = $vtodo->children[$commentIndex];
if ($comment['USERID'] == $this->userId) {
unset($vtodo->children[$commentIndex]);
\OC_Calendar_Object::edit($taskId, $vcalendar->serialize());
} else {
throw new \Exception('Not allowed.');
}
} catch (\Exception $e) {
// throw new BusinessLayerException($e->getMessage());
}
return $response;
}
示例14: explode
}
if ($_GET["path"] != "") {
$filename = $_GET["path"] . "/" . $_GET["file"];
} else {
$filename = "/" . $_GET["file"];
}
} else {
$id = OC_Calendar_Calendar::addCalendar(OC_User::getUser(), $_POST['calname']);
OC_Calendar_Calendar::setCalendarActive($id, 1);
$calid = $id;
if ($_POST["path"] != "") {
$filename = $_POST["path"] . "/" . $_POST["file"];
} else {
$filename = "/" . $_POST["file"];
}
}
$vcalendar = OC_Filesystem::file_get_contents($filename);
$vcalendar = explode("BEGIN:VEVENT", $vcalendar);
for ($i = 1; $i < count($vcalendar); $i++) {
$vcalendar[$i] = "BEGIN:VEVENT" . $vcalendar[$i];
}
for ($i = 1; $i < count($vcalendar) - 1; $i++) {
$vcalendar[$i] = $vcalendar[$i] . "END:VCALENDAR";
}
for ($i = 1; $i < count($vcalendar); $i++) {
$vcalendar[$i] = $vcalendar[0] . $vcalendar[$i];
}
for ($i = 1; $i < count($vcalendar); $i++) {
OC_Calendar_Object::add($calid, $vcalendar[$i]);
}
OC_JSON::success();
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:31,代码来源:owncloud_apps_calendar_import.php
示例15: generateEventOutput
/**
* @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);
}
}