// fix norm correct in AdminTabsController and AdminAttributesGroupsController (PSFV-94)
This commit is contained in:
+20
-20
@@ -100,20 +100,20 @@ class AttributeGroupCore extends ObjectModel
|
||||
|
||||
public static function cleanDeadCombinations()
|
||||
{
|
||||
$attributeCombinations = Db::getInstance()->executeS('
|
||||
$attribute_combinations = Db::getInstance()->executeS('
|
||||
SELECT pac.`id_attribute`, pa.`id_product_attribute`
|
||||
FROM `'._DB_PREFIX_.'product_attribute` pa
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
|
||||
');
|
||||
$toRemove = array();
|
||||
foreach ($attributeCombinations as $attributeCombination)
|
||||
if ((int)$attributeCombination['id_attribute'] == 0)
|
||||
$toRemove[] = (int)$attributeCombination['id_product_attribute'];
|
||||
if (!empty($toRemove) AND Db::getInstance()->execute('
|
||||
$to_remove = array();
|
||||
foreach ($attribute_combinations as $attribute_combination)
|
||||
if ((int)$attribute_combination['id_attribute'] == 0)
|
||||
$to_remove[] = (int)$attribute_combination['id_product_attribute'];
|
||||
if (!empty($to_remove) && Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'product_attribute`
|
||||
WHERE `id_product_attribute`
|
||||
IN ('.implode(', ', $toRemove).')') === false)
|
||||
IN ('.implode(', ', $to_remove).')') === false)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -121,21 +121,21 @@ class AttributeGroupCore extends ObjectModel
|
||||
public function delete()
|
||||
{
|
||||
/* Select children in order to find linked combinations */
|
||||
$attributeIds = Db::getInstance()->executeS('
|
||||
$attribute_ids = Db::getInstance()->executeS('
|
||||
SELECT `id_attribute`
|
||||
FROM `'._DB_PREFIX_.'attribute`
|
||||
WHERE `id_attribute_group` = '.(int)$this->id
|
||||
);
|
||||
if ($attributeIds === false)
|
||||
if ($attribute_ids === false)
|
||||
return false;
|
||||
/* Removing attributes to the found combinations */
|
||||
$toRemove = array();
|
||||
foreach ($attributeIds as $attribute)
|
||||
$toRemove[] = (int)$attribute['id_attribute'];
|
||||
if (!empty($toRemove) && Db::getInstance()->execute('
|
||||
$to_remove = array();
|
||||
foreach ($attribute_ids as $attribute)
|
||||
$to_remove[] = (int)$attribute['id_attribute'];
|
||||
if (!empty($to_remove) && Db::getInstance()->execute('
|
||||
DELETE FROM `'._DB_PREFIX_.'product_attribute_combination`
|
||||
WHERE `id_attribute`
|
||||
IN ('.implode(', ', $toRemove).')') === false)
|
||||
IN ('.implode(', ', $to_remove).')') === false)
|
||||
return false;
|
||||
/* Remove combinations if they do not possess attributes anymore */
|
||||
if (!self::cleanDeadCombinations())
|
||||
@@ -148,7 +148,7 @@ class AttributeGroupCore extends ObjectModel
|
||||
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)$this->id) === false)
|
||||
return false;
|
||||
$return = parent::delete();
|
||||
if($return)
|
||||
if ($return)
|
||||
Module::hookExec('afterDeleteAttributeGroup', array('id_attribute_group' => $this->id));
|
||||
return $return;
|
||||
}
|
||||
@@ -262,9 +262,9 @@ class AttributeGroupCore extends ObjectModel
|
||||
|
||||
foreach ($res as $group_attribute)
|
||||
if ((int)$group_attribute['id_attribute_group'] == (int)$this->id)
|
||||
$movedGroupAttribute = $group_attribute;
|
||||
$moved_group_attribute = $group_attribute;
|
||||
|
||||
if (!isset($movedGroupAttribute) || !isset($position))
|
||||
if (!isset($moved_group_attribute) || !isset($position))
|
||||
return false;
|
||||
|
||||
// < and > statements rather than BETWEEN operator
|
||||
@@ -274,12 +274,12 @@ class AttributeGroupCore extends ObjectModel
|
||||
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
||||
WHERE `position`
|
||||
'.($way
|
||||
? '> '.(int)$movedGroupAttribute['position'].' AND `position` <= '.(int)$position
|
||||
: '< '.(int)$movedGroupAttribute['position'].' AND `position` >= '.(int)$position)
|
||||
? '> '.(int)$moved_group_attribute['position'].' AND `position` <= '.(int)$position
|
||||
: '< '.(int)$moved_group_attribute['position'].' AND `position` >= '.(int)$position)
|
||||
) && Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'attribute_group`
|
||||
SET `position` = '.(int)$position.'
|
||||
WHERE `id_attribute_group`='.(int)$movedGroupAttribute['id_attribute_group'])
|
||||
WHERE `id_attribute_group`='.(int)$moved_group_attribute['id_attribute_group'])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+5
-7
@@ -337,7 +337,7 @@ class TabCore extends ObjectModel
|
||||
static $tabAccesses = null;
|
||||
|
||||
if ($tabAccesses === null)
|
||||
$tabAccesses = Profile::getProfileAccesses(Context::getContext()->employee->id_profile);
|
||||
$tabAccesses = Profile::getProfileAccesses(Context::getContext()->employee->id_profile);
|
||||
|
||||
if (isset($tabAccesses[(int)$id_tab]['view']))
|
||||
return ($tabAccesses[(int)$id_tab]['view'] === '1');
|
||||
@@ -346,12 +346,10 @@ class TabCore extends ObjectModel
|
||||
|
||||
public static function recursiveTab($id_tab, $tabs)
|
||||
{
|
||||
$adminTab = Tab::getTab((int)Context::getContext()->language->id, $id_tab);
|
||||
$tabs[]= $adminTab;
|
||||
if ($adminTab['id_parent'] > 0)
|
||||
{
|
||||
$tabs = Tab::recursiveTab($adminTab['id_parent'], $tabs);
|
||||
}
|
||||
$admin_tab = Tab::getTab((int)Context::getContext()->language->id, $id_tab);
|
||||
$tabs[] = $admin_tab;
|
||||
if ($admin_tab['id_parent'] > 0)
|
||||
$tabs = Tab::recursiveTab($admin_tab['id_parent'], $tabs);
|
||||
return $tabs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$str_attributes_groups = '';
|
||||
foreach ($attributes_groups AS $attribute_group)
|
||||
foreach ($attributes_groups as $attribute_group)
|
||||
$str_attributes_groups .= '"'.$attribute_group['id_attribute_group'].'" : '.($attribute_group['group_type'] == 'color' ? '1' : '0' ) .', ';
|
||||
|
||||
$image = _PS_IMG_DIR_.$this->fieldImageSettings['dir'].'/'.$obj->id.'.jpg';
|
||||
@@ -387,7 +387,9 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
{
|
||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').
|
||||
' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').
|
||||
'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -435,9 +437,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
Module::hookExec('postProcessAttributeGroup',
|
||||
array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessAttributeGroup to stop saving process
|
||||
|
||||
/**
|
||||
* If it's an attribute, load object Attribute()
|
||||
*/
|
||||
// If it's an attribute, load object Attribute()
|
||||
if (Tools::getValue('id_attribute') || Tools::isSubmit('deleteattribute') || Tools::isSubmit('submitAddattribute'))
|
||||
{
|
||||
// Override var of Controller
|
||||
@@ -458,7 +458,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
else
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=5&token='.Tools::getAdminTokenLite('AdminAttributesGroups'));
|
||||
}
|
||||
else if(Tools::isSubmit('deleteattribute') && Tools::getValue('id_attribute'))
|
||||
else if (Tools::isSubmit('deleteattribute') && Tools::getValue('id_attribute'))
|
||||
{
|
||||
if (!$object->delete())
|
||||
$this->_errors[] = Tools::displayError('Failed to delete attribute.');
|
||||
@@ -485,11 +485,11 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Tools::getValue('submitDel'.$this->table))
|
||||
if (Tools::getValue('submitDel'.$this->table))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (isset($_POST[$this->table.'Box']))
|
||||
if (isset($_POST[$this->table.'Box']))
|
||||
{
|
||||
$object = new $this->className();
|
||||
if ($object->deleteSelection($_POST[$this->table.'Box']))
|
||||
|
||||
@@ -33,7 +33,7 @@ class AdminTabsControllerCore extends AdminController
|
||||
$this->table = 'tab';
|
||||
$this->className = 'Tab';
|
||||
$this->lang = true;
|
||||
|
||||
|
||||
$this->fieldImageSettings = array(
|
||||
'name' => 'icon',
|
||||
'dir' => 't'
|
||||
@@ -219,8 +219,8 @@ class AdminTabsControllerCore extends AdminController
|
||||
return;
|
||||
}
|
||||
/* PrestaShop demo mode*/
|
||||
|
||||
if (($id_tab = (int)(Tools::getValue('id_tab'))) AND ($direction = Tools::getValue('move')) AND Validate::isLoadedObject($tab = new Tab($id_tab)))
|
||||
|
||||
if (($id_tab = (int)Tools::getValue('id_tab')) && ($direction = Tools::getValue('move')) && Validate::isLoadedObject($tab = new Tab($id_tab)))
|
||||
{
|
||||
if ($tab->move($direction))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
||||
@@ -230,7 +230,8 @@ class AdminTabsControllerCore extends AdminController
|
||||
if ($this->tabAccess['edit'] !== '1')
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
else if (!Validate::isLoadedObject($object = new Tab((int)Tools::getValue($this->identifier))))
|
||||
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.').
|
||||
' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
if (!$object->updatePosition((int)Tools::getValue('way'), (int)Tools::getValue('position')))
|
||||
$this->_errors[] = Tools::displayError('Failed to update the position.');
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user