forked from extern/egroupware
bringing notificaions to v1.4
This commit is contained in:
commit
fddb756140
@ -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 );
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 '
|
||||
|
@ -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");
|
||||
|
3
notifications/setup/phpgw_pl.lang
Normal file
3
notifications/setup/phpgw_pl.lang
Normal 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
|
@ -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
|
||||
|
@ -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')
|
||||
);
|
||||
|
||||
|
@ -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';
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user