本文整理汇总了PHP中Kronolith::getSyncCalendars方法的典型用法代码示例。如果您正苦于以下问题:PHP Kronolith::getSyncCalendars方法的具体用法?PHP Kronolith::getSyncCalendars怎么用?PHP Kronolith::getSyncCalendars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kronolith
的用法示例。
在下文中一共展示了Kronolith::getSyncCalendars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getChanges
/**
* Method for obtaining all server changes between two timestamps. Basically
* a wrapper around listBy(), but returns an array containing all adds,
* edits and deletions. If $ignoreExceptions is true, events representing
* recurring event exceptions will not be included in the results.
*
* @param integer $start The starting timestamp
* @param integer $end The ending timestamp.
* @param boolean $ignoreExceptions Do not include exceptions in results.
* @param boolean $isModSeq If true, $timestamp and $end are
* modification sequences and not
* timestamps. @since 4.1.1
* @param string|array $calendars The sources to check. @since 4.2.0
*
* @return array An hash with 'add', 'modify' and 'delete' arrays.
* @throws Horde_Exception_PermissionDenied
* @throws Kronolith_Exception
*/
public function getChanges($start, $end, $ignoreExceptions = true, $isModSeq = false, $calendars = null)
{
// Only get the calendar once
if (is_null($calendars)) {
$cs = Kronolith::getSyncCalendars();
} else {
if (!is_array($calendars)) {
$calendars = array($calendars);
}
$cs = $calendars;
}
$changes = array('add' => array(), 'modify' => array(), 'delete' => array());
foreach ($cs as $c) {
// New events
$driver = Kronolith::getDriver(null, $c);
$driver->synchronize(true);
$uids = $this->listBy('add', $start, $c, $end, $isModSeq);
if ($ignoreExceptions) {
foreach ($uids as $uid) {
try {
$event = Kronolith::getDriver()->getByUID($uid, array($c));
} catch (Exception $e) {
continue;
}
if (empty($event->baseid)) {
$changes['add'][] = $uid;
}
}
} else {
$changes['add'] = array_keys(array_flip(array_merge($changes['add'], $uids)));
}
// Edits
$uids = $this->listBy('modify', $start, $c, $end, $isModSeq);
if ($ignoreExceptions) {
foreach ($uids as $uid) {
try {
$event = Kronolith::getDriver()->getByUID($uid, array($c));
} catch (Exception $e) {
continue;
}
if (empty($event->baseid)) {
$changes['modify'][] = $uid;
}
}
} else {
$changes['modify'] = array_keys(array_flip(array_merge($changes['modify'], $uids)));
}
// No way to figure out if this was an exception, so we must include all
$changes['delete'] = array_keys(array_flip(array_merge($changes['delete'], $this->listBy('delete', $start, $c, $end, $isModSeq))));
}
return $changes;
}