* finish task #3289.
This commit is contained in:
@@ -530,7 +530,7 @@ class project extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function story($projectID = 0, $orderBy = 'order', $type = 'byModule', $param = 0, $recTotal = 0, $recPerPage = 50, $pageID = 1)
|
||||
public function story($projectID = 0, $orderBy = 'order_desc', $type = 'byModule', $param = 0, $recTotal = 0, $recPerPage = 50, $pageID = 1)
|
||||
{
|
||||
/* Load these models. */
|
||||
$this->loadModel('story');
|
||||
@@ -2010,17 +2010,11 @@ class project extends control
|
||||
$idList = explode(',', trim($this->post->storys, ','));
|
||||
$orderBy = $this->post->orderBy;
|
||||
|
||||
$stories = $this->dao->select('story,`order`')->from(TABLE_PROJECTSTORY)->alias('t1')
|
||||
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story=t2.id')
|
||||
->where('t1.story')->in($idList)
|
||||
->andWhere('t1.project')->eq($projectID)
|
||||
->orderBy($orderBy)
|
||||
->fetchPairs('order', 'story');
|
||||
foreach($stories as $order => $id)
|
||||
$order = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('story')->in($idList)->andWhere('project')->eq($projectID)->orderBy('order_asc')->fetch('order');
|
||||
foreach($idList as $storyID)
|
||||
{
|
||||
$newID = array_shift($idList);
|
||||
if($id == $newID) continue;
|
||||
$this->dao->update(TABLE_PROJECTSTORY)->set('`order`')->eq($order)->where('story')->eq($newID)->andWhere('project')->eq($projectID)->exec();
|
||||
$this->dao->update(TABLE_PROJECTSTORY)->set('`order`')->eq($order)->where('story')->eq($storyID)->andWhere('project')->eq($projectID)->exec();
|
||||
$order++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user