* finish task#1516.

This commit is contained in:
chencongzhi520@gmail.com
2013-07-15 06:47:26 +00:00
parent 04b22c74f9
commit 348e0577c8
3 changed files with 50 additions and 1 deletions
+2 -1
View File
@@ -151,7 +151,8 @@
<?php
foreach($lang->story->stageList as $key => $stage)
{
echo "<li><a href='#'>$stage</a></li>";
$actionLink = $this->createLink('story', 'batchChangeStage', "stage=$key");
echo "<li>" . html::a('#', $stage, '', "onclick=\"changeAction('$actionLink',true)\"") . "</li>";
}
?>
</ul>
+21
View File
@@ -723,6 +723,27 @@ class story extends control
die(js::locate($this->session->storyList, 'parent'));
}
/**
* Batch change the stage of story.
*
* @param string $stage
* @access public
* @return void
*/
public function batchChangeStage($stage)
{
$storyIDList = $this->post->storyIDList ? $this->post->storyIDList : die(js::locate($this->session->storyList, 'parent'));
$allChanges = $this->story->batchChangeStage($storyIDList, $stage);
if(dao::isError()) die(js::error(dao::getError()));
foreach($allChanges as $storyID => $changes)
{
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendMail($storyID, $actionID);
}
die(js::locate($this->session->storyList, 'parent'));
}
/**
* Tasks of a story.
*
+27
View File
@@ -650,6 +650,33 @@ class storyModel extends model
return $allChanges;
}
/**
* Batch change the stage of story.
*
* @param string $stage
* @access public
* @return array
*/
public function batchChangeStage($storyIDList, $stage)
{
$now = helper::now();
$allChanges = array();
foreach($storyIDList as $storyID)
{
$oldStory = $this->getById($storyID);
if($oldStory->status == 'draft') continue;
$story = new stdclass();
$story->lastEditedBy = $this->app->user->account;
$story->lastEditedDate = $now;
$story->stage = $stage;
$this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec();
if(!dao::isError()) $allChanges[$storyID] = common::createChanges($oldStory, $story);
}
return $allChanges;
}
/**
* Activate a story.
*