diff --git a/notifications/inc/class.iface_notification.inc.php b/notifications/inc/class.iface_notification.inc.php index 0eef4a789e..528e2acfe1 100644 --- a/notifications/inc/class.iface_notification.inc.php +++ b/notifications/inc/class.iface_notification.inc.php @@ -20,11 +20,13 @@ interface iface_notification { * @param object $_account * @param object $_preferences */ - public function __construct( $_account, $_preferences ); + public function __construct( $_account=false, $_preferences=false ); /** * sends notification * + * @abstract NOTE, $_message contains some html-tags (


) + * implementing class needs to handle them somehow. * @param string $_message */ public function send( $_message ); diff --git a/notifications/inc/class.notification.inc.php b/notifications/inc/class.notification.inc.php index 1ecda43efc..bc93c11746 100644 --- a/notifications/inc/class.notification.inc.php +++ b/notifications/inc/class.notification.inc.php @@ -43,6 +43,10 @@ final class notification { /** * sets notification message + * @abstract $message accepts html tags:


. + * NOTE: There is no XSS prevention in notifications framework! + * You have to filter userinputs yourseve (e.g. htmlspechialchars() ) + * * @param string &$message */ public function set_message($_message) { @@ -125,4 +129,26 @@ final class notification { return $this->receivers; } -} + /** + * Small helper function to just send a message + * + * @abstract To stay php4 compatible for the 1.4 release we don't + * throw exeptions here. This behaviour will change after 1.4! + * @param array $receivers + * @param string $message + * @return string + */ + public static function notify( array $_receivers, $_message ) { + $notification = new notification(); + $notification->set_receivers( $_receivers ); + $notification->set_message( $_message ); + try{ + $notification->send(); + } + catch(Exception $exception) { + return $exception->getMessage(); + } + return null; + } + +} \ No newline at end of file diff --git a/notifications/inc/class.notification_popup.inc.php b/notifications/inc/class.notification_popup.inc.php index 9b458dc585..61eac8725b 100644 --- a/notifications/inc/class.notification_popup.inc.php +++ b/notifications/inc/class.notification_popup.inc.php @@ -68,10 +68,8 @@ class notification_popup implements iface_notification { // If we are called from class notification account and prefs are objects. // otherwise we have to fetch this objects for current user. if (!is_object($_account)) { - $account_id = $GLOBALS['egw_info']['user']['account_id']; - $this->account = $GLOBALS['egw']->accounts->get_account_data($account_id); - $this->account[$account_id]['id'] = $account_id; - $this->account = (object)$this->account[$account_id]; + $this->account = (object) $GLOBALS['egw']->accounts->read($_account); + $this->account->id =& $this->account->account_id; } else { $this->account = $_account; @@ -94,7 +92,7 @@ class notification_popup implements iface_notification { $user_sessions[] = $session['session_id']; } } - if ( empty($user_sessions) ) throw new Exception("Notice: User $this->account isn't online. Can't send notification via popup"); + if ( empty($user_sessions) ) throw new Exception("Notice: User #{$this->account->id} isn't online. Can't send notification via popup"); $this->save( $_message, $user_sessions ); } @@ -118,10 +116,10 @@ class notification_popup implements iface_notification { while ($notification = $this->db->row(true)) { switch (self::_window ) { case 'div' : - $message .= nl2br($notification['message']). '
'; + $message .= '

'. nl2br($notification['message']). '

'; break; case 'alert' : - $message .= $notification['message']. "\n"; + $message .= ".\n". $notification['message']. "\n"; break; } } diff --git a/notifications/inc/hook_after_navbar.inc.php b/notifications/inc/hook_after_navbar.inc.php index 2a68db967a..3cea8cbdb0 100644 --- a/notifications/inc/hook_after_navbar.inc.php +++ b/notifications/inc/hook_after_navbar.inc.php @@ -11,10 +11,9 @@ * @link http://www.egroupware.org * @author Cornelius Weiss * @version $Id$ - * @todo check if user wants notifications via egw popup! */ -$GLOBALS['egw']->translation->add_app('notifications'); if (!$GLOBALS['egw_info']['user']['preferences']['notifications']['disable_ajaxpopup']) { + $GLOBALS['egw']->translation->add_app('notifications'); echo ''; echo ''; echo ' diff --git a/notifications/js/notificationajaxpopup.js b/notifications/js/notificationajaxpopup.js index 76f7e9554a..aeb51dabf5 100644 --- a/notifications/js/notificationajaxpopup.js +++ b/notifications/js/notificationajaxpopup.js @@ -13,7 +13,7 @@ function notificationwindow_init() { } function notificationwindow_setTimeout() { - window.setTimeout("notificationwindow_refresh();", 10000); + window.setTimeout("notificationwindow_refresh();", 60000); } function notificationwindow_refresh() { xajax_doXMLHTTP("notifications.notification_popup.ajax_get_notifications"); diff --git a/notifications/setup/phpgw_pl.lang b/notifications/setup/phpgw_pl.lang new file mode 100644 index 0000000000..b63f5d8288 --- /dev/null +++ b/notifications/setup/phpgw_pl.lang @@ -0,0 +1,3 @@ +don't notify me via popups in egroupware notifications pl Nie powiadamiaj mnie przez okienka wyskakuj±ce w eGroupWare +notification common pl Powiadomienie +preferences for notification notifications pl Preferencje dla powiadomienia diff --git a/notifications/setup/phpgw_sk.lang b/notifications/setup/phpgw_sk.lang index f34c46fe75..6a6a7313ea 100644 --- a/notifications/setup/phpgw_sk.lang +++ b/notifications/setup/phpgw_sk.lang @@ -1,3 +1,3 @@ don't notify me via popups in egroupware notifications sk Neupozorňuj ma cez vyskakovacie okná v eGroupWare notification common sk Pripomienka -preferences for notification notifications sk Nastavenia pre Pripomienky +preferences for notification notifications sk Predvoµby pre Pripomienky diff --git a/notifications/setup/setup.inc.php b/notifications/setup/setup.inc.php index 421ce9a475..b1525dda97 100644 --- a/notifications/setup/setup.inc.php +++ b/notifications/setup/setup.inc.php @@ -15,7 +15,7 @@ if (!defined('NOTIFICATION_APP')) } $setup_info[NOTIFICATION_APP]['name'] = NOTIFICATION_APP; -$setup_info[NOTIFICATION_APP]['version'] = '0.6'; +$setup_info[NOTIFICATION_APP]['version'] = '1.4'; $setup_info[NOTIFICATION_APP]['app_order'] = 1; $setup_info[NOTIFICATION_APP]['tables'] = array('egw_notificationpopup'); $setup_info[NOTIFICATION_APP]['enable'] = 2; @@ -40,10 +40,10 @@ $setup_info[NOTIFICATION_APP]['hooks'][] = 'preferences'; /* Dependencies for this app to work */ $setup_info[NOTIFICATION_APP]['depends'][] = array( 'appname' => 'phpgwapi', - 'versions' => Array('1.2','1.3') + 'versions' => Array('1.3','1.4','1.5') ); $setup_info[NOTIFICATION_APP]['depends'][] = array( 'appname' => 'etemplate', - 'versions' => Array('1.2','1.3') + 'versions' => Array('1.3','1.4','1.5') ); diff --git a/notifications/setup/tables_update.inc.php b/notifications/setup/tables_update.inc.php index f3cdb7ac70..15099a8354 100644 --- a/notifications/setup/tables_update.inc.php +++ b/notifications/setup/tables_update.inc.php @@ -22,4 +22,11 @@ return $GLOBALS['setup_info']['notifications']['currentver'] = '0.6'; } + + + $test[] = '0.6'; + function notifications_upgrade0_6() + { + return $GLOBALS['setup_info']['notifications']['currentver'] = '1.4'; + } ?>