bringing notificaions to v1.4

This commit is contained in:
Cornelius Weiß 2007-06-18 08:49:59 +00:00
commit fddb756140
9 changed files with 51 additions and 16 deletions

View File

@ -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 (<p><a><b><br>)
* implementing class needs to handle them somehow.
* @param string $_message
*/
public function send( $_message );

View File

@ -43,6 +43,10 @@ final class notification {
/**
* sets notification message
* @abstract $message accepts html tags: <p><a><b><br>.
* 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;
}
}

View File

@ -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']). '<br>';
$message .= '<p>'. nl2br($notification['message']). '</p>';
break;
case 'alert' :
$message .= $notification['message']. "\n";
$message .= ".\n". $notification['message']. "\n";
break;
}
}

View File

@ -11,10 +11,9 @@
* @link http://www.egroupware.org
* @author Cornelius Weiss <nelius@cwtech.de>
* @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 '<script src="'. $GLOBALS['egw_info']['server']['webserver_url']. '/notifications/js/notificationajaxpopup.js'. '" type="text/javascript"></script>';
echo '<script type="text/javascript">notificationwindow_init();</script>';
echo '

View File

@ -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");

View File

@ -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

View File

@ -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

View File

@ -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')
);

View File

@ -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';
}
?>