diff --git a/module/bug/control.php b/module/bug/control.php
index b1201af847..2823a38fe2 100644
--- a/module/bug/control.php
+++ b/module/bug/control.php
@@ -570,24 +570,15 @@ class bug extends control
* @access public
* @return void
*/
- public function resolve($bugID, $toStory = false)
+ public function resolve($bugID)
{
$this->view->users = $this->user->getPairs('nodeleted');
if(!empty($_POST))
{
- $storyID = $this->bug->resolve($bugID);
+ $this->bug->resolve($bugID);
if(dao::isError()) die(js::error(dao::getError()));
-
- if($this->post->resolution == 'tostory')
- {
- $actionID = $this->action->create('bug', $bugID, 'ToStory', $this->post->comment, $storyID);
- $this->action->create('bug', $bugID, 'Closed');
- }
- else
- {
- $actionID = $this->action->create('bug', $bugID, 'Resolved', $this->post->comment, $this->post->resolution);
- }
+ $actionID = $this->action->create('bug', $bugID, 'Resolved', $this->post->comment, $this->post->resolution);
$this->sendmail($bugID, $actionID);
$bug = $this->bug->getById($bugID);
@@ -606,7 +597,6 @@ class bug extends control
$this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]);
$this->view->position[] = $this->lang->bug->resolve;
- $this->view->toStory = $toStory;
$this->view->bug = $bug;
$this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID);
$this->view->actions = $this->action->getList('bug', $bugID);
diff --git a/module/bug/lang/en.php b/module/bug/lang/en.php
index daf7181bd3..34ce8e85bb 100644
--- a/module/bug/lang/en.php
+++ b/module/bug/lang/en.php
@@ -231,7 +231,6 @@ $lang->bug->resolutionList[''] = '';
$lang->bug->resolutionList['bydesign'] = 'By design';
$lang->bug->resolutionList['duplicate'] = 'Duplicate';
$lang->bug->resolutionList['external'] = 'External';
-$lang->bug->resolutionList['tostory'] = 'To story';
$lang->bug->resolutionList['fixed'] = 'Fixed';
$lang->bug->resolutionList['notrepro'] = 'Not reproduce';
$lang->bug->resolutionList['postponed'] = 'Postponed';
diff --git a/module/bug/lang/zh-cn.php b/module/bug/lang/zh-cn.php
index 7a086ed826..c62a1a8901 100644
--- a/module/bug/lang/zh-cn.php
+++ b/module/bug/lang/zh-cn.php
@@ -231,7 +231,6 @@ $lang->bug->resolutionList[''] = '';
$lang->bug->resolutionList['bydesign'] = '设计如此';
$lang->bug->resolutionList['duplicate'] = '重复Bug';
$lang->bug->resolutionList['external'] = '外部原因';
-$lang->bug->resolutionList['tostory'] = '转为需求';
$lang->bug->resolutionList['fixed'] = '已解决';
$lang->bug->resolutionList['notrepro'] = '无法重现';
$lang->bug->resolutionList['postponed'] = '延期处理';
diff --git a/module/bug/model.php b/module/bug/model.php
index 0d1e525bd6..5434d40bc3 100644
--- a/module/bug/model.php
+++ b/module/bug/model.php
@@ -211,66 +211,16 @@ class bugModel extends model
public function resolve($bugID)
{
$now = helper::now();
- $oldBug = $this->getById($bugID);
- $storyID = 0;
- if($this->post->resolution == 'tostory')
- {
- $story->product = $oldBug->product;
- $story->module = $oldBug->module;
- $story->source = 'bug';
- $story->fromBug = $bugID;
- $story->title = $oldBug->title;
- $story->keywords = $oldBug->keywords;
- $story->pri = $oldBug->pri;
- $story->status = 'active';
- $story->mailto = $oldBug->mailto;
- $story->openedBy = $this->app->user->account;
- $story->openedDate = $now;
- $story->assignedDate = 0;
- $story->version = 1;
-
- $this->dao->insert(TABLE_STORY)->data($story)->exec();
- if(dao::isError())
- {
- echo js::error(dao::getError());
- die(js::reload('parent'));
- }
-
- $storyID = $this->dao->lastInsertID();
-
- $storySpec->story = $storyID;
- $storySpec->version = 1;
- $storySpec->title = $oldBug->title;
- $storySpec->spec = $oldBug->steps;
- $this->dao->insert(TABLE_STORYSPEC)->data($storySpec)->exec();
-
- $actionID = $this->loadModel('action')->create('story', $storyID, 'Frombug', '', $bugID);
-
- $file = $this->dao->select('*')->from(TABLE_FILE)->where('objectType')->eq('bug')->andWhere('objectID')->eq($bugID)->fetch();
- if(!empty($file))
- {
- $file->objectType = 'story';
- $file->objectID = $storyID;
- unset($file->id);
- $this->dao->insert(TABLE_FILE)->data($file)->exec();
- }
- }
-
$bug = fixer::input('post')
->add('resolvedBy', $this->app->user->account)
->add('resolvedDate', $now)
+ ->add('status', 'resolved')
->add('confirmed', 1)
->add('assignedDate', $now)
->add('lastEditedBy', $this->app->user->account)
->add('lastEditedDate', $now)
->setDefault('duplicateBug', 0)
->setDefault('assignedTo', $oldBug->openedBy)
- ->setIF($this->post->resolution == 'tostory', 'toStory', $storyID)
- ->setIF($this->post->resolution == 'tostory', 'status', 'closed')
- ->setIF($this->post->resolution == 'tostory', 'closedBy', $this->app->user->account)
- ->setIF($this->post->resolution == 'tostory', 'closedDate', $now)
- ->setIF($this->post->resolution == 'tostory', 'assignedTo', 'closed')
- ->setIF($this->post->resolution != 'tostory', 'status', 'resolved')
->remove('comment')
->get();
@@ -281,10 +231,8 @@ class bugModel extends model
->checkIF($bug->resolution == 'fixed', 'resolvedBuild','notempty')
->where('id')->eq((int)$bugID)
->exec();
- return $storyID;
}
-
/**
* Activate a bug.
*
diff --git a/module/bug/view/resolve.html.php b/module/bug/view/resolve.html.php
index d5e585ede7..beb6bb5f10 100644
--- a/module/bug/view/resolve.html.php
+++ b/module/bug/view/resolve.html.php
@@ -16,11 +16,7 @@
title;?>
| bug->resolution;?> |
-
bug->resolutionList, '', 'class=select-3 onchange=setDuplicate(this.value)');?> |
-
- bug->resolutionList['tostory'];echo html::input('resolution', 'tostory', 'class=select-3 hidden');?> |
-
| bug->duplicateBug;?> |
diff --git a/module/bug/view/view.html.php b/module/bug/view/view.html.php
index 68d8a96c75..34e85665e3 100644
--- a/module/bug/view/view.html.php
+++ b/module/bug/view/view.html.php
@@ -25,9 +25,9 @@
common::printLink('bug', 'edit', $params, $lang->bug->buttonEdit);
if(!($bug->status == 'active' and common::printLink('bug', 'resolve', $params, $lang->bug->buttonResolve))) echo $lang->bug->buttonResolve . ' ';
if(!($bug->status == 'resolved' and common::printLink('bug', 'close', $params, $lang->bug->buttonClose))) echo $lang->bug->buttonClose . ' ';
- if($bug->status == 'active' and common::hasPriv('bug', 'resolve'))
+ if($bug->status == 'active' and common::hasPriv('story', 'create'))
{
- common::printLink('bug', 'resolve', "$params&toStory=true", $lang->bug->resolutionList['tostory']) . ' ';
+ common::printLink('story', 'create', "product=$bug->product&module=0&story=0&project=0&bugID=$bug->id", $lang->bug->resolutionList['tostory']) . ' ';
}
else
{
@@ -62,7 +62,7 @@
if(!($bug->status == 'resolved' and common::printLink('bug', 'close', $params, $lang->bug->buttonClose))) echo $lang->bug->buttonClose . ' ';
if($bug->status == 'active' and common::hasPriv('bug', 'resolve'))
{
- common::printLink('bug', 'resolve', "$params&toStory=true", $lang->bug->resolutionList['tostory']) . ' ';
+ common::printLink('story', 'create', "product=$bug->product&module=0&story=0&project=0&bugID=$bug->id", $lang->bug->resolutionList['tostory']) . ' ';
}
else
{
diff --git a/module/story/control.php b/module/story/control.php
index dee777b5c0..b5863398b9 100644
--- a/module/story/control.php
+++ b/module/story/control.php
@@ -33,14 +33,21 @@ class story extends control
* @access public
* @return void
*/
- public function create($productID = 0, $moduleID = 0, $storyID = 0, $projectID = 0)
+ public function create($productID = 0, $moduleID = 0, $storyID = 0, $projectID = 0, $bugID = 0)
{
if(!empty($_POST))
{
- $storyID = $this->story->create($projectID);
+ $storyID = $this->story->create($projectID, $bugID);
if(dao::isError()) die(js::error(dao::getError()));
$this->loadModel('action');
- $actionID = $this->action->create('story', $storyID, 'Opened', '');
+ if($bugID == 0)
+ {
+ $actionID = $this->action->create('story', $storyID, 'Opened', '');
+ }
+ else
+ {
+ $actionID = $this->action->create('story', $storyID, 'Frombug', '', $bugID);
+ }
$this->sendMail($storyID, $actionID);
if($projectID == 0)
{
@@ -75,6 +82,7 @@ class story extends control
/* Init vars. */
$planID = 0;
+ $source = '';
$pri = 0;
$estimate = '';
$title = '';
@@ -87,6 +95,7 @@ class story extends control
{
$story = $this->story->getByID($storyID);
$planID = $story->plan;
+ $source = $story->source;
$pri = $story->pri;
$productID = $story->product;
$moduleID = $story->module;
@@ -98,6 +107,17 @@ class story extends control
$mailto = $story->mailto;
}
+ if($bugID > 0)
+ {
+ $oldBug = $this->loadModel('bug')->getById($bugID);
+ $productID = $oldBug->product;
+ $source = 'bug';
+ $title = $oldBug->title;
+ $keywords = $oldBug->keywords;
+ $pri = $oldBug->pri;
+ $mailto = $oldBug->mailto;
+ }
+
$this->view->header->title = $product->name . $this->lang->colon . $this->lang->story->create;
$this->view->position[] = html::a($this->createLink('product', 'browse', "product=$productID"), $product->name);
$this->view->position[] = $this->lang->story->create;
@@ -107,6 +127,7 @@ class story extends control
$this->view->moduleOptionMenu = $moduleOptionMenu;
$this->view->plans = $this->loadModel('productplan')->getPairs($productID, 'unexpired');
$this->view->planID = $planID;
+ $this->view->source = $source;
$this->view->pri = $pri;
$this->view->productID = $productID;
$this->view->estimate = $estimate;
diff --git a/module/story/model.php b/module/story/model.php
index fec940f67b..0637b9bc7d 100644
--- a/module/story/model.php
+++ b/module/story/model.php
@@ -97,7 +97,7 @@ class storyModel extends model
* @access public
* @return int|bool the id of the created story or false when error.
*/
- public function create($projectID = 0)
+ public function create($projectID = 0, $bugID = 0)
{
$now = helper::now();
$story = fixer::input('post')
@@ -115,8 +115,10 @@ class storyModel extends model
->setIF($this->post->needNotReview, 'status', 'active')
->setIF($this->post->plan > 0, 'stage', 'planned')
->setIF($projectID > 0, 'stage', 'projected')
+ ->setIF($bugID > 0, 'fromBug', $bugID)
->remove('files,labels,spec,verify,needNotReview')
->get();
+
$this->dao->insert(TABLE_STORY)->data($story)->autoCheck()->batchCheck($this->config->story->create->requiredFields, 'notempty')->exec();
if(!dao::isError())
{
@@ -140,6 +142,19 @@ class storyModel extends model
->set('version')->eq(1)
->exec();
}
+
+ if($bugID > 0)
+ {
+ $bug->toStory = $storyID;
+ $bug->status = 'closed';
+ $bug->closedBy = $this->app->user->account;
+ $bug->closedDate = $now;
+ $bug->assignedTo = 'closed';
+ $this->dao->update(TABLE_BUG)->data($bug)->exec();
+
+ $this->loadModel('action')->create('bug', $bugID, 'ToStory', '', $storyID);
+ $this->action->create('bug', $bugID, 'Closed');
+ }
return $storyID;
}
return false;
diff --git a/module/story/view/create.html.php b/module/story/view/create.html.php
index 7e6dd80d70..2e07feb1d7 100644
--- a/module/story/view/create.html.php
+++ b/module/story/view/create.html.php
@@ -12,7 +12,7 @@
?>
-