sound() public static method

Return the path to a sound, using the default sound if the sound does not exist in the current theme.
public static sound ( string $name = null, mixed $options = [] ) : Horde_Themes_Sound
$name string The sound name. If null, will return the sound directory.
$options mixed Additional options. If a string, is taken to be the 'app' parameter. If an array, the following options are available: - app: (string) Use this application instead of the current app. - nohorde: (boolean) If true, do not fallback to horde for sound. - noview: (boolean) If true, do not load images from view-specific directories. (Since 2.4.0) - theme: (string) Use this theme instead of the Horde default.
return Horde_Themes_Sound An object which contains the URI and filesystem location of the sound.
Exemplo n.º 1
0
 /**
  * Returns an alarm hash of this event suitable for Horde_Alarm.
  *
  * @param Horde_Date $time  Time of alarm.
  * @param string $user      The user to return alarms for.
  * @param Prefs $prefs      A Prefs instance.
  *
  * @return array  Alarm hash or null.
  */
 public function toAlarm($time, $user = null, $prefs = null)
 {
     if (!$this->alarm || $this->status == Kronolith::STATUS_CANCELLED) {
         return;
     }
     if ($this->recurs()) {
         $eventDate = $this->recurrence->nextRecurrence($time);
         if (!$eventDate || $eventDate && $this->recurrence->hasException($eventDate->year, $eventDate->month, $eventDate->mday)) {
             return;
         }
         $start = clone $eventDate;
         $diff = Date_Calc::dateDiff($this->start->mday, $this->start->month, $this->start->year, $this->end->mday, $this->end->month, $this->end->year);
         if ($diff == -1) {
             $diff = 0;
         }
         $end = new Horde_Date(array('year' => $start->year, 'month' => $start->month, 'mday' => $start->mday + $diff, 'hour' => $this->end->hour, 'min' => $this->end->min, 'sec' => $this->end->sec));
     } else {
         $start = clone $this->start;
         $end = clone $this->end;
     }
     $serverName = $_SERVER['SERVER_NAME'];
     $serverConf = $GLOBALS['conf']['server']['name'];
     if (!empty($GLOBALS['conf']['reminder']['server_name'])) {
         $_SERVER['SERVER_NAME'] = $GLOBALS['conf']['server']['name'] = $GLOBALS['conf']['reminder']['server_name'];
     }
     if (empty($user)) {
         $user = $GLOBALS['registry']->getAuth();
     }
     if (empty($prefs)) {
         $prefs = $GLOBALS['prefs'];
     }
     $methods = !empty($this->methods) ? $this->methods : @unserialize($prefs->getValue('event_alarms'));
     if (isset($methods['notify'])) {
         $methods['notify']['show'] = array('__app' => $GLOBALS['registry']->getApp(), 'event' => $this->id, 'calendar' => $this->calendar);
         $methods['notify']['ajax'] = 'event:' . $this->calendarType . '|' . $this->calendar . ':' . $this->id . ':' . $start->dateString();
         if (!empty($methods['notify']['sound'])) {
             if ($methods['notify']['sound'] == 'on') {
                 // Handle boolean sound preferences.
                 $methods['notify']['sound'] = (string) Horde_Themes::sound('theetone.wav');
             } else {
                 // Else we know we have a sound name that can be
                 // served from Horde.
                 $methods['notify']['sound'] = (string) Horde_Themes::sound($methods['notify']['sound']);
             }
         }
         if ($this->isAllDay()) {
             if ($start->compareDate($end) == 0) {
                 $methods['notify']['subtitle'] = sprintf(_("On %s"), '<strong>' . $start->strftime($prefs->getValue('date_format')) . '</strong>');
             } else {
                 $methods['notify']['subtitle'] = sprintf(_("From %s to %s"), '<strong>' . $start->strftime($prefs->getValue('date_format')) . '</strong>', '<strong>' . $end->strftime($prefs->getValue('date_format')) . '</strong>');
             }
         } else {
             $methods['notify']['subtitle'] = sprintf(_("From %s at %s to %s at %s"), '<strong>' . $start->strftime($prefs->getValue('date_format')), $start->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia') . '</strong>', '<strong>' . $end->strftime($prefs->getValue('date_format')), $this->end->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia') . '</strong>');
         }
     }
     if (isset($methods['mail'])) {
         $image = Kronolith::getImagePart('big_alarm.png');
         $view = new Horde_View(array('templatePath' => KRONOLITH_TEMPLATES . '/alarm', 'encoding' => 'UTF-8'));
         new Horde_View_Helper_Text($view);
         $view->event = $this;
         $view->imageId = $image->getContentId();
         $view->user = $user;
         $view->dateFormat = $prefs->getValue('date_format');
         $view->timeFormat = $prefs->getValue('twentyFour') ? 'H:i' : 'h:ia';
         $view->start = $start;
         if (!$prefs->isLocked('event_reminder')) {
             $view->prefsUrl = Horde::url($GLOBALS['registry']->getServiceLink('prefs', 'kronolith'), true)->remove(session_name());
         }
         if ($this->attendees) {
             $view->attendees = Kronolith::getAttendeeEmailList($this->attendees)->addresses;
         }
         $methods['mail']['mimepart'] = Kronolith::buildMimeMessage($view, 'mail', $image);
     }
     if (isset($methods['desktop'])) {
         if ($this->isAllDay()) {
             if ($this->start->compareDate($this->end) == 0) {
                 $methods['desktop']['subtitle'] = sprintf(_("On %s"), $start->strftime($prefs->getValue('date_format')));
             } else {
                 $methods['desktop']['subtitle'] = sprintf(_("From %s to %s"), $start->strftime($prefs->getValue('date_format')), $end->strftime($prefs->getValue('date_format')));
             }
         } else {
             $methods['desktop']['subtitle'] = sprintf(_("From %s at %s to %s at %s"), $start->strftime($prefs->getValue('date_format')), $start->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia'), $end->strftime($prefs->getValue('date_format')), $this->end->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia'));
         }
         $methods['desktop']['url'] = strval($this->getViewUrl(array(), true, false));
     }
     $alarmStart = clone $start;
     $alarmStart->min -= $this->alarm;
     $alarm = array('id' => $this->uid, 'user' => $user, 'start' => $alarmStart, 'end' => $end, 'methods' => array_keys($methods), 'params' => $methods, 'title' => $this->getTitle($user), 'text' => $this->description, 'instanceid' => $this->recurs() ? $eventDate->dateString() : null);
     $_SERVER['SERVER_NAME'] = $serverName;
     $GLOBALS['conf']['server']['name'] = $serverConf;
     return $alarm;
 }
