| | |
| | | * New Mail Notifier plugin |
| | | * |
| | | * Supports three methods of notification: |
| | | * 1. Basic - focus browser window and change favicon |
| | | * 2. Sound - play wav file |
| | | * 3. Desktop - display desktop notification (using webkitNotifications feature, |
| | | * supported by Chrome and Firefox with 'HTML5 Notifications' plugin) |
| | | * 1. Basic - focus browser window and change favicon |
| | | * 2. Sound - play wav file |
| | | * 3. Desktop - display desktop notification (using window.Notification API) |
| | | * |
| | | * @version @package_version@ |
| | | * @author Aleksander Machniak <alec@alec.pl> |
| | | * |
| | | * Copyright (C) 2011-2016, Kolab Systems AG |
| | | * |
| | | * Copyright (C) 2011, Kolab Systems AG |
| | | * |
| | | * This program is free software; you can redistribute it and/or modify |
| | | * it under the terms of the GNU General Public License version 2 |
| | | * as published by the Free Software Foundation. |
| | | * This program is free software: you can redistribute it and/or modify |
| | | * it under the terms of the GNU General Public License as published by |
| | | * the Free Software Foundation, either version 3 of the License, or |
| | | * (at your option) any later version. |
| | | * |
| | | * This program is distributed in the hope that it will be useful, |
| | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| | | * GNU General Public License for more details. |
| | | * |
| | | * You should have received a copy of the GNU General Public License along |
| | | * with this program; if not, write to the Free Software Foundation, Inc., |
| | | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| | | * You should have received a copy of the GNU General Public License |
| | | * along with this program. If not, see http://www.gnu.org/licenses/. |
| | | */ |
| | | |
| | | class newmail_notifier extends rcube_plugin |
| | |
| | | $this->add_hook('preferences_save', array($this, 'prefs_save')); |
| | | } |
| | | else { // if ($this->rc->task == 'mail') { |
| | | // add script when not in ajax and not in frame |
| | | if ($this->rc->output->type == 'html' && empty($_REQUEST['_framed'])) { |
| | | // add script when not in ajax and not in frame and only in main window |
| | | if ($this->rc->output->type == 'html' && empty($_REQUEST['_framed']) && $this->rc->action == '') { |
| | | $this->add_texts('localization/'); |
| | | $this->rc->output->add_label('newmail_notifier.title', 'newmail_notifier.body'); |
| | | $this->include_script('newmail_notifier.js'); |
| | |
| | | } |
| | | } |
| | | |
| | | $type = 'desktop_timeout'; |
| | | $key = 'newmail_notifier_' . $type; |
| | | if (!in_array($key, $dont_override)) { |
| | | $field_id = '_' . $key; |
| | | $select = new html_select(array('name' => $field_id, 'id' => $field_id)); |
| | | |
| | | foreach (array(5, 10, 15, 30, 45, 60) as $sec) { |
| | | $label = $this->rc->gettext(array('name' => 'afternseconds', 'vars' => array('n' => $sec))); |
| | | $select->add($label, $sec); |
| | | } |
| | | |
| | | $args['blocks']['new_message']['options'][$key] = array( |
| | | 'title' => html::label($field_id, rcube::Q($this->gettext('desktoptimeout'))), |
| | | 'content' => $select->show((int) $this->rc->config->get($key)) |
| | | ); |
| | | } |
| | | |
| | | return $args; |
| | | } |
| | | |
| | |
| | | foreach (array('basic', 'desktop', 'sound') as $type) { |
| | | $key = 'newmail_notifier_' . $type; |
| | | if (!in_array($key, $dont_override)) { |
| | | $args['prefs'][$key] = rcube_utils::get_input_value('_'.$key, rcube_utils::INPUT_POST) ? true : false; |
| | | $args['prefs'][$key] = !empty(rcube_utils::get_input_value('_' . $key, rcube_utils::INPUT_POST)); |
| | | } |
| | | } |
| | | |
| | | $option = 'newmail_notifier_desktop_timeout'; |
| | | if (!in_array($option, $dont_override)) { |
| | | if ($value = (int) rcube_utils::get_input_value('_' . $option, rcube_utils::INPUT_POST)) { |
| | | $args['prefs'][$option] = $value; |
| | | } |
| | | } |
| | | |
| | |
| | | if ($unseen->count()) { |
| | | $this->notified = true; |
| | | |
| | | $this->rc->output->set_env('newmail_notifier_timeout', $this->rc->config->get('newmail_notifier_desktop_timeout')); |
| | | $this->rc->output->command('plugin.newmail_notifier', |
| | | array( |
| | | 'basic' => $this->opt['basic'], |