From cc4a22b1ede39ed53c76144a95add80bf4587ebd Mon Sep 17 00:00:00 2001 From: Benjamin Perche Date: Wed, 16 Jul 2014 11:04:20 +0200 Subject: [PATCH] =?UTF-8?q?Change=20error=20message=20=09modifi=C3=A9:=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20core/lib/Thelia/Controller/BaseControll?= =?UTF-8?q?er.php=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Th?= =?UTF-8?q?elia/Form/FirewallForm.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/lib/Thelia/Controller/BaseController.php | 5 ++++- core/lib/Thelia/Form/FirewallForm.php | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index d396fc8ca..424469876 100644 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -204,7 +204,10 @@ abstract class BaseController extends ContainerAware if ($aBaseForm instanceof FirewallForm && !$aBaseForm->isFirewallOk()) { throw new FormValidationException( $this->getTranslator()->trans( - "You have too much sent this form. Please wait before trying again." + "You've submitted this form too many times. Further submissions will be ignored during %time", + [ + "%time" => $aBaseForm->getWaitingTime(), + ] ) ); } diff --git a/core/lib/Thelia/Form/FirewallForm.php b/core/lib/Thelia/Form/FirewallForm.php index dc37d014f..1c793f21e 100644 --- a/core/lib/Thelia/Form/FirewallForm.php +++ b/core/lib/Thelia/Form/FirewallForm.php @@ -11,6 +11,7 @@ /*************************************************************************************/ namespace Thelia\Form; use Symfony\Component\HttpFoundation\Request; +use Thelia\Core\Translation\Translator; use Thelia\Model\ConfigQuery; use Thelia\Model\FormFirewall; use Thelia\Model\FormFirewallQuery; @@ -35,7 +36,7 @@ abstract class FirewallForm extends BaseForm { $this->firewallInstance = FormFirewallQuery::create() ->filterByFormName($this->getName()) - ->filterByIpAddress($this->request->getClientIp()) + ->filterByIpAddress($request->getClientIp()) ->findOne() ; parent::__construct($request, $type, $data, $options); @@ -103,4 +104,18 @@ abstract class FirewallForm extends BaseForm { return ConfigQuery::read("form_firewall_active", true); } + + public function getWaitingTime() + { + $time = $this->getConfigTime(); + $name = "hour(s)"; + + if ($time < 1) { + $time *= 60; + $name = "minute(s)"; + } + $time = round($time); + + return $time . " " . Translator::getInstance()->trans($name); + } }