* finish task#1516.
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user