// postprocess refactoring

This commit is contained in:
tDidierjean committed 2011-11-30 17:16:28 +00:00
1 parent 43a15145b9
commit e98ea15ec7
2 files changed
+9 -21

No files matched your search

@@ -276,9 +276,7 @@ class AdminAddressesControllerCore extends AdminController
return parent::renderForm(); return parent::renderForm();
} }
public function postProcess() public function processSave($token)
{
if ($this->action == 'save')
{ {
// Transform e-mail in id_customer for parent processing // Transform e-mail in id_customer for parent processing
if (Validate::isEmail(Tools::getValue('email'))) if (Validate::isEmail(Tools::getValue('email')))
@@ -341,9 +339,9 @@ class AdminAddressesControllerCore extends AdminController
if (isset($_POST['address_type'])) if (isset($_POST['address_type']))
$_POST['id_address'] = ''; $_POST['id_address'] = '';
} }
}
if (!sizeof($this->_errors)) if (empty($this->_errors))
parent::postProcess(); parent::processSave($token);
/* Reassignation of the order's new (invoice or delivery) address */ /* Reassignation of the order's new (invoice or delivery) address */
$address_type = ((int)(Tools::getValue('address_type')) == 2 ? 'invoice' : ((int)(Tools::getValue('address_type')) == 1 ? 'delivery' : '')); $address_type = ((int)(Tools::getValue('address_type')) == 2 ? 'invoice' : ((int)(Tools::getValue('address_type')) == 1 ? 'delivery' : ''));
+5 -15
View File
@@ -51,7 +51,7 @@ class AdminGroupsController extends AdminController
$this->fieldsDisplay = array( $this->fieldsDisplay = array(
'id_group' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'id_group' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'name' => array('title' => $this->l('Name'), 'width' => 80, 'filter_key' => 'b!name'), 'name' => array('title' => $this->l('Name'), 'width' => 'auto', 'filter_key' => 'b!name'),
'reduction' => array('title' => $this->l('Discount'), 'width' => 50, 'align' => 'right'), 'reduction' => array('title' => $this->l('Discount'), 'width' => 50, 'align' => 'right'),
'nb' => array('title' => $this->l('Members'), 'width' => 25, 'align' => 'center'), 'nb' => array('title' => $this->l('Members'), 'width' => 25, 'align' => 'center'),
'date_add' => array('title' => $this->l('Creation date'), 'width' => 60, 'type' => 'date', 'align' => 'right')); 'date_add' => array('title' => $this->l('Creation date'), 'width' => 60, 'type' => 'date', 'align' => 'right'));
@@ -76,14 +76,14 @@ class AdminGroupsController extends AdminController
$this->tpl_view_vars = array( $this->tpl_view_vars = array(
'group' => $group, 'group' => $group,
'customerList' => $this->initCustomersList($group), 'customerList' => $this->renderCustomersList($group),
'categorieReductions' => $this->formatCategoryDiscountList($group->id) 'categorieReductions' => $this->formatCategoryDiscountList($group->id)
); );
return parent::renderView(); return parent::renderView();
} }
protected function initCustomersList($group) protected function renderCustomersList($group)
{ {
$genders = array(0 => $this->l('?')); $genders = array(0 => $this->l('?'));
foreach (Gender::getGenders() as $gender) foreach (Gender::getGenders() as $gender)
@@ -275,11 +275,7 @@ class AdminGroupsController extends AdminController
return array('unauth_modules' => $unauth_modules, 'auth_modules' => $auth_modules); return array('unauth_modules' => $unauth_modules, 'auth_modules' => $auth_modules);
} }
public function postProcess() public function processSave($token)
{
if (Tools::isSubmit('submitAddgroup'))
{
if ($this->tabAccess['add'] === '1')
{ {
if (!$this->validateDiscount(Tools::getValue('reduction'))) if (!$this->validateDiscount(Tools::getValue('reduction')))
$this->_errors[] = Tools::displayError('Discount value is incorrect (must be a percentage)'); $this->_errors[] = Tools::displayError('Discount value is incorrect (must be a percentage)');
@@ -287,15 +283,9 @@ class AdminGroupsController extends AdminController
{ {
$this->updateCategoryReduction(); $this->updateCategoryReduction();
$this->updateRestrictions(); $this->updateRestrictions();
parent::postProcess(); parent::processSave($token);
} }
} }
else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
else
parent::postProcess();
}
protected function validateDiscount($reduction) protected function validateDiscount($reduction)
{ {