From 6f7c9611ea496fa8cb3242be6da05023c9f69024 Mon Sep 17 00:00:00 2001
From: Christian Binder <christian@jaytraxx.de>
Date: Mon, 6 Apr 2009 21:46:11 +0000
Subject: [PATCH] added configureable poll interval for egwpopup - default is
 60 seconds

---
 notifications/inc/hook_after_navbar.inc.php |  3 ++-
 notifications/js/notificationajaxpopup.js   | 12 +++++------
 notifications/templates/default/config.tpl  | 24 +++++++++++++++------
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/notifications/inc/hook_after_navbar.inc.php b/notifications/inc/hook_after_navbar.inc.php
index e343bc3d83..982a9a2f6f 100644
--- a/notifications/inc/hook_after_navbar.inc.php
+++ b/notifications/inc/hook_after_navbar.inc.php
@@ -15,9 +15,10 @@
 $notification_config = config::read('notifications');
 if ($notification_config['popup_enable']) {
 	$GLOBALS['egw']->translation->add_app('notifications');
+	$popup_poll_interval = empty($notification_config['popup_poll_interval']) ? 60 : $notification_config['popup_poll_interval'];
 	echo '<script src="'. $GLOBALS['egw_info']['server']['webserver_url']. '/notifications/js/notificationajaxpopup.js?'.
 		filemtime(EGW_SERVER_ROOT.'/notifications/js/notificationajaxpopup.js'). '" type="text/javascript"></script>';
-	echo '<script type="text/javascript">egwpopup_init();</script>';
+	echo '<script type="text/javascript">egwpopup_init("'.$popup_poll_interval.'");</script>';
 	echo '
 		<div id="egwpopup" style="display: none; z-index: 999;">
 			<div id="egwpopup_header">'.lang('Notification').'</div>
diff --git a/notifications/js/notificationajaxpopup.js b/notifications/js/notificationajaxpopup.js
index e9a19389d9..554eabf9f2 100644
--- a/notifications/js/notificationajaxpopup.js
+++ b/notifications/js/notificationajaxpopup.js
@@ -10,16 +10,16 @@
 
 var notifymessages = new Array();
 
-function egwpopup_init() {
-	window.setTimeout("egwpopup_refresh();", 1000);
+function egwpopup_init(_i) {
+	window.setTimeout("egwpopup_refresh(" + _i + ");", 1000);
 }
 
-function egwpopup_setTimeout() {
-	window.setTimeout("egwpopup_refresh();", 60000);
+function egwpopup_setTimeout(_i) {
+	window.setTimeout("egwpopup_refresh(" + _i + ");", _i*1000);
 }
-function egwpopup_refresh() {
+function egwpopup_refresh(_i) {
 	xajax_doXMLHTTP("notifications.notifications_ajax.get_notifications");
-	egwpopup_setTimeout();
+	egwpopup_setTimeout(_i);
 }
 
 function egwpopup_display() {
diff --git a/notifications/templates/default/config.tpl b/notifications/templates/default/config.tpl
index 08d026ebc2..bda08019d4 100644
--- a/notifications/templates/default/config.tpl
+++ b/notifications/templates/default/config.tpl
@@ -13,7 +13,7 @@
    <tr class="th">
     <td colspan="2">&nbsp;<b>{lang_eGroupWare-Popup_backend}</b></td>
    </tr>
-   <tr bgcolor="{row_on}">
+   <tr class="row_on">
     <td>{lang_Enable_eGroupWare-Popup_backend}</td>
     <td>
      <select name="newsettings[popup_enable]">
@@ -22,10 +22,20 @@
      </select>
     </td>
    </tr>
+   <tr class="row_off">
+    <td>{lang_Poll_interval}</td>
+    <td>
+     <select name="newsettings[popup_poll_interval]">
+      <option value="60"{selected_popup_poll_interval_60}>1 {lang_minute}</option>
+      <option value="120"{selected_popup_poll_interval_120}>2 {lang_minutes}</option>
+      <option value="300"{selected_popup_poll_interval_300}>5 {lang_minutes}</option>
+     </select>
+    </td>
+   </tr>
    <tr class="th">
     <td colspan="2">&nbsp;<b>{lang_Windows-Popup_backend}</b></td>
    </tr>
-   <tr bgcolor="{row_on}">
+   <tr class="row_on">
     <td>{lang_Enable_Windows-Popup_backend}</td>
     <td>
      <select name="newsettings[winpopup_enable]">
@@ -37,7 +47,7 @@
    <tr class="th">
     <td colspan="2">&nbsp;<b>{lang_SMS_backend}</b></td>
    </tr>
-   <tr bgcolor="{row_on}">
+   <tr class="row_on">
     <td>{lang_Enable_SMS_backend}</td>
     <td>
      <select name="newsettings[sms_enable]">
@@ -46,13 +56,13 @@
      </select>
     </td>
    </tr> 
-   <tr bgcolor="{row_off}">
+   <tr class="row_off">
     <td>{lang_Maximum_SMS_messages_per_notification}</td>
     <td>
      <select name="newsettings[sms_maxmessages]">
-      <option value="1">1</option>
-      <option value="2">2</option>
-      <option value="3">3</option>
+      <option value="1"{selected_sms_maxmessages_1}>1</option>
+      <option value="2"{selected_sms_maxmessages_2}>2</option>
+      <option value="3"{selected_sms_maxmessages_3}>3</option>
      </select>
     </td>
    </tr>