mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
Fix extra <br />s in HTML emails, cache notification body instead of re-doing for every notified user
This commit is contained in:
parent
06c1882273
commit
1236f38a5b
@ -695,6 +695,23 @@ abstract class bo_tracking
|
|||||||
translation::init();
|
translation::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cache message body to not have to re-generate it every time
|
||||||
|
static $body_cache = array();
|
||||||
|
$lang = translation::$userlang;
|
||||||
|
$date_format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] .
|
||||||
|
$GLOBALS['egw_info']['user']['preferences']['common']['timeformat'];
|
||||||
|
|
||||||
|
// Cache text body
|
||||||
|
if(!$body_cache[$lang][$date_format][false])
|
||||||
|
{
|
||||||
|
$body_cache[$lang][$date_format][false] = $this->get_body(false,$data,$old,false,$receiver);
|
||||||
|
}
|
||||||
|
// Cache HTML body
|
||||||
|
if(!$body_cache[$lang][$date_format][true])
|
||||||
|
{
|
||||||
|
$body_cache[$lang][$date_format][true] = $this->get_body(true,$data,$old,false,$receiver);
|
||||||
|
}
|
||||||
|
|
||||||
// send over notification_app
|
// send over notification_app
|
||||||
if ($GLOBALS['egw_info']['apps']['notifications']['enabled']) {
|
if ($GLOBALS['egw_info']['apps']['notifications']['enabled']) {
|
||||||
// send via notification_app
|
// send via notification_app
|
||||||
@ -702,8 +719,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($this->get_body(false,$data,$old,false,$receiver)); // set message as plaintext
|
$notification->set_message($body_cache[$lang][$date_format][false]);
|
||||||
$notification->set_message($this->get_body(true,$data,$old,false,$receiver)); // and html
|
$notification->set_message($body_cache[$lang][$date_format][true]);
|
||||||
$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)));
|
||||||
@ -713,7 +730,8 @@ abstract class bo_tracking
|
|||||||
}
|
}
|
||||||
$notification->send();
|
$notification->send();
|
||||||
}
|
}
|
||||||
catch (Exception $exception) {
|
catch (Exception $exception)
|
||||||
|
{
|
||||||
$this->errors[] = $exception->getMessage();
|
$this->errors[] = $exception->getMessage();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -911,10 +929,6 @@ abstract class bo_tracking
|
|||||||
if($this->get_config(self::CUSTOM_NOTIFICATION, $data, $old))
|
if($this->get_config(self::CUSTOM_NOTIFICATION, $data, $old))
|
||||||
{
|
{
|
||||||
$body = $this->get_custom_message($data,$old);
|
$body = $this->get_custom_message($data,$old);
|
||||||
if($html_email)
|
|
||||||
{
|
|
||||||
$body = nl2br($body);
|
|
||||||
}
|
|
||||||
if($sig = $this->get_signature($data,$old,$receiver))
|
if($sig = $this->get_signature($data,$old,$receiver))
|
||||||
{
|
{
|
||||||
$body .= ($html_email ? '<br />':'') . "\n$sig";
|
$body .= ($html_email ? '<br />':'') . "\n$sig";
|
||||||
|
Loading…
Reference in New Issue
Block a user