mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-26 15:59:23 +01:00
"explicit require bofelamimail, 'til it get a autoloading conform name"
This commit is contained in:
parent
a1c7c87195
commit
1b5bd9a1fb
@ -8,7 +8,7 @@
|
|||||||
* @link http://www.egroupware.org
|
* @link http://www.egroupware.org
|
||||||
* @author Cornelius Weiss <nelius@cwtech.de>, Christian Binder <christian@jaytraxx.de>
|
* @author Cornelius Weiss <nelius@cwtech.de>, Christian Binder <christian@jaytraxx.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajax methods for notifications
|
* Ajax methods for notifications
|
||||||
*/
|
*/
|
||||||
@ -17,52 +17,52 @@ class notifications_ajax {
|
|||||||
* Appname
|
* Appname
|
||||||
*/
|
*/
|
||||||
const _appname = 'notifications';
|
const _appname = 'notifications';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mailappname
|
* Mailappname
|
||||||
*/
|
*/
|
||||||
const _mailappname = 'felamimail';
|
const _mailappname = 'felamimail';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification table in SQL database
|
* Notification table in SQL database
|
||||||
*/
|
*/
|
||||||
const _notification_table = 'egw_notificationpopup';
|
const _notification_table = 'egw_notificationpopup';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* holds account object for user to notify
|
* holds account object for user to notify
|
||||||
*
|
*
|
||||||
* @var object
|
* @var object
|
||||||
*/
|
*/
|
||||||
private $recipient;
|
private $recipient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* holds config object (sitewide application config)
|
* holds config object (sitewide application config)
|
||||||
*
|
*
|
||||||
* @var object
|
* @var object
|
||||||
*/
|
*/
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* holds preferences array of user to notify
|
* holds preferences array of user to notify
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $preferences;
|
private $preferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reference to global db object
|
* reference to global db object
|
||||||
*
|
*
|
||||||
* @var db
|
* @var db
|
||||||
*/
|
*/
|
||||||
private $db;
|
private $db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* holds the users session data
|
* holds the users session data
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $session_data;
|
var $session_data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* holds the users session data defaults
|
* holds the users session data defaults
|
||||||
*
|
*
|
||||||
@ -71,14 +71,14 @@ class notifications_ajax {
|
|||||||
var $session_data_defaults = array(
|
var $session_data_defaults = array(
|
||||||
'notified_mail_uids' => array(),
|
'notified_mail_uids' => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the xml response object
|
* the xml response object
|
||||||
*
|
*
|
||||||
* @var response
|
* @var response
|
||||||
*/
|
*/
|
||||||
private $response;
|
private $response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
*
|
*
|
||||||
@ -96,31 +96,31 @@ class notifications_ajax {
|
|||||||
|
|
||||||
$this->db = $GLOBALS['egw']->db;
|
$this->db = $GLOBALS['egw']->db;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* destructor
|
* destructor
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __destruct() {}
|
public function __destruct() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* public AJAX trigger function to be called by the JavaScript client
|
* public AJAX trigger function to be called by the JavaScript client
|
||||||
*
|
*
|
||||||
* this function calls all other recurring AJAX notifications methods
|
* this function calls all other recurring AJAX notifications methods
|
||||||
* to have ONE single recurring AJAX call per user
|
* to have ONE single recurring AJAX call per user
|
||||||
*
|
*
|
||||||
* @return xajax response
|
* @return xajax response
|
||||||
*/
|
*/
|
||||||
public function get_notifications() {
|
public function get_notifications() {
|
||||||
$this->check_mailbox();
|
$this->check_mailbox();
|
||||||
$this->get_egwpopup();
|
$this->get_egwpopup();
|
||||||
|
|
||||||
return $this->response->getXML();
|
return $this->response->getXML();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks users mailbox and sends a notification if new mails have arrived
|
* checks users mailbox and sends a notification if new mails have arrived
|
||||||
*
|
*
|
||||||
* @return boolean true or false
|
* @return boolean true or false
|
||||||
*/
|
*/
|
||||||
private function check_mailbox() {
|
private function check_mailbox() {
|
||||||
@ -131,16 +131,18 @@ class notifications_ajax {
|
|||||||
if(count($notify_folders) == 0) {
|
if(count($notify_folders) == 0) {
|
||||||
return true; //no folders configured for notifying - exit
|
return true; //no folders configured for notifying - exit
|
||||||
}
|
}
|
||||||
|
// explicit require bofelamimail, 'til it get a autoloading conform name
|
||||||
|
require_once(EGW_INCLUDE_ROOT.'/felamimail/inc/class.bofelamimail.inc.php');
|
||||||
|
|
||||||
$bofelamimail = new bofelamimail($GLOBALS['egw']->translation->charset());
|
$bofelamimail = new bofelamimail($GLOBALS['egw']->translation->charset());
|
||||||
if(!$bofelamimail->openConnection()) {
|
if(!$bofelamimail->openConnection()) {
|
||||||
// TODO: This is ugly. Log a bit nicer!
|
// TODO: This is ugly. Log a bit nicer!
|
||||||
error_log(self::_appname.' (user: '.$this->recipient->account_lid.'): cannot connect to mailbox. Please check your prefs!');
|
error_log(self::_appname.' (user: '.$this->recipient->account_lid.'): cannot connect to mailbox. Please check your prefs!');
|
||||||
return false; // cannot connect to mailbox
|
return false; // cannot connect to mailbox
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->restore_session_data();
|
$this->restore_session_data();
|
||||||
|
|
||||||
$recent_messages = array();
|
$recent_messages = array();
|
||||||
$folder_status = array();
|
$folder_status = array();
|
||||||
foreach($notify_folders as $id=>$notify_folder) {
|
foreach($notify_folders as $id=>$notify_folder) {
|
||||||
@ -162,7 +164,7 @@ class notifications_ajax {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($recent_messages) > 0) {
|
if(count($recent_messages) > 0) {
|
||||||
// create notify message
|
// create notify message
|
||||||
$notification_subject = lang("You've got new mail");
|
$notification_subject = lang("You've got new mail");
|
||||||
@ -180,12 +182,12 @@ class notifications_ajax {
|
|||||||
// save notification status
|
// save notification status
|
||||||
$this->session_data['notified_mail_uids'][$recent_message['folder']][] = $recent_message['uid'];
|
$this->session_data['notified_mail_uids'][$recent_message['folder']][] = $recent_message['uid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// create etemplate
|
// create etemplate
|
||||||
$tpl = new etemplate();
|
$tpl = new etemplate();
|
||||||
$tpl->read('notifications.checkmailbox');
|
$tpl->read('notifications.checkmailbox');
|
||||||
$notification_message = $tpl->exec(false, $values, false, false, false, 1);
|
$notification_message = $tpl->exec(false, $values, false, false, false, 1);
|
||||||
|
|
||||||
// send notification
|
// send notification
|
||||||
$notification = new notifications();
|
$notification = new notifications();
|
||||||
$notification->set_receivers(array($this->recipient->account_id));
|
$notification->set_receivers(array($this->recipient->account_id));
|
||||||
@ -195,20 +197,20 @@ class notifications_ajax {
|
|||||||
$notification->set_skip_backends(array('email'));
|
$notification->set_skip_backends(array('email'));
|
||||||
$notification->send();
|
$notification->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->save_session_data();
|
$this->save_session_data();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets all egwpopup notifications for calling user
|
* gets all egwpopup notifications for calling user
|
||||||
*
|
*
|
||||||
* @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'];
|
$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,
|
'session_id' => $session_id,
|
||||||
@ -222,7 +224,7 @@ class notifications_ajax {
|
|||||||
'account_id' => $this->recipient->account_id,
|
'account_id' => $this->recipient->account_id,
|
||||||
'session_id' => $session_id,
|
'session_id' => $session_id,
|
||||||
),__LINE__,__FILE__,self::_appname);
|
),__LINE__,__FILE__,self::_appname);
|
||||||
|
|
||||||
switch($this->preferences[self::_appname]['egwpopup_verbosity']) {
|
switch($this->preferences[self::_appname]['egwpopup_verbosity']) {
|
||||||
case 'low':
|
case 'low':
|
||||||
$this->response->addScript('notificationbell_switch("active");');
|
$this->response->addScript('notificationbell_switch("active");');
|
||||||
@ -239,10 +241,10 @@ class notifications_ajax {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restores the users session data for notifications
|
* restores the users session data for notifications
|
||||||
*
|
*
|
||||||
* @return boolean true
|
* @return boolean true
|
||||||
*/
|
*/
|
||||||
private function restore_session_data() {
|
private function restore_session_data() {
|
||||||
@ -252,13 +254,13 @@ class notifications_ajax {
|
|||||||
} else {
|
} else {
|
||||||
$this->session_data = $this->session_data_defaults;
|
$this->session_data = $this->session_data_defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* saves the users session data for notifications
|
* saves the users session data for notifications
|
||||||
*
|
*
|
||||||
* @return boolean true
|
* @return boolean true
|
||||||
*/
|
*/
|
||||||
private function save_session_data() {
|
private function save_session_data() {
|
||||||
|
Loading…
Reference in New Issue
Block a user