diff --git a/admin-dev/ajax_send_mail_test.php b/admin-dev/ajax_send_mail_test.php deleted file mode 100644 index 2d6244f3f..000000000 --- a/admin-dev/ajax_send_mail_test.php +++ /dev/null @@ -1,50 +0,0 @@ - -* @copyright 2007-2012 PrestaShop SA -* @version Release: $Revision: 6844 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ -define('_PS_ADMIN_DIR_', getcwd()); -include_once(dirname(__FILE__).'/../config/config.inc.php'); - -/* Getting cookie or logout */ -require_once(dirname(__FILE__).'/init.php'); -if (Tools::getValue('token') != Tools::getAdminTokenLite('AdminEmails')) - die(Tools::displayError()); -$smtpChecked = (trim($_POST['mailMethod']) == 'smtp'); -$smtpServer = $_POST['smtpSrv']; -$content = urldecode($_POST['testMsg']); -$content = utf8_encode(html_entity_decode($content)); -$subject = urldecode($_POST['testSubject']); -$type = 'text/html'; -$to = $_POST['testEmail']; -$from = Configuration::get('PS_SHOP_EMAIL'); -$smtpLogin = $_POST['smtpLogin']; -$smtpPassword = (!empty($_POST['smtpPassword'])) ? urldecode($_POST['smtpPassword']) : Configuration::get('PS_MAIL_PASSWD'); -$smtpPort = $_POST['smtpPort']; -$smtpEncryption = $_POST['smtpEnc']; - -$result = Mail::sendMailTest(Tools::htmlentitiesUTF8($smtpChecked), Tools::htmlentitiesUTF8($smtpServer), Tools::htmlentitiesUTF8($content), Tools::htmlentitiesUTF8($subject), Tools::htmlentitiesUTF8($type), Tools::htmlentitiesUTF8($to), Tools::htmlentitiesUTF8($from), Tools::htmlentitiesUTF8($smtpLogin), Tools::htmlentitiesUTF8($smtpPassword), Tools::htmlentitiesUTF8($smtpPort), Tools::htmlentitiesUTF8($smtpEncryption)); -die($result === true ? 'ok' : $result); - - diff --git a/controllers/admin/AdminEmailsController.php b/controllers/admin/AdminEmailsController.php index bb19b43d9..959256720 100644 --- a/controllers/admin/AdminEmailsController.php +++ b/controllers/admin/AdminEmailsController.php @@ -206,4 +206,27 @@ class AdminEmailsControllerCore extends AdminController if ($_POST['PS_MAIL_METHOD'] == 2 && (empty($_POST['PS_MAIL_SERVER']) || empty($_POST['PS_MAIL_SMTP_PORT']))) $this->errors[] = Tools::displayError('You must define an SMTP server and an SMTP port. If you do not know, use the PHP mail() function instead.'); } + + public function ajaxProcessSendMailTest() + { + if ($this->tabAccess['view'] === '1') + { + $smtpChecked = (trim(Tools::getValue('mailMethod')) == 'smtp'); + $smtpServer = Tools::getValue('smtpSrv'); + $content = urldecode(Tools::getValue('testMsg')); + $content = utf8_encode(html_entity_decode($content)); + $subject = urldecode(Tools::getValue('testSubject')); + $type = 'text/html'; + $to = Tools::getValue('testEmail'); + $from = Configuration::get('PS_SHOP_EMAIL'); + $smtpLogin = Tools::getValue('smtpLogin'); + $smtpPassword = Tools::getValue('smtpPassword'); + $smtpPassword = (!empty($smtpPassword)) ? urldecode($smtpPassword) : Configuration::get('PS_MAIL_PASSWD'); + $smtpPort = Tools::getValue('smtpPort'); + $smtpEncryption = Tools::getValue('smtpEnc'); + + $result = Mail::sendMailTest(Tools::htmlentitiesUTF8($smtpChecked), Tools::htmlentitiesUTF8($smtpServer), Tools::htmlentitiesUTF8($content), Tools::htmlentitiesUTF8($subject), Tools::htmlentitiesUTF8($type), Tools::htmlentitiesUTF8($to), Tools::htmlentitiesUTF8($from), Tools::htmlentitiesUTF8($smtpLogin), Tools::htmlentitiesUTF8($smtpPassword), Tools::htmlentitiesUTF8($smtpPort), Tools::htmlentitiesUTF8($smtpEncryption)); + die($result === true ? 'ok' : $result); + } + } } diff --git a/controllers/admin/AdminFeaturesController.php b/controllers/admin/AdminFeaturesController.php index f0586caa4..e2d4075e2 100644 --- a/controllers/admin/AdminFeaturesController.php +++ b/controllers/admin/AdminFeaturesController.php @@ -473,30 +473,33 @@ class AdminFeaturesControllerCore extends AdminController public function ajaxProcessUpdatePositions() { - $way = (int)Tools::getValue('way'); - $id_feature = (int)Tools::getValue('id'); - $positions = Tools::getValue('feature'); - - $new_positions = array(); - foreach ($positions as $k => $v) - if (!empty($v)) - $new_positions[] = $v; - - foreach ($new_positions as $position => $value) + if ($this->tabAccess['edit'] === '1') { - $pos = explode('_', $value); + $way = (int)Tools::getValue('way'); + $id_feature = (int)Tools::getValue('id'); + $positions = Tools::getValue('feature'); - if (isset($pos[2]) && (int)$pos[2] === $id_feature) + $new_positions = array(); + foreach ($positions as $k => $v) + if (!empty($v)) + $new_positions[] = $v; + + foreach ($new_positions as $position => $value) { - if ($feature = new Feature((int)$pos[2])) - if (isset($position) && $feature->updatePosition($way, $position, $id_feature)) - echo 'ok position '.(int)$position.' for feature '.(int)$pos[1].'\r\n'; - else - echo '{"hasError" : true, "errors" : "Can not update feature '.(int)$id_feature.' to position '.(int)$position.' "}'; - else - echo '{"hasError" : true, "errors" : "This feature ('.(int)$id_feature.') can t be loaded"}'; + $pos = explode('_', $value); - break; + if (isset($pos[2]) && (int)$pos[2] === $id_feature) + { + if ($feature = new Feature((int)$pos[2])) + if (isset($position) && $feature->updatePosition($way, $position, $id_feature)) + echo 'ok position '.(int)$position.' for feature '.(int)$pos[1].'\r\n'; + else + echo '{"hasError" : true, "errors" : "Can not update feature '.(int)$id_feature.' to position '.(int)$position.' "}'; + else + echo '{"hasError" : true, "errors" : "This feature ('.(int)$id_feature.') can t be loaded"}'; + + break; + } } } }