From 52494a4f00a02037956011cb43c404beebb163e3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 2 Apr 2015 12:55:26 -0700 Subject: [PATCH] Admin-UI: Drag-n-drop sorting correction. --- e107_handlers/admin_ui.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index 95307925c..eb7058863 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -4860,6 +4860,7 @@ class e_admin_ui extends e_admin_controller_ui $sql = e107::getDb(); $c = ($_GET['from']) ? intval($_GET['from']) : 0; + // $c = $c+1; $updated = array(); $step = $this->orderStep ? intval($this->orderStep) : 1; @@ -4880,16 +4881,15 @@ class e_admin_ui extends e_admin_controller_ui } // Increment every other record above the one that was changed. + $changed = intval($_POST['neworder']) + intval($_GET['from']) + $step; // eg. $qry = "UPDATE e107_faqs e, (SELECT @n := 249) m SET e.faq_order = @n := @n + 1 WHERE 1"; - $qry = "UPDATE #".$this->table." e, (SELECT @n := ".($c-$step).") m SET e.".$this->sortField." = @n := @n + ".$step." WHERE ".$this->sortField." >= ".($c); + $qry = "UPDATE #".$this->table." e, (SELECT @n := ".($changed).") m SET e.".$this->sortField." = @n := @n + ".$step." WHERE ".$this->sortField." > ".($changed); $sql->gen($qry); // e107::getLog()->addDebug(print_r($_POST,true))->toFile('SortAjax','Admin-UI Ajax Sort Log', true); -// e107::getLog()->addDebug(print_r($updated,true))->toFile('SortAjax','Admin-UI Ajax Sort Log', true); + // e107::getLog()->addDebug(print_r($updated,true))->toFile('SortAjax','Admin-UI Ajax Sort Log', true); // e107::getLog()->addDebug($qry)->toFile('SortAjax','Admin-UI Ajax Sort Log', true); - - //echo "Updated ".implode(",",$updated); } /**