1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00

Corrected drag-n-drop sorting. Now increments correctly.

This commit is contained in:
Cameron 2015-04-02 12:33:15 -07:00
parent 80c9e440e4
commit 1740161a49
2 changed files with 21 additions and 6 deletions

View File

@ -755,7 +755,9 @@ class e_admin_log
{
return;
}
$text = '';
foreach($this->_allMessages as $m)
{
$text .= date('Y-m-d H:i:s', $m['time'])." \t".str_pad($m['dislevel'],10," ",STR_PAD_RIGHT)."\t".strip_tags($m['message'])."\n";

View File

@ -4860,22 +4860,35 @@ 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;
foreach($_POST['all'] as $row)
{
$c += $step;
list($tmp,$id) = explode("-", $row, 2);
$id = preg_replace('/[^\w-:.]/', '', $id);
if(!is_numeric($id)) $id = "'{$id}'";
if($sql->db_Update($this->table, $this->sortField." = {$c} WHERE ".$this->pid." = ".$id))
if($sql->update($this->table, $this->sortField." = {$c} WHERE ".$this->pid." = ".$id)!==false)
{
$updated[] = $id;
$updated[] = "#".$id." -- ".$this->sortField." = ".$c;
}
// echo($sql->getLastQuery()."\n");
$c += $step;
}
// Increment every other record above the one that was changed.
// 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);
$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($qry)->toFile('SortAjax','Admin-UI Ajax Sort Log', true);
//echo "Updated ".implode(",",$updated);
}