// BO refactoring
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12620 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -610,7 +610,10 @@ class AdminControllerCore extends Controller
|
|||||||
public function processSave($token)
|
public function processSave($token)
|
||||||
{
|
{
|
||||||
if ($this->id_object)
|
if ($this->id_object)
|
||||||
|
{
|
||||||
|
$this->object = $this->loadObject();
|
||||||
return $this->processUpdate($token);
|
return $this->processUpdate($token);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return $this->processAdd($token);
|
return $this->processAdd($token);
|
||||||
}
|
}
|
||||||
@@ -673,7 +676,7 @@ class AdminControllerCore extends Controller
|
|||||||
/* Checking fields validity */
|
/* Checking fields validity */
|
||||||
$this->validateRules();
|
$this->validateRules();
|
||||||
|
|
||||||
if (count($this->errors) <= 0)
|
if (empty($this->errors))
|
||||||
{
|
{
|
||||||
$id = (int)Tools::getValue($this->identifier);
|
$id = (int)Tools::getValue($this->identifier);
|
||||||
|
|
||||||
@@ -745,7 +748,7 @@ class AdminControllerCore extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->errors = array_unique($this->errors);
|
$this->errors = array_unique($this->errors);
|
||||||
if (count($this->errors) > 0)
|
if (!empty($this->errors))
|
||||||
return;
|
return;
|
||||||
if (isset($object))
|
if (isset($object))
|
||||||
return $object;
|
return $object;
|
||||||
|
|||||||
@@ -718,46 +718,49 @@ class AdminCustomersControllerCore extends AdminController
|
|||||||
parent::processDelete($token);
|
parent::processDelete($token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processSave($token)
|
public function processAdd($token)
|
||||||
{
|
{
|
||||||
// Check that the new email is not already in use
|
// Check that the new email is not already in use
|
||||||
// Case add
|
$customer_email = strval(Tools::getValue('email'));
|
||||||
if (!$this->id_object)
|
$customer = new Customer();
|
||||||
|
if (Validate::isEmail($customer_email))
|
||||||
|
$customer->getByEmail($customer_email);
|
||||||
|
if ($customer->id)
|
||||||
|
$this->errors[] = Tools::displayError('An account already exists for this e-mail address:').' '.$customer_email;
|
||||||
|
else
|
||||||
|
return parent::processAdd($token);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processUpdate($token)
|
||||||
|
{
|
||||||
|
if (Validate::isLoadedObject($this->object))
|
||||||
{
|
{
|
||||||
$customer_email = strval(Tools::getValue('email'));
|
$customer_email = strval(Tools::getValue('email'));
|
||||||
$customer = new Customer();
|
|
||||||
if (Validate::isEmail($customer_email))
|
// check if e-mail already used
|
||||||
$customer->getByEmail($customer_email);
|
if ($customer_email != $this->object->email)
|
||||||
if ($customer->id)
|
|
||||||
$this->errors[] = Tools::displayError('An account already exists for this e-mail address:').' '.$customer_email;
|
|
||||||
}
|
|
||||||
// Case update
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$object = new $this->className($this->id_object);
|
|
||||||
if (Validate::isLoadedObject($object))
|
|
||||||
{
|
{
|
||||||
$customer_email = strval(Tools::getValue('email'));
|
$customer = new Customer();
|
||||||
|
$customer->getByEmail($customer_email);
|
||||||
// check if e-mail already used
|
if ($customer->id)
|
||||||
if ($customer_email != $object->email)
|
$this->errors[] = Tools::displayError('An account already exists for this e-mail address:').' '.$customer_email;
|
||||||
{
|
|
||||||
$customer = new Customer();
|
|
||||||
$customer->getByEmail($customer_email);
|
|
||||||
if ($customer->id)
|
|
||||||
$this->errors[] = Tools::displayError('An account already exists for this e-mail address:').' '.$customer_email;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
$this->errors[] = Tools::displayError('An error occurred while loading object.').'
|
|
||||||
<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return parent::processUpdate($token);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->errors[] = Tools::displayError('An error occurred while loading object.').'
|
||||||
|
<b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processSave($token)
|
||||||
|
{
|
||||||
// Check that default group is selected
|
// Check that default group is selected
|
||||||
if (!is_array(Tools::getValue('groupBox')) || !in_array(Tools::getValue('id_default_group'), Tools::getValue('groupBox')))
|
if (!is_array(Tools::getValue('groupBox')) || !in_array(Tools::getValue('id_default_group'), Tools::getValue('groupBox')))
|
||||||
$this->errors[] = Tools::displayError('Default customer group must be selected in group box.');
|
$this->errors[] = Tools::displayError('Default customer group must be selected in group box.');
|
||||||
|
|
||||||
parent::processSave($token);
|
return parent::processSave($token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterDelete($object, $oldId)
|
public function afterDelete($object, $oldId)
|
||||||
|
|||||||
Reference in New Issue
Block a user