From bbfcbb061708420729d8a26fdde25b4a3ec9f72b Mon Sep 17 00:00:00 2001 From: rMalie Date: Mon, 14 May 2012 14:56:56 +0000 Subject: [PATCH] // Cannot create customers in all / group context #PSCFV-2207 git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15282 b9a71923-0436-4b27-9f14-aed3839534dd --- .../admin/AdminCustomersController.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 65f43921d..78e7c280e 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -31,6 +31,7 @@ class AdminCustomersControllerCore extends AdminController protected $_defaultOrderBy = 'date_add'; protected $_defaultOrderWay = 'DESC'; + protected $can_add_customer = true; public function __construct() { @@ -139,6 +140,18 @@ class AdminCustomersControllerCore extends AdminController $this->shopShareDatas = Shop::SHARE_CUSTOMER; parent::__construct(); + + // Check if we can add a customer + if (Shop::isFeatureActive() && (Shop::getContext() == Shop::CONTEXT_ALL || Shop::getContext() == Shop::CONTEXT_GROUP)) + $this->can_add_customer = false; + } + + public function postProcess() + { + if (!$this->can_add_customer && $this->display) + $this->redirect_after = $this->context->link->getAdminLink('AdminCustomers'); + + parent::postProcess(); } public function initContent() @@ -150,9 +163,19 @@ class AdminCustomersControllerCore extends AdminController 'boxes' => $this->boxes, )); + if (!$this->can_add_customer && !$this->display) + $this->informations[] = $this->l('You have to select a shop if you want to create a customer'); + parent::initContent(); } + public function initToolbar() + { + parent::initToolbar(); + if (!$this->can_add_customer) + unset($this->toolbar_btn['new']); + } + public function initProcess() { parent::initProcess();