1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-10 00:27:45 +02:00

More corrections to ajaxSorting.

This commit is contained in:
Cameron
2015-04-02 13:57:37 -07:00
parent 26877d1aaa
commit daedd65214

View File

@@ -4858,17 +4858,16 @@ class e_admin_ui extends e_admin_controller_ui
return; return;
} }
$sql = e107::getDb(); $sql = e107::getDb();
$c = ($_GET['from']) ? intval($_GET['from']) : 0; $step = $this->orderStep ? intval($this->orderStep) : 1;
$from = ($_GET['from']) ? intval($_GET['from']) * $step : 0;
// $c = $c+1; $c = $from;
$updated = array(); $updated = array();
$step = $this->orderStep ? intval($this->orderStep) : 1;
foreach($_POST['all'] as $row) foreach($_POST['all'] as $row)
{ {
$c += $step;
list($tmp,$id) = explode("-", $row, 2); list($tmp,$id) = explode("-", $row, 2);
$id = preg_replace('/[^\w-:.]/', '', $id); $id = preg_replace('/[^\w-:.]/', '', $id);
if(!is_numeric($id)) $id = "'{$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; $updated[] = "#".$id." -- ".$this->sortField." = ".$c;
} }
// echo($sql->getLastQuery()."\n"); // echo($sql->getLastQuery()."\n");
$c += $step;
} }
// Increment every other record above the one that was changed. // Increment every other record after the current page of records.
$changed = intval($_POST['neworder']) + intval($_GET['from']) + $step; // $changed = (intval($_POST['neworder']) * $step) + $from ;
// eg. $qry = "UPDATE e107_faqs e, (SELECT @n := 249) m SET e.faq_order = @n := @n + 1 WHERE 1"; $changed = $c - $step;
$qry = "UPDATE `#".$this->table."` e, (SELECT @n := ".($changed).") m SET e.".$this->sortField." = @n := @n + ".$step." WHERE ".$this->sortField." > ".($changed); $qry = "UPDATE `#".$this->table."` e, (SELECT @n := ".($changed).") m SET e.".$this->sortField." = @n := @n + ".$step." WHERE ".$this->sortField." > ".($changed);
$sql->gen($qry); $sql->gen($qry);
// e107::getLog()->addDebug(print_r($_POST,true))->toFile('SortAjax','Admin-UI Ajax Sort Log', true); // 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); // 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";
} }
/** /**