// Fix normalize and replace $_GET and $_POST by Tools::isSubmit() in CMS's controllers
This commit is contained in:
1 parent
fc9a29dd26
commit
247ab71069
3 files changed
+48
-27
No files matched your search
@@ -28,7 +28,7 @@
|
|||||||
class AdminCmsCategoriesControllerCore extends AdminController
|
class AdminCmsCategoriesControllerCore extends AdminController
|
||||||
{
|
{
|
||||||
/** @var object CMSCategory() instance for navigation*/
|
/** @var object CMSCategory() instance for navigation*/
|
||||||
protected $_CMSCategory;
|
protected $cms_category;
|
||||||
|
|
||||||
protected $position_identifier = 'id_cms_category_to_move';
|
protected $position_identifier = 'id_cms_category_to_move';
|
||||||
|
|
||||||
@@ -47,10 +47,13 @@ class AdminCmsCategoriesControllerCore extends AdminController
|
|||||||
'name' => array('title' => $this->l('Name'), 'width' => 'auto', 'callback' => 'hideCMSCategoryPosition', 'callback_object' => 'CMSCategory'),
|
'name' => array('title' => $this->l('Name'), 'width' => 'auto', 'callback' => 'hideCMSCategoryPosition', 'callback_object' => 'CMSCategory'),
|
||||||
'description' => array('title' => $this->l('Description'), 'width' => 500, 'maxlength' => 90, 'orderby' => false),
|
'description' => array('title' => $this->l('Description'), 'width' => 500, 'maxlength' => 90, 'orderby' => false),
|
||||||
'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'position', 'align' => 'center', 'position' => 'position'),
|
'position' => array('title' => $this->l('Position'), 'width' => 40,'filter_key' => 'position', 'align' => 'center', 'position' => 'position'),
|
||||||
'active' => array('title' => $this->l('Displayed'), 'width' => 25, 'active' => 'status', 'align' => 'center', 'type' => 'bool', 'orderby' => false));
|
'active' => array(
|
||||||
|
'title' => $this->l('Displayed'), 'width' => 25, 'active' => 'status',
|
||||||
|
'align' => 'center','type' => 'bool', 'orderby' => false
|
||||||
|
));
|
||||||
|
|
||||||
$this->_CMSCategory = AdminCmsContentController::getCurrentCMSCategory();
|
$this->cms_category = AdminCmsContentController::getCurrentCMSCategory();
|
||||||
$this->_filter = 'AND `id_parent` = '.(int)($this->_CMSCategory->id);
|
$this->_filter = 'AND `id_parent` = '.(int)$this->cms_category->id;
|
||||||
$this->_select = 'position ';
|
$this->_select = 'position ';
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
@@ -81,9 +84,9 @@ class AdminCmsCategoriesControllerCore extends AdminController
|
|||||||
if (Tools::isSubmit('submitAdd'.$this->table))
|
if (Tools::isSubmit('submitAdd'.$this->table))
|
||||||
{
|
{
|
||||||
$this->action = 'save';
|
$this->action = 'save';
|
||||||
if ($id_cms_category = (int)(Tools::getValue('id_cms_category')))
|
if ($id_cms_category = (int)Tools::getValue('id_cms_category'))
|
||||||
{
|
{
|
||||||
if (!CMSCategory::checkBeforeMove($id_cms_category, (int)(Tools::getValue('id_parent'))))
|
if (!CMSCategory::checkBeforeMove($id_cms_category, (int)Tools::getValue('id_parent')))
|
||||||
{
|
{
|
||||||
$this->errors[] = Tools::displayError('CMS Category cannot be moved here');
|
$this->errors[] = Tools::displayError('CMS Category cannot be moved here');
|
||||||
return false;
|
return false;
|
||||||
@@ -91,25 +94,29 @@ class AdminCmsCategoriesControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Change object statuts (active, inactive) */
|
/* Change object statuts (active, inactive) */
|
||||||
elseif (isset($_GET['statuscms_category']) && Tools::getValue($this->identifier))
|
elseif (Tools::isSubmit('statuscms_category') && Tools::getValue($this->identifier))
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['edit'] === '1')
|
if ($this->tabAccess['edit'] === '1')
|
||||||
{
|
{
|
||||||
if (Validate::isLoadedObject($object = $this->loadObject()))
|
if (Validate::isLoadedObject($object = $this->loadObject()))
|
||||||
{
|
{
|
||||||
if ($object->toggleStatus())
|
if ($object->toggleStatus())
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=5'.((int)$object->id_parent ? '&id_cms_category='.(int)$object->id_parent : '').'&token='.Tools::getValue('token'));
|
{
|
||||||
|
$identifier = ((int)$object->id_parent ? '&id_cms_category='.(int)$object->id_parent : '');
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&conf=5'.$identifier.'&token='.Tools::getValue('token'));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
$this->errors[] = Tools::displayError('An error occurred while updating status.');
|
$this->errors[] = Tools::displayError('An error occurred while updating status.');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$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)');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
|
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||||
}
|
}
|
||||||
/* Delete object */
|
/* Delete object */
|
||||||
elseif (isset($_GET['delete'.$this->table]))
|
elseif (Tools::isSubmit('delete'.$this->table))
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['delete'] === '1')
|
if ($this->tabAccess['delete'] === '1')
|
||||||
{
|
{
|
||||||
@@ -117,7 +124,8 @@ class AdminCmsCategoriesControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
// check if request at least one object with noZeroObject
|
// check if request at least one object with noZeroObject
|
||||||
if (isset($object->noZeroObject) && count($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1)
|
if (isset($object->noZeroObject) && count($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1)
|
||||||
$this->errors[] = Tools::displayError('You need at least one object.').' <b>'.$this->table.'</b><br />'.Tools::displayError('You cannot delete all of the items.');
|
$this->errors[] = Tools::displayError('You need at least one object.')
|
||||||
|
.' <b>'.$this->table.'</b><br />'.Tools::displayError('You cannot delete all of the items.');
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($this->deleted)
|
if ($this->deleted)
|
||||||
@@ -132,36 +140,49 @@ class AdminCmsCategoriesControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->errors[] = Tools::displayError('An error occurred while deleting object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
$this->errors[] = Tools::displayError('An error occurred while deleting object.')
|
||||||
|
.' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->errors[] = Tools::displayError('You do not have permission to delete here.');
|
$this->errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||||
}
|
}
|
||||||
elseif (isset($_GET['position']))
|
elseif (Tools::isSubmit('position'))
|
||||||
{
|
{
|
||||||
|
$object = new CMSCategory((int)Tools::getValue($this->identifier, Tools::getValue('id_cms_category_to_move', 1)));
|
||||||
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.');
|
||||||
elseif (!Validate::isLoadedObject($object = new CMSCategory((int)(Tools::getValue($this->identifier, Tools::getValue('id_cms_category_to_move', 1))))))
|
elseif (!Validate::isLoadedObject($object))
|
||||||
$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.')
|
||||||
elseif (!$object->updatePosition((int)(Tools::getValue('way')), (int)(Tools::getValue('position'))))
|
.' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||||
|
elseif (!$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
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.(($id_category = (int)(Tools::getValue($this->identifier, Tools::getValue('id_cms_category_parent', 1)))) ? ('&'.$this->identifier.'='.$id_category) : '').'&token='.Tools::getAdminTokenLite('AdminCmsContent'));
|
{
|
||||||
|
$identifier = '';
|
||||||
|
if ($id_category = (int)Tools::getValue($this->identifier, Tools::getValue('id_cms_category_parent', 1)))
|
||||||
|
$identifier = '&'.$this->identifier.'='.$id_category;
|
||||||
|
$token = Tools::getAdminTokenLite('AdminCmsContent');
|
||||||
|
|
||||||
|
Tools::redirectAdmin(
|
||||||
|
self::$currentIndex.'&'.$this->table.'Orderby=position&'.$this->table.'Orderway=asc&conf=5'.$identifier.'&token='.$token
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Delete multiple objects */
|
/* Delete multiple objects */
|
||||||
elseif (Tools::getValue('submitDel'.$this->table))
|
elseif (Tools::getValue('submitDel'.$this->table))
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['delete'] === '1')
|
if ($this->tabAccess['delete'] === '1')
|
||||||
{
|
{
|
||||||
if (isset($_POST[$this->table.'Box']))
|
if (Tools::isSubmit($this->table.'Box'))
|
||||||
{
|
{
|
||||||
$cms_category = new CMSCategory();
|
$cms_category = new CMSCategory();
|
||||||
$result = true;
|
$result = true;
|
||||||
$result = $cms_category->deleteSelection(Tools::getValue($this->table.'Box'));
|
$result = $cms_category->deleteSelection(Tools::getValue($this->table.'Box'));
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$cms_category->cleanPositions((int)(Tools::getValue('id_cms_category')));
|
$cms_category->cleanPositions((int)Tools::getValue('id_cms_category'));
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=2&token='.Tools::getAdminTokenLite('AdminCmsContent').'&id_category='.(int)(Tools::getValue('id_cms_category')));
|
$token = Tools::getAdminTokenLite('AdminCmsContent');
|
||||||
|
Tools::redirectAdmin(self::$currentIndex.'&conf=2&token='.$token.'&id_category='.(int)Tools::getValue('id_cms_category'));
|
||||||
}
|
}
|
||||||
$this->errors[] = Tools::displayError('An error occurred while deleting selection.');
|
$this->errors[] = Tools::displayError('An error occurred while deleting selection.');
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class AdminCmsContentControllerCore extends AdminController
|
|||||||
if (Tools::isSubmit('submitDelcms')
|
if (Tools::isSubmit('submitDelcms')
|
||||||
|| Tools::isSubmit('previewSubmitAddcmsAndPreview')
|
|| Tools::isSubmit('previewSubmitAddcmsAndPreview')
|
||||||
|| Tools::isSubmit('submitAddcms')
|
|| Tools::isSubmit('submitAddcms')
|
||||||
|| isset($_GET['deletecms'])
|
|| Tools::isSubmit('deletecms')
|
||||||
|| Tools::isSubmit('viewcms')
|
|| Tools::isSubmit('viewcms')
|
||||||
|| (Tools::isSubmit('statuscms') && Tools::isSubmit('id_cms'))
|
|| (Tools::isSubmit('statuscms') && Tools::isSubmit('id_cms'))
|
||||||
|| (Tools::isSubmit('way') && Tools::isSubmit('id_cms')) && (Tools::isSubmit('position')))
|
|| (Tools::isSubmit('way') && Tools::isSubmit('id_cms')) && (Tools::isSubmit('position')))
|
||||||
@@ -120,18 +120,18 @@ class AdminCmsContentControllerCore extends AdminController
|
|||||||
else if (Tools::isSubmit('submitDelcms_category')
|
else if (Tools::isSubmit('submitDelcms_category')
|
||||||
|| Tools::isSubmit('submitAddcms_categoryAndBackToParent')
|
|| Tools::isSubmit('submitAddcms_categoryAndBackToParent')
|
||||||
|| Tools::isSubmit('submitAddcms_category')
|
|| Tools::isSubmit('submitAddcms_category')
|
||||||
|| isset($_GET['deletecms_category'])
|
|| Tools::isSubmit('deletecms_category')
|
||||||
|| (Tools::isSubmit('statuscms_category') && Tools::isSubmit('id_cms_category'))
|
|| (Tools::isSubmit('statuscms_category') && Tools::isSubmit('id_cms_category'))
|
||||||
|| (Tools::isSubmit('position') && Tools::isSubmit('id_cms_category_to_move')))
|
|| (Tools::isSubmit('position') && Tools::isSubmit('id_cms_category_to_move')))
|
||||||
$this->admin_cms_categories->postProcess();
|
$this->admin_cms_categories->postProcess();
|
||||||
|
|
||||||
if (((Tools::isSubmit('submitAddcms_category') || Tools::isSubmit('submitAddcms_categoryAndStay')) && count($this->admin_cms_categories->errors))
|
if (((Tools::isSubmit('submitAddcms_category') || Tools::isSubmit('submitAddcms_categoryAndStay')) && count($this->admin_cms_categories->errors))
|
||||||
|| isset($_GET['updatecms_category'])
|
|| Tools::isSubmit('updatecms_category')
|
||||||
|| isset($_GET['addcms_category']))
|
|| Tools::isSubmit('addcms_category'))
|
||||||
$this->display = 'edit_category';
|
$this->display = 'edit_category';
|
||||||
else if (((Tools::isSubmit('submitAddcms') || Tools::isSubmit('submitAddcmsAndStay')) && count($this->admin_cms->errors))
|
else if (((Tools::isSubmit('submitAddcms') || Tools::isSubmit('submitAddcmsAndStay')) && count($this->admin_cms->errors))
|
||||||
|| isset($_GET['updatecms'])
|
|| Tools::isSubmit('updatecms')
|
||||||
|| isset($_GET['addcms']))
|
|| Tools::isSubmit('addcms'))
|
||||||
$this->display = 'edit_page';
|
$this->display = 'edit_page';
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ class AdminCmsControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
if ($this->tabAccess['delete'] === '1')
|
if ($this->tabAccess['delete'] === '1')
|
||||||
{
|
{
|
||||||
if (isset($_POST[$this->table.'Box']))
|
if (Tools::isSubmit($this->table.'Box'))
|
||||||
{
|
{
|
||||||
$cms = new CMS();
|
$cms = new CMS();
|
||||||
$result = true;
|
$result = true;
|
||||||
|
|||||||
Reference in new issue
Block a user