// fix norm correct in AdminTabsController and AdminAttributesGroupsController (PSFV-94)
This commit is contained in:
1 parent
8e328c8393
commit
8f0399b4e3
4 files changed
+38
-39
No files matched your search
+20
-20
@@ -100,20 +100,20 @@ class AttributeGroupCore extends ObjectModel
|
|||||||
|
|
||||||
public static function cleanDeadCombinations()
|
public static function cleanDeadCombinations()
|
||||||
{
|
{
|
||||||
$attributeCombinations = Db::getInstance()->executeS('
|
$attribute_combinations = Db::getInstance()->executeS('
|
||||||
SELECT pac.`id_attribute`, pa.`id_product_attribute`
|
SELECT pac.`id_attribute`, pa.`id_product_attribute`
|
||||||
FROM `'._DB_PREFIX_.'product_attribute` pa
|
FROM `'._DB_PREFIX_.'product_attribute` pa
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||||
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
|
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
|
||||||
');
|
');
|
||||||
$toRemove = array();
|
$to_remove = array();
|
||||||
foreach ($attributeCombinations as $attributeCombination)
|
foreach ($attribute_combinations as $attribute_combination)
|
||||||
if ((int)$attributeCombination['id_attribute'] == 0)
|
if ((int)$attribute_combination['id_attribute'] == 0)
|
||||||
$toRemove[] = (int)$attributeCombination['id_product_attribute'];
|
$to_remove[] = (int)$attribute_combination['id_product_attribute'];
|
||||||
if (!empty($toRemove) AND Db::getInstance()->execute('
|
if (!empty($to_remove) && Db::getInstance()->execute('
|
||||||
DELETE FROM `'._DB_PREFIX_.'product_attribute`
|
DELETE FROM `'._DB_PREFIX_.'product_attribute`
|
||||||
WHERE `id_product_attribute`
|
WHERE `id_product_attribute`
|
||||||
IN ('.implode(', ', $toRemove).')') === false)
|
IN ('.implode(', ', $to_remove).')') === false)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -121,21 +121,21 @@ class AttributeGroupCore extends ObjectModel
|
|||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
/* Select children in order to find linked combinations */
|
/* Select children in order to find linked combinations */
|
||||||
$attributeIds = Db::getInstance()->executeS('
|
$attribute_ids = Db::getInstance()->executeS('
|
||||||
SELECT `id_attribute`
|
SELECT `id_attribute`
|
||||||
FROM `'._DB_PREFIX_.'attribute`
|
FROM `'._DB_PREFIX_.'attribute`
|
||||||
WHERE `id_attribute_group` = '.(int)$this->id
|
WHERE `id_attribute_group` = '.(int)$this->id
|
||||||
);
|
);
|
||||||
if ($attributeIds === false)
|
if ($attribute_ids === false)
|
||||||
return false;
|
return false;
|
||||||
/* Removing attributes to the found combinations */
|
/* Removing attributes to the found combinations */
|
||||||
$toRemove = array();
|
$to_remove = array();
|
||||||
foreach ($attributeIds as $attribute)
|
foreach ($attribute_ids as $attribute)
|
||||||
$toRemove[] = (int)$attribute['id_attribute'];
|
$to_remove[] = (int)$attribute['id_attribute'];
|
||||||
if (!empty($toRemove) && Db::getInstance()->execute('
|
if (!empty($to_remove) && Db::getInstance()->execute('
|
||||||
DELETE FROM `'._DB_PREFIX_.'product_attribute_combination`
|
DELETE FROM `'._DB_PREFIX_.'product_attribute_combination`
|
||||||
WHERE `id_attribute`
|
WHERE `id_attribute`
|
||||||
IN ('.implode(', ', $toRemove).')') === false)
|
IN ('.implode(', ', $to_remove).')') === false)
|
||||||
return false;
|
return false;
|
||||||
/* Remove combinations if they do not possess attributes anymore */
|
/* Remove combinations if they do not possess attributes anymore */
|
||||||
if (!self::cleanDeadCombinations())
|
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)
|
Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)$this->id) === false)
|
||||||
return false;
|
return false;
|
||||||
$return = parent::delete();
|
$return = parent::delete();
|
||||||
if($return)
|
if ($return)
|
||||||
Module::hookExec('afterDeleteAttributeGroup', array('id_attribute_group' => $this->id));
|
Module::hookExec('afterDeleteAttributeGroup', array('id_attribute_group' => $this->id));
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
@@ -262,9 +262,9 @@ class AttributeGroupCore extends ObjectModel
|
|||||||
|
|
||||||
foreach ($res as $group_attribute)
|
foreach ($res as $group_attribute)
|
||||||
if ((int)$group_attribute['id_attribute_group'] == (int)$this->id)
|
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;
|
return false;
|
||||||
|
|
||||||
// < and > statements rather than BETWEEN operator
|
// < and > statements rather than BETWEEN operator
|
||||||
@@ -274,12 +274,12 @@ class AttributeGroupCore extends ObjectModel
|
|||||||
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
||||||
WHERE `position`
|
WHERE `position`
|
||||||
'.($way
|
'.($way
|
||||||
? '> '.(int)$movedGroupAttribute['position'].' AND `position` <= '.(int)$position
|
? '> '.(int)$moved_group_attribute['position'].' AND `position` <= '.(int)$position
|
||||||
: '< '.(int)$movedGroupAttribute['position'].' AND `position` >= '.(int)$position)
|
: '< '.(int)$moved_group_attribute['position'].' AND `position` >= '.(int)$position)
|
||||||
) && Db::getInstance()->execute('
|
) && Db::getInstance()->execute('
|
||||||
UPDATE `'._DB_PREFIX_.'attribute_group`
|
UPDATE `'._DB_PREFIX_.'attribute_group`
|
||||||
SET `position` = '.(int)$position.'
|
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;
|
static $tabAccesses = null;
|
||||||
|
|
||||||
if ($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']))
|
if (isset($tabAccesses[(int)$id_tab]['view']))
|
||||||
return ($tabAccesses[(int)$id_tab]['view'] === '1');
|
return ($tabAccesses[(int)$id_tab]['view'] === '1');
|
||||||
@@ -346,12 +346,10 @@ class TabCore extends ObjectModel
|
|||||||
|
|
||||||
public static function recursiveTab($id_tab, $tabs)
|
public static function recursiveTab($id_tab, $tabs)
|
||||||
{
|
{
|
||||||
$adminTab = Tab::getTab((int)Context::getContext()->language->id, $id_tab);
|
$admin_tab = Tab::getTab((int)Context::getContext()->language->id, $id_tab);
|
||||||
$tabs[]= $adminTab;
|
$tabs[] = $admin_tab;
|
||||||
if ($adminTab['id_parent'] > 0)
|
if ($admin_tab['id_parent'] > 0)
|
||||||
{
|
$tabs = Tab::recursiveTab($admin_tab['id_parent'], $tabs);
|
||||||
$tabs = Tab::recursiveTab($adminTab['id_parent'], $tabs);
|
|
||||||
}
|
|
||||||
return $tabs;
|
return $tabs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -352,7 +352,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$str_attributes_groups = '';
|
$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' ) .', ';
|
$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';
|
$image = _PS_IMG_DIR_.$this->fieldImageSettings['dir'].'/'.$obj->id.'.jpg';
|
||||||
@@ -387,7 +387,9 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
if (!Combination::isFeatureActive())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,9 +437,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
Module::hookExec('postProcessAttributeGroup',
|
Module::hookExec('postProcessAttributeGroup',
|
||||||
array('errors' => &$this->_errors)); // send _errors as reference to allow postProcessAttributeGroup to stop saving process
|
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'))
|
if (Tools::getValue('id_attribute') || Tools::isSubmit('deleteattribute') || Tools::isSubmit('submitAddattribute'))
|
||||||
{
|
{
|
||||||
// Override var of Controller
|
// Override var of Controller
|
||||||
@@ -458,7 +458,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=5&token='.Tools::getAdminTokenLite('AdminAttributesGroups'));
|
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())
|
if (!$object->delete())
|
||||||
$this->_errors[] = Tools::displayError('Failed to delete attribute.');
|
$this->_errors[] = Tools::displayError('Failed to delete attribute.');
|
||||||
@@ -485,11 +485,11 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(Tools::getValue('submitDel'.$this->table))
|
if (Tools::getValue('submitDel'.$this->table))
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['delete'] === '1')
|
if ($this->tabAccess['delete'] === '1')
|
||||||
{
|
{
|
||||||
if (isset($_POST[$this->table.'Box']))
|
if (isset($_POST[$this->table.'Box']))
|
||||||
{
|
{
|
||||||
$object = new $this->className();
|
$object = new $this->className();
|
||||||
if ($object->deleteSelection($_POST[$this->table.'Box']))
|
if ($object->deleteSelection($_POST[$this->table.'Box']))
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class AdminTabsControllerCore extends AdminController
|
|||||||
$this->table = 'tab';
|
$this->table = 'tab';
|
||||||
$this->className = 'Tab';
|
$this->className = 'Tab';
|
||||||
$this->lang = true;
|
$this->lang = true;
|
||||||
|
|
||||||
$this->fieldImageSettings = array(
|
$this->fieldImageSettings = array(
|
||||||
'name' => 'icon',
|
'name' => 'icon',
|
||||||
'dir' => 't'
|
'dir' => 't'
|
||||||
@@ -219,8 +219,8 @@ class AdminTabsControllerCore extends AdminController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* PrestaShop demo mode*/
|
/* 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))
|
if ($tab->move($direction))
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
||||||
@@ -230,7 +230,8 @@ class AdminTabsControllerCore extends AdminController
|
|||||||
if ($this->tabAccess['edit'] !== '1')
|
if ($this->tabAccess['edit'] !== '1')
|
||||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||||
else if (!Validate::isLoadedObject($object = new Tab((int)Tools::getValue($this->identifier))))
|
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')))
|
if (!$object->updatePosition((int)Tools::getValue('way'), (int)Tools::getValue('position')))
|
||||||
$this->_errors[] = Tools::displayError('Failed to update the position.');
|
$this->_errors[] = Tools::displayError('Failed to update the position.');
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in new issue
Block a user