From 9cea6cd0f4a57b8d7d77bae5cfc9c1f71ab491c6 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Thu, 16 Apr 2020 23:21:49 +0200 Subject: [PATCH 01/25] Converting mail from updatenotification to mail template --- .../sql/updates/mysql/4.0.0-2020-04-16.sql | 1 + .../updates/postgresql/4.0.0-2020-04-16.sql | 1 + .../en-GB/plg_system_updatenotification.ini | 12 ++----- installation/sql/mysql/supports.sql | 3 +- installation/sql/postgresql/supports.sql | 3 +- libraries/src/Mail/MailTemplate.php | 4 +-- .../updatenotification/updatenotification.php | 35 ++++++------------- 7 files changed, 20 insertions(+), 39 deletions(-) create mode 100644 administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql create mode 100644 administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql new file mode 100644 index 0000000000000..ca97fd1e548d8 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql @@ -0,0 +1 @@ +INSERT INTO `#__mail_templates` (`template_id`, `subject`, `body`, `params`) VALUES ('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'); diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql new file mode 100644 index 0000000000000..f4f28298ac503 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql @@ -0,0 +1 @@ +INSERT INTO "#__mail_templates" ("template_id", "subject", "body", "params") VALUES ('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'); diff --git a/administrator/language/en-GB/plg_system_updatenotification.ini b/administrator/language/en-GB/plg_system_updatenotification.ini index 73f42c83c9e4d..ba4b79da568d4 100644 --- a/administrator/language/en-GB/plg_system_updatenotification.ini +++ b/administrator/language/en-GB/plg_system_updatenotification.ini @@ -6,16 +6,8 @@ PLG_SYSTEM_UPDATENOTIFICATION="System - Joomla! Update Notification" PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_LBL="Super User Emails" PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_DESC="A comma separated list of the email addresses which will receive the update notification emails. The addresses in the list MUST belong to existing users of your site who have the Super User privilege. If none of the listed emails belongs to Super Users, or if it's left blank, all Super Users of this site will receive the update notification email." -; You can use the following merge codes: -; [NEWVERSION] New Joomla! version, e.g. 1.2.3 -; [CURVERSION] Currently installed Joomla! version, e.g. 1.2.0 -; [SITENAME] Site name, as set in Global Configuration. -; [URL] URL of the site's frontend page. -; [LINK] Update URL (link to com_joomlaupdate, will request login if the Super User isn't already logged in). -; [RELEASENEWS] URL to the release news on joomla.org -; \n Newline character. Use it to start a new line in the email. -PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT="Joomla! Update available for [SITENAME] – [URL]" -PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY="This email IS NOT sent by Joomla.org. It is sent automatically by your own site,\n[SITENAME] - [URL] \n\n================================================================================\nUPDATE INFORMATION\n================================================================================\n\nYour site has discovered that there is an updated version of Joomla! available for download.\n\nJoomla! version currently installed: [CURVERSION]\nJoomla! version available for installation: [NEWVERSION]\n\nThis email is sent to you by your site to remind you of this fact.\nThe Joomla! project will never contact you directly about available updates of Joomla! on your site.\n\n================================================================================\nUPDATE INSTRUCTIONS\n================================================================================\n\nTo install the update on [SITENAME] please select the following link. (If the URL is not a link, copy & paste it to your browser).\n\nUpdate link: [LINK]\n\nRelease News can be found here: [RELEASENEWS]\n\n================================================================================\nWHY AM I RECEIVING THIS EMAIL?\n================================================================================\n\nThis email has been automatically sent by a plugin provided by Joomla!, the software which powers your site.\nThis plugin looks for updated versions of Joomla! and sends an email notification to its administrators.\nYou will receive several similar emails from your site until you either update the software or disable these emails.\n\nTo disable these emails, please unpublish the 'System - Joomla! Update Notification' plugin in the Plugin Manager on your site.\n\nIf you do not understand what Joomla! is and what you need to do please do not contact the Joomla! project.\nThey are NOT sending you this email and they cannot help you. Instead, please contact the person who built or manages your site.\n\nIf you are the person who built or manages your website, please note that this plugin may have been activated automatically when you installed or updated Joomla! on your site.\n\n================================================================================\nWHO SENT ME THIS EMAIL?\n================================================================================\n\nThis email is sent to you by your own site, [SITENAME]" +PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT="Joomla! Update available for {SITENAME} – {URL}" +PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY="This email IS NOT sent by Joomla.org. It is sent automatically by your own site,\n{SITENAME} - {URL} \n\n================================================================================\nUPDATE INFORMATION\n================================================================================\n\nYour site has discovered that there is an updated version of Joomla! available for download.\n\nJoomla! version currently installed: {CURVERSION}\nJoomla! version available for installation: {NEWVERSION}\n\nThis email is sent to you by your site to remind you of this fact.\nThe Joomla! project will never contact you directly about available updates of Joomla! on your site.\n\n================================================================================\nUPDATE INSTRUCTIONS\n================================================================================\n\nTo install the update on {SITENAME} please select the following link. (If the URL is not a link, copy & paste it to your browser).\n\nUpdate link: {LINK}\n\nRelease News can be found here: {RELEASENEWS}\n\n================================================================================\nWHY AM I RECEIVING THIS EMAIL?\n================================================================================\n\nThis email has been automatically sent by a plugin provided by Joomla!, the software which powers your site.\nThis plugin looks for updated versions of Joomla! and sends an email notification to its administrators.\nYou will receive several similar emails from your site until you either update the software or disable these emails.\n\nTo disable these emails, please unpublish the 'System - Joomla! Update Notification' plugin in the Plugin Manager on your site.\n\nIf you do not understand what Joomla! is and what you need to do please do not contact the Joomla! project.\nThey are NOT sending you this email and they cannot help you. Instead, please contact the person who built or manages your site.\n\nIf you are the person who built or manages your website, please note that this plugin may have been activated automatically when you installed or updated Joomla! on your site.\n\n================================================================================\nWHO SENT ME THIS EMAIL?\n================================================================================\n\nThis email is sent to you by your own site, {SITENAME}" PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_LBL="Email Language" PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_DESC="Select a language for the update notification emails. Set to Auto to send them in the site language at the time." PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_NONE="Auto" diff --git a/installation/sql/mysql/supports.sql b/installation/sql/mysql/supports.sql index 8ab9f112f8f9b..fbeb9ff30ed16 100644 --- a/installation/sql/mysql/supports.sql +++ b/installation/sql/mysql/supports.sql @@ -427,4 +427,5 @@ CREATE TABLE IF NOT EXISTS `#__mail_templates` ( -- INSERT INTO `#__mail_templates` (`template_id`, `language`, `subject`, `body`, `htmlbody`, `attachments`, `params`) VALUES -('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'); +('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'), +('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'); diff --git a/installation/sql/postgresql/supports.sql b/installation/sql/postgresql/supports.sql index eaeae4bc19da4..247d61a8bceac 100644 --- a/installation/sql/postgresql/supports.sql +++ b/installation/sql/postgresql/supports.sql @@ -438,4 +438,5 @@ CREATE INDEX "#__mail_templates_idx_language" ON "#__mail_templates" ("language" -- INSERT INTO "#__mail_templates" ("template_id", "language", "subject", "body", "htmlbody", "attachments", "params") VALUES -('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'); +('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'), +('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'); diff --git a/libraries/src/Mail/MailTemplate.php b/libraries/src/Mail/MailTemplate.php index b3f2274fd3f02..0c2d837d76e58 100644 --- a/libraries/src/Mail/MailTemplate.php +++ b/libraries/src/Mail/MailTemplate.php @@ -123,11 +123,11 @@ public function addAttachment($name, $file) * * @since 4.0.0 */ - public function addRecipient($mail, $name, $type = 'to') + public function addRecipient($mail, $name = null, $type = 'to') { $recipient = new \stdClass; $recipient->mail = $mail; - $recipient->name = $name; + $recipient->name = $name ?? $mail; $recipient->type = $type; $this->recipients[] = $recipient; } diff --git a/plugins/system/updatenotification/updatenotification.php b/plugins/system/updatenotification/updatenotification.php index 7b0d82d662bd6..63e20e22de6c5 100644 --- a/plugins/system/updatenotification/updatenotification.php +++ b/plugins/system/updatenotification/updatenotification.php @@ -17,6 +17,7 @@ use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; use Joomla\CMS\Mail\Exception\MailDisabledException; +use Joomla\CMS\Mail\MailTemplate; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Table\Table; use Joomla\CMS\Updater\Updater; @@ -242,11 +243,6 @@ public function onAfterRender() $jLanguage->load('plg_system_updatenotification', JPATH_ADMINISTRATOR, $forcedLanguage, true, false); } - // Set up the email subject and body - - $email_subject = Text::_('PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT'); - $email_body = Text::_('PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY'); - // Replace merge codes with their values $newVersion = $update->version; @@ -254,36 +250,25 @@ public function onAfterRender() $currentVersion = $jVersion->getShortVersion(); $sitename = $this->app->get('sitename'); - $mailFrom = $this->app->get('mailfrom'); - $fromName = $this->app->get('fromname'); $substitutions = [ - '[NEWVERSION]' => $newVersion, - '[CURVERSION]' => $currentVersion, - '[SITENAME]' => $sitename, - '[URL]' => Uri::base(), - '[LINK]' => $uri->toString(), - '[RELEASENEWS]' => 'https://www.joomla.org/announcements/release-news/', - '\\n' => "\n", + 'newversion' => $newVersion, + 'curversion' => $currentVersion, + 'sitename' => $sitename, + 'url' => Uri::base(), + 'link' => $uri->toString(), + 'releasenews' => 'https://www.joomla.org/announcements/release-news/' ]; - foreach ($substitutions as $k => $v) - { - $email_subject = str_replace($k, $v, $email_subject); - $email_body = str_replace($k, $v, $email_body); - } - // Send the emails to the Super Users foreach ($superUsers as $superUser) { try { - $mailer = Factory::getMailer(); - $mailer->setSender([$mailFrom, $fromName]); + $mailer = new MailTemplate('joomla.updatenotification', $jLanguage->getTag()); $mailer->addRecipient($superUser->email); - $mailer->setSubject($email_subject); - $mailer->setBody($email_body); - $mailer->Send(); + $mailer->addTemplateData($substitutions); + $mailer->send(); } catch (MailDisabledException | phpMailerException $exception) { From 4c661704f8ca4651d814b39e213f8f60540f65c3 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 17 Apr 2020 10:55:27 +0200 Subject: [PATCH 02/25] Converting contact form to mail templates --- .../sql/updates/mysql/4.0.0-2020-04-16.sql | 5 +- .../updates/postgresql/4.0.0-2020-04-16.sql | 5 +- .../src/Controller/ContactController.php | 50 ++++++++----------- installation/sql/mysql/supports.sql | 4 +- installation/sql/postgresql/supports.sql | 4 +- language/en-GB/com_contact.ini | 7 +-- libraries/src/Mail/MailTemplate.php | 31 ++++++++++++ 7 files changed, 71 insertions(+), 35 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql index ca97fd1e548d8..d4fa3644d1d2e 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql @@ -1 +1,4 @@ -INSERT INTO `#__mail_templates` (`template_id`, `subject`, `body`, `params`) VALUES ('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'); +INSERT INTO `#__mail_templates` (`template_id`, `subject`, `body`, `params`) VALUES +('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('com_contact.mail', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'); diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql index f4f28298ac503..7a711ee3e6f94 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql @@ -1 +1,4 @@ -INSERT INTO "#__mail_templates" ("template_id", "subject", "body", "params") VALUES ('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'); +INSERT INTO "#__mail_templates" ("template_id", "subject", "body", "params") VALUES +('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('com_contact.mail', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'); diff --git a/components/com_contact/src/Controller/ContactController.php b/components/com_contact/src/Controller/ContactController.php index 03b157270b517..68a2c2c71f181 100644 --- a/components/com_contact/src/Controller/ContactController.php +++ b/components/com_contact/src/Controller/ContactController.php @@ -15,6 +15,7 @@ use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; use Joomla\CMS\Mail\Exception\MailDisabledException; +use Joomla\CMS\Mail\MailTemplate; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Router\Route; @@ -243,16 +244,17 @@ private function _sendEmail($data, $contact, $copy_email_activated) $mailfrom = $app->get('mailfrom'); $fromname = $app->get('fromname'); - $sitename = $app->get('sitename'); - $name = $data['contact_name']; - $email = PunycodeHelper::emailToPunycode($data['contact_email']); - $subject = $data['contact_subject']; - $body = $data['contact_message']; - - // Prepare email body - $prefix = Text::sprintf('COM_CONTACT_ENQUIRY_TEXT', Uri::base()); - $body = $prefix . "\n" . $name . ' <' . $email . '>' . "\r\n\r\n" . stripslashes($body); + $templateData = [ + 'sitename' => $app->get('sitename'), + 'name' => $data['contact_name'], + 'contactname' => $contact->name, + 'email' => PunycodeHelper::emailToPunycode($data['contact_email']), + 'subject' => $data['contact_subject'], + 'body' => stripslashes($data['contact_message']), + 'url' => Uri::base(), + 'customfields' => '' + ]; // Load the custom fields if (!empty($data['com_fields']) && $fields = FieldsHelper::getFields('com_contact.mail', $contact, true, $data['com_fields'])) @@ -269,34 +271,26 @@ private function _sendEmail($data, $contact, $copy_email_activated) if ($output) { - $body .= "\r\n\r\n" . $output; + $templateData['customfields'] = $output; } } try { - $mail = Factory::getMailer(); - $mail->addRecipient($contact->email_to); - $mail->addReplyTo($email, $name); - $mail->setSender(array($mailfrom, $fromname)); - $mail->setSubject($sitename . ': ' . $subject); - $mail->setBody($body); - $sent = $mail->Send(); + $mailer = new MailTemplate('com_contact.mail', $app->getLanguage()->getTag()); + $mailer->addRecipient($contact->email_to); + $mailer->setReplyTo($templateData['email'], $templateData['name']); + $mailer->addTemplateData($templateData); + $sent = $mailer->send(); // If we are supposed to copy the sender, do so. if ($copy_email_activated == true && !empty($data['contact_email_copy'])) { - $copytext = Text::sprintf('COM_CONTACT_COPYTEXT_OF', $contact->name, $sitename); - $copytext .= "\r\n\r\n" . $body; - $copysubject = Text::sprintf('COM_CONTACT_COPYSUBJECT_OF', $subject); - - $mail = Factory::getMailer(); - $mail->addRecipient($email); - $mail->addReplyTo($email, $name); - $mail->setSender(array($mailfrom, $fromname)); - $mail->setSubject($copysubject); - $mail->setBody($copytext); - $sent = $mail->Send(); + $mailer = new MailTemplate('com_contact.mail.copy', $app->getLanguage()->getTag()); + $mailer->addRecipient($templateData['email']); + $mailer->setReplyTo($templateData['email'], $templateData['name']); + $mailer->addTemplateData($templateData); + $sent = $mailer->send(); } } catch (MailDisabledException | phpMailerException $exception) diff --git a/installation/sql/mysql/supports.sql b/installation/sql/mysql/supports.sql index fbeb9ff30ed16..be55eefa2b36a 100644 --- a/installation/sql/mysql/supports.sql +++ b/installation/sql/mysql/supports.sql @@ -428,4 +428,6 @@ CREATE TABLE IF NOT EXISTS `#__mail_templates` ( INSERT INTO `#__mail_templates` (`template_id`, `language`, `subject`, `body`, `htmlbody`, `attachments`, `params`) VALUES ('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'), -('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'); +('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'); diff --git a/installation/sql/postgresql/supports.sql b/installation/sql/postgresql/supports.sql index 247d61a8bceac..318ce4cb45ffc 100644 --- a/installation/sql/postgresql/supports.sql +++ b/installation/sql/postgresql/supports.sql @@ -439,4 +439,6 @@ CREATE INDEX "#__mail_templates_idx_language" ON "#__mail_templates" ("language" INSERT INTO "#__mail_templates" ("template_id", "language", "subject", "body", "htmlbody", "attachments", "params") VALUES ('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'), -('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'); +('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'); diff --git a/language/en-GB/com_contact.ini b/language/en-GB/com_contact.ini index e25450cba26c2..7dd542098bc04 100644 --- a/language/en-GB/com_contact.ini +++ b/language/en-GB/com_contact.ini @@ -18,8 +18,8 @@ COM_CONTACT_FILTER_SEARCH_DESC="Contact Filter Search" COM_CONTACT_CHECKED_OUT_BY="Checked out by %s" COM_CONTACT_CONTACT_MESSAGE_SUBJECT_LABEL="Subject" COM_CONTACT_CONTACT_SEND="Send Email" -COM_CONTACT_COPYSUBJECT_OF="Copy of: %s" -COM_CONTACT_COPYTEXT_OF="This is a copy of the following message you sent to %s via %s" +COM_CONTACT_COPYSUBJECT_OF="Copy of: {SUBJECT}" +COM_CONTACT_COPYTEXT_OF="This is a copy of the following message you sent to {CONTACTNAME} via {SITENAME}\n\n{BODY}" COM_CONTACT_COUNT="Contact count:" COM_CONTACT_COUNTRY="Country" COM_CONTACT_DEFAULT_PAGE_TITLE="Contacts" @@ -29,7 +29,8 @@ COM_CONTACT_EDIT_CONTACT="Edit Contact" COM_CONTACT_EMAIL_FORM="Contact Form" COM_CONTACT_EMAIL_LABEL="Email" COM_CONTACT_EMAIL_THANKS="Thank you for your email." -COM_CONTACT_ENQUIRY_TEXT="This is an enquiry email via %s from:" +COM_CONTACT_ENQUIRY_SUBJECT="{SITENAME}: {SUBJECT}" +COM_CONTACT_ENQUIRY_TEXT="This is an enquiry email via {URL} from:\n{NAME} <{EMAIL}>\n\n{BODY}\n\n{CUSTOMFIELDS}" COM_CONTACT_ERROR_CONTACT_NOT_FOUND="Contact not found" COM_CONTACT_FAX="Fax" COM_CONTACT_FAX_NUMBER="Fax: %s" diff --git a/libraries/src/Mail/MailTemplate.php b/libraries/src/Mail/MailTemplate.php index 0c2d837d76e58..270b678850b9f 100644 --- a/libraries/src/Mail/MailTemplate.php +++ b/libraries/src/Mail/MailTemplate.php @@ -70,6 +70,14 @@ class MailTemplate */ protected $recipients = array(); + /** + * Reply To of the email + * + * @var \stdClass + * @since 4.0.0 + */ + protected $replyto; + /** * Constructor for the mail templating class * @@ -132,6 +140,24 @@ public function addRecipient($mail, $name = null, $type = 'to') $this->recipients[] = $recipient; } + /** + * Set reply to for this mail + * + * @param string $mail Mail address to reply to + * @param string $name Name + * + * @return void + * + * @since 4.0.0 + */ + public function setReplyTo($mail, $name = '') + { + $reply = new \stdClass; + $reply->mail = $mail; + $reply->name = $name; + $this->replyto = $reply; + } + /** * Add data to replace in the template * @@ -240,6 +266,11 @@ public function send() } } + if ($this->replyto) + { + $this->mailer->addReplyTo($this->replyto->mail, $this->replyto->name); + } + $path = JPATH_ROOT . '/' . $config->get('attachment_folder') . '/'; foreach ((array) json_decode($mail->attachments) as $attachment) From 20388466776de1b4f45a39d3bc8a7fd15b90c938 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 17 Apr 2020 13:35:13 +0200 Subject: [PATCH 03/25] Converting com_contact API controller to Mailtemplates --- .../src/Controller/ContactController.php | 60 ++++++++----------- .../src/Controller/ContactController.php | 3 - 2 files changed, 25 insertions(+), 38 deletions(-) diff --git a/api/components/com_contact/src/Controller/ContactController.php b/api/components/com_contact/src/Controller/ContactController.php index a669b9e0572d0..dc472a46b0222 100644 --- a/api/components/com_contact/src/Controller/ContactController.php +++ b/api/components/com_contact/src/Controller/ContactController.php @@ -17,6 +17,7 @@ use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; use Joomla\CMS\Mail\Exception\MailDisabledException; +use Joomla\CMS\Mail\MailTemplate; use Joomla\CMS\MVC\Controller\Exception\SendEmail; use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Uri\Uri; @@ -210,63 +211,52 @@ private function _sendEmail($data, $contact, $copy_email_activated) $contact->email_to = $contact_user->get('email'); } - $mailfrom = $app->get('mailfrom'); - $fromname = $app->get('fromname'); - $sitename = $app->get('sitename'); - - $name = $data['contact_name']; - $email = PunycodeHelper::emailToPunycode($data['contact_email']); - $subject = $data['contact_subject']; - $body = $data['contact_message']; - - // Prepare email body - $prefix = Text::sprintf('COM_CONTACT_ENQUIRY_TEXT', Uri::base()); - $body = $prefix . "\n" . $name . ' <' . $email . '>' . "\r\n\r\n" . stripslashes($body); + $templateData = [ + 'sitename' => $app->get('sitename'), + 'name' => $data['contact_name'], + 'contactname' => $contact->name, + 'email' => PunycodeHelper::emailToPunycode($data['contact_email']), + 'subject' => $data['contact_subject'], + 'body' => stripslashes($data['contact_message']), + 'url' => Uri::base(), + 'customfields' => '' + ]; // Load the custom fields if (!empty($data['com_fields']) && $fields = FieldsHelper::getFields('com_contact.mail', $contact, true, $data['com_fields'])) { $output = FieldsHelper::render( 'com_contact.mail', - 'fields.render', [ + 'fields.render', + array( 'context' => 'com_contact.mail', 'item' => $contact, 'fields' => $fields, - ] + ) ); if ($output) { - $body .= "\r\n\r\n" . $output; + $templateData['customfields'] = $output; } } try { - $mail = Factory::getMailer(); - $mail->addRecipient($contact->email_to); - $mail->addReplyTo($email, $name); - $mail->setSender([$mailfrom, $fromname]); - $mail->setSubject($sitename . ': ' . $subject); - $mail->setBody($body); - $sent = $mail->Send(); + $mailer = new MailTemplate('com_contact.mail', $app->getLanguage()->getTag()); + $mailer->addRecipient($contact->email_to); + $mailer->setReplyTo($templateData['email'], $templateData['name']); + $mailer->addTemplateData($templateData); + $sent = $mailer->send(); // If we are supposed to copy the sender, do so. - - // Check whether email copy function activated if ($copy_email_activated == true && !empty($data['contact_email_copy'])) { - $copytext = Text::sprintf('COM_CONTACT_COPYTEXT_OF', $contact->name, $sitename); - $copytext .= "\r\n\r\n" . $body; - $copysubject = Text::sprintf('COM_CONTACT_COPYSUBJECT_OF', $subject); - - $mail = Factory::getMailer(); - $mail->addRecipient($email); - $mail->addReplyTo($email, $name); - $mail->setSender([$mailfrom, $fromname]); - $mail->setSubject($copysubject); - $mail->setBody($copytext); - $sent = $mail->Send(); + $mailer = new MailTemplate('com_contact.mail.copy', $app->getLanguage()->getTag()); + $mailer->addRecipient($templateData['email']); + $mailer->setReplyTo($templateData['email'], $templateData['name']); + $mailer->addTemplateData($templateData); + $sent = $mailer->send(); } } catch (MailDisabledException | phpMailerException $exception) diff --git a/components/com_contact/src/Controller/ContactController.php b/components/com_contact/src/Controller/ContactController.php index 68a2c2c71f181..be1865a2f01a6 100644 --- a/components/com_contact/src/Controller/ContactController.php +++ b/components/com_contact/src/Controller/ContactController.php @@ -242,9 +242,6 @@ private function _sendEmail($data, $contact, $copy_email_activated) $contact->email_to = $contact_user->get('email'); } - $mailfrom = $app->get('mailfrom'); - $fromname = $app->get('fromname'); - $templateData = [ 'sitename' => $app->get('sitename'), 'name' => $data['contact_name'], From c5d168bb3ebd6edcc2d7c9e91480491c9b72a4e3 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 17 Apr 2020 14:52:53 +0200 Subject: [PATCH 04/25] Converting Massmailer mail to mail templates --- .../sql/updates/mysql/4.0.0-2020-04-16.sql | 3 +- .../updates/postgresql/4.0.0-2020-04-16.sql | 3 +- .../com_users/src/Model/MailModel.php | 28 +++++++++++++------ administrator/language/en-GB/com_users.ini | 2 ++ installation/sql/mysql/supports.sql | 3 +- installation/sql/postgresql/supports.sql | 3 +- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql index d4fa3644d1d2e..63bfcf805b13f 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql @@ -1,4 +1,5 @@ INSERT INTO `#__mail_templates` (`template_id`, `subject`, `body`, `params`) VALUES ('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'); +('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'); diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql index 7a711ee3e6f94..9345aec54af5a 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql @@ -1,4 +1,5 @@ INSERT INTO "#__mail_templates" ("template_id", "subject", "body", "params") VALUES ('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'); +('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'); diff --git a/administrator/components/com_users/src/Model/MailModel.php b/administrator/components/com_users/src/Model/MailModel.php index 9c6ac54e52f82..11a4daf7cabc7 100644 --- a/administrator/components/com_users/src/Model/MailModel.php +++ b/administrator/components/com_users/src/Model/MailModel.php @@ -19,6 +19,7 @@ use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; use Joomla\CMS\Mail\Exception\MailDisabledException; +use Joomla\CMS\Mail\MailTemplate; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\Database\ParameterType; use PHPMailer\PHPMailer\Exception as phpMailerException; @@ -103,7 +104,6 @@ public function send() $access = new Access; $db = $this->getDbo(); - $mode = array_key_exists('mode', $data) ? (int) $data['mode'] : 0; $subject = array_key_exists('subject', $data) ? $data['subject'] : ''; $grp = array_key_exists('group', $data) ? (int) $data['group'] : 0; $recurse = array_key_exists('recurse', $data) ? (int) $data['recurse'] : 0; @@ -176,30 +176,40 @@ public function send() } // Get the Mailer - $mailer = Factory::getMailer(); + $mailer = new MailTemplate('com_users.mail'); + //$mailer = Factory::getMailer(); $params = ComponentHelper::getParams('com_users'); try { // Build email message format. - $mailer->setSender(array($app->get('mailfrom'), $app->get('fromname'))); - $mailer->setSubject($params->get('mailSubjectPrefix') . stripslashes($subject)); - $mailer->setBody($message_body . $params->get('mailBodySuffix')); - $mailer->IsHtml($mode); + $data = [ + 'subject' => stripslashes($subject), + 'body' => $message_body, + 'subjectprefix' => $params->get('mailSubjectPrefix', ''), + 'bodysuffix' => $params->get('mailBodySuffix', '') + ]; + $mailer->addTemplateData($data); // Add recipients if ($bcc) { - $mailer->addBcc($rows); + foreach ($rows as $row) + { + $mailer->addRecipient($row, null, 'bcc'); + } $mailer->addRecipient($app->get('mailfrom')); } else { - $mailer->addRecipient($rows); + foreach ($rows as $row) + { + $mailer->addRecipient($row); + } } // Send the Mail - $rs = $mailer->Send(); + $rs = $mailer->send(); } catch (MailDisabledException | phpMailerException $exception) { diff --git a/administrator/language/en-GB/com_users.ini b/administrator/language/en-GB/com_users.ini index c135efd50ef69..e40a368f86c4d 100644 --- a/administrator/language/en-GB/com_users.ini +++ b/administrator/language/en-GB/com_users.ini @@ -187,6 +187,8 @@ COM_USERS_MAIL_PLEASE_SELECT_A_GROUP="Please select a Group" COM_USERS_MAIL_THE_MAIL_COULD_NOT_BE_SENT="The mail could not be sent." COM_USERS_MASS_MAIL="Mass Mail Users" COM_USERS_MASS_MAIL_DESC="Mass Mail options." +COM_USERS_MASSMAIL_MAIL_BODY="{BODY} {BODYSUFFIX}" +COM_USERS_MASSMAIL_MAIL_SUBJECT="{SUBJECTPREFIX} {SUBJECT}" COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N="Password does not have enough digits. At least %s digits are required." COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N_1="Password does not have enough digits. At least 1 digit is required." COM_USERS_MSG_NOT_ENOUGH_LOWERCASE_LETTERS_N="Password does not have enough lower case characters. At least %s lower case characters are required." diff --git a/installation/sql/mysql/supports.sql b/installation/sql/mysql/supports.sql index be55eefa2b36a..821c4f8e0e242 100644 --- a/installation/sql/mysql/supports.sql +++ b/installation/sql/mysql/supports.sql @@ -430,4 +430,5 @@ INSERT INTO `#__mail_templates` (`template_id`, `language`, `subject`, `body`, ` ('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'), ('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'); +('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'); diff --git a/installation/sql/postgresql/supports.sql b/installation/sql/postgresql/supports.sql index 318ce4cb45ffc..bedf555740f9e 100644 --- a/installation/sql/postgresql/supports.sql +++ b/installation/sql/postgresql/supports.sql @@ -441,4 +441,5 @@ INSERT INTO "#__mail_templates" ("template_id", "language", "subject", "body", " ('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'), ('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'); +('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'); From 84c946396357dfcde6c5abe7756a2c3da8c6bfb1 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 17 Apr 2020 21:43:06 +0200 Subject: [PATCH 05/25] Converting new user mail from plg_user_joomla to mail templates --- .../sql/updates/mysql/4.0.0-2020-04-16.sql | 3 +- .../updates/postgresql/4.0.0-2020-04-16.sql | 3 +- .../language/en-GB/plg_user_joomla.ini | 2 +- installation/sql/mysql/supports.sql | 3 +- installation/sql/postgresql/supports.sql | 3 +- plugins/user/joomla/joomla.php | 38 ++++++++----------- 6 files changed, 24 insertions(+), 28 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql index 63bfcf805b13f..4959554f5c6b7 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql @@ -2,4 +2,5 @@ INSERT INTO `#__mail_templates` (`template_id`, `subject`, `body`, `params`) VAL ('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'); +('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), +('com_users.administration.new_user.user', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '{"tags":["name","sitename","url","username","password","email"]}'); diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql index 9345aec54af5a..d3eac61902686 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql @@ -2,4 +2,5 @@ INSERT INTO "#__mail_templates" ("template_id", "subject", "body", "params") VAL ('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'); +('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), +('com_users.administration.new_user.user', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '{"tags":["name","sitename","url","username","password","email"]}'); diff --git a/administrator/language/en-GB/plg_user_joomla.ini b/administrator/language/en-GB/plg_user_joomla.ini index 318b912c62b4f..2c1296518cf4c 100644 --- a/administrator/language/en-GB/plg_user_joomla.ini +++ b/administrator/language/en-GB/plg_user_joomla.ini @@ -8,7 +8,7 @@ PLG_USER_JOOMLA_FIELD_AUTOREGISTER_LABEL="Auto-create Users" PLG_USER_JOOMLA_FIELD_FORCELOGOUT_LABEL="Force Logout for all Sessions?" PLG_USER_JOOMLA_FIELD_MAILTOUSER_LABEL="Notification Mail to User" PLG_USER_JOOMLA_FIELD_STRONG_PASSWORDS_LABEL="Strong Passwords" -PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY="Hello %s,\n\n\nYou have been added as a User to %s by an Administrator.\n\nThis email has your username and password to log in to %s\n\nUsername: %s\nPassword: %s\n\n\nPlease do not respond to this message as it is automatically generated and is for information purposes only." +PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY="Hello {NAME},\n\n\nYou have been added as a User to {SITENAME} by an Administrator.\n\nThis email has your username and password to log in to {URL}\n\nUsername: {USERNAME}\nPassword: {PASSWORD}\n\n\nPlease do not respond to this message as it is automatically generated and is for information purposes only." PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT="New User Details" PLG_USER_JOOMLA_POSTINSTALL_STRONGPW_BTN="Enable Strong Password Encryption" PLG_USER_JOOMLA_POSTINSTALL_STRONGPW_TEXT="As a security feature, Joomla allows you to switch to strong password encryption.
To turn strong passwords on select the button below. Alternatively you can edit the User - Joomla plugin and change the strong password setting to On.
Before enabling you should verify that all third party registration/login, user management or bridge extensions installed on your site support this strong password encryption." diff --git a/installation/sql/mysql/supports.sql b/installation/sql/mysql/supports.sql index 821c4f8e0e242..e91a8f0be8db1 100644 --- a/installation/sql/mysql/supports.sql +++ b/installation/sql/mysql/supports.sql @@ -431,4 +431,5 @@ INSERT INTO `#__mail_templates` (`template_id`, `language`, `subject`, `body`, ` ('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'); +('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), +('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'); diff --git a/installation/sql/postgresql/supports.sql b/installation/sql/postgresql/supports.sql index bedf555740f9e..57e4fadc92eaa 100644 --- a/installation/sql/postgresql/supports.sql +++ b/installation/sql/postgresql/supports.sql @@ -442,4 +442,5 @@ INSERT INTO "#__mail_templates" ("template_id", "language", "subject", "body", " ('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'); +('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), +('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'); diff --git a/plugins/user/joomla/joomla.php b/plugins/user/joomla/joomla.php index 8a799ead6e952..b4193778d29b2 100644 --- a/plugins/user/joomla/joomla.php +++ b/plugins/user/joomla/joomla.php @@ -14,6 +14,7 @@ use Joomla\CMS\Language\LanguageFactoryInterface; use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; +use Joomla\CMS\Mail\MailTemplate; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Uri\Uri; use Joomla\CMS\User\User; @@ -203,32 +204,23 @@ public function onUserAfterSave($user, $isnew, $success, $msg) // Load plugin language files. $this->loadLanguage(); - // Compute the mail subject. - $emailSubject = Text::sprintf( - 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', - $user['name'], - $this->app->get('sitename') - ); - - // Compute the mail body. - $emailBody = Text::sprintf( - 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', - $user['name'], - $this->app->get('sitename'), - Uri::root(), - $user['username'], - $user['password_clear'] - ); + // Collect data for mail + $data = [ + 'name' => $user['name'], + 'sitename' => $this->app->get('sitename'), + 'url' => Uri::root(), + 'username' => $user['username'], + 'password' => $user['password_clear'], + 'email' => $user['email'] + ]; + + $mailer = new MailTemplate('com_users.administration.new_user.user', $userLocale); + $mailer->addTemplateData($data); + $mailer->addRecipient($user['email'], $user['name']); try { - $res = Factory::getMailer()->sendMail( - $this->app->get('mailfrom'), - $this->app->get('fromname'), - $user['email'], - $emailSubject, - $emailBody - ); + $res = $mailer->send(); } catch (\Exception $exception) { From 7ad2a4273738a75c5aa487399804407652826328 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 17 Apr 2020 22:02:39 +0200 Subject: [PATCH 06/25] Converting password reset mail to mail templates --- .../sql/updates/mysql/4.0.0-2020-04-16.sql | 3 ++- .../updates/postgresql/4.0.0-2020-04-16.sql | 3 ++- components/com_users/src/Model/ResetModel.php | 19 +++++-------------- installation/sql/mysql/supports.sql | 3 ++- installation/sql/postgresql/supports.sql | 3 ++- language/en-GB/com_users.ini | 4 ++-- 6 files changed, 15 insertions(+), 20 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql index 4959554f5c6b7..0957ee080f501 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql @@ -3,4 +3,5 @@ INSERT INTO `#__mail_templates` (`template_id`, `subject`, `body`, `params`) VAL ('com_contact.mail', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), -('com_users.administration.new_user.user', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '{"tags":["name","sitename","url","username","password","email"]}'); +('com_users.administration.new_user.user', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '{"tags":["name","sitename","url","username","password","email"]}'), +('com_users.password_reset', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '{"tags":["name","email","sitename","link_text","link_html","token"]}'); diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql index d3eac61902686..21b821bda7c27 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql @@ -3,4 +3,5 @@ INSERT INTO "#__mail_templates" ("template_id", "subject", "body", "params") VAL ('com_contact.mail', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), -('com_users.administration.new_user.user', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '{"tags":["name","sitename","url","username","password","email"]}'); +('com_users.administration.new_user.user', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '{"tags":["name","sitename","url","username","password","email"]}'), +('com_users.password_reset', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '{"tags":["name","email","sitename","link_text","link_html","token"]}'); diff --git a/components/com_users/src/Model/ResetModel.php b/components/com_users/src/Model/ResetModel.php index ad8efc10d1aff..dc9b420b36b28 100644 --- a/components/com_users/src/Model/ResetModel.php +++ b/components/com_users/src/Model/ResetModel.php @@ -16,6 +16,7 @@ use Joomla\CMS\Form\Form; use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; +use Joomla\CMS\Mail\MailTemplate; use Joomla\CMS\MVC\Model\FormModel; use Joomla\CMS\Router\Route; use Joomla\CMS\String\PunycodeHelper; @@ -472,29 +473,19 @@ public function processResetRequest($data) // Put together the email template data. $data = $user->getProperties(); - $data['fromname'] = $app->get('fromname'); - $data['mailfrom'] = $app->get('mailfrom'); $data['sitename'] = $app->get('sitename'); $data['link_text'] = Route::_($link, false, $mode); $data['link_html'] = Route::_($link, true, $mode); $data['token'] = $token; - $subject = Text::sprintf( - 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', - $data['sitename'] - ); - - $body = Text::sprintf( - 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', - $data['sitename'], - $data['token'], - $data['link_text'] - ); + $mailer = new MailTemplate('com_users.password_reset', $app->getLanguage()->getTag()); + $mailer->addTemplateData($data); + $mailer->addRecipient($user->email, $user->name); // Try to send the password reset request email. try { - $return = Factory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $user->email, $subject, $body); + $return = $mailer->send(); } catch (\Exception $exception) { diff --git a/installation/sql/mysql/supports.sql b/installation/sql/mysql/supports.sql index e91a8f0be8db1..7669524865c8b 100644 --- a/installation/sql/mysql/supports.sql +++ b/installation/sql/mysql/supports.sql @@ -432,4 +432,5 @@ INSERT INTO `#__mail_templates` (`template_id`, `language`, `subject`, `body`, ` ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), -('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'); +('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), +('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'); diff --git a/installation/sql/postgresql/supports.sql b/installation/sql/postgresql/supports.sql index 57e4fadc92eaa..a848085ed88e8 100644 --- a/installation/sql/postgresql/supports.sql +++ b/installation/sql/postgresql/supports.sql @@ -443,4 +443,5 @@ INSERT INTO "#__mail_templates" ("template_id", "language", "subject", "body", " ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), -('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'); +('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), +('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'); diff --git a/language/en-GB/com_users.ini b/language/en-GB/com_users.ini index 4c8b7d90605b5..148b15d51aa77 100644 --- a/language/en-GB/com_users.ini +++ b/language/en-GB/com_users.ini @@ -14,8 +14,8 @@ COM_USERS_EMAIL_ACTIVATE_WITH_ADMIN_ACTIVATION_BODY="Hello administrator,\n\nA n COM_USERS_EMAIL_ACTIVATE_WITH_ADMIN_ACTIVATION_SUBJECT="Registration approval required for account of %s at %s" COM_USERS_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_BODY="Hello %s,\n\nYour account has been activated by an administrator. You can now login at %s using the username %s and the password you chose while registering." COM_USERS_EMAIL_ACTIVATED_BY_ADMIN_ACTIVATION_SUBJECT="Account activated for %s at %s" -COM_USERS_EMAIL_PASSWORD_RESET_BODY="Hello,\n\nA request has been made to reset your %s account password. To reset your password, you will need to submit this verification code to verify that the request was legitimate.\n\nThe verification code is %s\n\nSelect the URL below and proceed with resetting your password.\n\n %s \n\nThank you." -COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT="Your %s password reset request" +COM_USERS_EMAIL_PASSWORD_RESET_BODY="Hello,\n\nA request has been made to reset your {SITENAME} account password. To reset your password, you will need to submit this verification code to verify that the request was legitimate.\n\nThe verification code is {TOKEN}\n\nSelect the URL below and proceed with resetting your password.\n\n {LINK_TEXT} \n\nThank you." +COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT="Your {SITENAME} password reset request" COM_USERS_EMAIL_REGISTERED_BODY="Hello %s,\n\nThank you for registering at %s.\n\nYou may now log in to %s using the following username and password:\n\nUsername: %s\nPassword: %s" COM_USERS_EMAIL_REGISTERED_BODY_NOPW="Hello %s,\n\nThank you for registering at %s.\n\nYou may now log in to %s using the username and password you registered with." COM_USERS_EMAIL_REGISTERED_NOTIFICATION_TO_ADMIN_BODY="Hello administrator, \n\nA new user '%s', username '%s', has registered at %s." From f4df2b147ea6df886bb777ad0fe6bb2104e872e5 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Sat, 18 Apr 2020 11:07:35 +0200 Subject: [PATCH 07/25] Converting com_users remind mail to mail templates --- .../sql/updates/mysql/4.0.0-2020-04-16.sql | 3 ++- .../updates/postgresql/4.0.0-2020-04-16.sql | 3 ++- components/com_users/src/Model/RemindModel.php | 18 +++++------------- installation/sql/mysql/supports.sql | 3 ++- installation/sql/postgresql/supports.sql | 3 ++- language/en-GB/com_users.ini | 4 ++-- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql index 0957ee080f501..43fffe6daf95b 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql @@ -4,4 +4,5 @@ INSERT INTO `#__mail_templates` (`template_id`, `subject`, `body`, `params`) VAL ('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), ('com_users.administration.new_user.user', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '{"tags":["name","sitename","url","username","password","email"]}'), -('com_users.password_reset', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '{"tags":["name","email","sitename","link_text","link_html","token"]}'); +('com_users.password_reset', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), +('com_users.reminder', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql index 21b821bda7c27..2092ced83e764 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql @@ -4,4 +4,5 @@ INSERT INTO "#__mail_templates" ("template_id", "subject", "body", "params") VAL ('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), ('com_users.administration.new_user.user', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '{"tags":["name","sitename","url","username","password","email"]}'), -('com_users.password_reset', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '{"tags":["name","email","sitename","link_text","link_html","token"]}'); +('com_users.password_reset', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), +('com_users.reminder', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); diff --git a/components/com_users/src/Model/RemindModel.php b/components/com_users/src/Model/RemindModel.php index 483bcc0b793ff..0b845d5c342c7 100644 --- a/components/com_users/src/Model/RemindModel.php +++ b/components/com_users/src/Model/RemindModel.php @@ -15,6 +15,7 @@ use Joomla\CMS\Form\Form; use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; +use Joomla\CMS\Mail\MailTemplate; use Joomla\CMS\MVC\Model\FormModel; use Joomla\CMS\Router\Route; use Joomla\CMS\String\PunycodeHelper; @@ -176,27 +177,18 @@ public function processRemindRequest($data) // Put together the email template data. $data = ArrayHelper::fromObject($user); - $data['fromname'] = $app->get('fromname'); - $data['mailfrom'] = $app->get('mailfrom'); $data['sitename'] = $app->get('sitename'); $data['link_text'] = Route::_($link, false, $mode); $data['link_html'] = Route::_($link, true, $mode); - $subject = Text::sprintf( - 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', - $data['sitename'] - ); - $body = Text::sprintf( - 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', - $data['sitename'], - $data['username'], - $data['link_text'] - ); + $mailer = new MailTemplate('com_users.reminder', $app->getLanguage()->getTag()); + $mailer->addTemplateData($data); + $mailer->addRecipient($user->email, $user->name); // Try to send the password reset request email. try { - $return = Factory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $user->email, $subject, $body); + $return = $mailer->send(); } catch (\Exception $exception) { diff --git a/installation/sql/mysql/supports.sql b/installation/sql/mysql/supports.sql index 7669524865c8b..490dd1cd156f4 100644 --- a/installation/sql/mysql/supports.sql +++ b/installation/sql/mysql/supports.sql @@ -433,4 +433,5 @@ INSERT INTO `#__mail_templates` (`template_id`, `language`, `subject`, `body`, ` ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), ('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), -('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'); +('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), +('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); diff --git a/installation/sql/postgresql/supports.sql b/installation/sql/postgresql/supports.sql index a848085ed88e8..3e1b1a12c2b11 100644 --- a/installation/sql/postgresql/supports.sql +++ b/installation/sql/postgresql/supports.sql @@ -444,4 +444,5 @@ INSERT INTO "#__mail_templates" ("template_id", "language", "subject", "body", " ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), ('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), -('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'); +('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), +('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); diff --git a/language/en-GB/com_users.ini b/language/en-GB/com_users.ini index 148b15d51aa77..db71eed18a976 100644 --- a/language/en-GB/com_users.ini +++ b/language/en-GB/com_users.ini @@ -23,8 +23,8 @@ COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY="Hello %s,\n\nThank you for regi COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY_NOPW="Hello %s,\n\nThank you for registering at %s. Your account is created and must be activated before you can use it.\nTo activate the account select the following link or copy-paste it in your browser:\n%s \n\nAfter activation you may login to %s using the following username and the password you entered during registration:\n\nUsername: %s" COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY="Hello %s,\n\nThank you for registering at %s. Your account is created and must be verified before you can use it.\nTo verify the account select the following link or copy-paste it in your browser:\n %s \n\nAfter verification an administrator will be notified to activate your account. You'll receive a confirmation when it's done.\nOnce that account has been activated you may login to %s using the following username and password:\n\nUsername: %s\nPassword: %s" COM_USERS_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY_NOPW="Hello %s,\n\nThank you for registering at %s. Your account is created and must be verified before you can use it.\nTo verify the account select the following link or copy-paste it in your browser:\n %s \n\nAfter verification an administrator will be notified to activate your account. You'll receive a confirmation when it's done.\nOnce that account has been activated you may login to %s using the following username and the password you entered during registration:\n\nUsername: %s" -COM_USERS_EMAIL_USERNAME_REMINDER_BODY="Hello,\n\nA username reminder has been requested for your %s account.\n\nYour username is %s.\n\nTo login to your account, select the link below.\n\n%s \n\nThank you." -COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT="Your %s username" +COM_USERS_EMAIL_USERNAME_REMINDER_BODY="Hello,\n\nA username reminder has been requested for your {SITENAME} account.\n\nYour username is {USERNAME}.\n\nTo login to your account, select the link below.\n\n{LINK_TEXT} \n\nThank you." +COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT="Your {SITENAME} username" COM_USERS_ERROR_SECRET_CODE_WITHOUT_TFA="You have entered a Secret Code but two factor authentication is not enabled in your user account. If you want to use a secret code to secure your login please edit your user profile and enable two factor authentication." COM_USERS_FIELD_PASSWORD_RESET_DESC="Please enter the email address associated with your User account.
A verification code will be sent to you. Once you have received the verification code, you will be able to choose a new password for your account." COM_USERS_FIELD_PASSWORD_RESET_LABEL="Email Address" From 7d56d8f8a6ad25ca4f29f692645a6c7e852eb58c Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Sat, 18 Apr 2020 16:27:05 +0200 Subject: [PATCH 08/25] Codestyle --- administrator/components/com_users/src/Model/MailModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_users/src/Model/MailModel.php b/administrator/components/com_users/src/Model/MailModel.php index 11a4daf7cabc7..6dcd87bc1122c 100644 --- a/administrator/components/com_users/src/Model/MailModel.php +++ b/administrator/components/com_users/src/Model/MailModel.php @@ -177,7 +177,6 @@ public function send() // Get the Mailer $mailer = new MailTemplate('com_users.mail'); - //$mailer = Factory::getMailer(); $params = ComponentHelper::getParams('com_users'); try @@ -198,6 +197,7 @@ public function send() { $mailer->addRecipient($row, null, 'bcc'); } + $mailer->addRecipient($app->get('mailfrom')); } else From db33d1870cf4ca8596dbe43a5ad04a0ed233e7b5 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 26 Apr 2020 14:50:30 +0200 Subject: [PATCH 09/25] Fix update sql for new mail templates --- .../sql/updates/mysql/4.0.0-2020-04-16.sql | 16 ++++++++-------- .../sql/updates/postgresql/4.0.0-2020-04-16.sql | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql index 43fffe6daf95b..7694c99cdf904 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql @@ -1,8 +1,8 @@ -INSERT INTO `#__mail_templates` (`template_id`, `subject`, `body`, `params`) VALUES -('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), -('com_contact.mail', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), -('com_users.administration.new_user.user', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '{"tags":["name","sitename","url","username","password","email"]}'), -('com_users.password_reset', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), -('com_users.reminder', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); +INSERT INTO `#__mail_templates` (`template_id`, `language`, `subject`, `body`, `htmlbody`, `attachments`, `params`) VALUES +('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), +('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), +('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), +('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql index 2092ced83e764..9bc42f06eeac2 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql @@ -1,8 +1,8 @@ -INSERT INTO "#__mail_templates" ("template_id", "subject", "body", "params") VALUES -('joomla.updatenotification', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), -('com_contact.mail', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_contact.mail.copy', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), -('com_users.massmail.mail', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), -('com_users.administration.new_user.user', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '{"tags":["name","sitename","url","username","password","email"]}'), -('com_users.password_reset', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), -('com_users.reminder', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); +INSERT INTO "#__mail_templates" ("template_id", "language", "subject", "body", "htmlbody", "attachments", "params") VALUES +('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), +('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), +('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), +('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), +('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); From e710ca29bd6713116260b4af41bcc6d2c00d97e2 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 26 Apr 2020 16:22:55 +0200 Subject: [PATCH 10/25] Replace dots by underscores in mail termplate sub_id --- administrator/components/com_mails/tmpl/template/edit.php | 1 + administrator/components/com_mails/tmpl/templates/default.php | 1 + 2 files changed, 2 insertions(+) diff --git a/administrator/components/com_mails/tmpl/template/edit.php b/administrator/components/com_mails/tmpl/template/edit.php index 9b4fc7029ddfa..8f1191922900e 100644 --- a/administrator/components/com_mails/tmpl/template/edit.php +++ b/administrator/components/com_mails/tmpl/template/edit.php @@ -28,6 +28,7 @@ $input = $app->input; list($component, $sub_id) = explode('.', $this->master->template_id, 2); +$sub_id = str_replace('.', '_', $sub_id); $doc->addScriptOptions('com_mails', ['templateData' => $this->templateData]); diff --git a/administrator/components/com_mails/tmpl/templates/default.php b/administrator/components/com_mails/tmpl/templates/default.php index c5ffe05c14e8b..4d4f52ed79d5a 100644 --- a/administrator/components/com_mails/tmpl/templates/default.php +++ b/administrator/components/com_mails/tmpl/templates/default.php @@ -57,6 +57,7 @@ items as $i => $item) : list($component, $sub_id) = explode('.', $item->template_id, 2); + $sub_id = str_replace('.', '_', $sub_id); ?> From 2673ccb6b02653429ce55ea8ed3c4a5185c5024a Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 26 Apr 2020 16:23:27 +0200 Subject: [PATCH 11/25] Add missing language strings for com_contact --- administrator/language/en-GB/com_contact.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/administrator/language/en-GB/com_contact.ini b/administrator/language/en-GB/com_contact.ini index 37362c6e0dcc5..33be5b269b304 100644 --- a/administrator/language/en-GB/com_contact.ini +++ b/administrator/language/en-GB/com_contact.ini @@ -141,6 +141,10 @@ COM_CONTACT_HEADING_ASSOCIATION="Association" COM_CONTACT_ICONS_SETTINGS="Icons" COM_CONTACT_ID_LABEL="ID" COM_CONTACT_MAIL_FIELDSET_LABEL="Mail Options" +COM_CONTACT_MAIL_MAIL_COPY_DESC="This mail is sent to the submitter of a mail with the contact form if option \"Send Copy to Submitter\" is switched on in the form settings." +COM_CONTACT_MAIL_MAIL_COPY_TITLE="Contacts: Contact Form Mail Copy" +COM_CONTACT_MAIL_MAIL_DESC="This mail is sent with the contact form." +COM_CONTACT_MAIL_MAIL_TITLE="Contacts: Contact Form Mail" COM_CONTACT_MANAGER_CONTACTS="Contacts" COM_CONTACT_MANAGER_CONTACT_EDIT="Contacts: Edit" COM_CONTACT_MANAGER_CONTACT_NEW="Contacts: New" From bba2450648e28a65005b1c39f02412aa333c4be7 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 26 Apr 2020 17:01:05 +0200 Subject: [PATCH 12/25] Add missing language strings for com_users --- administrator/language/en-GB/com_users.ini | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/administrator/language/en-GB/com_users.ini b/administrator/language/en-GB/com_users.ini index e40a368f86c4d..c9b9388902c75 100644 --- a/administrator/language/en-GB/com_users.ini +++ b/administrator/language/en-GB/com_users.ini @@ -167,6 +167,8 @@ COM_USERS_LEVEL_SAVE_SUCCESS="Access level saved." COM_USERS_LEVELS_N_ITEMS_DELETED="%d View Permission Levels deleted." COM_USERS_LEVELS_N_ITEMS_DELETED_1="View Permission Level deleted." COM_USERS_LEVELS_TABLE_CAPTION="Table of Viewing Access Levels" +COM_USERS_MAIL_ADMINISTRATION_NEW_USER_USER_DESC="This mail is sent to a new user who has just been created in backend." +COM_USERS_MAIL_ADMINISTRATION_NEW_USER_USER_TITLE="Users: New User" COM_USERS_MAIL_DETAILS="Details" COM_USERS_MAIL_EMAIL_SENT_TO_N_USERS="Email sent to %s users." COM_USERS_MAIL_EMAIL_SENT_TO_N_USERS_1="Email sent to one user." @@ -178,12 +180,18 @@ COM_USERS_MAIL_FIELD_SEND_AS_BLIND_CARBON_COPY_LABEL="Recipients as BCC" COM_USERS_MAIL_FIELD_SEND_IN_HTML_MODE_LABEL="Send in HTML Mode" COM_USERS_MAIL_FIELD_SUBJECT_LABEL="Subject" COM_USERS_MAIL_FIELD_VALUE_ALL_USERS_GROUPS="All Users Groups" +COM_USERS_MAIL_MASSMAIL_MAIL_DESC="This mail is sent with the \"Mass Mail Users\" form in backend." +COM_USERS_MAIL_MASSMAIL_MAIL_TITLE="Users: Mass Mail Users" COM_USERS_MAIL_NO_USERS_COULD_BE_FOUND_IN_THIS_GROUP="No users could be found in this group." COM_USERS_MAIL_ONLY_YOU_COULD_BE_FOUND_IN_THIS_GROUP="You are the only user in this group." +COM_USERS_MAIL_PASSWORD_RESET_DESC="This mail is sent to the site administrator when a user uses the \"Forgot your password?\" link e.g. in a login form." +COM_USERS_MAIL_PASSWORD_RESET_TITLE="Users: Password Reset" COM_USERS_MAIL_PLEASE_FILL_IN_THE_FORM_CORRECTLY="Please fill in the form correctly." COM_USERS_MAIL_PLEASE_FILL_IN_THE_MESSAGE="Please enter a message" COM_USERS_MAIL_PLEASE_FILL_IN_THE_SUBJECT="Please enter a subject" COM_USERS_MAIL_PLEASE_SELECT_A_GROUP="Please select a Group" +COM_USERS_MAIL_REMINDER_DESC="This mail is sent to the site administrator when a user uses the \"Forgot your username?\" link e.g. in a login form." +COM_USERS_MAIL_REMINDER_TITLE="Users: Username Reminder" COM_USERS_MAIL_THE_MAIL_COULD_NOT_BE_SENT="The mail could not be sent." COM_USERS_MASS_MAIL="Mass Mail Users" COM_USERS_MASS_MAIL_DESC="Mass Mail options." From ec9be3cd6d6a3b81d60010f90718fc06a42bbd0d Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 26 Apr 2020 17:21:24 +0200 Subject: [PATCH 13/25] Add missing strings for update notification mail template --- administrator/language/en-GB/joomla.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini index fb32729ae60d0..334151929975e 100644 --- a/administrator/language/en-GB/joomla.ini +++ b/administrator/language/en-GB/joomla.ini @@ -1101,3 +1101,6 @@ TRASHED="Trashed" UNPUBLISH="Unpublish" UNPUBLISHED="Unpublished" +; Mail template for the Joomla Update notification +JOOMLA_MAIL_UPDATENOTIFICATION_DESC="This mail is sent to the site administrator when the \"Joomla! Update Notification\" system plugin has detected an available update." +JOOMLA_MAIL_UPDATENOTIFICATION_TITLE="Joomla: Update Notification" From 01d2a9e4cd979814a4eaa8c0b8d157e3adabb2fe Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 26 Apr 2020 18:16:55 +0200 Subject: [PATCH 14/25] Correct user mail descriptions --- administrator/language/en-GB/com_users.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/language/en-GB/com_users.ini b/administrator/language/en-GB/com_users.ini index c9b9388902c75..7819c473b2230 100644 --- a/administrator/language/en-GB/com_users.ini +++ b/administrator/language/en-GB/com_users.ini @@ -184,13 +184,13 @@ COM_USERS_MAIL_MASSMAIL_MAIL_DESC="This mail is sent with the \"Mass Mail Users\ COM_USERS_MAIL_MASSMAIL_MAIL_TITLE="Users: Mass Mail Users" COM_USERS_MAIL_NO_USERS_COULD_BE_FOUND_IN_THIS_GROUP="No users could be found in this group." COM_USERS_MAIL_ONLY_YOU_COULD_BE_FOUND_IN_THIS_GROUP="You are the only user in this group." -COM_USERS_MAIL_PASSWORD_RESET_DESC="This mail is sent to the site administrator when a user uses the \"Forgot your password?\" link e.g. in a login form." +COM_USERS_MAIL_PASSWORD_RESET_DESC="This mail is sent to a user by using the \"Forgot your password?\" link e.g. in a login form." COM_USERS_MAIL_PASSWORD_RESET_TITLE="Users: Password Reset" COM_USERS_MAIL_PLEASE_FILL_IN_THE_FORM_CORRECTLY="Please fill in the form correctly." COM_USERS_MAIL_PLEASE_FILL_IN_THE_MESSAGE="Please enter a message" COM_USERS_MAIL_PLEASE_FILL_IN_THE_SUBJECT="Please enter a subject" COM_USERS_MAIL_PLEASE_SELECT_A_GROUP="Please select a Group" -COM_USERS_MAIL_REMINDER_DESC="This mail is sent to the site administrator when a user uses the \"Forgot your username?\" link e.g. in a login form." +COM_USERS_MAIL_REMINDER_DESC="This mail is sent to a user when by the \"Forgot your username?\" link e.g. in a login form." COM_USERS_MAIL_REMINDER_TITLE="Users: Username Reminder" COM_USERS_MAIL_THE_MAIL_COULD_NOT_BE_SENT="The mail could not be sent." COM_USERS_MASS_MAIL="Mass Mail Users" From f054a8b97b5cc65930192923b5f933fdc6fc5b60 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 26 Apr 2020 18:37:38 +0200 Subject: [PATCH 15/25] Mode update notification language strings --- .../com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql | 2 +- .../com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql | 2 +- administrator/language/en-GB/joomla.ini | 4 ---- .../language/en-GB/plg_system_updatenotification.ini | 2 ++ installation/sql/mysql/supports.sql | 2 +- installation/sql/postgresql/supports.sql | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql index 7694c99cdf904..5925a8f8d7262 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql @@ -1,5 +1,5 @@ INSERT INTO `#__mail_templates` (`template_id`, `language`, `subject`, `body`, `htmlbody`, `attachments`, `params`) VALUES -('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql index 9bc42f06eeac2..cbf9b28081404 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql @@ -1,5 +1,5 @@ INSERT INTO "#__mail_templates" ("template_id", "language", "subject", "body", "htmlbody", "attachments", "params") VALUES -('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini index 334151929975e..8c0d6d4a392d1 100644 --- a/administrator/language/en-GB/joomla.ini +++ b/administrator/language/en-GB/joomla.ini @@ -1100,7 +1100,3 @@ TRASH="Trash" TRASHED="Trashed" UNPUBLISH="Unpublish" UNPUBLISHED="Unpublished" - -; Mail template for the Joomla Update notification -JOOMLA_MAIL_UPDATENOTIFICATION_DESC="This mail is sent to the site administrator when the \"Joomla! Update Notification\" system plugin has detected an available update." -JOOMLA_MAIL_UPDATENOTIFICATION_TITLE="Joomla: Update Notification" diff --git a/administrator/language/en-GB/plg_system_updatenotification.ini b/administrator/language/en-GB/plg_system_updatenotification.ini index ba4b79da568d4..a7db863dd0b4c 100644 --- a/administrator/language/en-GB/plg_system_updatenotification.ini +++ b/administrator/language/en-GB/plg_system_updatenotification.ini @@ -15,3 +15,5 @@ PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME="The Joomla! Update No PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME_BODY="In your Installer Configuration you have set the Option Update Cache (in Hours) to 0 this means that Joomla is not caching the Update. This means an email should be sent on every page visit but this is not possible. Please increase the value (6 is default) or confirm that the Joomla! Update Notification will never send you mails." PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME_ACTION="Set it back to the default setting (6 Hours)" PLG_SYSTEM_UPDATENOTIFICATION_XML_DESCRIPTION="This plugin periodically checks for the availability of new Joomla! versions. When one is found it will send you an email, reminding you to update Joomla!. Pro Tip: You can customise the email message by overriding the language string keys PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT and PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY." +PLG_SYSTEM_UPDATENOTIFICATION_MAIL_MAIL_DESC="This mail is sent to the site administrator when the \"Joomla! Update Notification\" system plugin has detected an available update." +PLG_SYSTEM_UPDATENOTIFICATION_MAIL_MAIL_TITLE="Joomla: Update Notification" diff --git a/installation/sql/mysql/supports.sql b/installation/sql/mysql/supports.sql index 490dd1cd156f4..8657bca7b7b09 100644 --- a/installation/sql/mysql/supports.sql +++ b/installation/sql/mysql/supports.sql @@ -428,7 +428,7 @@ CREATE TABLE IF NOT EXISTS `#__mail_templates` ( INSERT INTO `#__mail_templates` (`template_id`, `language`, `subject`, `body`, `htmlbody`, `attachments`, `params`) VALUES ('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'), -('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), diff --git a/installation/sql/postgresql/supports.sql b/installation/sql/postgresql/supports.sql index 3e1b1a12c2b11..22b3346a44e62 100644 --- a/installation/sql/postgresql/supports.sql +++ b/installation/sql/postgresql/supports.sql @@ -439,7 +439,7 @@ CREATE INDEX "#__mail_templates_idx_language" ON "#__mail_templates" ("language" INSERT INTO "#__mail_templates" ("template_id", "language", "subject", "body", "htmlbody", "attachments", "params") VALUES ('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'), -('joomla.updatenotification', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), From 74ad1f018efcee995c59db2d5ecf38b6210e09da Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 26 Apr 2020 18:38:47 +0200 Subject: [PATCH 16/25] alpha order language strings --- .../language/en-GB/plg_system_updatenotification.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/language/en-GB/plg_system_updatenotification.ini b/administrator/language/en-GB/plg_system_updatenotification.ini index a7db863dd0b4c..4dd1bd5514769 100644 --- a/administrator/language/en-GB/plg_system_updatenotification.ini +++ b/administrator/language/en-GB/plg_system_updatenotification.ini @@ -11,9 +11,9 @@ PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY="This email IS NOT sent by Joomla.org. PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_LBL="Email Language" PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_DESC="Select a language for the update notification emails. Set to Auto to send them in the site language at the time." PLG_SYSTEM_UPDATENOTIFICATION_LANGUAGE_OVERRIDE_NONE="Auto" +PLG_SYSTEM_UPDATENOTIFICATION_MAIL_MAIL_DESC="This mail is sent to the site administrator when the \"Joomla! Update Notification\" system plugin has detected an available update." +PLG_SYSTEM_UPDATENOTIFICATION_MAIL_MAIL_TITLE="Joomla: Update Notification" PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME="The Joomla! Update Notification will not run in this configuration" PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME_BODY="In your Installer Configuration you have set the Option Update Cache (in Hours) to 0 this means that Joomla is not caching the Update. This means an email should be sent on every page visit but this is not possible. Please increase the value (6 is default) or confirm that the Joomla! Update Notification will never send you mails." PLG_SYSTEM_UPDATENOTIFICATION_POSTINSTALL_UPDATECACHETIME_ACTION="Set it back to the default setting (6 Hours)" PLG_SYSTEM_UPDATENOTIFICATION_XML_DESCRIPTION="This plugin periodically checks for the availability of new Joomla! versions. When one is found it will send you an email, reminding you to update Joomla!. Pro Tip: You can customise the email message by overriding the language string keys PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT and PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY." -PLG_SYSTEM_UPDATENOTIFICATION_MAIL_MAIL_DESC="This mail is sent to the site administrator when the \"Joomla! Update Notification\" system plugin has detected an available update." -PLG_SYSTEM_UPDATENOTIFICATION_MAIL_MAIL_TITLE="Joomla: Update Notification" From a64860c29dc7fb2827db5d1db1ad132189df32d9 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 26 Apr 2020 18:39:35 +0200 Subject: [PATCH 17/25] revert unwanted change --- administrator/language/en-GB/joomla.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini index 8c0d6d4a392d1..fb32729ae60d0 100644 --- a/administrator/language/en-GB/joomla.ini +++ b/administrator/language/en-GB/joomla.ini @@ -1100,3 +1100,4 @@ TRASH="Trash" TRASHED="Trashed" UNPUBLISH="Unpublish" UNPUBLISHED="Unpublished" + From d54de26f63275b64b65ecf1089e005088d3f5103 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Tue, 28 Apr 2020 19:51:39 +0200 Subject: [PATCH 18/25] Fixing a few bugs --- .../com_mails/src/View/Template/HtmlView.php | 1 + .../components/com_users/src/Model/MailModel.php | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/administrator/components/com_mails/src/View/Template/HtmlView.php b/administrator/components/com_mails/src/View/Template/HtmlView.php index 11eb214c0c90f..bf10e1ad46396 100644 --- a/administrator/components/com_mails/src/View/Template/HtmlView.php +++ b/administrator/components/com_mails/src/View/Template/HtmlView.php @@ -87,6 +87,7 @@ public function display($tpl = null) $fields = array('subject', 'body', 'htmlbody'); $this->templateData = array(); $language = Factory::getLanguage(); + $language->load($component, JPATH_SITE, $this->item->language, true); $language->load($component, JPATH_ADMINISTRATOR, $this->item->language, true); foreach ($fields as $field) diff --git a/administrator/components/com_users/src/Model/MailModel.php b/administrator/components/com_users/src/Model/MailModel.php index 6dcd87bc1122c..6d59af148d69c 100644 --- a/administrator/components/com_users/src/Model/MailModel.php +++ b/administrator/components/com_users/src/Model/MailModel.php @@ -98,11 +98,12 @@ protected function preprocessForm(Form $form, $data, $group = 'user') */ public function send() { - $app = Factory::getApplication(); - $data = $app->input->post->get('jform', array(), 'array'); - $user = Factory::getUser(); - $access = new Access; - $db = $this->getDbo(); + $app = Factory::getApplication(); + $data = $app->input->post->get('jform', array(), 'array'); + $user = Factory::getUser(); + $access = new Access; + $db = $this->getDbo(); + $language = Factory::getLanguage(); $subject = array_key_exists('subject', $data) ? $data['subject'] : ''; $grp = array_key_exists('group', $data) ? (int) $data['group'] : 0; @@ -176,7 +177,7 @@ public function send() } // Get the Mailer - $mailer = new MailTemplate('com_users.mail'); + $mailer = new MailTemplate('com_users.massmail.mail', $language->getTag()); $params = ComponentHelper::getParams('com_users'); try From 0d4c296d99c11592c4cfb3862f61f25ea485dab3 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Thu, 21 May 2020 22:25:12 +0200 Subject: [PATCH 19/25] Update plugins/system/updatenotification/updatenotification.php Co-authored-by: Richard Fath --- plugins/system/updatenotification/updatenotification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/system/updatenotification/updatenotification.php b/plugins/system/updatenotification/updatenotification.php index 63e20e22de6c5..01c70acc86842 100644 --- a/plugins/system/updatenotification/updatenotification.php +++ b/plugins/system/updatenotification/updatenotification.php @@ -265,7 +265,7 @@ public function onAfterRender() { try { - $mailer = new MailTemplate('joomla.updatenotification', $jLanguage->getTag()); + $mailer = new MailTemplate('plg_system_updatenotification.mail', $jLanguage->getTag()); $mailer->addRecipient($superUser->email); $mailer->addTemplateData($substitutions); $mailer->send(); From 8d01652fe2360ea4fdd15b74e0a81c97c72c27c2 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Thu, 21 May 2020 22:31:41 +0200 Subject: [PATCH 20/25] Reverting removal of mode line --- administrator/components/com_users/src/Model/MailModel.php | 1 + 1 file changed, 1 insertion(+) diff --git a/administrator/components/com_users/src/Model/MailModel.php b/administrator/components/com_users/src/Model/MailModel.php index 6d59af148d69c..53cbdf85c412e 100644 --- a/administrator/components/com_users/src/Model/MailModel.php +++ b/administrator/components/com_users/src/Model/MailModel.php @@ -105,6 +105,7 @@ public function send() $db = $this->getDbo(); $language = Factory::getLanguage(); + $mode = array_key_exists('mode', $data) ? (int) $data['mode'] : 0; $subject = array_key_exists('subject', $data) ? $data['subject'] : ''; $grp = array_key_exists('group', $data) ? (int) $data['group'] : 0; $recurse = array_key_exists('recurse', $data) ? (int) $data['recurse'] : 0; From 7da691688e596efa6c63eb609ed774da1b0d3af2 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Fri, 22 May 2020 12:30:17 +0200 Subject: [PATCH 21/25] Fix PHP notice "Undefined offset: 0" in Mail Templates Fix PHP notice "Undefined offset: 0" in Mail Templates when sending password reset mail. --- libraries/src/Mail/MailTemplate.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libraries/src/Mail/MailTemplate.php b/libraries/src/Mail/MailTemplate.php index 270b678850b9f..97fde3e696a69 100644 --- a/libraries/src/Mail/MailTemplate.php +++ b/libraries/src/Mail/MailTemplate.php @@ -313,21 +313,23 @@ protected function replaceTags($text, $tags) if (is_array($value)) { $matches = array(); - preg_match_all('/{' . strtoupper($key) . '}(.*?){/' . strtoupper($key) . '}/s', $text, $matches); - foreach ($matches[0] as $i => $match) + if (preg_match_all('/{' . strtoupper($key) . '}(.*?){/' . strtoupper($key) . '}/s', $text, $matches)) { - $replacement = ''; - - foreach ($value as $subvalue) + foreach ($matches[0] as $i => $match) { - if (is_array($subvalue)) + $replacement = ''; + + foreach ($value as $subvalue) { - $replacement .= $this->replaceTags($matches[1][$i], $subvalue); + if (is_array($subvalue)) + { + $replacement .= $this->replaceTags($matches[1][$i], $subvalue); + } } - } - $text = str_replace($match, $replacement, $text); + $text = str_replace($match, $replacement, $text); + } } } else From 7e27a4bfeadda8e38033dfed480f09cf624271f9 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Fri, 22 May 2020 13:17:15 +0200 Subject: [PATCH 22/25] Quote slash in regular expression --- libraries/src/Mail/MailTemplate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Mail/MailTemplate.php b/libraries/src/Mail/MailTemplate.php index 97fde3e696a69..55eb446cd4e72 100644 --- a/libraries/src/Mail/MailTemplate.php +++ b/libraries/src/Mail/MailTemplate.php @@ -314,7 +314,7 @@ protected function replaceTags($text, $tags) { $matches = array(); - if (preg_match_all('/{' . strtoupper($key) . '}(.*?){/' . strtoupper($key) . '}/s', $text, $matches)) + if (preg_match_all('/{' . strtoupper($key) . '}(.*?){\/' . strtoupper($key) . '}/s', $text, $matches)) { foreach ($matches[0] as $i => $match) { From 519fc814a52d03992e8513e54c97c28ed5425fcd Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 24 May 2020 14:02:09 +0200 Subject: [PATCH 23/25] Correct template ID for new user and alpha order mail templates in SQL --- .../com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql | 6 +++--- .../com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql | 6 +++--- administrator/language/en-GB/com_users.ini | 2 -- administrator/language/en-GB/plg_user_joomla.ini | 2 ++ installation/sql/mysql/supports.sql | 6 +++--- installation/sql/postgresql/supports.sql | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql index 5925a8f8d7262..6507312fcfdd4 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2020-04-16.sql @@ -1,8 +1,8 @@ INSERT INTO `#__mail_templates` (`template_id`, `language`, `subject`, `body`, `htmlbody`, `attachments`, `params`) VALUES -('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), -('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), ('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), -('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); +('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'), +('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('plg_user_joomla.mail', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'); diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql index cbf9b28081404..339469fb36008 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2020-04-16.sql @@ -1,8 +1,8 @@ INSERT INTO "#__mail_templates" ("template_id", "language", "subject", "body", "htmlbody", "attachments", "params") VALUES -('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), -('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), ('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), -('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); +('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'), +('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('plg_user_joomla.mail', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'); diff --git a/administrator/language/en-GB/com_users.ini b/administrator/language/en-GB/com_users.ini index 7819c473b2230..ba8a58e9b84cc 100644 --- a/administrator/language/en-GB/com_users.ini +++ b/administrator/language/en-GB/com_users.ini @@ -167,8 +167,6 @@ COM_USERS_LEVEL_SAVE_SUCCESS="Access level saved." COM_USERS_LEVELS_N_ITEMS_DELETED="%d View Permission Levels deleted." COM_USERS_LEVELS_N_ITEMS_DELETED_1="View Permission Level deleted." COM_USERS_LEVELS_TABLE_CAPTION="Table of Viewing Access Levels" -COM_USERS_MAIL_ADMINISTRATION_NEW_USER_USER_DESC="This mail is sent to a new user who has just been created in backend." -COM_USERS_MAIL_ADMINISTRATION_NEW_USER_USER_TITLE="Users: New User" COM_USERS_MAIL_DETAILS="Details" COM_USERS_MAIL_EMAIL_SENT_TO_N_USERS="Email sent to %s users." COM_USERS_MAIL_EMAIL_SENT_TO_N_USERS_1="Email sent to one user." diff --git a/administrator/language/en-GB/plg_user_joomla.ini b/administrator/language/en-GB/plg_user_joomla.ini index 2c1296518cf4c..2db2e81187b1c 100644 --- a/administrator/language/en-GB/plg_user_joomla.ini +++ b/administrator/language/en-GB/plg_user_joomla.ini @@ -8,6 +8,8 @@ PLG_USER_JOOMLA_FIELD_AUTOREGISTER_LABEL="Auto-create Users" PLG_USER_JOOMLA_FIELD_FORCELOGOUT_LABEL="Force Logout for all Sessions?" PLG_USER_JOOMLA_FIELD_MAILTOUSER_LABEL="Notification Mail to User" PLG_USER_JOOMLA_FIELD_STRONG_PASSWORDS_LABEL="Strong Passwords" +PLG_USER_JOOMLA_MAIL_MAIL_DESC="This mail is sent to a new user who has just been created in backend." +PLG_USER_JOOMLA_MAIL_MAIL_TITLE="Users: New User" PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY="Hello {NAME},\n\n\nYou have been added as a User to {SITENAME} by an Administrator.\n\nThis email has your username and password to log in to {URL}\n\nUsername: {USERNAME}\nPassword: {PASSWORD}\n\n\nPlease do not respond to this message as it is automatically generated and is for information purposes only." PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT="New User Details" PLG_USER_JOOMLA_POSTINSTALL_STRONGPW_BTN="Enable Strong Password Encryption" diff --git a/installation/sql/mysql/supports.sql b/installation/sql/mysql/supports.sql index 8657bca7b7b09..ee93005b0b8ff 100644 --- a/installation/sql/mysql/supports.sql +++ b/installation/sql/mysql/supports.sql @@ -428,10 +428,10 @@ CREATE TABLE IF NOT EXISTS `#__mail_templates` ( INSERT INTO `#__mail_templates` (`template_id`, `language`, `subject`, `body`, `htmlbody`, `attachments`, `params`) VALUES ('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'), -('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), -('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), ('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), -('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); +('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'), +('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('plg_user_joomla.mail', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'); diff --git a/installation/sql/postgresql/supports.sql b/installation/sql/postgresql/supports.sql index 22b3346a44e62..f4a75d0bbc45a 100644 --- a/installation/sql/postgresql/supports.sql +++ b/installation/sql/postgresql/supports.sql @@ -439,10 +439,10 @@ CREATE INDEX "#__mail_templates_idx_language" ON "#__mail_templates" ("language" INSERT INTO "#__mail_templates" ("template_id", "language", "subject", "body", "htmlbody", "attachments", "params") VALUES ('com_config.test_mail', '', 'COM_CONFIG_SENDMAIL_SUBJECT', 'COM_CONFIG_SENDMAIL_BODY', '', '', '{"tags":["sitename","method"]}'), -('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), ('com_contact.mail', '', 'COM_CONTACT_ENQUIRY_SUBJECT', 'COM_CONTACT_ENQUIRY_TEXT', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_contact.mail.copy', '', 'COM_CONTACT_COPYSUBJECT_OF', 'COM_CONTACT_COPYTEXT_OF', '', '', '{"tags":["sitename","name","email","subject","body","url","customfields"]}'), ('com_users.massmail.mail', '', 'COM_USERS_MASSMAIL_MAIL_SUBJECT', 'COM_USERS_MASSMAIL_MAIL_BODY', '', '', '{"tags":["subject","body","subjectprefix","bodysuffix"]}'), -('com_users.administration.new_user.user', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'), ('com_users.password_reset', '', 'COM_USERS_EMAIL_PASSWORD_RESET_SUBJECT', 'COM_USERS_EMAIL_PASSWORD_RESET_BODY', '', '', '{"tags":["name","email","sitename","link_text","link_html","token"]}'), -('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'); +('com_users.reminder', '', 'COM_USERS_EMAIL_USERNAME_REMINDER_SUBJECT', 'COM_USERS_EMAIL_USERNAME_REMINDER_BODY', '', '', '{"tags":["name","username","sitename","email","link_text","link_html"]}'), +('plg_system_updatenotification.mail', '', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_SUBJECT', 'PLG_SYSTEM_UPDATENOTIFICATION_EMAIL_BODY', '', '', '{"tags":["newversion","curversion","sitename","url","link","releasenews"]}'), +('plg_user_joomla.mail', '', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', '', '', '{"tags":["name","sitename","url","username","password","email"]}'); From 2242494a13676fddbed2fc82c41a004ba9740c73 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 24 May 2020 14:39:23 +0200 Subject: [PATCH 24/25] Load the right mail template --- plugins/user/joomla/joomla.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/user/joomla/joomla.php b/plugins/user/joomla/joomla.php index b4193778d29b2..bfe6b2ffa575e 100644 --- a/plugins/user/joomla/joomla.php +++ b/plugins/user/joomla/joomla.php @@ -214,7 +214,7 @@ public function onUserAfterSave($user, $isnew, $success, $msg) 'email' => $user['email'] ]; - $mailer = new MailTemplate('com_users.administration.new_user.user', $userLocale); + $mailer = new MailTemplate('plg_user_joomla.mail', $userLocale); $mailer->addTemplateData($data); $mailer->addRecipient($user['email'], $user['name']); From 1110ca1dbf8770146d3e91984f3d81a90604a796 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Mon, 25 May 2020 14:42:42 +0200 Subject: [PATCH 25/25] Load client language file for com_contact in API submitt contact form --- api/components/com_contact/src/Controller/ContactController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/components/com_contact/src/Controller/ContactController.php b/api/components/com_contact/src/Controller/ContactController.php index dc472a46b0222..769616606176e 100644 --- a/api/components/com_contact/src/Controller/ContactController.php +++ b/api/components/com_contact/src/Controller/ContactController.php @@ -205,6 +205,8 @@ private function _sendEmail($data, $contact, $copy_email_activated) { $app = $this->app; + Factory::getLanguage()->load('com_contact', JPATH_SITE, $app->getLanguage()->getTag(), true); + if ($contact->email_to == '' && $contact->user_id != 0) { $contact_user = User::getInstance($contact->user_id);