forked from extern/egroupware
async notifications can NOT use a single static variable as cache, as it will be used for all the different entries notified
--> using a class variable (different per app) and indexing cache be id or entry
This commit is contained in:
parent
82a442b722
commit
27a40efc84
@ -647,6 +647,13 @@ abstract class bo_tracking
|
|||||||
return !count($this->errors);
|
return !count($this->errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache for notificaton body
|
||||||
|
*
|
||||||
|
* Cache is by id, language, date-format and type text/html
|
||||||
|
*/
|
||||||
|
protected $body_cache = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sending a notification to the given email-address
|
* Sending a notification to the given email-address
|
||||||
*
|
*
|
||||||
@ -702,20 +709,20 @@ abstract class bo_tracking
|
|||||||
egw_time::init();
|
egw_time::init();
|
||||||
|
|
||||||
// Cache message body to not have to re-generate it every time
|
// Cache message body to not have to re-generate it every time
|
||||||
static $body_cache = array();
|
|
||||||
$lang = translation::$userlang;
|
$lang = translation::$userlang;
|
||||||
$date_format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] .
|
$date_format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] .
|
||||||
$GLOBALS['egw_info']['user']['preferences']['common']['timeformat'];
|
$GLOBALS['egw_info']['user']['preferences']['common']['timeformat'];
|
||||||
|
|
||||||
// Cache text body
|
// Cache text body
|
||||||
if(!$body_cache[$lang][$date_format][false])
|
$body_cache =& $this->body_cache[$data[$this->id_field]][$lang][$date_format];
|
||||||
|
if(empty($data[$this->id_field]) || !isset($body_cache['text']))
|
||||||
{
|
{
|
||||||
$body_cache[$lang][$date_format][false] = $this->get_body(false,$data,$old,false,$receiver);
|
$body_cache['text'] = $this->get_body(false,$data,$old,false,$receiver);
|
||||||
}
|
}
|
||||||
// Cache HTML body
|
// Cache HTML body
|
||||||
if(!$body_cache[$lang][$date_format][true])
|
if(empty($data[$this->id_field]) || !isset($body_cache['html']))
|
||||||
{
|
{
|
||||||
$body_cache[$lang][$date_format][true] = $this->get_body(true,$data,$old,false,$receiver);
|
$body_cache['html'] = $this->get_body(true,$data,$old,false,$receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
// send over notification_app
|
// send over notification_app
|
||||||
@ -725,8 +732,8 @@ abstract class bo_tracking
|
|||||||
try {
|
try {
|
||||||
$notification = new notifications();
|
$notification = new notifications();
|
||||||
$notification->set_receivers(array($receiver));
|
$notification->set_receivers(array($receiver));
|
||||||
$notification->set_message($body_cache[$lang][$date_format][false]);
|
$notification->set_message($body_cache['text']);
|
||||||
$notification->set_message($body_cache[$lang][$date_format][true]);
|
$notification->set_message($body_cache['html']);
|
||||||
$notification->set_sender($this->get_sender($data,$old,true,$receiver));
|
$notification->set_sender($this->get_sender($data,$old,true,$receiver));
|
||||||
$notification->set_subject($this->get_subject($data,$old,$deleted,$receiver));
|
$notification->set_subject($this->get_subject($data,$old,$deleted,$receiver));
|
||||||
$notification->set_links(array($this->get_notification_link($data,$old,$receiver)));
|
$notification->set_links(array($this->get_notification_link($data,$old,$receiver)));
|
||||||
|
Loading…
Reference in New Issue
Block a user