* finish task #3289.

This commit is contained in:
wangyidong
2017-11-02 14:28:02 +08:00
parent 5c1ef6e4f2
commit 99bd7ed909
6 changed files with 33 additions and 28 deletions
+5 -11
View File
@@ -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++;
}
}