From b2b7d05ad5a10e0a8eb162af4d64690be7c8c90e Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Wed, 19 Oct 2011 15:38:57 +0000 Subject: [PATCH] [*] BO : #PSFV-94 - added AdminEmailsController --- admin-dev/themes/template/emails/content.tpl | 38 ++++ admin-dev/themes/template/options.tpl | 194 +++++++++--------- classes/HelperOptions.php | 4 +- .../admin/AdminEmailsController.php | 111 +++++----- 4 files changed, 187 insertions(+), 160 deletions(-) create mode 100644 admin-dev/themes/template/emails/content.tpl rename admin-dev/tabs/AdminEmails.php => controllers/admin/AdminEmailsController.php (63%) diff --git a/admin-dev/themes/template/emails/content.tpl b/admin-dev/themes/template/emails/content.tpl new file mode 100644 index 000000000..b3b7ebc19 --- /dev/null +++ b/admin-dev/themes/template/emails/content.tpl @@ -0,0 +1,38 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + + + +{$content} + + diff --git a/admin-dev/themes/template/options.tpl b/admin-dev/themes/template/options.tpl index 1fb5af6b7..241426d06 100644 --- a/admin-dev/themes/template/options.tpl +++ b/admin-dev/themes/template/options.tpl @@ -44,106 +44,110 @@ {/if} {foreach $categoryData['fields'] AS $key => $field} -
- {if $field['title']} -
{/foreach} {if isset($categoryData['submit'])}
@@ -157,7 +161,7 @@ {if $required_fields}
* {l s ='Required field'}
{/if} -
{if isset($categoryData['bottom'])}{$categoryData['bottom']}{/if} +
{/foreach} diff --git a/classes/HelperOptions.php b/classes/HelperOptions.php index 065945fc0..f0396b5fe 100644 --- a/classes/HelperOptions.php +++ b/classes/HelperOptions.php @@ -120,9 +120,11 @@ class HelperOptionsCore extends Helper $this->context->smarty->assign(array( 'current' => $this->currentIndex, + 'table' => $this->table, + 'token' => $this->token, 'option_list' => $option_list, 'current_id_lang' => $this->context->language->id, - 'required_fields' => $this->required, + 'required_fields' => isset($required_fields) ? $required_fields : false, )); return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->tpl); } diff --git a/admin-dev/tabs/AdminEmails.php b/controllers/admin/AdminEmailsController.php similarity index 63% rename from admin-dev/tabs/AdminEmails.php rename to controllers/admin/AdminEmailsController.php index 680592a73..a3bff0089 100644 --- a/admin-dev/tabs/AdminEmails.php +++ b/controllers/admin/AdminEmailsController.php @@ -25,9 +25,7 @@ * International Registered Trademark & Property of PrestaShop SA */ -include_once(_PS_ADMIN_DIR_.'/tabs/AdminPreferences.php'); - -class AdminEmails extends AdminPreferences +class AdminEmailsControllerCore extends AdminController { public function __construct() { @@ -39,20 +37,29 @@ class AdminEmails extends AdminPreferences foreach (Contact::getContacts($this->context->language->id) AS $contact) $arr[] = array('email_message' => $contact['id_contact'], 'name' => $contact['name']); - $this->optionsList = array( + $this->options = array( 'email' => array( - 'title' => $this->l('E-mail'), - 'icon' => 'email', + 'title' => $this->l('E-mail'), + 'icon' => 'email', 'fields' => array( 'PS_MAIL_EMAIL_MESSAGE' => array('title' => $this->l('Send e-mail to:'), 'desc' => $this->l('When customers send message from order page'), 'validation' => 'isUnsignedId', 'type' => 'select', 'cast' => 'intval', 'identifier' => 'email_message', 'list' => $arr), 'PS_MAIL_METHOD' => array('title' => '', 'validation' => 'isGenericName', 'type' => 'radio', 'required' => true, 'choices' => array(1 => $this->l('Use PHP mail() function. Recommended; works in most cases'), 2 => $this->l('Set my own SMTP parameters. For advanced users ONLY')), 'js' => array(1 => 'onclick="$(\'#smtp\').slideUp();"', 2 => 'onclick="$(\'#smtp\').slideDown();"'), 'visibility' => Shop::CONTEXT_ALL), 'PS_MAIL_TYPE' => array('title' => '', 'validation' => 'isGenericName', 'type' => 'radio', 'required' => true, 'choices' => array(1 => $this->l('Send e-mail as HTML'), 2 => $this->l('Send e-mail as Text'), 3 => $this->l('Both'))), ), + 'submit' => array() ), 'smtp' => array( - 'title' => $this->l('E-mail'), - 'icon' => 'email', - 'fields' => array( + 'title' => $this->l('E-mail'), + 'icon' => 'email', + 'top' => '
', + 'bottom' => ' +
', + 'fields' => array( 'PS_MAIL_DOMAIN' => array('title' => $this->l('Mail domain:'), 'desc' => $this->l('Fully qualified domain name (keep it empty if you do not know)'), 'empty' => true, 'validation' => 'isUrl', 'size' => 30, 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL), 'PS_MAIL_SERVER' => array('title' => $this->l('SMTP server:'), 'desc' => $this->l('IP or server name (e.g., smtp.mydomain.com)'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL), 'PS_MAIL_USER' => array('title' => $this->l('SMTP user:'), 'desc' => $this->l('Leave blank if not applicable'), 'validation' => 'isGenericName', 'size' => 30, 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL), @@ -60,10 +67,41 @@ class AdminEmails extends AdminPreferences 'PS_MAIL_SMTP_ENCRYPTION' => array('title' => $this->l('Encryption:'), 'desc' => $this->l('Use an encrypt protocol'), 'type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => array(array('mode' => 'off', 'name' => $this->l('None')), array('mode' => 'tls', 'name' => $this->l('TLS')), array('mode' => 'ssl', 'name' => $this->l('SSL'))), 'visibility' => Shop::CONTEXT_ALL), 'PS_MAIL_SMTP_PORT' => array('title' => $this->l('Port:'), 'desc' => $this->l('Number of port to use'), 'validation' => 'isInt', 'size' => 5, 'type' => 'text', 'cast' => 'intval', 'visibility' => Shop::CONTEXT_ALL), ), + 'submit' => array() ), + 'test' => array( + 'title' => $this->l('Test your e-mail configuration'), + 'icon' => 'email', + 'class' => 'width2', + 'fields' => array( + 'PS_SHOP_EMAIL' => array('title' => $this->l('Send a test e-mail to'), 'type' => 'text', 'size' => 40, 'id' => 'testEmail'), + 'PS_MAIL_METHOD' => array('type' => 'hidden'), + 'PS_MAIL_SERVER' => array('type' => 'hidden'), + 'PS_MAIL_USER' => array('type' => 'hidden'), + 'PS_MAIL_PASSWD' => array('type' => 'hidden'), + 'PS_MAIL_SMTP_PORT' => array('type' => 'hidden'), + 'PS_MAIL_SMTP_ENCRYPTION' => array('type' => 'hidden'), + 'PS_MAIL_SERVER' => array('type' => 'hidden'), + 'PS_MAIL_SERVER' => array('type' => 'hidden'), + ), + 'bottom' => '

+
', + ) ); } + public function initContent() + { + $helper = new HelperOptions(); + $helper->id = $this->id; + $helper->currentIndex = self::$currentIndex; + $helper->table = $this->table; + $helper->token = $this->token; + $this->content .= $helper->generateOptions($this->options); + + parent::initContent(); + } + public function beforeUpdateOptions() { /* PrestaShop demo mode */ @@ -77,59 +115,4 @@ class AdminEmails extends AdminPreferences if ($_POST['PS_MAIL_METHOD'] == 2 AND (empty($_POST['PS_MAIL_SERVER']) OR empty($_POST['PS_MAIL_SMTP_PORT']))) $this->_errors[] = Tools::displayError('You must define a SMTP server and a SMTP port. If you do not know, use the PHP mail() function instead.'); } - - public function display() - { - parent::display(); - - $this->_displayMailTest(); - } - - private function _displayMailTest() - { - echo ' -
- '.$this->l('Test your e-mail configuration').' - - -
- -
-
- - - - - - -
- -
-
-
'; - } - - public function displayTopOptionCategory($category, $categoryData) - { - if ($category == 'smtp') - echo '
'; - } - - public function displayBottomOptionCategory($category, $categoryData) - { - if ($category == 'smtp') - echo ' -
'; - } }