mailing sytem admin
This commit is contained in:
62
core/lib/Thelia/Action/MailingSystem.php
Normal file
62
core/lib/Thelia/Action/MailingSystem.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\MailingSystem\MailingSystemEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
class MailingSystem extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @param MailingSystemEvent $event
|
||||
*/
|
||||
public function update(MailingSystemEvent $event)
|
||||
{
|
||||
if($event->getEnabled()) {
|
||||
ConfigQuery::enableSmtp();
|
||||
} else {
|
||||
ConfigQuery::disableSmtp();
|
||||
}
|
||||
ConfigQuery::setSmtpHost($event->getHost());
|
||||
ConfigQuery::setSmtpPort($event->getPort());
|
||||
ConfigQuery::setSmtpEncryption($event->getEncryption());
|
||||
ConfigQuery::setSmtpUsername($event->getUsername());
|
||||
ConfigQuery::setSmtpPassword($event->getPassword());
|
||||
ConfigQuery::setSmtpAuthMode($event->getAuthMode());
|
||||
ConfigQuery::setSmtpTimeout($event->getTimeout());
|
||||
ConfigQuery::setSmtpSourceIp($event->getSourceIp());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::MAILING_SYSTEM_UPDATE => array("update", 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -166,6 +166,11 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.mailing_system" class="Thelia\Action\MailingSystem">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.newsletter" class="Thelia\Action\Newsletter">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
|
||||
@@ -148,6 +148,8 @@
|
||||
<form name="thelia.admin.administrator.add" class="Thelia\Form\AdministratorCreationForm"/>
|
||||
<form name="thelia.admin.administrator.update" class="Thelia\Form\AdministratorModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.mailing-system.update" class="Thelia\Form\MailingSystemModificationForm"/>
|
||||
|
||||
<form name="thelia.admin.template.creation" class="Thelia\Form\TemplateCreationForm"/>
|
||||
<form name="thelia.admin.template.modification" class="Thelia\Form\TemplateModificationForm"/>
|
||||
|
||||
|
||||
@@ -812,6 +812,18 @@
|
||||
|
||||
<!-- end administrator management -->
|
||||
|
||||
<!-- mailing-system management -->
|
||||
|
||||
<route id="admin.configuration.mailing-system.view" path="/admin/configuration/mailingSystem">
|
||||
<default key="_controller">Thelia\Controller\Admin\MailingSystemController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.mailing-system.save" path="/admin/configuration/mailingSystem/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\MailingSystemController::updateAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end mailing-system management -->
|
||||
|
||||
<!-- feature and features value management -->
|
||||
|
||||
<route id="admin.configuration.features.default" path="/admin/configuration/features">
|
||||
|
||||
@@ -23,20 +23,91 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Event\MailingSystem\MailingSystemEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Form\MailingSystemModificationForm;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
* Class MailingSystemController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class MailingSystemController extends BaseAdminController
|
||||
{
|
||||
const RESOURCE_CODE = "admin.mailing-system";
|
||||
|
||||
public function defaultAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MAILING_SYSTEM, AccessManager::VIEW)) return $response;
|
||||
return $this->render("mailing-system");
|
||||
if (null !== $response = $this->checkAuth(self::RESOURCE_CODE, AccessManager::VIEW)) return $response;
|
||||
|
||||
// Hydrate the form abd pass it to the parser
|
||||
$data = array(
|
||||
'enabled' => ConfigQuery::isSmtpEnable() ? 1 : 0,
|
||||
'host' => ConfigQuery::getSmtpHost(),
|
||||
'port' => ConfigQuery::getSmtpPort(),
|
||||
'encryption' => ConfigQuery::getSmtpEncryption(),
|
||||
'username' => ConfigQuery::getSmtpUsername(),
|
||||
'password' => ConfigQuery::getSmtpPassword(),
|
||||
'authmode' => ConfigQuery::getSmtpAuthMode(),
|
||||
'timeout' => ConfigQuery::getSmtpTimeout(),
|
||||
'sourceip' => ConfigQuery::getSmtpSourceIp(),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
$form = new MailingSystemModificationForm($this->getRequest(), "form", $data);
|
||||
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($form);
|
||||
|
||||
// Render the edition template.
|
||||
return $this->render('mailing-system');
|
||||
}
|
||||
|
||||
public function updateAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth(self::RESOURCE_CODE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
// Create the form from the request
|
||||
$form = new MailingSystemModificationForm($this->getRequest());
|
||||
|
||||
try {
|
||||
|
||||
// Check the form against constraints violations
|
||||
$formData = $this->validateForm($form, "POST");
|
||||
|
||||
// Get the form field values
|
||||
$event = new MailingSystemEvent();
|
||||
$event->setEnabled($formData->get('enabled')->getData());
|
||||
$event->setHost($formData->get('host')->getData());
|
||||
$event->setPort($formData->get('port')->getData());
|
||||
$event->setEncryption($formData->get('encryption')->getData());
|
||||
$event->setUsername($formData->get('username')->getData());
|
||||
$event->setPassword($formData->get('password')->getData());
|
||||
$event->setAuthMode($formData->get('authmode')->getData());
|
||||
$event->setTimeout($formData->get('timeout')->getData());
|
||||
$event->setSourceIp($formData->get('sourceip')->getData());
|
||||
|
||||
$this->dispatch(TheliaEvents::MAILING_SYSTEM_UPDATE, $event);
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirectToRoute("admin.configuration.mailing-system.view");
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("mailing system modification", array()),
|
||||
$error_msg,
|
||||
$form,
|
||||
$ex
|
||||
);
|
||||
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->render('mailing-system');
|
||||
}
|
||||
}
|
||||
|
||||
183
core/lib/Thelia/Core/Event/MailingSystem/MailingSystemEvent.php
Normal file
183
core/lib/Thelia/Core/Event/MailingSystem/MailingSystemEvent.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\MailingSystem;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class MailingSystemEvent extends ActionEvent
|
||||
{
|
||||
protected $enabled = null;
|
||||
protected $host = null;
|
||||
protected $port = null;
|
||||
protected $encryption = null;
|
||||
protected $username = null;
|
||||
protected $password = null;
|
||||
protected $authMode = null;
|
||||
protected $timeout = null;
|
||||
protected $sourceIp = null;
|
||||
|
||||
/**
|
||||
* @param null $authMode
|
||||
*/
|
||||
public function setAuthMode($authMode)
|
||||
{
|
||||
$this->authMode = $authMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getAuthMode()
|
||||
{
|
||||
return $this->authMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $enabled
|
||||
*/
|
||||
public function setEnabled($enabled)
|
||||
{
|
||||
$this->enabled = $enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getEnabled()
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $encryption
|
||||
*/
|
||||
public function setEncryption($encryption)
|
||||
{
|
||||
$this->encryption = $encryption;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getEncryption()
|
||||
{
|
||||
return $this->encryption;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $host
|
||||
*/
|
||||
public function setHost($host)
|
||||
{
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getHost()
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $password
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $port
|
||||
*/
|
||||
public function setPort($port)
|
||||
{
|
||||
$this->port = $port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getPort()
|
||||
{
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $sourceIp
|
||||
*/
|
||||
public function setSourceIp($sourceIp)
|
||||
{
|
||||
$this->sourceIp = $sourceIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getSourceIp()
|
||||
{
|
||||
return $this->sourceIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $timeout
|
||||
*/
|
||||
public function setTimeout($timeout)
|
||||
{
|
||||
$this->timeout = $timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getTimeout()
|
||||
{
|
||||
return $this->timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $username
|
||||
*/
|
||||
public function setUsername($username)
|
||||
{
|
||||
$this->username = $username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
}
|
||||
@@ -566,6 +566,10 @@ final class TheliaEvents
|
||||
const ADMINISTRATOR_UPDATE = "action.updateAdministrator";
|
||||
const ADMINISTRATOR_DELETE = "action.deleteAdministrator";
|
||||
|
||||
// -- Mailing System management ---------------------------------------------
|
||||
|
||||
const MAILING_SYSTEM_UPDATE = "action.updateMailingSystem";
|
||||
|
||||
// -- Tax Rules management ---------------------------------------------
|
||||
|
||||
const TAX_RULE_CREATE = "action.createTaxRule";
|
||||
|
||||
95
core/lib/Thelia/Form/MailingSystemModificationForm.php
Normal file
95
core/lib/Thelia/Form/MailingSystemModificationForm.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ProfileQuery;
|
||||
|
||||
/**
|
||||
* Class MailingSystemModificationForm
|
||||
* @package Thelia\Form
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class MailingSystemModificationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("enabled", "choice", array(
|
||||
"choices" => array(1 => "Yes", 0 => "No"),
|
||||
"label" => Translator::getInstance()->trans("Enable remote SMTP use"),
|
||||
"label_attr" => array("for" => "enabled_field"),
|
||||
))
|
||||
->add("host", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Host"),
|
||||
"label_attr" => array("for" => "host_field"),
|
||||
))
|
||||
->add("port", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Port"),
|
||||
"label_attr" => array("for" => "port_field"),
|
||||
))
|
||||
->add("encryption", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Encryption"),
|
||||
"label_attr" => array("for" => "encryption_field"),
|
||||
))
|
||||
->add("username", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Username"),
|
||||
"label_attr" => array("for" => "username_field"),
|
||||
))
|
||||
->add("password", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Password"),
|
||||
"label_attr" => array("for" => "password_field"),
|
||||
))
|
||||
->add("authmode", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Auth mode"),
|
||||
"label_attr" => array("for" => "authmode_field"),
|
||||
))
|
||||
->add("timeout", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Timeout"),
|
||||
"label_attr" => array("for" => "timeout_field"),
|
||||
))
|
||||
->add("sourceip", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Source IP"),
|
||||
"label_attr" => array("for" => "sourceip_field"),
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_mailing_system_modification";
|
||||
}
|
||||
|
||||
/*public function verifyCode($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$profile = ProfileQuery::create()
|
||||
->findOneByCode($value);
|
||||
|
||||
if (null !== $profile) {
|
||||
$context->addViolation("Profile `code` already exists");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class MailerFactory {
|
||||
if($transporterEvent->hasTransporter()) {
|
||||
$transporter = $transporterEvent->getTransporter();
|
||||
} else {
|
||||
if (ConfigQuery::read("smtp.enabled")) {
|
||||
if (ConfigQuery::isSmtpEnable()) {
|
||||
$transporter = $this->configureSmtp();
|
||||
} else {
|
||||
$transporter = \Swift_MailTransport::newInstance();
|
||||
@@ -65,14 +65,14 @@ class MailerFactory {
|
||||
private function configureSmtp()
|
||||
{
|
||||
$smtpTransporter = new \Swift_SmtpTransport();
|
||||
$smtpTransporter->setHost(Configquery::read('smtp.host', 'localhost'))
|
||||
->setPort(ConfigQuery::read('smtp.host'))
|
||||
->setEncryption(ConfigQuery::read('smtp.encryption'))
|
||||
->setUsername(ConfigQuery::read('smtp.username'))
|
||||
->setPassword(ConfigQuery::read('smtp.password'))
|
||||
->setAuthMode(ConfigQuery::read('smtp.authmode'))
|
||||
->setTimeout(ConfigQuery::read('smtp.timeout', 30))
|
||||
->setSourceIp(ConfigQuery::read('smtp.sourceip'))
|
||||
$smtpTransporter->setHost(Configquery::getSmtpHost())
|
||||
->setPort(ConfigQuery::getSmtpPort())
|
||||
->setEncryption(ConfigQuery::getSmtpEncryption())
|
||||
->setUsername(ConfigQuery::getSmtpUsername())
|
||||
->setPassword(ConfigQuery::getSmtpPassword())
|
||||
->setAuthMode(ConfigQuery::getSmtpAuthMode())
|
||||
->setTimeout(ConfigQuery::getSmtpTimeout())
|
||||
->setSourceIp(ConfigQuery::getSmtpSourceIp())
|
||||
;
|
||||
return $smtpTransporter;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,23 @@ class ConfigQuery extends BaseConfigQuery {
|
||||
return self::$cache[$search];
|
||||
}
|
||||
|
||||
public static function write($configName, $value, $secured, $hidden)
|
||||
{
|
||||
$config = self::create()->findOneByName($configName);
|
||||
|
||||
if(null == $config) {
|
||||
$config = new Config();
|
||||
$config->setName($configName);
|
||||
}
|
||||
|
||||
$config->setSecured($secured ? 1 : 0);
|
||||
$config->setHidden($hidden ? 1 : 0);
|
||||
$config->setValue($value);
|
||||
$config->save();
|
||||
|
||||
self::$cache[$configName] = $value;
|
||||
}
|
||||
|
||||
public static function resetCache($key = null)
|
||||
{
|
||||
if($key) {
|
||||
@@ -74,4 +91,101 @@ class ConfigQuery extends BaseConfigQuery {
|
||||
{
|
||||
return self::read('use_tax_free_amounts', 'default') == 1;
|
||||
}
|
||||
|
||||
/* smtp config */
|
||||
public static function isSmtpEnable()
|
||||
{
|
||||
return self::read('smtp.enabled') == 1;
|
||||
}
|
||||
|
||||
public static function getSmtpHost()
|
||||
{
|
||||
return self::read('smtp.host', 'localhost');
|
||||
}
|
||||
|
||||
public static function getSmtpPort()
|
||||
{
|
||||
return self::read('smtp.port');
|
||||
}
|
||||
|
||||
public static function getSmtpEncryption()
|
||||
{
|
||||
return self::read('smtp.encryption');
|
||||
}
|
||||
|
||||
public static function getSmtpUsername()
|
||||
{
|
||||
return self::read('smtp.username');
|
||||
}
|
||||
|
||||
public static function getSmtpPassword()
|
||||
{
|
||||
return self::read('smtp.authmode');
|
||||
}
|
||||
|
||||
public static function getSmtpAuthMode()
|
||||
{
|
||||
return self::read('smtp.host');
|
||||
}
|
||||
|
||||
public static function getSmtpTimeout()
|
||||
{
|
||||
return self::read('smtp.timeout', 30);
|
||||
}
|
||||
|
||||
public static function getSmtpSourceIp()
|
||||
{
|
||||
return self::read('smtp.sourceip');
|
||||
}
|
||||
|
||||
public static function enableSmtp()
|
||||
{
|
||||
self::write('smtp.enabled', 1, 1, 1);
|
||||
}
|
||||
|
||||
public static function disableSmtp()
|
||||
{
|
||||
self::write('smtp.enabled', 0, 1, 1);
|
||||
}
|
||||
|
||||
public static function setSmtpHost($value)
|
||||
{
|
||||
return self::write('smtp.host', $value, 1, 1);
|
||||
}
|
||||
|
||||
public static function setSmtpPort($value)
|
||||
{
|
||||
return self::write('smtp.port', $value, 1, 1);
|
||||
}
|
||||
|
||||
public static function setSmtpEncryption($value)
|
||||
{
|
||||
return self::write('smtp.encryption', $value, 1, 1);
|
||||
}
|
||||
|
||||
public static function setSmtpUsername($value)
|
||||
{
|
||||
return self::write('smtp.username', $value, 1, 1);
|
||||
}
|
||||
|
||||
public static function setSmtpPassword($value)
|
||||
{
|
||||
return self::write('smtp.password', $value, 1, 1);
|
||||
}
|
||||
|
||||
public static function setSmtpAuthMode($value)
|
||||
{
|
||||
return self::write('smtp.authmode', $value, 1, 1);
|
||||
}
|
||||
|
||||
public static function setSmtpTimeout($value)
|
||||
{
|
||||
return self::write('smtp.timeout', $value, 1, 1);
|
||||
}
|
||||
|
||||
public static function setSmtpSourceIp($value)
|
||||
{
|
||||
return self::write('smtp.sourceip', $value, 1, 1);
|
||||
}
|
||||
/* end smtp config */
|
||||
} // ConfigQuery
|
||||
|
||||
@@ -151,14 +151,14 @@
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{* {loop type="auth" name="pcc6" role="ADMIN" resource="admin.configuration.mailing-system" access="VIEW"}
|
||||
{loop type="auth" name="pcc6" role="ADMIN" resource="admin.configuration.mailing-system" access="VIEW"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/mailing_system'}">{intl l='Mailing system'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/mailing_system'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/mailingSystem'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc7" role="ADMIN" resource="admin.configuration.admin-logs" access="VIEW"}
|
||||
{* {loop type="auth" name="pcc7" role="ADMIN" resource="admin.configuration.admin-logs" access="VIEW"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/admin_logs'}">{intl l='Administration logs'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/admin_logs'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
|
||||
@@ -24,68 +24,98 @@
|
||||
|
||||
<div class="title title-without-tabs">{intl l="Configuration variables"}</div>
|
||||
|
||||
<form action="" method="">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="" class="label-control">{intl l="SMTP Server"}</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="" placeholder="{intl l="SMTP Server"}">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default btn-primary"><span class="glyphicon glyphicon-remove"></span></button>
|
||||
</span>
|
||||
{form name="thelia.admin.mailing-system.update"}
|
||||
|
||||
<form method="POST" action="{url path="/admin/configuration/mailingSystem/save"}" {form_enctype form=$form} >
|
||||
|
||||
<div class="row inner-toolbar">
|
||||
<div class="col-md-12 inner-actions clearfix">
|
||||
<button type="submit" name="save_mode" value="stay" class="btn btn-default btn-success pull-right" title="Save">Save <span class="glyphicon glyphicon-ok"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="" class="label-control">{intl l="Port"}</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="" placeholder="{intl l="port"}">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default btn-primary"><span class="glyphicon glyphicon-remove"></span></button>
|
||||
</span>
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
{form_field form=$form field='enabled'}
|
||||
<div class="form-group">
|
||||
<label for="{$label_attr.for}" class="label-control">{intl l="Enable remote SMTP use : "}</label>
|
||||
|
||||
<input type="hidden" id="smtp_enabled" name="{$name}" value="{if $form_error}{$value}{else}{if {config key="smtp.enabled"}}1{else}0{/if}{/if}">
|
||||
|
||||
<div class="make-switch switch-small" id="enable-smtp" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input type="checkbox" id="{$label_attr.for}" {if $form_error AND $value == 1 OR !$form_error AND {config key="smtp.enabled"} == 1}checked{/if}>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
<div class="form-group">
|
||||
<label for="" class="label-control">{intl l="Username"}</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="" placeholder="{intl l="username"}">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default btn-primary"><span class="glyphicon glyphicon-remove"></span></button>
|
||||
</span>
|
||||
{form_field form=$form field='host'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="label-control">{intl l="Host :"}</label>
|
||||
<input type="text" class="form-control" id="{$label_attr.for}" name="{$name}" placeholder="{intl l="Host"}" value="{if $form_error}{$value}{else}{config key="smtp.host"}{/if}">
|
||||
</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
<div class="form-group">
|
||||
<label for="" class="label-control">{intl l="Password"}</label>
|
||||
<div class="input-group">
|
||||
<input type="password" class="form-control" name="" placeholder="{intl l="password"}">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default btn-primary"><span class="glyphicon glyphicon-remove"></span></button>
|
||||
</span>
|
||||
{form_field form=$form field='port'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="label-control">{intl l="Port :"}</label>
|
||||
<input type="text" class="form-control" id="{$label_attr.for}" name="{$name}" placeholder="{intl l="Port"}" value="{if $form_error}{$value}{else}{config key="smtp.port"}{/if}">
|
||||
</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
<div class="form-group">
|
||||
<label for="" class="label-control">{intl l="Protocol"}</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="" placeholder="{intl l="protocol"}">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default btn-primary"><span class="glyphicon glyphicon-remove"></span></button>
|
||||
</span>
|
||||
{form_field form=$form field='encryption'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="label-control">{intl l="Encryption :"}</label>
|
||||
<input type="text" class="form-control" id="{$label_attr.for}" name="{$name}" placeholder="{intl l="Encryption"}" value="{if $form_error}{$value}{else}{config key="smtp.encryption"}{/if}">
|
||||
</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
<div class="form-group">
|
||||
<label for="" class="label-control">{intl l="Active ?"}</label>
|
||||
{form_field form=$form field='username'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="label-control">{intl l="Username :"}</label>
|
||||
<input type="text" class="form-control" id="{$label_attr.for}" name="{$name}" placeholder="{intl l="Username"}" value="{if $form_error}{$value}{else}{config key="smtp.username"}{/if}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input type="checkbox" name="" id="" checked>
|
||||
{form_field form=$form field='password'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="label-control">{intl l="Password :"}</label>
|
||||
<input type="password" class="form-control" id="{$label_attr.for}" name="{$name}" value="{if $form_error}{$value}{else}{config key="smtp.password"}{/if}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='authmode'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="label-control">{intl l="Auth Mode :"}</label>
|
||||
<input type="text" class="form-control" id="{$label_attr.for}" name="{$name}" placeholder="{intl l="Auth Mode"}" value="{if $form_error}{$value}{else}{config key="smtp.authmode"}{/if}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='timeout'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="label-control">{intl l="Timeout :"}</label>
|
||||
<input type="text" class="form-control" id="{$label_attr.for}" name="{$name}" placeholder="{intl l="Timeout"}" value="{if $form_error}{$value}{else}{config key="smtp.timeout"}{/if}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='sourceip'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="label-control">{intl l="Source IP :"}</label>
|
||||
<input type="text" class="form-control" id="{$label_attr.for}" name="{$name}" placeholder="{intl l="Source IP"}" value="{if $form_error}{$value}{else}{config key="smtp.sourceip"}{/if}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
<div class="row inner-toolbar">
|
||||
<div class="col-md-12 inner-actions clearfix">
|
||||
<button type="submit" name="save_mode" value="stay" class="btn btn-default btn-success pull-right" title="Save">Save <span class="glyphicon glyphicon-ok"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
{/form}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -100,4 +130,14 @@
|
||||
{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
jQuery(function($) {
|
||||
$('#enable-smtp').on('switch-change', function (e, data) {
|
||||
$('#smtp_enabled').val(data.value ? 1 : 0);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
{/block}
|
||||
Reference in New Issue
Block a user