Exemplo n.º 2
0
 /**
  * Returns an alarm hash of this task suitable for Horde_Alarm.
  *
  * @param string $user  The user to return alarms for.
  * @param Prefs $prefs  A Prefs instance.
  *
  * @return array  Alarm hash or null.
  */
 public function toAlarm($user = null, $prefs = null)
 {
     if (empty($this->alarm) || $this->completed) {
         return;
     }
     if (empty($user)) {
         $user = $GLOBALS['registry']->getAuth();
     }
     if (empty($prefs)) {
         $prefs = $GLOBALS['prefs'];
     }
     $methods = !empty($this->methods) ? $this->methods : @unserialize($prefs->getValue('task_alarms'));
     if (!$methods) {
         $methods = array();
     }
     if (isset($methods['notify'])) {
         $methods['notify']['show'] = array('__app' => $GLOBALS['registry']->getApp(), 'task' => $this->id, 'tasklist' => $this->tasklist);
         $methods['notify']['ajax'] = 'task:' . $this->tasklist . ':' . $this->id;
         if (!empty($methods['notify']['sound'])) {
             if ($methods['notify']['sound'] == 'on') {
                 // Handle boolean sound preferences;
                 $methods['notify']['sound'] = (string) Horde_Themes::sound('theetone.wav');
             } else {
                 // Else we know we have a sound name that can be
                 // served from Horde.
                 $methods['notify']['sound'] = (string) Horde_Themes::sound($methods['notify']['sound']);
             }
         }
     }
     if (isset($methods['mail'])) {
         $image = Nag::getImagePart('big_alarm.png');
         $view = new Horde_View(array('templatePath' => NAG_TEMPLATES . '/alarm', 'encoding' => 'UTF-8'));
         new Horde_View_Helper_Text($view);
         $view->task = $this;
         $view->imageId = $image->getContentId();
         $view->due = new Horde_Date($this->due);
         $view->dateFormat = $prefs->getValue('date_format');
         $view->timeFormat = $prefs->getValue('twentyFour') ? 'H:i' : 'h:ia';
         if (!$prefs->isLocked('task_alarms')) {
             $view->prefsUrl = Horde::url($GLOBALS['registry']->getServiceLink('prefs', 'nag'), true)->remove(session_name());
         }
         $methods['mail']['mimepart'] = Nag::buildMimeMessage($view, 'mail', $image);
     }
     if (isset($methods['desktop'])) {
         $methods['desktop']['url'] = Horde::url('view.php', true)->add('tasklist', $this->tasklist)->add('task', $this->id)->toString(true, true);
     }
     return array('id' => $this->uid, 'user' => $user, 'start' => new Horde_Date($this->due - $this->alarm * 60), 'methods' => array_keys($methods), 'params' => $methods, 'title' => $this->name, 'text' => $this->desc);
 }
