当前位置: 首页>>代码示例>>PHP>>正文


PHP Kronolith::listAlarms方法代码示例

本文整理汇总了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;
 }
开发者ID:horde,项目名称:horde,代码行数:62,代码来源:Application.php


注:本文中的Kronolith::listAlarms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。