17 import(
'lib.pkp.classes.mail.Mail');
 
   19 define(
'MAIL_ERROR_INVALID_EMAIL', 0x000001);
 
   56       parent::__construct();
 
   68       $this->bccSender = $request->getUserVar(
'bccSender');
 
   70       $this->addressFieldsEnabled = 
true;
 
   72       if (isset($this->emailKey)) {
 
   77       $user = defined(
'SESSION_DISABLE_INIT')?
null:$request->getUser();
 
   78       if ($user && $this->includeSignature) {
 
   79          $userSig = $user->getLocalizedSignature();
 
   80          if (!empty($userSig)) $userSig = 
"<br/>" . $userSig;
 
   83       if (isset($emailTemplate)) {
 
   84          $this->
setSubject($emailTemplate->getData(
'subject', $this->locale));
 
   85          $this->
setBody($emailTemplate->getData(
'body', $this->locale) . $userSig);
 
   86          $this->enabled = $emailTemplate->getData(
'enabled');
 
   89          $this->enabled = 
true;
 
   94          $this->
setFrom($user->getEmail(), $user->getFullName());
 
   96          $site = $request->getSite();
 
   97          $this->
setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName());
 
   99          $this->
setFrom($context->getData(
'contactEmail'), 
$context->getData(
'contactName'));
 
  103          $this->
setSubject(
'[' . $context->getLocalizedAcronym() . 
'] ' . $this->getSubject());
 
  107       $this->params = array();
 
  134       return ($this->errorMessages != 
null);
 
  144       $site = $request->getSite();
 
  146       if ($this->context) {
 
  150             'principalContactSignature' => $this->context->getData(
'contactName'),
 
  151             'contextName' => $this->context->getLocalizedName(),
 
  152             'contextUrl' => $dispatcher->url($request, ROUTE_PAGE, $this->context->getPath()),
 
  157             'principalContactSignature' => $site->getLocalizedContactName(),
 
  161       if (!defined(
'SESSION_DISABLE_INIT') && ($user = $request->getUser())) {
 
  164             'senderEmail' => $user->getEmail(),
 
  165             'senderName' => $user->getFullName(),
 
  171          'siteTitle' => $site->getLocalizedTitle(),
 
  190       if (isset($this->context)) {
 
  191          $signature = $this->context->getData(
'emailSignature');
 
  192          if (strstr($this->
getBody(), 
'{$templateSignature}') === 
false) {
 
  195             $this->
setBody(str_replace(
'{$templateSignature}', $signature, $this->
getBody()));
 
  198          $envelopeSender = $this->context->getData(
'envelopeSender');
 
  203       $user = defined(
'SESSION_DISABLE_INIT')?
null:$request->getUser();
 
  205       if ($user && $this->bccSender) {
 
  206          $this->
addBcc($user->getEmail(), $user->getFullName());
 
  212       return parent::send();
 
  222       foreach ($this->params as $key => $value) {
 
  223          if (!is_object($value)) {
 
  225             if (filter_var($value, FILTER_VALIDATE_URL) != 
false) {
 
  228                $body = str_replace(
'{$' . $key . 
'}', $value, $body);
 
  232          $subject = str_replace(
'{$' . $key . 
'}', $value, $subject);
 
  250       $ret = $this->
send();
 
  265       $this->
setData(
'recipients', 
null);
 
  269          $this->
setData(
'headers', 
null);
 
  282       preg_match_all(
'/=[\\\'"]{\\$' . preg_quote($key) . 
'}/', $targetString, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
 
  288          for($i = count($matches)-1; $i >= 0; $i--) {
 
  289             $match = $matches[$i][0];
 
  290             $targetString = substr_replace($targetString,  str_replace(
'{$' . $key . 
'}', $value, $match[0]), $match[1], strlen($match[0]));
 
  295       $value = 
"<a href='$value' class='$key-style-class'>$value</a>";
 
  297       $targetString = str_replace(
'{$' . $key . 
'}', $value, $targetString);
 
  299       return $targetString;