* Finish task #8345.

This commit is contained in:
Yagami
2020-11-13 16:55:21 +08:00
parent c0b7a35108
commit a4333ffdb7
3 changed files with 29 additions and 21 deletions
+7 -19
View File
@@ -2335,29 +2335,17 @@ class project extends control
*/
public function updateOrder()
{
$orderBy = $this->post->orderBy;
if(strpos($orderBy, 'order') === false)
{
return $this->send(array('result' => 'fail'));
}
$idList = explode(',', trim($this->post->projects, ','));
$projects = $this->dao->select('id, `order`')->from(TABLE_PROJECT)
->where('id')->in($idList)
->fetchPairs('id', 'order');
$orderBy = $this->post->orderBy;
if(strpos($orderBy, 'order') === false) return false;
foreach($projects as $id => $order)
$projects = $this->dao->select('id,`order`')->from(TABLE_PROJECT)->where('id')->in($idList)->orderBy($orderBy)->fetchPairs('order', 'id');
foreach($projects as $order => $id)
{
$newOrder = $orders[$id];
if($order != $newOrder)
{
$this->dao->update(TABLE_PROJECT)
->set('`order`')->eq($newOrder)
->where('id')->eq($id)
->exec();
}
$newID = array_shift($idList);
if($id == $newID) continue;
$this->dao->update(TABLE_PROJECT)->set('`order`')->eq($order)->where('id')->eq($newID)->exec();
}
$this->send(array('result' => 'success'));
}
/**