* Calendar: fixed since last update missing event details, notification iCal adds description with (required) *~*~*~*~*~*~*~*~*~* separator, extended has description before event details and links

This commit is contained in:
Ralf Becker 2012-08-21 14:49:26 +00:00
parent 6db28c5a1a
commit 1b3e897eec
3 changed files with 31 additions and 21 deletions

View File

@ -845,7 +845,7 @@ class calendar_boupdate extends calendar_bo
$details['olddate'] = $olddate->format($timeformat); $details['olddate'] = $olddate->format($timeformat);
} }
list($subject,$body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
$popup = ''; $popup = '';
switch($part_prefs['calendar']['update_format']) switch($part_prefs['calendar']['update_format'])
{ {
@ -868,7 +868,8 @@ class calendar_boupdate extends calendar_bo
$subject = $event['title']; $subject = $event['title'];
// fall through // fall through
case 'extended': case 'extended':
$body .= "\n\n".lang('Event Details follow').":\n";
$details_body = lang('Event Details follow').":\n";
foreach($event_arr as $key => $val) foreach($event_arr as $key => $val)
{ {
if(!empty($details[$key])) if(!empty($details[$key]))
@ -879,15 +880,14 @@ class calendar_boupdate extends calendar_bo
case 'priority': case 'priority':
case 'link': case 'link':
case 'description': case 'description':
case 'title':
break; break;
default: default:
$popup .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]); $details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]);
break; break;
} }
} }
} }
// description need to be separated from body by fancy separator
$body .= "\n*~*~*~*~*~*~*~*~*~*\n\n".$details['description'];
break; break;
} }
// send via notification_app // send via notification_app
@ -897,14 +897,22 @@ class calendar_boupdate extends calendar_bo
//error_log(__METHOD__."() notifying $userid from $senderid: $subject"); //error_log(__METHOD__."() notifying $userid from $senderid: $subject");
$notification = new notifications(); $notification = new notifications();
$notification->set_receivers(array($userid)); $notification->set_receivers(array($userid));
$notification->set_message($body);
$notification->set_sender($senderid); $notification->set_sender($senderid);
$notification->set_subject($subject); $notification->set_subject($subject);
// as we want ical body to be just describtion, we can NOT set links, as they get appended to body // as we want ical body to be just describtion, we can NOT set links, as they get appended to body
if ($part_prefs['calendar']['update_format'] != 'ical') if ($part_prefs['calendar']['update_format'] != 'ical')
{ {
$notification->set_message($notify_body."\n\n".$details['description']."\n\n".$details_body);
$notification->set_links(array($details['link_arr'])); $notification->set_links(array($details['link_arr']));
} }
else
{
// set message (without separator) for popup notifications
$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
// iCal: description need to be separated from body by fancy separator
$notification->set_message($notify_body."\n\n".$details_body."\n*~*~*~*~*~*~*~*~*~*\n\n".$details['description']);
}
if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
$notification->send(); $notification->send();
} }

View File

@ -290,7 +290,7 @@ final class notifications {
*/ */
public function set_popupmessage($_message) { public function set_popupmessage($_message) {
//popup requires html //popup requires html
if(strlen($_message) == strlen(strip_tags($_message))) $_message=nl2br($_message); if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message);
$this->message_popup = $_message; $this->message_popup = $_message;
return true; return true;
} }
@ -518,12 +518,23 @@ final class notifications {
if(!empty($_message_html)) { if(!empty($_message_html)) {
$messages['html'] = $_message_html; $messages['html'] = $_message_html;
} else { } else {
$messages['html'] = nl2br($_message_plain); $messages['html'] = self::plain2html($_message_plain);
} }
if (!empty($_message_popup)) $messages['popup']=$_message_popup; if (!empty($_message_popup)) $messages['popup']=$_message_popup;
return $messages; return $messages;
} }
/**
* Create html from plaintext message
*
* @param string $_plain
* @return string html message
*/
public static function plain2html($_plain)
{
return nl2br(html::htmlspecialchars($_plain, true));
}
/** /**
* prepends another message to the messages array * prepends another message to the messages array
* *

View File

@ -96,26 +96,17 @@ class notifications_email implements notifications_iface {
$this->mail->From = $this->sender->account_email; $this->mail->From = $this->sender->account_email;
$this->mail->FromName = $this->sender->account_fullname; $this->mail->FromName = $this->sender->account_fullname;
$this->mail->Subject = $_subject; $this->mail->Subject = $_subject;
//error_log(__METHOD__.__LINE__.array2string($_attachments)); // add iCal invitation as mulitpart alternative for calendar notifications
$isMeetingRequestNotif = false;
if ($_attachments && stripos($_attachments[0]->type,"text/calendar; method=")!==false) if ($_attachments && stripos($_attachments[0]->type,"text/calendar; method=")!==false)
{ {
$this->mail->AltExtended = $_attachments[0]->string; $this->mail->AltExtended = $_attachments[0]->string;
$this->mail->AltExtendedContentType = $_attachments[0]->type; $this->mail->AltExtendedContentType = $_attachments[0]->type;
unset($_attachments[0]); unset($_attachments[0]);
$isMeetingRequestNotif = true;
} }
// do not send html part if this is a meeting request notification
$this->mail->IsHTML(($isMeetingRequestNotif?false:true)); $this->mail->IsHTML(($isMeetingRequestNotif?false:true));
if ($isMeetingRequestNotif===false)
{
$this->mail->Body = $body_html; $this->mail->Body = $body_html;
$this->mail->AltBody = $body_plain; $this->mail->AltBody = $body_plain;
}
else
{
$this->mail->Body = $body_plain;
}
if(is_array($_attachments) && count($_attachments) > 0) if(is_array($_attachments) && count($_attachments) > 0)
{ {
foreach($_attachments as $attachment) foreach($_attachments as $attachment)