1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-08 15:46:44 +02:00

Admin-UI: Drag-n-drop sorting correction.

This commit is contained in:
Cameron
2015-04-02 12:55:26 -07:00
parent 077489bb72
commit 52494a4f00

View File

@@ -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);
}
/**