From daedd65214b34c9a24128682c00e70326ecdbfa7 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 2 Apr 2015 13:57:37 -0700 Subject: [PATCH] More corrections to ajaxSorting. --- e107_handlers/admin_ui.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index 106ae3f36..dbd7fbe1b 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -4858,17 +4858,16 @@ class e_admin_ui extends e_admin_controller_ui return; } - $sql = e107::getDb(); - $c = ($_GET['from']) ? intval($_GET['from']) : 0; + $sql = e107::getDb(); + $step = $this->orderStep ? intval($this->orderStep) : 1; + $from = ($_GET['from']) ? intval($_GET['from']) * $step : 0; - // $c = $c+1; + $c = $from; $updated = array(); - $step = $this->orderStep ? intval($this->orderStep) : 1; - foreach($_POST['all'] as $row) { - $c += $step; + list($tmp,$id) = explode("-", $row, 2); $id = preg_replace('/[^\w-:.]/', '', $id); if(!is_numeric($id)) $id = "'{$id}'"; @@ -4877,19 +4876,22 @@ class e_admin_ui extends e_admin_controller_ui $updated[] = "#".$id." -- ".$this->sortField." = ".$c; } // echo($sql->getLastQuery()."\n"); + $c += $step; } - // 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"; + // Increment every other record after the current page of records. + // $changed = (intval($_POST['neworder']) * $step) + $from ; + $changed = $c - $step; $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); + // eg. $qry = "UPDATE e107_faqs e, (SELECT @n := 249) m SET e.faq_order = @n := @n + 1 WHERE 1"; + } /**