forked from extern/egroupware
Popup notifications now go to all windows and are removed when user clicks OK. Or, close the popup with (X) to mark all as read.
This commit is contained in:
parent
056f61ef72
commit
babc62d9f1
@ -614,4 +614,19 @@ final class notifications {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actions to take when an account is deleted
|
||||||
|
*
|
||||||
|
* @param settings array with keys account_id and new_owner (new_owner is optional)
|
||||||
|
*/
|
||||||
|
public function deleteaccount($settings) {
|
||||||
|
foreach($this->backends as $backend) {
|
||||||
|
$notification_backend = self::_appname.'_'.$backend;
|
||||||
|
$backend_obj = new $notification_backend();
|
||||||
|
if(method_exists($backend_obj, 'deleteaccount')) {
|
||||||
|
$backend_obj->deleteaccount($settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,18 @@ class notifications_ajax {
|
|||||||
return $this->response->getXML();
|
return $this->response->getXML();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Let the user confirm that they have seen the message.
|
||||||
|
* After they've seen it, remove it from the database
|
||||||
|
*/
|
||||||
|
public function confirm_message($message) {
|
||||||
|
error_log( html_entity_decode($message));
|
||||||
|
$myval=$this->db->delete(self::_notification_table,array(
|
||||||
|
'account_id' => $this->recipient->account_id,
|
||||||
|
'message' => html_entity_decode($message)
|
||||||
|
),__LINE__,__FILE__,self::_appname);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks users mailbox and sends a notification if new mails have arrived
|
* checks users mailbox and sends a notification if new mails have arrived
|
||||||
*
|
*
|
||||||
@ -211,22 +223,16 @@ class notifications_ajax {
|
|||||||
* @return boolean true or false
|
* @return boolean true or false
|
||||||
*/
|
*/
|
||||||
private function get_egwpopup() {
|
private function get_egwpopup() {
|
||||||
$session_id = $GLOBALS['egw_info']['user']['sessionid'];
|
|
||||||
$message = '';
|
$message = '';
|
||||||
$rs = $this->db->select(self::_notification_table,
|
$rs = $this->db->select(self::_notification_table,
|
||||||
'*', array(
|
'*', array(
|
||||||
'account_id' => $this->recipient->account_id,
|
'account_id' => $this->recipient->account_id,
|
||||||
'session_id' => $session_id,
|
|
||||||
),
|
),
|
||||||
__LINE__,__FILE__,false,'',self::_appname);
|
__LINE__,__FILE__,false,'',self::_appname);
|
||||||
if ($rs->NumRows() > 0) {
|
if ($rs->NumRows() > 0) {
|
||||||
foreach ($rs as $notification) {
|
foreach ($rs as $notification) {
|
||||||
$this->response->addScriptCall('append_notification_message',$notification['message']);
|
$this->response->addScriptCall('append_notification_message',$notification['message']);
|
||||||
}
|
}
|
||||||
$myval=$this->db->delete(self::_notification_table,array(
|
|
||||||
'account_id' => $this->recipient->account_id,
|
|
||||||
'session_id' => $session_id,
|
|
||||||
),__LINE__,__FILE__,self::_appname);
|
|
||||||
|
|
||||||
switch($this->preferences[self::_appname]['egwpopup_verbosity']) {
|
switch($this->preferences[self::_appname]['egwpopup_verbosity']) {
|
||||||
case 'low':
|
case 'low':
|
||||||
|
@ -104,21 +104,18 @@ class notifications_popup implements notifications_iface {
|
|||||||
* @param array $_attachments
|
* @param array $_attachments
|
||||||
*/
|
*/
|
||||||
public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false) {
|
public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false) {
|
||||||
$sessions = egw_session::session_list(0, 'asc', 'session_dla', true);
|
// Check access log to see if user is still logged in
|
||||||
$user_sessions = array();
|
if ( !egw_session::notifications_active($this->recipient->account_id) )
|
||||||
foreach ($sessions as $session) {
|
{
|
||||||
if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) {
|
throw new Exception("User {$this->recipient->account_lid} isn't online. Can't send notification via popup");
|
||||||
$user_sessions[] = $session['session_id'];
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ( empty($user_sessions) ) throw new Exception("User {$this->recipient->account_lid} isn't online. Can't send notification via popup");
|
|
||||||
|
|
||||||
$message = $this->render_infos($_subject)
|
$message = $this->render_infos($_subject)
|
||||||
.html::hr()
|
.html::hr()
|
||||||
.$_messages['html']
|
.$_messages['html']
|
||||||
.$this->render_links($_links);
|
.$this->render_links($_links);
|
||||||
|
|
||||||
$this->save( $message, $user_sessions );
|
$this->save( $message );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,14 +124,11 @@ class notifications_popup implements notifications_iface {
|
|||||||
* @param string $_message
|
* @param string $_message
|
||||||
* @param array $_user_sessions
|
* @param array $_user_sessions
|
||||||
*/
|
*/
|
||||||
private function save( $_message, array $_user_sessions ) {
|
private function save( $_message ) {
|
||||||
foreach ($_user_sessions as $user_session) {
|
|
||||||
$result = $this->db->insert( self::_notification_table, array(
|
$result = $this->db->insert( self::_notification_table, array(
|
||||||
'account_id' => $this->recipient->account_id,
|
'account_id' => $this->recipient->account_id,
|
||||||
'session_id' => $user_session,
|
|
||||||
'message' => $_message
|
'message' => $_message
|
||||||
), false,__LINE__,__FILE__,self::_appname);
|
), false,__LINE__,__FILE__,self::_appname);
|
||||||
}
|
|
||||||
if ($result === false) throw new Exception("Can't save notification into SQL table");
|
if ($result === false) throw new Exception("Can't save notification into SQL table");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,4 +201,23 @@ class notifications_popup implements notifications_iface {
|
|||||||
if(!empty($_subject)) { $infos[] = html::bold($_subject); }
|
if(!empty($_subject)) { $infos[] = html::bold($_subject); }
|
||||||
return implode($newline,$infos);
|
return implode($newline,$infos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actions to take when deleting an account
|
||||||
|
*
|
||||||
|
* @param settings array with keys account_id and new_owner (new_owner is optional)
|
||||||
|
*/
|
||||||
|
public function deleteaccount($settings) {
|
||||||
|
if($settings['new_owner']) {
|
||||||
|
$this->db->update( self::_notification_table, array(
|
||||||
|
'account_id' => $settings['new_owner']
|
||||||
|
), array(
|
||||||
|
'account_id' => $settings['account_id']
|
||||||
|
),__LINE__,__FILE__,self::_appname);
|
||||||
|
} else {
|
||||||
|
$this->db->delete( self::_notification_table, array(
|
||||||
|
'account_id' => $settings['account_id']
|
||||||
|
),__LINE__,__FILE__,self::_appname);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,9 @@ if ($notification_config['popup_enable'] && $GLOBALS['egw_info']['user']['apps']
|
|||||||
echo '<script type="text/javascript">egwpopup_init("'.$popup_poll_interval.'");</script>';
|
echo '<script type="text/javascript">egwpopup_init("'.$popup_poll_interval.'");</script>';
|
||||||
echo '
|
echo '
|
||||||
<div id="egwpopup" style="display: none; z-index: 999;">
|
<div id="egwpopup" style="display: none; z-index: 999;">
|
||||||
<div id="egwpopup_header">'.lang('Notification').'</div>
|
<div id="egwpopup_header">'.lang('Notification'). '<span style="float:right;">'.
|
||||||
|
html::submit_button('egwpopup_close_button', 'X', 'egwpopup_button_close();',true,'', 'close.button') .
|
||||||
|
'</span></div>
|
||||||
<div id="egwpopup_message"></div>
|
<div id="egwpopup_message"></div>
|
||||||
<div id="egwpopup_footer">
|
<div id="egwpopup_footer">
|
||||||
<input id="egwpopup_ok_button" type="submit" value="'. lang('ok'). '" onClick="egwpopup_button_ok();">
|
<input id="egwpopup_ok_button" type="submit" value="'. lang('ok'). '" onClick="egwpopup_button_ok();">
|
||||||
|
@ -64,6 +64,7 @@ function egwpopup_button_ok() {
|
|||||||
egwpopup = document.getElementById("egwpopup");
|
egwpopup = document.getElementById("egwpopup");
|
||||||
egwpopup_message = document.getElementById("egwpopup_message");
|
egwpopup_message = document.getElementById("egwpopup_message");
|
||||||
egwpopup_message.scrollTop = 0;
|
egwpopup_message.scrollTop = 0;
|
||||||
|
xajax_doXMLHTTP("notifications.notifications_ajax.confirm_message", notifymessages[0]);
|
||||||
notifymessages.shift();
|
notifymessages.shift();
|
||||||
if(notifymessages.length > 0) {
|
if(notifymessages.length > 0) {
|
||||||
egwpopup_display();
|
egwpopup_display();
|
||||||
@ -74,6 +75,21 @@ function egwpopup_button_ok() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function append_notification_message(_message) {
|
// Close and mark all as read
|
||||||
notifymessages.push(_message);
|
function egwpopup_button_close() {
|
||||||
|
for(var i = 0; i < notifymessages.length; i++) {
|
||||||
|
xajax_doXMLHTTP("notifications.notifications_ajax.confirm_message", notifymessages[i]);
|
||||||
|
}
|
||||||
|
var egwpopup = document.getElementById("egwpopup");
|
||||||
|
var egwpopup_message = document.getElementById("egwpopup_message");
|
||||||
|
egwpopup.style.display = "none";
|
||||||
|
egwpopup_message.innerHTML = "";
|
||||||
|
notificationbell_switch("inactive");
|
||||||
|
}
|
||||||
|
|
||||||
|
function append_notification_message(_message) {
|
||||||
|
// Check to prevent duplicates
|
||||||
|
if(notifymessages.indexOf(_message) == -1) {
|
||||||
|
notifymessages.push(_message);
|
||||||
|
}
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ if (!defined('NOTIFICATION_APP'))
|
|||||||
}
|
}
|
||||||
|
|
||||||
$setup_info[NOTIFICATION_APP]['name'] = NOTIFICATION_APP;
|
$setup_info[NOTIFICATION_APP]['name'] = NOTIFICATION_APP;
|
||||||
$setup_info[NOTIFICATION_APP]['version'] = '1.8';
|
$setup_info[NOTIFICATION_APP]['version'] = '1.9.001';
|
||||||
$setup_info[NOTIFICATION_APP]['app_order'] = 1;
|
$setup_info[NOTIFICATION_APP]['app_order'] = 1;
|
||||||
$setup_info[NOTIFICATION_APP]['tables'] = array('egw_notificationpopup');
|
$setup_info[NOTIFICATION_APP]['tables'] = array('egw_notificationpopup');
|
||||||
$setup_info[NOTIFICATION_APP]['enable'] = 2;
|
$setup_info[NOTIFICATION_APP]['enable'] = 2;
|
||||||
@ -34,6 +34,7 @@ $setup_info[NOTIFICATION_APP]['hooks'][] = 'after_navbar';
|
|||||||
$setup_info[NOTIFICATION_APP]['hooks'][] = 'preferences';
|
$setup_info[NOTIFICATION_APP]['hooks'][] = 'preferences';
|
||||||
$setup_info[NOTIFICATION_APP]['hooks'][] = 'settings';
|
$setup_info[NOTIFICATION_APP]['hooks'][] = 'settings';
|
||||||
$setup_info[NOTIFICATION_APP]['hooks'][] = 'admin';
|
$setup_info[NOTIFICATION_APP]['hooks'][] = 'admin';
|
||||||
|
$setup_info[NOTIFICATION_APP]['hooks']['deleteaccount'] = 'notifications.notifications.deleteaccount';
|
||||||
//$setup_info[NOTIFICATION_APP]['hooks']['settings'] = NOTIFICATION_APP.'.ts_admin_prefs_sidebox_hooks.settings';
|
//$setup_info[NOTIFICATION_APP]['hooks']['settings'] = NOTIFICATION_APP.'.ts_admin_prefs_sidebox_hooks.settings';
|
||||||
//$setup_info[NOTIFICATION_APP]['hooks']['admin'] = NOTIFICATION_APP.'.ts_admin_prefs_sidebox_hooks.all_hooks';
|
//$setup_info[NOTIFICATION_APP]['hooks']['admin'] = NOTIFICATION_APP.'.ts_admin_prefs_sidebox_hooks.all_hooks';
|
||||||
//$setup_info[NOTIFICATION_APP]['hooks']['sidebox_menu'] = NOTIFICATION_APP.'.ts_admin_prefs_sidebox_hooks.all_hooks';
|
//$setup_info[NOTIFICATION_APP]['hooks']['sidebox_menu'] = NOTIFICATION_APP.'.ts_admin_prefs_sidebox_hooks.all_hooks';
|
||||||
@ -49,3 +50,4 @@ $setup_info[NOTIFICATION_APP]['depends'][] = array(
|
|||||||
'versions' => Array('1.7','1.8','1.9')
|
'versions' => Array('1.7','1.8','1.9')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,16 +9,15 @@
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$phpgw_baseline = array(
|
$phpgw_baseline = array(
|
||||||
'egw_notificationpopup' => array(
|
'egw_notificationpopup' => array(
|
||||||
'fd' => array(
|
'fd' => array(
|
||||||
'account_id' => array('type' => 'int','precision' => '20','nullable' => False),
|
'account_id' => array('type' => 'int','precision' => '20','nullable' => False),
|
||||||
'session_id' => array('type' => 'varchar','precision' => '255','nullable' => False),
|
|
||||||
'message' => array('type' => 'longtext')
|
'message' => array('type' => 'longtext')
|
||||||
),
|
),
|
||||||
'pk' => array(),
|
'pk' => array(),
|
||||||
'fk' => array(),
|
'fk' => array(),
|
||||||
'ix' => array('account_id','session_id'),
|
'ix' => array('account_id'),
|
||||||
'uc' => array()
|
'uc' => array()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -38,3 +38,30 @@ function notifications_upgrade1_6()
|
|||||||
{
|
{
|
||||||
return $GLOBALS['setup_info']['notifications']['currentver'] = '1.8';
|
return $GLOBALS['setup_info']['notifications']['currentver'] = '1.8';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function notifications_upgrade1_8()
|
||||||
|
{
|
||||||
|
$GLOBALS['egw_setup']->oProc->DropColumn('egw_notificationpopup',array(
|
||||||
|
'fd' => array(
|
||||||
|
'account_id' => array('type' => 'int','precision' => '20','nullable' => False),
|
||||||
|
'message' => array('type' => 'longtext')
|
||||||
|
),
|
||||||
|
'pk' => array(),
|
||||||
|
'fk' => array(),
|
||||||
|
'ix' => array('account_id'),
|
||||||
|
'uc' => array()
|
||||||
|
),'session_id');
|
||||||
|
$GLOBALS['egw_setup']->oProc->RefreshTable('egw_notificationpopup',array(
|
||||||
|
'fd' => array(
|
||||||
|
'account_id' => array('type' => 'int','precision' => '20','nullable' => False),
|
||||||
|
'message' => array('type' => 'longtext')
|
||||||
|
),
|
||||||
|
'pk' => array(),
|
||||||
|
'fk' => array(),
|
||||||
|
'ix' => array('account_id'),
|
||||||
|
'uc' => array()
|
||||||
|
));
|
||||||
|
|
||||||
|
return $GLOBALS['setup_info']['notifications']['currentver'] = '1.9.001';
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user