Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../var/softacul.../leto
File: inc.ClassEmailNotify.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Implementation of notifation system using email
[2] Fix | Delete
*
[3] Fix | Delete
* @category DMS
[4] Fix | Delete
* @package LetoDMS
[5] Fix | Delete
* @license GPL 2
[6] Fix | Delete
* @version @version@
[7] Fix | Delete
* @author Uwe Steinmann <uwe@steinmann.cx>
[8] Fix | Delete
* @copyright Copyright (C) 2002-2005 Markus Westphal,
[9] Fix | Delete
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
[10] Fix | Delete
* 2010 Uwe Steinmann
[11] Fix | Delete
* @version Release: @package_version@
[12] Fix | Delete
*/
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Include parent class
[16] Fix | Delete
*/
[17] Fix | Delete
require_once("inc.ClassNotify.php");
[18] Fix | Delete
require_once("[[softpath]]/LetoDMS/Mail.php");
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Class to send email notifications to individuals or groups
[22] Fix | Delete
*
[23] Fix | Delete
* @category DMS
[24] Fix | Delete
* @package LetoDMS
[25] Fix | Delete
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
[26] Fix | Delete
* @copyright Copyright (C) 2002-2005 Markus Westphal,
[27] Fix | Delete
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
[28] Fix | Delete
* 2010 Uwe Steinmann
[29] Fix | Delete
* @version Release: @package_version@
[30] Fix | Delete
*/
[31] Fix | Delete
class LetoDMS_EmailNotify extends LetoDMS_Notify {
[32] Fix | Delete
/**
[33] Fix | Delete
* Instanz of DMS
[34] Fix | Delete
*/
[35] Fix | Delete
protected $_dms;
[36] Fix | Delete
[37] Fix | Delete
protected $smtp_server;
[38] Fix | Delete
[39] Fix | Delete
protected $smtp_port;
[40] Fix | Delete
[41] Fix | Delete
protected $smtp_user;
[42] Fix | Delete
[43] Fix | Delete
protected $smtp_password;
[44] Fix | Delete
[45] Fix | Delete
protected $from_address;
[46] Fix | Delete
[47] Fix | Delete
protected $lazy_ssl;
[48] Fix | Delete
[49] Fix | Delete
protected $debug;
[50] Fix | Delete
[51] Fix | Delete
function __construct($dms, $from_address='', $smtp_server='', $smtp_port='', $smtp_username='', $smtp_password='', $lazy_ssl=true) { /* {{{ */
[52] Fix | Delete
$this->_dms = $dms;
[53] Fix | Delete
$this->smtp_server = $smtp_server;
[54] Fix | Delete
$this->smtp_port = $smtp_port;
[55] Fix | Delete
$this->smtp_user = $smtp_username;
[56] Fix | Delete
$this->smtp_password = $smtp_password;
[57] Fix | Delete
$this->from_address = $from_address;
[58] Fix | Delete
$this->lazy_ssl = $lazy_ssl;
[59] Fix | Delete
$this->debug = false;
[60] Fix | Delete
} /* }}} */
[61] Fix | Delete
[62] Fix | Delete
public function setDebug($debug=true) { /* {{{ */
[63] Fix | Delete
$this->debug = (bool) $debug;
[64] Fix | Delete
} /* }}} */
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Send mail to individual user
[68] Fix | Delete
*
[69] Fix | Delete
* @param mixed $sender individual sending the email. This can be a
[70] Fix | Delete
* user object or a string. If it is left empty, then
[71] Fix | Delete
* $this->from_address will be used.
[72] Fix | Delete
* @param object $recipient individual receiving the mail
[73] Fix | Delete
* @param string $subject key of string containing the subject of the mail
[74] Fix | Delete
* @param string $message key of string containing the body of the mail
[75] Fix | Delete
* @param array $params list of parameters which replaces placeholder in
[76] Fix | Delete
* the subject and body
[77] Fix | Delete
* @return false or -1 in case of error, otherwise true
[78] Fix | Delete
*/
[79] Fix | Delete
function toIndividual($sender, $recipient, $subject, $message, $params=array()) { /* {{{ */
[80] Fix | Delete
if(is_object($recipient) && !strcasecmp(get_class($recipient), $this->_dms->getClassname('user')) && !$recipient->isDisabled() && $recipient->getEmail()!="") {
[81] Fix | Delete
$to = $recipient->getEmail();
[82] Fix | Delete
$lang = $recipient->getLanguage();
[83] Fix | Delete
} elseif(is_string($recipient) && trim($recipient) != "") {
[84] Fix | Delete
$to = $recipient;
[85] Fix | Delete
if(isset($params['__lang__']))
[86] Fix | Delete
$lang = $params['__lang__'];
[87] Fix | Delete
else
[88] Fix | Delete
$lang = 'en_GB';
[89] Fix | Delete
} else {
[90] Fix | Delete
return false;
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
$returnpath = $this->from_address;
[94] Fix | Delete
if(is_object($sender) && !strcasecmp(get_class($sender), $this->_dms->getClassname('user'))) {
[95] Fix | Delete
$from = $sender->getFullName() ." <". $sender->getEmail() .">";
[96] Fix | Delete
if(!$returnpath)
[97] Fix | Delete
$returnpath = $sender->getEmail();
[98] Fix | Delete
} elseif(is_string($sender) && trim($sender) != "") {
[99] Fix | Delete
$from = $sender;
[100] Fix | Delete
if(!$returnpath)
[101] Fix | Delete
$returnpath = $sender;
[102] Fix | Delete
} else {
[103] Fix | Delete
$from = $this->from_address;
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
[107] Fix | Delete
$message = getMLText("email_header", array(), "", $lang)."\r\n\r\n".getMLText($message, $params, "", $lang);
[108] Fix | Delete
$message .= "\r\n\r\n".getMLText("email_footer", array(), "", $lang);
[109] Fix | Delete
[110] Fix | Delete
$headers = array ();
[111] Fix | Delete
$headers['From'] = $from;
[112] Fix | Delete
if($returnpath)
[113] Fix | Delete
$headers['Return-Path'] = $returnpath;
[114] Fix | Delete
$headers['To'] = $to;
[115] Fix | Delete
$preferences = array("input-charset" => "UTF-8", "output-charset" => "UTF-8");
[116] Fix | Delete
$encoded_subject = iconv_mime_encode("Subject", getMLText($subject, $params, "", $lang), $preferences);
[117] Fix | Delete
$headers['Subject'] = substr($encoded_subject, strlen('Subject: '));
[118] Fix | Delete
$headers['Date'] = date('r', time());
[119] Fix | Delete
$headers['MIME-Version'] = "1.0";
[120] Fix | Delete
$headers['Content-type'] = "text/plain; charset=utf-8";
[121] Fix | Delete
[122] Fix | Delete
$mail_params = array();
[123] Fix | Delete
if($this->smtp_server) {
[124] Fix | Delete
if($this->debug)
[125] Fix | Delete
$mail_params['debug'] = true;
[126] Fix | Delete
$mail_params['host'] = $this->smtp_server;
[127] Fix | Delete
if($this->smtp_port) {
[128] Fix | Delete
$mail_params['port'] = $this->smtp_port;
[129] Fix | Delete
}
[130] Fix | Delete
if($this->smtp_user) {
[131] Fix | Delete
$mail_params['auth'] = true;
[132] Fix | Delete
$mail_params['username'] = $this->smtp_user;
[133] Fix | Delete
$mail_params['password'] = $this->smtp_password;
[134] Fix | Delete
}
[135] Fix | Delete
/* See ticket #384 */
[136] Fix | Delete
if($this->lazy_ssl)
[137] Fix | Delete
$mail_params['socket_options'] = array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false));
[138] Fix | Delete
[139] Fix | Delete
$mail = Mail::factory('smtp', $mail_params);
[140] Fix | Delete
} else {
[141] Fix | Delete
$mail = Mail::factory('mail', $mail_params);
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
if (isset($GLOBALS['LetoDMS_HOOKS']['mailqueue'])) {
[145] Fix | Delete
foreach($GLOBALS['LetoDMS_HOOKS']['mailqueue'] as $queueService) {
[146] Fix | Delete
if(method_exists($queueService, 'queueMailJob')) {
[147] Fix | Delete
$ret = $queueService->queueMailJob($mail_params, $to, $headers, getMLText($subject, $params, "", $lang), $message);
[148] Fix | Delete
if($ret !== null)
[149] Fix | Delete
return $ret;
[150] Fix | Delete
}
[151] Fix | Delete
}
[152] Fix | Delete
}
[153] Fix | Delete
$result = $mail->send($to, $headers, $message);
[154] Fix | Delete
if (PEAR::isError($result)) {
[155] Fix | Delete
return false;
[156] Fix | Delete
} else {
[157] Fix | Delete
return true;
[158] Fix | Delete
}
[159] Fix | Delete
} /* }}} */
[160] Fix | Delete
[161] Fix | Delete
function toGroup($sender, $groupRecipient, $subject, $message, $params=array()) { /* {{{ */
[162] Fix | Delete
if ((!is_object($sender) && strcasecmp(get_class($sender), $this->_dms->getClassname('user'))) ||
[163] Fix | Delete
(!is_object($groupRecipient) || strcasecmp(get_class($groupRecipient), $this->_dms->getClassname('group')))) {
[164] Fix | Delete
return false;
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
foreach ($groupRecipient->getUsers() as $recipient) {
[168] Fix | Delete
$this->toIndividual($sender, $recipient, $subject, $message, $params);
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
return true;
[172] Fix | Delete
} /* }}} */
[173] Fix | Delete
[174] Fix | Delete
function toList($sender, $recipients, $subject, $message, $params=array()) { /* {{{ */
[175] Fix | Delete
if ((!is_object($sender) && strcasecmp(get_class($sender), $this->_dms->getClassname('user'))) ||
[176] Fix | Delete
(!is_array($recipients) && count($recipients)==0)) {
[177] Fix | Delete
return false;
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
foreach ($recipients as $recipient) {
[181] Fix | Delete
$this->toIndividual($sender, $recipient, $subject, $message, $params);
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
return true;
[185] Fix | Delete
} /* }}} */
[186] Fix | Delete
}
[187] Fix | Delete
?>
[188] Fix | Delete
[189] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function