[-] BO : improved error display on admincarriers #PSCFV-5660

This commit is contained in:
DamienMetzger
2012-11-27 12:01:27 +01:00
parent 545e37a57f
commit ded3b0cd5e
+35 -31
View File
@@ -467,43 +467,47 @@ class AdminCarriersControllerCore extends AdminController
/* Object update */ /* Object update */
if (isset($id) && !empty($id)) if (isset($id) && !empty($id))
{ {
if ($this->tabAccess['edit'] === '1') try {
{ if ($this->tabAccess['edit'] === '1')
$current_carrier = new Carrier($id);
if (!Validate::isLoadedObject($current_carrier))
throw new PrestaShopException('Cannot load Carrier object');
// Duplicate current Carrier
$new_carrier = $current_carrier->duplicateObject();
if (Validate::isLoadedObject($new_carrier))
{ {
// Set flag deteled to true for historization $current_carrier = new Carrier($id);
$current_carrier->deleted = true; if (!Validate::isLoadedObject($current_carrier))
$current_carrier->update(); throw new PrestaShopException('Cannot load Carrier object');
// Fill the new carrier object // Duplicate current Carrier
$this->copyFromPost($new_carrier, $this->table); $new_carrier = $current_carrier->duplicateObject();
$new_carrier->position = $current_carrier->position; if (Validate::isLoadedObject($new_carrier))
$new_carrier->update(); {
// Set flag deteled to true for historization
$current_carrier->deleted = true;
$current_carrier->update();
$this->updateAssoShop($new_carrier->id); // Fill the new carrier object
$new_carrier->copyCarrierData((int)$current_carrier->id); $this->copyFromPost($new_carrier, $this->table);
$this->changeGroups($new_carrier->id); $new_carrier->position = $current_carrier->position;
// Call of hooks $new_carrier->update();
Hook::exec('actionCarrierUpdate', array(
'id_carrier' => (int)$current_carrier->id, $this->updateAssoShop($new_carrier->id);
'carrier' => $new_carrier $new_carrier->copyCarrierData((int)$current_carrier->id);
)); $this->changeGroups($new_carrier->id);
$this->postImage($new_carrier->id); // Call of hooks
$this->changeZones($new_carrier->id); Hook::exec('actionCarrierUpdate', array(
$new_carrier->setTaxRulesGroup((int)Tools::getValue('id_tax_rules_group')); 'id_carrier' => (int)$current_carrier->id,
Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$current_carrier->id.'&conf=4&token='.$this->token); 'carrier' => $new_carrier
));
$this->postImage($new_carrier->id);
$this->changeZones($new_carrier->id);
$new_carrier->setTaxRulesGroup((int)Tools::getValue('id_tax_rules_group'));
Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$current_carrier->id.'&conf=4&token='.$this->token);
}
else
$this->errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b>';
} }
else else
$this->errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b>'; $this->errors[] = Tools::displayError('You do not have permission to edit here.');
} catch (PrestaShopException $e) {
$this->errors[] = $e->getMessage();
} }
else
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
} }
/* Object creation */ /* Object creation */