/usr/share/php/Horde/Alarm/Handler/Notify.php is in php-horde-alarm 2.2.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | <?php
/**
* Copyright 2010-2014 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL-2.1
* @package Alarm
*/
/**
* The Horde_Alarm_Handler_Notification class is a Horde_Alarm handler that
* notifies of active alarms over the Horde_Notification system.
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @copyright 2010-2014 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL-2.1
* @package Alarm
*/
class Horde_Alarm_Handler_Notify extends Horde_Alarm_Handler
{
/**
* A notification handler injector.
*
* @var object
*/
protected $_notification;
/**
* Whether a sound already had been played during the page request.
*
* @var boolean
*/
protected $_soundPlayed = false;
/**
* Constructor.
*
* @param array $params Any parameters that the handler might need.
* Required parameter:
* - notification: (object) A factory that implements create() and
* returns a Notification object.
*
* @throws Horde_Alarm_Exception
*/
public function __construct(array $params = null)
{
if (!isset($params['notification'])) {
throw new Horde_Alarm_Exception('Parameter \'notification\' missing.');
}
if (!method_exists($params['notification'], 'create')) {
throw new Horde_Alarm_Exception('Parameter \'notification\' does not have a method create().');
}
$this->_notification = $params['notification'];
}
/**
* Notifies about an alarm through Horde_Notification.
*
* @param array $alarm An alarm hash.
*/
public function notify(array $alarm)
{
$notification = $this->_notification->create();
$notification->push($alarm['title'], 'horde.alarm', array('alarm' => $alarm));
if (!empty($alarm['params']['notify']['sound']) &&
!isset($this->_soundPlayed[$alarm['params']['notify']['sound']])) {
$notification->attach('audio');
$notification->push($alarm['params']['notify']['sound'], 'audio');
$this->_soundPlayed[$alarm['params']['notify']['sound']] = true;
}
}
/**
* Returns a human readable description of the handler.
*
* @return string
*/
public function getDescription()
{
return Horde_Alarm_Translation::t("Inline");
}
/**
* Returns a hash of user-configurable parameters for the handler.
*
* The parameters are hashes with parameter names as keys and parameter
* information as values. The parameter information is a hash with the
* following keys:
* - type: the parameter type as a preference type.
* - desc: a parameter description.
* - required: whether this parameter is required.
*
* @return array
*/
public function getParameters()
{
return array(
'sound' => array(
'type' => 'sound',
'desc' => Horde_Alarm_Translation::t("Play a sound?"),
'required' => false));
}
}
|