Exemplo n.º 3
0
 /**
  */
 protected function _notify(Horde_Notification_Handler $handler, Horde_Notification_Listener $listener)
 {
     global $injector, $prefs, $session;
     if (!$prefs->getValue('newmail_notify') || !$listener instanceof Horde_Notification_Listener_Status) {
         return;
     }
     /* Rate limit. If rate limit is not yet set, this is the initial
      * login so skip. */
     $curr = time();
     $ratelimit = $session->get('imp', self::SESS_RATELIMIT);
     if ($ratelimit && $ratelimit + self::RATELIMIT > $curr) {
         return;
     }
     $session->set('imp', self::SESS_RATELIMIT, $curr);
     if (!$ratelimit) {
         return;
     }
     $ajax_queue = $injector->getInstance('IMP_Ajax_Queue');
     $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
     $recent = array();
     try {
         foreach ($imp_imap->status($injector->getInstance('IMP_Ftree')->poll->getPollList(), Horde_Imap_Client::STATUS_RECENT_TOTAL, array('sort' => true)) as $key => $val) {
             if (!empty($val['recent_total'])) {
                 /* Open the mailbox R/W so we ensure the 'recent' flag is
                  * cleared. */
                 $imp_imap->openMailbox($key, Horde_Imap_Client::OPEN_READWRITE);
                 $mbox = IMP_Mailbox::get($key);
                 $recent[$mbox->display] = $val['recent_total'];
                 $ajax_queue->poll($mbox);
             }
         }
     } catch (Exception $e) {
     }
     if (empty($recent)) {
         return;
     }
     $recent_sum = array_sum($recent);
     reset($recent);
     switch (count($recent)) {
         case 1:
             $mbox_list = key($recent);
             break;
         case 2:
             $mbox_list = implode(_(" and "), array_keys($recent));
             break;
         default:
             $akeys = array_keys($recent);
             $mbox_list = $akeys[0] . ', ' . $akeys[1] . ', ' . _("and") . ' ' . $akeys[2];
             if ($addl_mbox = count($recent) - 3) {
                 $mbox_list .= ' (' . sprintf(ngettext("and %d more mailbox", "and %d more mailboxes", $addl_mbox), $addl_mbox) . ')';
             }
             break;
     }
     $text = sprintf(ngettext("You have %d new mail message in %s.", "You have %d new mail messages in %s.", $recent_sum), $recent_sum, $mbox_list);
     /* Status notification. */
     $handler->push($text, 'horde.message');
     /* Web notifications. */
     $handler->attach('webnotification', null, 'Horde_Core_Notification_Listener_Webnotification');
     $handler->push(Horde_Core_Notification_Event_Webnotification::createEvent($text, array('icon' => strval(Horde_Themes::img('unseen.png')))), 'webnotification');
     if ($audio = $prefs->getValue('newmail_audio')) {
         $handler->attach('audio');
         $handler->push(Horde_Themes::sound($audio), 'audio');
     }
 }
Exemplo n.º 4
0
if ($form->validate()) {
    $form->getInfo($vars, $info);
    if (empty($info['alarm'])) {
        $info['alarm'] = strval(new Horde_Support_Uuid());
    }
    $params = array();
    foreach ($info['methods'] as $method) {
        foreach ($info as $name => $value) {
            if (strpos($name, $method . '_') === 0) {
                $params[$method][substr($name, strlen($method) + 1)] = $value;
            }
        }
    }
    // Full path to any sound files.
    if (!empty($params['notify']['sound'])) {
        $params['notify']['sound'] = (string) Horde_Themes::sound($params['notify']['sound']);
    }
    try {
        $horde_alarm->set(array('id' => $info['alarm'], 'title' => $info['title'], 'text' => $info['text'], 'start' => new Horde_Date($info['start']), 'end' => empty($info['end']) ? null : new Horde_Date($info['end']), 'methods' => $info['methods'], 'params' => $params));
        $notification->push(_("The alarm has been saved."), 'horde.success');
    } catch (Horde_Alarm_Exception $e) {
        $notification->push($e);
    }
}
$id = $vars->get('alarm');
if ($id) {
    if ($vars->get('delete')) {
        try {
            $horde_alarm->delete($id, '');
            $notification->push(_("The alarm has been deleted."), 'horde.success');
        } catch (Horde_Alarm_Exception $e) {
Exemplo n.º 5
0
Arquivo: Html.php Projeto: horde/horde
 protected function _renderVarInput_sound(&$form, &$var, &$vars)
 {
     $value = htmlspecialchars($var->getValue($vars));
     $html = '<ul class="sound-list">';
     if (!$var->isRequired()) {
         $html .= '<li><label><input type="radio" id="' . $this->_genID($var->getVarName(), false) . '" name="' . htmlspecialchars($var->getVarName()) . '" value=""' . (!$value ? ' checked="checked"' : '') . ' /> ' . Horde_Core_Translation::t("No Sound") . '</label></li>';
     }
     foreach ($var->type->getSounds() as $sound) {
         $sound = htmlspecialchars($sound);
         $html .= '<li><label><input type="radio" id="' . $this->_genID($var->getVarName(), false) . '" name="' . htmlspecialchars($var->getVarName()) . '" value="' . $sound . '"' . ($value == $sound ? ' checked="checked"' : '') . ' />' . $sound . '</label>' . ' <embed autostart="false" src="' . Horde_Themes::sound($sound) . '" /></li>';
     }
     return $html . '</ul>';
 }