// Fix shop association on new object + some strict standard for Franck

This commit is contained in:
rMalie
2011-07-11 13:18:17 +00:00
parent 55007357e1
commit 923269001b
5 changed files with 23 additions and 22 deletions
+16 -15
View File
@@ -717,6 +717,7 @@ abstract class AdminTabCore
{
$parent_id = (int)(Tools::getValue('id_parent', 1));
$this->afterAdd($object);
$this->updateAssoShop($object->id);
// Save and stay on same form
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
Tools::redirectAdmin($currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&update'.$this->table.'&token='.$token);
@@ -868,21 +869,21 @@ abstract class AdminTabCore
protected function updateAssoShop($id_object = false)
{
$assos = array();
foreach ($_POST AS $k => $row)
{
if (!preg_match('/^checkBoxShopAsso_'.$this->table.'_([0-9]+)?_([0-9]+)$/Ui', $k, $res))
continue;
$id_asso_object = (!empty($res[1]) ? $res[1] : $id_object);
$assos[] = array('id_object' => (int)$id_asso_object, 'id_shop' => (int)$res[2]);
}
if (!sizeof($assos))
return;
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.$this->table.'_shop'.($id_object ? ' WHERE `'.$this->identifier.'`='.(int)$id_object : ''));
foreach ($assos AS $asso)
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.$this->table.'_shop(`'.pSQL($this->identifier).'`, id_shop)
VALUES('.(int)$asso['id_object'].', '.(int)$asso['id_shop'].')');
$assos = array();
foreach ($_POST AS $k => $row)
{
if (!preg_match('/^checkBoxShopAsso_'.$this->table.'_([0-9]+)?_([0-9]+)$/Ui', $k, $res))
continue;
$id_asso_object = (!empty($res[1]) ? $res[1] : $id_object);
$assos[] = array('id_object' => (int)$id_asso_object, 'id_shop' => (int)$res[2]);
}
if (!sizeof($assos))
return;
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.$this->table.'_shop'.($id_object ? ' WHERE `'.$this->identifier.'`='.(int)$id_object : ''));
foreach ($assos AS $asso)
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.$this->table.'_shop(`'.pSQL($this->identifier).'`, id_shop)
VALUES('.(int)$asso['id_object'].', '.(int)$asso['id_shop'].')');
}
protected function updateOptions($token)