mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
allow to add attachments by giving a path, instead of a string, eg. egw_vfs::PREFIX.$path for a vfs path in $path
This commit is contained in:
parent
3d09b732e3
commit
f25185f0b9
@ -298,11 +298,13 @@ final class notifications {
|
||||
$this->attachments = array(); // clear array if set
|
||||
foreach($_attachments as $attachment) {
|
||||
if(is_array($attachment)) {
|
||||
$this->add_attachment( $attachment['string'],
|
||||
$attachment['filename'],
|
||||
$attachment['encoding'],
|
||||
$attachment['type']
|
||||
);
|
||||
$this->add_attachment(
|
||||
$attachment['string'],
|
||||
$attachment['filename'],
|
||||
$attachment['encoding'],
|
||||
$attachment['type'],
|
||||
$attachment['path']
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -313,18 +315,21 @@ final class notifications {
|
||||
* This method can be used to attach ascii or binary data,
|
||||
* such as a BLOB record from a database.
|
||||
*
|
||||
* @param string $_string Attachment data.
|
||||
* @param string $_string Attachment data or null to use $_path
|
||||
* @param string $_filename Name of the attachment.
|
||||
* @param string $_encoding File encoding (see $Encoding).
|
||||
* @param string $_type File extension (MIME) type.
|
||||
* @param string $_path optional path to attachment, if !$_string
|
||||
*/
|
||||
public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream") {
|
||||
if(!$_string || !$_filename) { return false; }
|
||||
$this->attachments[] = (object)array( 'string' => $_string,
|
||||
'filename' => $_filename,
|
||||
'encoding' => $_encoding,
|
||||
'type' => $_type,
|
||||
);
|
||||
public function add_attachment($_string, $_filename, $_encoding = "base64", $_type = "application/octet-stream", $_path=null) {
|
||||
if(!$_string && (!$_path || !file_exists($_path)) || !$_filename) return false;
|
||||
$this->attachments[] = (object)array(
|
||||
'string' => $_string,
|
||||
'filename' => $_filename,
|
||||
'encoding' => $_encoding ? $_encoding : "base64",
|
||||
'type' => $_type ? $_type : "application/octet-stream",
|
||||
'path' => $_path,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -44,14 +44,14 @@ class notifications_email implements notifications_iface {
|
||||
/**
|
||||
* holds preferences object of user to notify
|
||||
*
|
||||
* @var object
|
||||
* @var preferences
|
||||
*/
|
||||
private $preferences;
|
||||
|
||||
/**
|
||||
* holds mail object
|
||||
*
|
||||
* @var object
|
||||
* @var send
|
||||
*/
|
||||
private $mail;
|
||||
|
||||
@ -95,7 +95,7 @@ class notifications_email implements notifications_iface {
|
||||
$this->mail->AddCustomHeader('X-eGroupWare-type: notification-mail');
|
||||
$this->mail->From = $this->sender->account_email;
|
||||
$this->mail->FromName = $this->sender->account_fullname;
|
||||
$this->mail->Subject = $this->mail->encode_subject($_subject);
|
||||
$this->mail->Subject = $_subject;
|
||||
//error_log(__METHOD__.__LINE__.array2string($_attachments));
|
||||
if ($_attachments && stripos($_attachments[0]->type,"text/calendar; method=")!==false)
|
||||
{
|
||||
@ -106,12 +106,22 @@ class notifications_email implements notifications_iface {
|
||||
$this->mail->IsHTML(true);
|
||||
$this->mail->Body = $body_html;
|
||||
$this->mail->AltBody = $body_plain;
|
||||
if(is_array($_attachments) && count($_attachments) > 0) {
|
||||
foreach($_attachments as $attachment) {
|
||||
$this->mail->AddStringAttachment($attachment->string, $attachment->filename, $attachment->encoding, $attachment->type);
|
||||
if(is_array($_attachments) && count($_attachments) > 0)
|
||||
{
|
||||
foreach($_attachments as $attachment)
|
||||
{
|
||||
if ($attachment->string)
|
||||
{
|
||||
$this->mail->AddStringAttachment($attachment->string, $attachment->filename, $attachment->encoding, $attachment->type);
|
||||
}
|
||||
elseif($attachment->path)
|
||||
{
|
||||
$this->mail->AddAttachment($attachment->path, $attachment->filename, $attachment->encoding, $attachment->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$error=$this->mail->Send()) {
|
||||
if(!$error=$this->mail->Send())
|
||||
{
|
||||
throw new Exception("Failed sending notification message via email.$error".print_r($this->mail->ErrorInfo,true));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user