diff --git a/email.php b/email.php index ba2234f..27d257d 100644 --- a/email.php +++ b/email.php @@ -2,7 +2,7 @@ /* * @package RadicalMart Package * @subpackage plg_radicalmart_message_email - * @version 1.0.0 + * @version 1.1.0 * @author Delo Design - delo-design.ru * @copyright Copyright (c) 2021 Delo Design. All rights reserved. * @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html @@ -12,7 +12,9 @@ defined('_JEXEC') or die; use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Form; use Joomla\CMS\Language\Text; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Uri\Uri; @@ -37,6 +39,38 @@ class plgRadicalMart_MessageEmail extends CMSPlugin */ protected $autoloadLanguage = true; + /** + * Add email config form to RadicalMart. + * + * @param Form $form The form to be altered. + * @param mixed $data The associated data for the form. + * + * @throws Exception + * + * @since 1.1.0 + */ + public function onRadicalMartPrepareConfigForm($form, $data) + { + Form::addFormPath(__DIR__ . '/forms'); + $form->loadFile('radicalmart'); + } + + /** + * Add email config form to RadicalMart Express. + * + * @param Form $form The form to be altered. + * @param mixed $data The associated data for the form. + * + * @throws Exception + * + * @since 1.1.0 + */ + public function onRadicalMartExpressPrepareConfigForm($form, $data) + { + Form::addFormPath(__DIR__ . '/forms'); + $form->loadFile('radicalmart'); + } + /** * Method to send message. * @@ -52,11 +86,14 @@ public function onRadicalMartSendMessage($type = null, $data = null) if (!in_array($type, array('user.create', 'order.create', 'order.change_status', 'express.user.create', 'express.order.create', 'express.order.change_status'))) return; - $constant = 'COM_RADICALMART'; + $constant = 'COM_RADICALMART'; + $component = 'com_radicalmart'; if (in_array($type, array('express.user.create', 'express.order.create', 'express.order.change_status'))) { - $constant .= '_EXPRESS'; + $constant .= '_EXPRESS'; + $component .= '_express'; } + $params = ComponentHelper::getParams($component); if ($type === 'order.create' || $type === 'order.change_status' || $type === 'express.order.create' || $type === 'express.order.change_status') @@ -65,8 +102,8 @@ public function onRadicalMartSendMessage($type = null, $data = null) $layout = ($type === 'order.create' || $type === 'express.order.create') ? 'create' : 'status'; $subject = ($type === 'order.create' || $type === 'express.order.create') - ? Text::sprintf('PLG_RADICALMART_MESSAGE_ORDER_CREATE', $data->number) - : Text::sprintf('PLG_RADICALMART_MESSAGE_ORDER_CHANGE_STATUS', $data->number, Text::_($data->status->title)); + ? Text::sprintf('PLG_RADICALMART_MESSAGE_EMAIL_ORDER_CREATE', $data->number) + : Text::sprintf('PLG_RADICALMART_MESSAGE_EMAIL_ORDER_CHANGE_STATUS', $data->number, Text::_($data->status->title)); $links = true; if (($type === 'express.order.create' || $type === 'express.order.change_status') && $data->status->id !== 2) @@ -78,19 +115,41 @@ public function onRadicalMartSendMessage($type = null, $data = null) if (!empty($data->contacts['email'])) { $this->sendEmail($subject, $data->contacts['email'], - RadicalMartHelperMessage::renderLayout('email.order.' . $layout, - array('recipient' => 'client', 'order' => $data, 'constant' => $constant, 'links' => $links))); + RadicalMartHelperMessage::renderLayout('email.order.' . $layout, array( + 'recipient' => 'client', + 'order' => $data, + 'constant' => $constant, + 'component' => $component, + 'params' => $params, + 'links' => $links + ))); } // Send admin email - $this->sendEmail($subject, $config->get('replyto', $config->get('mailfrom')), - RadicalMartHelperMessage::renderLayout('email.order.' . $layout, - array('recipient' => 'admin', 'order' => $data, 'constant' => $constant, 'links' => $links))); + $adminEmails = array(); + if (!empty($params->get('messages_email_admin'))) + { + foreach ((array) $params->get('messages_email_admin') as $param) + { + if (!empty($param->email)) $adminEmails[] = $param->email; + } + } + if (empty($adminEmails)) $adminEmails[] = $config->get('replyto', $config->get('mailfrom')); + + $this->sendEmail($subject, $adminEmails, + RadicalMartHelperMessage::renderLayout('email.order.' . $layout, array( + 'recipient' => 'admin', + 'order' => $data, + 'constant' => $constant, + 'component' => $component, + 'params' => $params, + 'links' => $links + ))); } elseif (($type === 'user.create' || $type === 'express.user.create') && !empty($data['result'])) { // Prepare data - $subject = Text::sprintf('PLG_RADICALMART_MESSAGE_USER_CREATE', $data['user']->name, + $subject = Text::sprintf('PLG_RADICALMART_MESSAGE_EMAIL_USER_CREATE', $data['user']->name, Uri::getInstance()->getHost()); $recipient = $data['user']->email; $body = RadicalMartHelperMessage::renderLayout('email.user.create', diff --git a/email.xml b/email.xml index 58015cf..c730106 100644 --- a/email.xml +++ b/email.xml @@ -2,12 +2,12 @@ PLG_RADICALMART_MESSAGE_EMAIL Delo Design - August 2021 + March 2022 Copyright © 2021 Delo Design. All rights reserved. https://www.gnu.org/copyleft/gpl.html GNU/GPL boss@delo-design.ru https://delo-design.ru - 1.0.0 + 1.1.0 PLG_RADICALMART_MESSAGE_EMAIL_DESCRIPTION script.php @@ -18,13 +18,14 @@ email.php + forms user order - + https://radicalmart.ru/update?element=plg_radicalmart_message_email diff --git a/forms/express.xml b/forms/express.xml new file mode 100644 index 0000000..4322543 --- /dev/null +++ b/forms/express.xml @@ -0,0 +1,14 @@ + +
+
+ + + + + + +
+ \ No newline at end of file diff --git a/forms/radicalmart.xml b/forms/radicalmart.xml new file mode 100644 index 0000000..cb191f0 --- /dev/null +++ b/forms/radicalmart.xml @@ -0,0 +1,14 @@ + +
+
+ + + + + + +
+ \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_radicalmart_message_email.ini b/language/en-GB/en-GB.plg_radicalmart_message_email.ini index 9f10cde..4eae6a5 100644 --- a/language/en-GB/en-GB.plg_radicalmart_message_email.ini +++ b/language/en-GB/en-GB.plg_radicalmart_message_email.ini @@ -1,6 +1,6 @@ ; @package RadicalMart Package ; @subpackage plg_radicalmart_message_email -; @version 1.0.0 +; @version 1.1.0 ; @author Delo Design - delo-design.ru ; @copyright Copyright (c) 2021 Delo Design. All rights reserved. ; @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html diff --git a/language/en-GB/en-GB.plg_radicalmart_message_email.sys.ini b/language/en-GB/en-GB.plg_radicalmart_message_email.sys.ini index 9f10cde..4eae6a5 100644 --- a/language/en-GB/en-GB.plg_radicalmart_message_email.sys.ini +++ b/language/en-GB/en-GB.plg_radicalmart_message_email.sys.ini @@ -1,6 +1,6 @@ ; @package RadicalMart Package ; @subpackage plg_radicalmart_message_email -; @version 1.0.0 +; @version 1.1.0 ; @author Delo Design - delo-design.ru ; @copyright Copyright (c) 2021 Delo Design. All rights reserved. ; @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html diff --git a/language/ru-RU/ru-RU.plg_radicalmart_message_email.ini b/language/ru-RU/ru-RU.plg_radicalmart_message_email.ini index b053cc7..de5c514 100644 --- a/language/ru-RU/ru-RU.plg_radicalmart_message_email.ini +++ b/language/ru-RU/ru-RU.plg_radicalmart_message_email.ini @@ -1,6 +1,6 @@ ; @package RadicalMart Package ; @subpackage plg_radicalmart_message_email -; @version 1.0.0 +; @version 1.1.0 ; @author Delo Design - delo-design.ru ; @copyright Copyright (c) 2021 Delo Design. All rights reserved. ; @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html @@ -10,11 +10,13 @@ PLG_RADICALMART_MESSAGE_EMAIL = "RadicalMart Message: Email" PLG_RADICALMART_MESSAGE_EMAIL_DESCRIPTION = "Плагин отправки email сообщений" -PLG_RADICALMART_MESSAGE_ORDER_CREATE = "Новый заказ №%s" -PLG_RADICALMART_MESSAGE_ORDER_CHANGE_STATUS = "Статус заказа №%s изменился на %s" -PLG_RADICALMART_MESSAGE_ORDER_INFORMATION = "Информация о заказе №%s" -PLG_RADICALMART_MESSAGE_USER_CREATE = "%s, ваш доступ к сайту %s" -PLG_RADICALMART_MESSAGE_USER_CREATE_TITLE = "%s, для вас на сайте %s автоматически создана учетная запись." -PLG_RADICALMART_MESSAGE_USER_CREATE_DESC = "Вы можете в любой момент времени авторизоваться на сайте %ы используя" -PLG_RADICALMART_MESSAGE_USER_LOGIN = "Логин" -PLG_RADICALMART_MESSAGE_USER_PASSWORD = "Пароль" \ No newline at end of file +PLG_RADICALMART_MESSAGE_EMAIL_PARAMS_ADMIN = "Почта администраторов" + +PLG_RADICALMART_MESSAGE_EMAIL_ORDER_CREATE = "Новый заказ №%s" +PLG_RADICALMART_MESSAGE_EMAIL_ORDER_CHANGE_STATUS = "Статус заказа №%s изменился на %s" +PLG_RADICALMART_MESSAGE_EMAIL_ORDER_INFORMATION = "Информация о заказе №%s" +PLG_RADICALMART_MESSAGE_EMAIL_USER_CREATE = "%s, ваш доступ к сайту %s" +PLG_RADICALMART_MESSAGE_EMAIL_USER_CREATE_TITLE = "%s, для вас на сайте %s автоматически создана учетная запись." +PLG_RADICALMART_MESSAGE_EMAIL_USER_CREATE_DESC = "Вы можете в любой момент времени авторизоваться на сайте %s используя" +PLG_RADICALMART_MESSAGE_EMAIL_USER_LOGIN = "Логин" +PLG_RADICALMART_MESSAGE_EMAIL_USER_PASSWORD = "Пароль" \ No newline at end of file diff --git a/language/ru-RU/ru-RU.plg_radicalmart_message_email.sys.ini b/language/ru-RU/ru-RU.plg_radicalmart_message_email.sys.ini index 6530bcb..5696048 100644 --- a/language/ru-RU/ru-RU.plg_radicalmart_message_email.sys.ini +++ b/language/ru-RU/ru-RU.plg_radicalmart_message_email.sys.ini @@ -1,6 +1,6 @@ ; @package RadicalMart Package ; @subpackage plg_radicalmart_message_email -; @version 1.0.0 +; @version 1.1.0 ; @author Delo Design - delo-design.ru ; @copyright Copyright (c) 2021 Delo Design. All rights reserved. ; @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html diff --git a/layouts/order/create.php b/layouts/order/create.php index 0d62baf..b267954 100644 --- a/layouts/order/create.php +++ b/layouts/order/create.php @@ -2,7 +2,7 @@ /* * @package RadicalMart Package * @subpackage plg_radicalmart_message_email - * @version 1.0.0 + * @version 1.1.0 * @author Delo Design - delo-design.ru * @copyright Copyright (c) 2021 Delo Design. All rights reserved. * @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html @@ -15,6 +15,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\Uri\Uri; +use Joomla\Registry\Registry; extract($displayData); @@ -22,22 +23,23 @@ * Layout variables * ----------------- * - * @var object $order The order id. - * @var string $recipient Mail recipient. - * @var string $constant Language constant. - * @var boolean $links Products links. + * @var object $order The order id. + * @var string $recipient Mail recipient. + * @var string $constant Language constant. + * @var string $component Component name constant. + * @var boolean $links Products links. + * @var Registry $params Component params. * */ -$component = strtolower($constant); -$link = Uri::getInstance('site')->toString(array('scheme', 'host', 'port')); -$link .= ($recipient === 'admin') ? '/administrator/index.php?option=' . $component . '&task=order.edit&id=' + +$link = Uri::getInstance()->toString(array('scheme', 'host', 'port')); +$link .= ($recipient === 'admin') ? '/administrator/index.php?option=' . $component . '&task=order.edit&id=' . $order->id : $order->link; -$params = ComponentHelper::getParams($component); ?>

