本文整理汇总了PHP中OC_Calendar_Object::cleanByAccessClass方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Calendar_Object::cleanByAccessClass方法的具体用法?PHP OC_Calendar_Object::cleanByAccessClass怎么用?PHP OC_Calendar_Object::cleanByAccessClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Calendar_Object
的用法示例。
在下文中一共展示了OC_Calendar_Object::cleanByAccessClass方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: checkTask
/**
* check if task is valid
*
* @param \OCA\Tasks\Db\Tasks $task
* @return mixed
*/
public function checkTask($task)
{
$object = $this->readTask($task);
if (!$object) {
return false;
}
if (\OC_Calendar_Object::getowner($task->getId()) !== \OC::$server->getUserSession()->getUser()->getUID()) {
$sharedAccessClassPermissions = \OC_Calendar_Object::getAccessClassPermissions($object);
if (!($sharedAccessClassPermissions & \OCP\Constants::PERMISSION_READ)) {
return false;
}
}
$taskID = $task->getId();
$object = \OC_Calendar_Object::cleanByAccessClass($taskID, $object);
$vtodo = $object->VTODO;
$vtodo->ID = $taskID;
return $vtodo;
}
示例4: 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 '';
}
示例5: 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);
}
}
示例6: getCalendarObject
/**
* Returns information from a single calendar object, based on it's object
* uri.
*
* The returned array must have the same keys as getCalendarObjects. The
* 'calendardata' object is required here though, while it's not required
* for getCalendarObjects.
*
* @param string $calendarId
* @param string $objectUri
* @return array
*/
public function getCalendarObject($calendarId, $objectUri)
{
if ($calendarId === 'contact_birthdays') {
$objectUri = substr($objectUri, 0, strlen($objectUri) - 4);
$objectUriArray = explode('::', $objectUri);
if (count($objectUriArray) === 3) {
$app = new \OCA\Contacts\App();
list($backend, $addressBookId, $contactId) = $objectUriArray;
$contact = $app->getContact($backend, $addressBookId, $contactId);
$vevent = $contact->getBirthdayEvent();
if (is_null($vevent)) {
return false;
}
return $this->OCAddETag(array('id' => 0, 'calendarid' => 'contact_birthdays', 'uri' => $contact->getBackend()->name . '::' . $contact->getParent()->getId() . '::' . $contact->getId() . '.ics', 'lastmodified' => $contact->lastModified(), 'calendardata' => $vevent->serialize()));
}
}
$data = OC_Calendar_Object::findWhereDAVDataIs($calendarId, $objectUri);
if (is_array($data)) {
$data = $this->OCAddETag($data);
$object = \Sabre\VObject\Reader::read($data['calendardata']);
if (!$object) {
return false;
}
$object = OC_Calendar_Object::cleanByAccessClass($data['id'], $object);
$data['calendardata'] = $object->serialize();
}
return $data;
}
示例7: array
* later.
* See the COPYING-README file.
*/
if (!OCP\User::isLoggedIn()) {
OCP\User::checkLoggedIn();
}
OCP\JSON::checkAppEnabled('calendar');
$id = $_POST['id'];
$data = OC_Calendar_App::getEventObject($id, false, false);
if (!$data) {
OCP\JSON::error(array('data' => array('message' => OC_Calendar_App::$l10n->t('Wrong calendar'))));
exit;
}
$object = OC_VObject::parse($data['calendardata']);
$vevent = $object->VEVENT;
$object = OC_Calendar_Object::cleanByAccessClass($id, $object);
$accessclass = $vevent->getAsString('CLASS');
$permissions = OC_Calendar_App::getPermissions($id, OC_Calendar_App::EVENT, $accessclass);
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
switch ($dtstart->getDateType()) {
case Sabre\VObject\Property\DateTime::UTC:
$timezone = new DateTimeZone(OC_Calendar_App::getTimezone());
$newDT = $dtstart->getDateTime();
$newDT->setTimezone($timezone);
$dtstart->setDateTime($newDT);
$newDT = $dtend->getDateTime();
$newDT->setTimezone($timezone);
$dtend->setDateTime($newDT);
case Sabre\VObject\Property\DateTime::LOCALTZ:
case Sabre\VObject\Property\DateTime::LOCAL:
示例8: getCalendarObject
/**
* Returns information from a single calendar object, based on it's object
* uri.
*
* The returned array must have the same keys as getCalendarObjects. The
* 'calendardata' object is required here though, while it's not required
* for getCalendarObjects.
*
* @param string $calendarId
* @param string $objectUri
* @return array
*/
public function getCalendarObject($calendarId, $objectUri)
{
$data = OC_Calendar_Object::findWhereDAVDataIs($calendarId, $objectUri);
if (is_array($data)) {
$object = OC_VObject::parse($data['calendardata']);
$object = OC_Calendar_Object::cleanByAccessClass($data['id'], $object);
$data['calendardata'] = $object->serialize();
$data = $this->OCAddETag($data);
}
return $data;
}