diff --git a/module/issue/control.php b/module/issue/control.php index 4384512d62..56a289a94c 100644 --- a/module/issue/control.php +++ b/module/issue/control.php @@ -267,16 +267,18 @@ class issue extends control { if($_POST) { - $this->issue->resolve($issueID); - $resolution = $this->post->resolution; + $data = fixer::input('post')->stripTags('steps', $this->config->allowedTags)->get(); + $resolution = $data->resolution; + unset($_POST['resolution'], $_POST['resolvedBy'], $_POST['resolvedDate']); $objectID = ''; if($resolution == 'totask') { - $objectID = $this->issue->createTask($issueID); + $objectID = $this->issue->createTask($issueID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $objectLink = html::a($this->createLink('task', 'view', "id=$objectID"), $this->post->name, "data-toggle='modal'"); - $comment = sprintf($this->lang->issue->logComments[$resolution], $objectLink); + + $objectLink = html::a($this->createLink('task', 'view', "id=$objectID"), $this->post->name); + $comment = sprintf($this->lang->issue->logComments[$resolution], $objectLink, "data-toggle='modal'"); $this->loadModel('action')->create('task', $objectID, 'Opened', ''); $this->loadModel('action')->create('issue', $issueID, 'Resolved', $comment); @@ -297,7 +299,6 @@ class issue extends control { $objectID = $this->issue->createBug($issueID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $objectLink = html::a($this->createLink('story', 'view', "id=$objectID"), $this->post->title, "data-toggle='modal'"); $objectLink = html::a($this->createLink('bug', 'view', "id=$objectID"), $this->post->title, "data-toggle='modal'"); $comment = sprintf($this->lang->issue->logComments[$resolution], $objectLink); @@ -309,7 +310,6 @@ class issue extends control { $objectID = $this->issue->createRisk($issueID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - $objectLink = html::a($this->createLink('story', 'view', "id=$objectID"), $this->post->name, "data-toggle='modal'"); $objectLink = html::a($this->createLink('risk', 'view', "id=$objectID"), $this->post->name, "data-toggle='modal'"); $comment = sprintf($this->lang->issue->logComments[$resolution], $objectLink); @@ -317,6 +317,7 @@ class issue extends control $this->loadModel('action')->create('issue', $issueID, 'Resolved', $comment); } + $this->issue->resolve($issueID, $data); if($resolution == 'resolved') $this->loadModel('action')->create('issue', $issueID, 'Resolved'); $this->dao->update(TABLE_ISSUE)->set('objectID')->eq($objectID)->where('id')->eq($issueID)->exec(); @@ -375,16 +376,14 @@ class issue extends control $this->view->showAllModule = 'allModule';; $this->view->projects = $projects; $this->view->projectID = $projectID; - $this->view->showFields = $this->config->task->custom->createFields; $this->view->moduleID = 0; $this->view->branch = 0; } if(in_array($data->mode, array('tostory', 'tobug'))) { - $products = $this->loadModel('product')->getPairs(); - $productID = $this->session->product; - $productID = isset($products[$productID]) ? $productID : key($products); + $products = $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); + $productID = key($products); $branches = $this->loadModel('branch')->getPairs($productID, 'noempty'); $module = $data->mode == 'tostory' ? 'story' : 'bug'; @@ -405,23 +404,24 @@ class issue extends control $members = $this->project->getTeamMemberPairs($projectID, 'nodeleted'); $stories = $this->story->getProjectStoryPairs($projectID, 0, 0); - $this->view->project = $project; - $this->view->members = $members; - $this->view->stories = $stories; + $this->view->project = $project; + $this->view->members = $members; + $this->view->stories = $stories; + $this->view->showFields = $this->config->task->custom->createFields; $this->display('issue', 'taskform'); break; case 'tobug': $this->loadModel('bug'); - $this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID, '', 'noempty,noterminate,nodone'); - $this->view->buildID = 0; + $this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID, '', 'noempty,noterminate,nodone'); + $this->view->buildID = 0; + $this->view->showFields = $this->config->bug->custom->createFields; $this->display('issue', 'bugform'); break; case 'tostory': $this->loadModel('story'); - $this->view->showFields = $this->config->task->custom->createFields; - + $this->fetch('story', 'replaceURLang', 'type=requirement'); $this->display('issue', 'storyform'); break; case 'torisk': diff --git a/module/issue/model.php b/module/issue/model.php index 9b68651987..9baf9255c5 100644 --- a/module/issue/model.php +++ b/module/issue/model.php @@ -308,13 +308,12 @@ class issueModel extends model * Resolve an issue. * * @param int $issueID + * @param object $data * @access public * @return object */ - public function resolve($issueID) + public function resolve($issueID, $data) { - $data = fixer::input('post')->stripTags('steps', $this->config->allowedTags)->get(); - $issue = new stdClass(); $issue->resolution = $data->resolution; $issue->resolutionComment = isset($data->resolutionComment) ? $data->resolutionComment : ''; @@ -333,15 +332,12 @@ class issueModel extends model */ public function createTask() { - $task = fixer::input('post') - ->remove('resolution,resolvedBy,resolvedDate') - ->add('openedBy', $this->app->user->account) - ->add('openedDate', helper::today()) - ->stripTags('desc', $this->config->allowedTags) - ->get(); + $projectID = $this->post->project; + $tasks = $this->loadModel('task')->create($projectID); + if(dao::isError()) return false; - $this->dao->insert(TABLE_TASK)->data($task)->exec(); - return $this->dao->lastInsertID(); + $task = current($tasks); + return $task['id']; } /** @@ -352,25 +348,9 @@ class issueModel extends model */ public function createStory() { - $story = fixer::input('post') - ->add('openedBy', $this->app->user->account) - ->add('openedDate', helper::now()) - ->setIF($this->post->needNotReview or $this->post->product > 0, 'status', 'active') - ->stripTags('spec', $this->config->allowedTags) - ->remove('resolution,resolvedBy,resolvedDate,needNotReview') - ->get(); - - $this->dao->insert(TABLE_STORY)->data($story, 'spec')->exec(); - - $stotyID = $this->dao->lastInsertID(); - $this->dao->insert(TABLE_STORYSPEC) - ->set('story')->eq($stotyID) - ->set('title')->eq($story->title) - ->set('spec')->eq($this->post->spec) - ->set('version')->eq(1) - ->exec(); - - return $stotyID; + $storyResult = $this->loadModel('story')->create(); + if(dao::isError()) return false; + return $storyResult['id']; } /** @@ -381,16 +361,9 @@ class issueModel extends model */ public function createBug() { - $bug = fixer::input('post') - ->remove('resolution,resolvedBy,resolvedDate') - ->join('openedBuild', ',') - ->add('openedBy', $this->app->user->account) - ->add('openedDate', helper::now()) - ->stripTags('steps', $this->config->allowedTags) - ->get(); - - $this->dao->insert(TABLE_BUG)->data($bug)->exec(); - return $this->dao->lastInsertID(); + $bugResult = $this->loadModel('bug')->create(); + if(dao::isError()) return false; + return $bugResult['id']; } /** @@ -401,14 +374,9 @@ class issueModel extends model */ public function createRisk() { - $risk = fixer::input('post') - ->add('createdBy', $this->app->user->account) - ->add('createdDate', helper::now()) - ->remove('resolution,resolvedBy,resolvedDate') - ->get(); - - $this->dao->insert(TABLE_RISK)->data($risk)->exec(); - return $this->dao->lastInsertID(); + $riskID = $this->loadModel('risk')->create(); + if(dao::isError()) return false; + return $riskID; } /** diff --git a/module/issue/view/bugform.html.php b/module/issue/view/bugform.html.php index 3a21c63acf..848d9da0c5 100644 --- a/module/issue/view/bugform.html.php +++ b/module/issue/view/bugform.html.php @@ -43,11 +43,8 @@ -