[-] BO : BugFix : Admin suppliers errors message (add) & Admin attributes add / update fix

This commit is contained in:
François Gaillard
2011-12-27 10:40:32 +00:00
parent e8066f4d80
commit 93df3eee13
3 changed files with 26 additions and 8 deletions
+8 -6
View File
@@ -580,10 +580,10 @@ class AdminControllerCore extends Controller
*/ */
public function processSave($token) public function processSave($token)
{ {
if ((!$this->id_object) || (!Tools::getValue('submitAdd'.$this->table))) if ($this->id_object)
return $this->processAdd($token);
else
return $this->processUpdate($token); return $this->processUpdate($token);
else
return $this->processAdd($token);
} }
/** /**
@@ -596,12 +596,13 @@ class AdminControllerCore extends Controller
/* Checking fields validity */ /* Checking fields validity */
$this->validateRules(); $this->validateRules();
if (!count($this->_errors)) if (count($this->_errors) <= 0)
{ {
$object = new $this->className(); $object = new $this->className();
$this->copyFromPost($object, $this->table); $this->copyFromPost($object, $this->table);
$this->beforeAdd($object); $this->beforeAdd($object);
if (!$object->add()) if (method_exists($object, 'add') && !$object->add())
{ {
$this->_errors[] = Tools::displayError('An error occurred while creating object.'). $this->_errors[] = Tools::displayError('An error occurred while creating object.').
' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>'; ' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
@@ -625,8 +626,9 @@ class AdminControllerCore extends Controller
} }
$this->_errors = array_unique($this->_errors); $this->_errors = array_unique($this->_errors);
if (count($this->_errors) > 0) if (count($this->_errors) > 0) {
return; return;
}
return $object; return $object;
} }
@@ -435,6 +435,22 @@ class AdminAttributesGroupsControllerCore extends AdminController
} }
} }
/**
* Call the right method for creating or updating object
*
* @param $token
* @return mixed
*/
public function processSave()
{
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
if ((int)Tools::getValue('id_attribute') <= 0)
return $this->processAdd($token);
else
return $this->processUpdate($token);
}
public function postProcess() public function postProcess()
{ {
if (!Combination::isFeatureActive()) if (!Combination::isFeatureActive())
@@ -486,7 +502,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
$_POST['position'] = DB::getInstance()->getValue($sql); $_POST['position'] = DB::getInstance()->getValue($sql);
} }
$_POST['id_parent'] = 0; $_POST['id_parent'] = 0;
parent::postProcess(); $this->processSave();
} }
} }
else else
@@ -327,7 +327,7 @@ class AdminSuppliersControllerCore extends AdminController
if (Tools::isSubmit('submitAdd'.$this->table)) if (Tools::isSubmit('submitAdd'.$this->table))
{ {
if (!($obj = $this->loadObject(true))) if (Tools::isSubmit('id_supplier') && !($obj = $this->loadObject(true)))
return; return;
// updates/creates address if it does not exist // updates/creates address if it does not exist