[*] BO : #PSFV-94 - added AdminEmailsController
This commit is contained in:
1 parent
05621cb1f0
commit
b2b7d05ad5
4 files changed
+89
-62
No files matched your search
@@ -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 <contact@prestashop.com>
|
||||||
|
* @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
|
||||||
|
*}
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var textMsg = "{l s='This is a test message, your server is now available to send email'}";
|
||||||
|
var textSubject = "{l s='Test message - Prestashop'}";
|
||||||
|
var textSendOk = "{l s='Mail is sent'}";
|
||||||
|
var textSendError= "{l s='Error: please check your configuration'}";
|
||||||
|
var errorMail = "{l s='This email address is wrong!'}";
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="../js/sendMailTest.js"></script>
|
||||||
|
|
||||||
|
{$content}
|
||||||
|
|
||||||
|
|
||||||
@@ -44,8 +44,11 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{foreach $categoryData['fields'] AS $key => $field}
|
{foreach $categoryData['fields'] AS $key => $field}
|
||||||
|
{if $field['type'] == 'hidden'}
|
||||||
|
<input type="hidden" name="{$key}" value="{$field['value']}" />
|
||||||
|
{else}
|
||||||
<div style="clear: both; padding-top:15px;" id="conf_id_{$key}" {if $field['is_invisible']} class="isInvisible"{/if}>
|
<div style="clear: both; padding-top:15px;" id="conf_id_{$key}" {if $field['is_invisible']} class="isInvisible"{/if}>
|
||||||
{if $field['title']}
|
{if isset($field['title'])}
|
||||||
<label class="conf_title">
|
<label class="conf_title">
|
||||||
{if (isset($field['required']) && $field['required'])}
|
{if (isset($field['required']) && $field['required'])}
|
||||||
<sup>*</sup>
|
<sup>*</sup>
|
||||||
@@ -144,6 +147,7 @@
|
|||||||
{if isset($field['desc'])}<p class="preference_description">{$field['desc']}</p>{/if}
|
{if isset($field['desc'])}<p class="preference_description">{$field['desc']}</p>{/if}
|
||||||
{if $field['is_invisible']}<p class="multishop_warning">{l s='You can\'t change the value of this configuration field in this shop context'}</p>{/if}
|
{if $field['is_invisible']}<p class="multishop_warning">{l s='You can\'t change the value of this configuration field in this shop context'}</p>{/if}
|
||||||
</div></div>
|
</div></div>
|
||||||
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{if isset($categoryData['submit'])}
|
{if isset($categoryData['submit'])}
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
@@ -157,7 +161,7 @@
|
|||||||
{if $required_fields}
|
{if $required_fields}
|
||||||
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
<div class="small"><sup>*</sup> {l s ='Required field'}</div>
|
||||||
{/if}
|
{/if}
|
||||||
</fieldset><br />
|
|
||||||
{if isset($categoryData['bottom'])}{$categoryData['bottom']}{/if}
|
{if isset($categoryData['bottom'])}{$categoryData['bottom']}{/if}
|
||||||
|
</fieldset><br />
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</form>
|
</form>
|
||||||
@@ -120,9 +120,11 @@ class HelperOptionsCore extends Helper
|
|||||||
|
|
||||||
$this->context->smarty->assign(array(
|
$this->context->smarty->assign(array(
|
||||||
'current' => $this->currentIndex,
|
'current' => $this->currentIndex,
|
||||||
|
'table' => $this->table,
|
||||||
|
'token' => $this->token,
|
||||||
'option_list' => $option_list,
|
'option_list' => $option_list,
|
||||||
'current_id_lang' => $this->context->language->id,
|
'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);
|
return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->tpl);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,7 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include_once(_PS_ADMIN_DIR_.'/tabs/AdminPreferences.php');
|
class AdminEmailsControllerCore extends AdminController
|
||||||
|
|
||||||
class AdminEmails extends AdminPreferences
|
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@@ -39,7 +37,7 @@ class AdminEmails extends AdminPreferences
|
|||||||
foreach (Contact::getContacts($this->context->language->id) AS $contact)
|
foreach (Contact::getContacts($this->context->language->id) AS $contact)
|
||||||
$arr[] = array('email_message' => $contact['id_contact'], 'name' => $contact['name']);
|
$arr[] = array('email_message' => $contact['id_contact'], 'name' => $contact['name']);
|
||||||
|
|
||||||
$this->optionsList = array(
|
$this->options = array(
|
||||||
'email' => array(
|
'email' => array(
|
||||||
'title' => $this->l('E-mail'),
|
'title' => $this->l('E-mail'),
|
||||||
'icon' => 'email',
|
'icon' => 'email',
|
||||||
@@ -48,10 +46,19 @@ class AdminEmails extends AdminPreferences
|
|||||||
'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_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'))),
|
'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(
|
'smtp' => array(
|
||||||
'title' => $this->l('E-mail'),
|
'title' => $this->l('E-mail'),
|
||||||
'icon' => 'email',
|
'icon' => 'email',
|
||||||
|
'top' => '<div id="smtp" style="display: '.((Configuration::get('PS_MAIL_METHOD') == 2) ? 'block' : 'none').';">',
|
||||||
|
'bottom' => '<script type="text/javascript">
|
||||||
|
if (getE(\'PS_MAIL_METHOD2_on\').checked)
|
||||||
|
getE(\'smtp\').style.display = \'block\';
|
||||||
|
else
|
||||||
|
getE(\'smtp\').style.display = \'none\';
|
||||||
|
</script>
|
||||||
|
</div>',
|
||||||
'fields' => array(
|
'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_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_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),
|
||||||
@@ -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_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),
|
'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' => '<div class="margin-form"><input type="button" class="button" name="btEmailTest" id="btEmailTest" value="'.$this->l('Send an e-mail test').'" onClick="verifyMail();" /><br />
|
||||||
|
<p id="mailResultCheck" style="display:none;"></p></div>',
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
public function beforeUpdateOptions()
|
||||||
{
|
{
|
||||||
/* PrestaShop demo mode */
|
/* 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'])))
|
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.');
|
$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 '
|
|
||||||
<fieldset class="width2" style="margin-top: 10px;">
|
|
||||||
<legend><img src="../img/admin/email.gif" alt="" /> '.$this->l('Test your e-mail configuration').'</legend>
|
|
||||||
<script type="text/javascript">
|
|
||||||
var textMsg = "'.urlencode($this->l('This is a test message, your server is now available to send email')).'";
|
|
||||||
var textSubject = "'.urlencode($this->l('Test message - Prestashop')).'";
|
|
||||||
var textSendOk = "'.$this->l('Mail is sent').'";
|
|
||||||
var textSendError= "'.$this->l('Error: please check your configuration').'";
|
|
||||||
var errorMail = "'.$this->l('This email address is wrong!').'";
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="'._PS_JS_DIR_.'sendMailTest.js"></script>
|
|
||||||
<div style="clear: both; padding-top: 15px;">
|
|
||||||
<label>'.$this->l('Send a test e-mail to').'</label>
|
|
||||||
<div class="margin-form">
|
|
||||||
<input type="text" name="testEmail" id="testEmail" value="'.Configuration::get('PS_SHOP_EMAIL').'" style="width:210px;margin-bottom:4px;" /><br />
|
|
||||||
<input type="hidden" id="PS_MAIL_METHOD" name="PS_MAIL_METHOD" value="'.Configuration::get('PS_MAIL_METHOD').'" />
|
|
||||||
<input type="hidden" id="PS_MAIL_SERVER" name="PS_MAIL_SERVER" value="'.Configuration::get('PS_MAIL_SERVER').'" />
|
|
||||||
<input type="hidden" id="PS_MAIL_USER" name="PS_MAIL_USER" value="'.Configuration::get('PS_MAIL_USER').'" />
|
|
||||||
<input type="hidden" id="PS_MAIL_PASSWD" name="PS_MAIL_PASSWD" value="'.Configuration::get('PS_MAIL_PASSWD').'" />
|
|
||||||
<input type="hidden" id="PS_MAIL_SMTP_PORT" name="PS_MAIL_SMTP_PORT" value="'.Configuration::get('PS_MAIL_SMTP_PORT').'" />
|
|
||||||
<input type="hidden" id="PS_MAIL_SMTP_ENCRYPTION" name="PS_MAIL_SMTP_ENCRYPTION" value="'.Configuration::get('PS_MAIL_SMTP_ENCRYPTION').'" />
|
|
||||||
<input type="button" class="button" name="btEmailTest" id="btEmailTest" value="'.$this->l('Send an e-mail test').'" onClick="verifyMail();" /><br />
|
|
||||||
<p id="mailResultCheck" style="display:none;"></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</fieldset>';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayTopOptionCategory($category, $categoryData)
|
|
||||||
{
|
|
||||||
if ($category == 'smtp')
|
|
||||||
echo '<div id="smtp" style="display: '.((Configuration::get('PS_MAIL_METHOD') == 2) ? 'block' : 'none').';">';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayBottomOptionCategory($category, $categoryData)
|
|
||||||
{
|
|
||||||
if ($category == 'smtp')
|
|
||||||
echo '<script type="text/javascript">
|
|
||||||
if (getE(\'PS_MAIL_METHOD2_on\').checked)
|
|
||||||
getE(\'smtp\').style.display = \'block\';
|
|
||||||
else
|
|
||||||
getE(\'smtp\').style.display = \'none\';
|
|
||||||
</script>
|
|
||||||
</div>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user