當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。