* Code for task#62968.

This commit is contained in:
xieqiyu
2022-08-17 08:41:05 +08:00
parent 8c2e982023
commit a61ad52efa
4 changed files with 67 additions and 27 deletions
+2 -1
View File
@@ -510,7 +510,8 @@ class actionModel extends model
elseif(($actionName == 'closed' and $action->objectType == 'story') or ($actionName == 'resolved' and $action->objectType == 'bug'))
{
$action->appendLink = '';
if(strpos($action->extra, ':')!== false)
if(strpos($action->extra, '|') !== false) $action->extra = substr($action->extra, 0, strpos($action->extra, '|'));
if(strpos($action->extra, ':') !== false)
{
list($extra, $id) = explode(':', $action->extra);
$action->extra = $extra;
+29 -21
View File
@@ -1201,6 +1201,7 @@ class story extends control
}
$this->commonAction($storyID);
$this->story->setActivateStatus($storyID);
/* Assign. */
$this->view->title = $this->lang->story->activate . "STORY" . $this->lang->colon . $this->view->story->title;
@@ -1645,6 +1646,8 @@ class story extends control
*/
public function close($storyID, $from = '')
{
$story = $this->story->getById($storyID);
if(!empty($_POST))
{
$changes = $this->story->close($storyID);
@@ -1653,7 +1656,10 @@ class story extends control
if($changes)
{
$actionID = $this->action->create('story', $storyID, 'Closed', $this->post->comment, ucfirst($this->post->closedReason) . ($this->post->duplicateStory ? ':' . (int)$this->post->duplicateStory : ''));
$preStatus = $story->status;
if($preStatus == 'reviewing') $preStatus = $story->changedBy ? 'changing' : 'draft';
$actionID = $this->action->create('story', $storyID, 'Closed', $this->post->comment, ucfirst($this->post->closedReason) . ($this->post->duplicateStory ? ':' . (int)$this->post->duplicateStory : '') . "|$preStatus");
$this->action->logHistory($actionID, $changes);
}
@@ -1699,7 +1705,6 @@ class story extends control
}
/* Get story and product. */
$story = $this->story->getById($storyID);
$product = $this->dao->findById($story->product)->from(TABLE_PRODUCT)->fields('name, id')->fetch();
$this->story->replaceURLang($story->type);
@@ -1736,30 +1741,12 @@ class story extends control
*/
public function batchClose($productID = 0, $executionID = 0, $storyType = 'story', $from = '')
{
if($this->post->comments)
{
$data = fixer::input('post')->get();
$allChanges = $this->story->batchClose();
if($allChanges)
{
foreach($allChanges as $storyID => $changes)
{
$actionID = $this->action->create('story', $storyID, 'Closed', htmlSpecialString($this->post->comments[$storyID]), ucfirst($this->post->closedReasons[$storyID]) . ($this->post->duplicateStoryIDList[$storyID] ? ':' . (int)$this->post->duplicateStoryIDList[$storyID] : ''));
$this->action->logHistory($actionID, $changes);
}
}
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther');
return print(js::locate($this->session->storyList, 'parent'));
}
if(!$this->post->storyIdList) return print(js::locate($this->session->storyList, 'parent'));
$storyIdList = $this->post->storyIdList;
$storyIdList = array_unique($storyIdList);
/* Get edited stories. */
$stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($storyIdList)->fetchAll('id');
$stories = $this->story->getByList($storyIdList);
foreach($stories as $story)
{
if($story->parent == -1)
@@ -1774,6 +1761,27 @@ class story extends control
}
}
if($this->post->comments)
{
$data = fixer::input('post')->get();
$allChanges = $this->story->batchClose();
if($allChanges)
{
foreach($allChanges as $storyID => $changes)
{
$preStatus = $stories[$storyID]->status;
if($preStatus == 'reviewing') $preStatus = $stories[$storyID]->changedBy ? 'changing' : 'draft';
$actionID = $this->action->create('story', $storyID, 'Closed', htmlSpecialString($this->post->comments[$storyID]), ucfirst($this->post->closedReasons[$storyID]) . ($this->post->duplicateStoryIDList[$storyID] ? ':' . (int)$this->post->duplicateStoryIDList[$storyID] : '') . "|$preStatus");
$this->action->logHistory($actionID, $changes);
}
}
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther');
return print(js::locate($this->session->storyList, 'parent'));
}
$errorTips = '';
if(isset($closedStory)) $errorTips .= sprintf($this->lang->story->closedStory, join(',', $closedStory));
if(isset($skipStory)) $errorTips .= sprintf($this->lang->story->skipStory, join(',', $skipStory));
+36 -1
View File
@@ -5551,7 +5551,7 @@ class storyModel extends model
if($result != 'revert')
{
if($story->status == 'closed') $this->action->create('story', $story->id, 'ReviewRejected');
if($story->status == 'closed') $this->action->create('story', $story->id, 'ReviewRejected', '', empty($story->changedBy) ? 'draft' : 'changing');
if($story->status == 'active') $this->action->create('story', $story->id, 'ReviewPassed');
if(!array_diff(array_keys($reviewers), $reviewedBy) and ($story->status == 'draft' or $story->status == 'changing')) $this->action->create('story', $story->id, 'ReviewClarified');
}
@@ -5853,4 +5853,39 @@ class storyModel extends model
return $stories;
}
/**
* Set the selectable status when activated.
*
* @param int $storyID
* @access public
* @return void
*/
public function setActivateStatus($storyID)
{
$lastRecord = $this->dao->select('action,extra')->from(TABLE_ACTION)
->where('objectType')->eq('story')
->andWhere('objectID')->eq($storyID)
->orderBy('id_desc')
->fetch();
$lastAction = $lastRecord->action;
$preStatus = $lastRecord->extra;
if(strpos($preStatus, '|') !== false) $preStatus = substr($preStatus, strpos($preStatus, '|') + 1);
if(strpos('closed,reviewrejected', $lastAction) !== false)
{
foreach($this->lang->story->statusList as $status => $lang)
{
if($preStatus == $status or $status == 'active') continue;
unset($this->lang->story->statusList[$status]);
}
if($this->checkForceReview() and $preStatus != 'active') unset($this->lang->story->statusList['active']);
}
else
{
foreach(array('', 'closed', 'changing', 'reviewing') as $status) unset($this->lang->story->statusList[$status]);
}
}
}
-4
View File
@@ -32,10 +32,6 @@
<th><?php echo $lang->story->status;?></th>
<td>
<?php
unset($lang->story->statusList['']);
unset($lang->story->statusList['closed']);
unset($lang->story->statusList['changing']);
unset($lang->story->statusList['reviewing']);
echo html::select('status', $lang->story->statusList, 'active', 'class="form-control chosen"');
?>
</td>