- number); ?> + number); ?>

@@ -45,7 +47,7 @@ : status->title); ?>
- shipping): ?> + shipping)): ?>
: @@ -54,7 +56,7 @@
- payment): ?> + payment)): ?>
: diff --git a/layouts/order/status.php b/layouts/order/status.php index 0d62baf..01f22bb 100644 --- a/layouts/order/status.php +++ b/layouts/order/status.php @@ -2,7 +2,7 @@ /* * @package RadicalMart Package * @subpackage plg_radicalmart_message_email - * @version 1.0.0 + * @version 1.1.0 * @author Delo Design - delo-design.ru * @copyright Copyright (c) 2021 Delo Design. All rights reserved. * @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html @@ -15,6 +15,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\Uri\Uri; +use Joomla\Registry\Registry; extract($displayData); @@ -22,22 +23,22 @@ * Layout variables * ----------------- * - * @var object $order The order id. - * @var string $recipient Mail recipient. - * @var string $constant Language constant. - * @var boolean $links Products links. + * @var object $order The order id. + * @var string $recipient Mail recipient. + * @var string $constant Language constant. + * @var string $component Component name constant. + * @var boolean $links Products links. + * @var Registry $params Component params. * */ -$component = strtolower($constant); -$link = Uri::getInstance('site')->toString(array('scheme', 'host', 'port')); +$link = Uri::getInstance()->toString(array('scheme', 'host', 'port')); $link .= ($recipient === 'admin') ? '/administrator/index.php?option=' . $component . '&task=order.edit&id=' . $order->id : $order->link; -$params = ComponentHelper::getParams($component); ?>

- number); ?> + number); ?>

@@ -45,7 +46,7 @@ : status->title); ?>
- shipping): ?> + shipping)): ?>
: @@ -54,7 +55,7 @@
- payment): ?> + payment)): ?>
: diff --git a/layouts/user/create.php b/layouts/user/create.php index 854e337..4b8b17b 100644 --- a/layouts/user/create.php +++ b/layouts/user/create.php @@ -2,7 +2,7 @@ /* * @package RadicalMart Package * @subpackage plg_radicalmart_message_email - * @version 1.0.0 + * @version 1.1.0 * @author Delo Design - delo-design.ru * @copyright Copyright (c) 2021 Delo Design. All rights reserved. * @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html @@ -28,20 +28,20 @@ $site = Uri::getInstance()->getHost(); ?>
- name, $site); ?> + name, $site); ?>
- +
- + username; ?>
- + diff --git a/script.php b/script.php index 3042c07..32bc235 100644 --- a/script.php +++ b/script.php @@ -2,7 +2,7 @@ /* * @package RadicalMart Package * @subpackage plg_radicalmart_message_email - * @version 1.0.0 + * @version 1.1.0 * @author Delo Design - delo-design.ru * @copyright Copyright (c) 2021 Delo Design. All rights reserved. * @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html