From e68c124218863034db1dbdb93d58ffbf5de46a17 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Mon, 16 Sep 2013 11:40:29 +0200 Subject: [PATCH] [-] FO : replace ucfirst by ucwords for the customer firstname #PSCFV-10396 --- classes/Tools.php | 7 +++++++ controllers/front/AuthController.php | 1 + controllers/front/IdentityController.php | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/classes/Tools.php b/classes/Tools.php index 31adb3bbf..bc0721a84 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1260,6 +1260,13 @@ class ToolsCore return Tools::strtoupper(Tools::substr($str, 0, 1)).Tools::substr($str, 1); } + public static function ucwords($str) + { + if (function_exists('mb_convert_case')) + return mb_convert_case($str, MB_CASE_TITLE); + return ucwords(strtolower($str)); + } + public static function orderbyPrice(&$array, $order_way) { foreach ($array as &$row) diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 79b09cce6..505630aaa 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -425,6 +425,7 @@ class AuthControllerCore extends FrontController if (Tools::isSubmit('newsletter')) $this->processCustomerNewsletter($customer); + $customer->firstname = Tools::ucwords($customer->firstname); $customer->birthday = (empty($_POST['years']) ? '' : (int)$_POST['years'].'-'.(int)$_POST['months'].'-'.(int)$_POST['days']); if (!Validate::isBirthDate($customer->birthday)) $this->errors[] = Tools::displayError('Invalid date of birth.'); diff --git a/controllers/front/IdentityController.php b/controllers/front/IdentityController.php index 7f0eb50b4..109cf3bc8 100644 --- a/controllers/front/IdentityController.php +++ b/controllers/front/IdentityController.php @@ -79,7 +79,7 @@ class IdentityControllerCore extends FrontController if (!count($this->errors)) { $this->customer->id_default_group = (int)$prev_id_default_group; - $this->customer->firstname = Tools::ucfirst(Tools::strtolower($this->customer->firstname)); + $this->customer->firstname = Tools::ucwords($this->customer->firstname); if (!isset($_POST['newsletter'])) $this->customer->newsletter = 0;