本文整理匯總了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;
}