From f806ed5c9e66e970efb958f087530b1b75afcd78 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 12 Sep 2013 12:06:12 +0200 Subject: Implemented configurable timeout for desktop notification (#1489205) --- plugins/newmail_notifier/newmail_notifier.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'plugins/newmail_notifier/newmail_notifier.php') diff --git a/plugins/newmail_notifier/newmail_notifier.php b/plugins/newmail_notifier/newmail_notifier.php index ca1c2ff67..20c542f58 100644 --- a/plugins/newmail_notifier/newmail_notifier.php +++ b/plugins/newmail_notifier/newmail_notifier.php @@ -123,6 +123,23 @@ class newmail_notifier extends rcube_plugin } } + $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; } @@ -148,6 +165,13 @@ class newmail_notifier extends rcube_plugin } } + $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; + } + } + return $args; } @@ -180,6 +204,7 @@ class newmail_notifier extends rcube_plugin 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'], -- cgit v1.2.3