本文整理汇总了PHP中Kronolith::listAlarms方法的典型用法代码示例。如果您正苦于以下问题:PHP Kronolith::listAlarms方法的具体用法?PHP Kronolith::listAlarms怎么用?PHP Kronolith::listAlarms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kronolith
的用法示例。
在下文中一共展示了Kronolith::listAlarms方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listAlarms
/**
*/
public function listAlarms($time, $user = null)
{
$current_user = $GLOBALS['registry']->getAuth();
if ((empty($user) || $user != $current_user) && !$GLOBALS['registry']->isAdmin()) {
throw new Horde_Exception_PermissionDenied();
}
$group = $GLOBALS['injector']->getInstance('Horde_Group');
$kronolith_shares = $GLOBALS['injector']->getInstance('Kronolith_Shares');
$alarm_list = array();
$time = new Horde_Date($time);
$calendars = is_null($user) ? array_keys($kronolith_shares->listAllShares()) : $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS);
$alarms = Kronolith::listAlarms($time, $calendars, true);
foreach ($alarms as $calendar => $cal_alarms) {
if (!$cal_alarms) {
continue;
}
try {
$share = $kronolith_shares->getShare($calendar);
} catch (Exception $e) {
continue;
}
if (empty($user)) {
$users = $share->listUsers(Horde_Perms::READ);
$groups = $share->listGroups(Horde_Perms::READ);
foreach ($groups as $gid) {
try {
$users = array_merge($users, $group->listUsers($gid));
} catch (Horde_Group_Exception $e) {
}
}
$users = array_unique($users);
} else {
$users = array($user);
}
$owner = $share->get('owner');
foreach ($cal_alarms as $event) {
foreach ($users as $alarm_user) {
if ($alarm_user == $current_user) {
$prefs = $GLOBALS['prefs'];
} else {
$prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('kronolith', array('cache' => false, 'user' => $alarm_user));
}
// Don't show alarms for private events if not the owner.
if ($event->isPrivate($alarm_user)) {
continue;
}
$shown_calendars = unserialize($prefs->getValue('display_cals'));
$reminder = $prefs->getValue('event_reminder');
if ($reminder == 'owner' && $alarm_user == $owner || $reminder == 'show' && in_array($calendar, $shown_calendars) || $reminder == 'read') {
$GLOBALS['registry']->setLanguageEnvironment($prefs->getValue('language'));
$alarm = $event->toAlarm($time, $alarm_user, $prefs);
if ($alarm) {
$alarm_list[] = $alarm;
}
}
}
}
}
return $alarm_list;
}