/** * Constructor. * @param $emailKey string unique identifier for the template * @param $locale string locale of the template */ function MailTemplate($emailKey = null, $locale = null) { parent::PKPMailTemplate($emailKey, $locale); if (isset($this->emailKey)) { $emailTemplateDao = DAORegistry::getDAO('EmailTemplateDAO'); $emailTemplate =& $emailTemplateDao->getEmailTemplate($this->emailKey, $this->locale); } if (isset($emailTemplate) && Request::getUserVar('subject') == null && Request::getUserVar('body') == null) { $this->setSubject($emailTemplate->getSubject()); $this->setBody($emailTemplate->getBody()); $this->enabled = $emailTemplate->getEnabled(); if (Request::getUserVar('usePostedAddresses')) { $to = Request::getUserVar('to'); if (is_array($to)) { $this->setRecipients($this->processAddresses($this->getRecipients(), $to)); } $cc = Request::getUserVar('cc'); if (is_array($cc)) { $this->setCcs($this->processAddresses($this->getCcs(), $cc)); } $bcc = Request::getUserVar('bcc'); if (is_array($bcc)) { $this->setBccs($this->processAddresses($this->getBccs(), $bcc)); } } } else { $this->setSubject(Request::getUserVar('subject')); $this->setBody(Request::getUserVar('body')); $this->skip = ($tmp = Request::getUserVar('send')) && is_array($tmp) && isset($tmp['skip']); $this->enabled = true; if (is_array($toEmails = Request::getUserVar('to'))) { $this->setRecipients($this->processAddresses($this->getRecipients(), $toEmails)); } if (is_array($ccEmails = Request::getUserVar('cc'))) { $this->setCcs($this->processAddresses($this->getCcs(), $ccEmails)); } if (is_array($bccEmails = Request::getUserVar('bcc'))) { $this->setBccs($this->processAddresses($this->getBccs(), $bccEmails)); } } $site =& Request::getSite(); $this->setFrom($site->getLocalizedSetting('contactEmail'), $site->getLocalizedSetting('contactName')); }
/** * Constructor. * @param $emailKey string unique identifier for the template * @param $locale string locale of the template * @param $enableAttachments boolean optional Whether or not to enable article attachments in the template * @param $journal object optional The journal this message relates to * @param $includeSignature boolean optional * @param $ignorePostedData boolean optional */ function MailTemplate($emailKey = null, $locale = null, $enableAttachments = null, $journal = null, $includeSignature = true, $ignorePostedData = false) { parent::PKPMailTemplate($emailKey, $locale, $enableAttachments, $includeSignature); // If a journal wasn't specified, use the current request. if ($journal === null) { $journal =& Request::getJournal(); } if (isset($this->emailKey)) { $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO'); $emailTemplate =& $emailTemplateDao->getEmailTemplate($this->emailKey, $this->locale, $journal == null ? 0 : $journal->getId()); } $userSig = ''; $user =& Request::getUser(); if ($user && $includeSignature) { $userSig = $user->getLocalizedSignature(); if (!empty($userSig)) { $userSig = "\n" . $userSig; } } if (isset($emailTemplate) && ($ignorePostedData || Request::getUserVar('subject') == null && Request::getUserVar('body') == null)) { $this->setSubject($emailTemplate->getSubject()); $this->setBody($emailTemplate->getBody() . $userSig); $this->enabled = $emailTemplate->getEnabled(); if (Request::getUserVar('usePostedAddresses')) { $to = Request::getUserVar('to'); if (is_array($to)) { $this->setRecipients($this->processAddresses($this->getRecipients(), $to)); } $cc = Request::getUserVar('cc'); if (is_array($cc)) { $this->setCcs($this->processAddresses($this->getCcs(), $cc)); } $bcc = Request::getUserVar('bcc'); if (is_array($bcc)) { $this->setBccs($this->processAddresses($this->getBccs(), $bcc)); } } } else { $this->setSubject(Request::getUserVar('subject')); $body = Request::getUserVar('body'); if (empty($body)) { $this->setBody($userSig); } else { $this->setBody($body); } $this->skip = ($tmp = Request::getUserVar('send')) && is_array($tmp) && isset($tmp['skip']); $this->enabled = true; if (is_array($toEmails = Request::getUserVar('to'))) { $this->setRecipients($this->processAddresses($this->getRecipients(), $toEmails)); } if (is_array($ccEmails = Request::getUserVar('cc'))) { $this->setCcs($this->processAddresses($this->getCcs(), $ccEmails)); } if (is_array($bccEmails = Request::getUserVar('bcc'))) { $this->setBccs($this->processAddresses($this->getBccs(), $bccEmails)); } } // Default "From" to user if available, otherwise site/journal principal contact $user =& Request::getUser(); if ($user) { $this->setFrom($user->getEmail(), $user->getFullName()); } elseif (is_null($journal) || is_null($journal->getSetting('contactEmail'))) { $site =& Request::getSite(); $this->setFrom($site->getLocalizedContactEmail(), $site->getLocalizedContactName()); } else { $this->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); } if ($journal && !Request::getUserVar('continued')) { $this->setSubject('[' . $journal->getLocalizedSetting('initials') . '] ' . $this->getSubject()); } $this->journal =& $journal; }