From f0e00394fabe59e7084cf5fb2f4051e9fe78cfbf Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 18 Sep 2017 17:44:09 +0200 Subject: [PATCH] Clean ajax and add parameter to not loop in categoryUpdate hook --- adm/ajax.php | 6 ++---- js/admin-dnd.js | 4 ++-- modules/privatesales/privatesales.php | 14 +++++++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/adm/ajax.php b/adm/ajax.php index e90821cc..da09b1e2 100755 --- a/adm/ajax.php +++ b/adm/ajax.php @@ -236,9 +236,8 @@ if (array_key_exists('ajaxCategoriesPositions', $_POST)) $category = new Category($id_category_to_move); if (Validate::isLoadedObject($category)) { - if (isset($position) && $category->updatePosition($way, $position)) + if (isset($position) && $category->updatePosition($way, $position)) { - Module::hookExec('categoryUpdate'); die(true); } else @@ -246,7 +245,6 @@ if (array_key_exists('ajaxCategoriesPositions', $_POST)) } else die('{"hasError" : true, "errors" : "This category can not be loaded"}'); - } if (array_key_exists('ajaxCMSCategoriesPositions', $_POST)) @@ -703,7 +701,7 @@ if (Tools::isSubmit('getAdminHomeElement')) } if (Tools::isSubmit('getChildrenCategories') && Tools::getValue('id_category_parent')) -{ +{ $children_categories = Category::getChildrenWithNbSelectedSubCat(Tools::getValue('id_category_parent'), Tools::getValue('selectedCat'), $cookie->id_lang); die(Tools::jsonEncode($children_categories)); } diff --git a/js/admin-dnd.js b/js/admin-dnd.js index c7acdaa7..518304d4 100755 --- a/js/admin-dnd.js +++ b/js/admin-dnd.js @@ -121,7 +121,7 @@ $(document).ready(function() { // Down links $(this).find('td.dragHandle a:even').attr('href', $(this).find('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&')); - }); + }); tableDrag.find('tr').not('.nodrag').removeClass('alt_row'); tableDrag.find('tr:not(".nodrag"):odd').addClass('alt_row'); tableDrag.find('tr td.dragHandle a:hidden').show(); @@ -150,7 +150,7 @@ $(document).ready(function() { // Down links $(this).find('td.dragHandle a:even').attr('href', $(this).find('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&')); - }); + }); tableDrag.find('tr').not('.nodrag').removeClass('alt_row'); tableDrag.find('tr:not(".nodrag"):odd').addClass('alt_row'); diff --git a/modules/privatesales/privatesales.php b/modules/privatesales/privatesales.php index 2ac5ecca..a4a2d093 100755 --- a/modules/privatesales/privatesales.php +++ b/modules/privatesales/privatesales.php @@ -473,11 +473,15 @@ class PrivateSales extends Module { return $this->display(__FILE__, 'header.tpl'); } - public function hookCategoryAddition($params) { - $sale = Sale::getSaleFromCategory($params['category']->id, FALSE); - if($sale !== NULL) { - $sale->buildCategoryCache(); - } + public function hookCategoryAddition($params) + { + if (isset($params['position']) && $params['position'] === true) { + } else { + $sale = Sale::getSaleFromCategory($params['category']->id, FALSE); + if($sale !== NULL) { + $sale->buildCategoryCache(); + } + } } public function hookCategoryUpdate($params) {