diff --git a/db/update15.0.sql b/db/update15.0.sql index 4a1c55ec3c..193e250ca4 100644 --- a/db/update15.0.sql +++ b/db/update15.0.sql @@ -26,3 +26,5 @@ ALTER TABLE `zt_testtask` ADD `testreport` mediumint(8) unsigned NOT NULL AFTER ALTER TABLE `zt_story` MODIFY COLUMN `reviewedDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00'; REPLACE INTO `zt_config` (`owner`, `module`, `section`, `key`, `value`) VALUES ('system', 'story', '', 'reviewRules', 'allpass'); + +UPDATE zt_project SET lifetime = '' WHERE lifetime = 'sprint'; diff --git a/module/action/model.php b/module/action/model.php index 4d00876581..09eb78dbf3 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -182,34 +182,10 @@ class actionModel extends model return $relation; } - /* Only process these object types. */ if(strpos($this->config->action->needGetRelateField, ",{$objectType},") !== false) { if(!isset($this->config->objectTables[$objectType])) return $emptyRecord; - if($objectType == 'story' and ($actionType == 'linked2build' or $actionType == 'unlinkedfrombuild')) - { - $build = $this->dao->select('project,execution')->from(TABLE_BUILD)->where('id')->eq((int)$extra)->fetch(); - $action->project = $build->project; - $action->execution = $build->execution; - } - - if($objectType == 'story' and $actionType == 'estimated') - { - $action->project = $this->dao->select('project')->from(TABLE_EXECUTION)->where('id')->eq((int)$extra)->fetch('project'); - $action->execution = (int)$extra; - } - - if($objectType == 'case' and (strpos(',linked2testtask,unlinkedfromtesttask,assigned,run,', ',' . $actionType . ',') !== false) and (int)$extra) - { - $testtask = $this->dao->select('project,execution')->from(TABLE_TESTTASK)->where('id')->eq((int)$extra)->fetch(); - $action->project = $testtask->project; - $action->execution = $testtask->execution; - } - - if($objectType == 'whitelist' and $extra == 'product') $action->product = $objectID; - if($objectType == 'whitelist' and $extra == 'project') $action->project = $objectID; - if($objectType == 'whitelist' and ($extra == 'sprint' or $extra == 'stage')) $action->execution = $objectID; /* Set fields to fetch. */ $fields = '*'; @@ -244,6 +220,30 @@ class actionModel extends model $record->product = join(',', array_keys($products)); } } + + if($objectType == 'story' and ($actionType == 'linked2build' or $actionType == 'unlinkedfrombuild')) + { + $build = $this->dao->select('project,execution')->from(TABLE_BUILD)->where('id')->eq((int)$extra)->fetch(); + $record->project = $build->project; + $record->execution = $build->execution; + } + + if($objectType == 'story' and $actionType == 'estimated') + { + $record->project = $this->dao->select('project')->from(TABLE_EXECUTION)->where('id')->eq((int)$extra)->fetch('project'); + $record->execution = (int)$extra; + } + + if($objectType == 'case' and (strpos(',linked2testtask,unlinkedfromtesttask,assigned,run,', ',' . $actionType . ',') !== false) and (int)$extra) + { + $testtask = $this->dao->select('project,execution')->from(TABLE_TESTTASK)->where('id')->eq((int)$extra)->fetch(); + $record->project = $testtask->project; + $record->execution = $testtask->execution; + } + + if($objectType == 'whitelist' and $extra == 'product') $record->product = $objectID; + if($objectType == 'whitelist' and $extra == 'project') $record->project = $objectID; + if($objectType == 'whitelist' and ($extra == 'sprint' or $extra == 'stage')) $record->execution = $objectID; if($actionType == 'unlinkedfromproject' or $actionType == 'linked2project') $record->project = (int)$extra ; if($actionType == 'unlinkedfromexecution' or $actionType == 'linked2execution') $record->execution = (int)$extra; diff --git a/module/project/view/edit.html.php b/module/project/view/edit.html.php index 7858ee7a3b..8c52ae4ae2 100644 --- a/module/project/view/edit.html.php +++ b/module/project/view/edit.html.php @@ -160,7 +160,7 @@ echo html::hidden('model', $project->model); echo html::submitButton(); $browseLink = $this->session->projectList ? $this->session->projectList : $this->createLink('project', 'browse'); - echo isonlybody() ? html::backButton() : html::a($browseLink, $lang->goback, '', 'class="btn btn-back btn-wide"'); + if(!isonlybody()) echo html::a($browseLink, $lang->goback, '', 'class="btn btn-back btn-wide"'); ?> diff --git a/module/story/control.php b/module/story/control.php index 7a47d54b07..41b308aef2 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -610,7 +610,8 @@ class story extends control $users = $this->user->getPairs('pofirst|nodeleted|noclosed', "$story->assignedTo,$story->openedBy,$story->closedBy"); $isShowReviewer = true; - $reviewerList = $this->dao->select('reviewer')->from(TABLE_STORYREVIEW)->where('story')->eq($story->id)->andWhere('version')->eq($story->version)->fetchPairs('reviewer'); + $reviewerList = $this->story->getReviewerPairs($story->id, $story->version); + $reviewerList = array_keys($reviewerList); $reviewedBy = explode(',', trim($story->reviewedBy, ',')); if(!array_diff($reviewerList, $reviewedBy)) $isShowReviewer = false; @@ -835,7 +836,7 @@ class story extends control $this->app->loadLang('execution'); $story = $this->story->getById($storyID); - $reviewer = $this->dao->select('reviewer')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($story->version)->fetchAll('reviewer'); + $reviewer = $this->story->getReviewerPairs($storyID, $story->version); /* Assign. */ $this->view->title = $this->lang->story->change . "STORY" . $this->lang->colon . $this->view->story->title; @@ -908,7 +909,7 @@ class story extends control $modulePath = $this->tree->getParents($story->module); $storyModule = empty($story->module) ? '' : $this->tree->getById($story->module); $users = $this->user->getPairs('noletter'); - $reviewers = $this->dao->select('reviewer,result')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($story->version)->fetchAll('reviewer'); + $reviewers = $this->story->getReviewerPairs($storyID, $story->version); /* Set the menu. */ $from = $this->app->openApp; @@ -1012,15 +1013,8 @@ class story extends control if($changes) { - $result = $this->post->result; - $reasonParam = $result == 'reject' ? ',' . $this->post->closedReason : ''; - $story = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch(); - $reviewers = $this->dao->select('reviewer,result')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($story->version)->fetchAll('reviewer'); - $reviewedBy = explode(',', trim($story->reviewedBy, ',')); - $actionID = $this->action->create('story', $storyID, 'Reviewed', $this->post->comment, ucfirst($result) . $reasonParam); - if($story->status == 'closed') $actionID = $this->action->create('story', $storyID, 'ReviewClosed'); - if($story->status == 'active') $actionID = $this->action->create('story', $storyID, 'PassReviewed'); - if(!array_diff(array_keys($reviewers), $reviewedBy) and ($story->status == 'draft' || $story->status == 'changed')) $actionID = $this->action->create('story', $storyID, 'ClarifyReviewed'); + $story = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch(); + $actionID = $this->story->recordReviewAction($story, $this->post->result, $this->post->closedReason); $this->action->logHistory($actionID, $changes); } @@ -1028,7 +1022,6 @@ class story extends control if(isonlybody()) die(js::reload('parent.parent')); - $module = $from == 'project' ? 'projectstory' : 'story'; die(js::locate($this->createLink($module, 'view', "storyID=$storyID"), 'parent')); } @@ -1055,10 +1048,13 @@ class story extends control } /* Set the review result options. */ - $reviewers = $this->dao->select('reviewer')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($story->version)->fetchAll('reviewer'); + $reviewers = $this->story->getReviewerPairs($storyID, $story->version); $this->lang->story->resultList = $this->lang->story->reviewResultList; + if($story->status == 'draft' and $story->version == 1) unset($this->lang->story->resultList['revert']); + if($story->status == 'changed') unset($this->lang->story->resultList['reject']); + if(count($reviewers) > 1) unset($this->lang->story->resultList['revert']); $this->view->title = $this->lang->story->review . "STORY" . $this->lang->colon . $story->title; diff --git a/module/story/model.php b/module/story/model.php index 8deb4be27d..d121dc3b2c 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -409,8 +409,8 @@ class storyModel extends model $story->category = $stories->category[$i]; $story->pri = $stories->pri[$i]; $story->estimate = $stories->estimate[$i]; - $story->status = ($this->app->openApp == project || $this->app->openApp == execution ||($stories->needReview[$i] == 0 and !$forceReview)) ? 'active' : 'draft'; - $story->stage = ($this->app->openApp == project || $this->app->openApp == execution) ? 'projected' : 'wait'; + $story->status = ($this->app->openApp == project or $this->app->openApp == execution or ($stories->needReview[$i] == 0 and !$forceReview)) ? 'active' : 'draft'; + $story->stage = ($this->app->openApp == project or $this->app->openApp == execution) ? 'projected' : 'wait'; $story->keywords = $stories->keywords[$i]; $story->sourceNote = $stories->sourceNote[$i]; $story->product = $productID; @@ -633,14 +633,14 @@ class storyModel extends model unset($story->spec); unset($oldStory->spec); - $this->dao->delete()->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->andWhere('reviewer')->notin(implode(',', $_POST['reviewer']))->exec(); + if(isset($_POST['reviewer'])) $this->dao->delete()->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->andWhere('reviewer')->notin(implode(',', $_POST['reviewer']))->exec(); } /* Update the reviewer. */ - $oldReviewerList = $this->dao->select('reviewer')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->fetchPairs('reviewer'); + $oldReviewerList = $this->getReviewerPairs($storyID, $oldStory->version); foreach($_POST['reviewer'] as $reviewer) { - if(!$specChanged and in_array($reviewer, $oldReviewerList)) continue; + if(!$specChanged and in_array($reviewer, array_keys($oldReviewerList))) continue; $reviewData = new stdclass(); $reviewData->story = $storyID; @@ -808,17 +808,16 @@ class storyModel extends model if(empty($oldStory->plan) or empty($story->plan)) $this->setStage($storyID); // Set new stage for this story. } - $_POST['reviewer'] = array_filter($_POST['reviewer']); - $oldReviewer = $this->dao->select('reviewer')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->fetchAll('reviewer'); + $_POST['reviewer'] = array_filter($_POST['reviewer']); + $oldReviewer = $this->getReviewerPairs($storyID, $oldStory->version); $oldStory->reviewers = implode(',', array_keys($oldReviewer)); $story->reviewers = implode(',', $_POST['reviewer']); /* Update story reviewer. */ $this->dao->delete()->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->andWhere('reviewer')->notin(implode(',', $_POST['reviewer']))->exec(); - $existedReviewer = $this->dao->select('reviewer')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->fetchPairs('reviewer'); foreach($_POST['reviewer'] as $reviewer) { - if(in_array($reviewer, $existedReviewer)) continue; + if(in_array($reviewer, array_keys($oldReviewer))) continue; $reviewData = new stdclass(); $reviewData->story = $storyID; @@ -1192,6 +1191,7 @@ class storyModel extends model $story = fixer::input('post') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) + ->setDefault('status', $oldStory->status) ->setIF($this->post->result == 'revert', 'version', $this->post->preVersion) ->setIF($this->post->result == 'revert', 'status', 'active') ->removeIF($this->post->result != 'reject', 'closedReason, duplicateStory, childStories') @@ -1208,11 +1208,12 @@ class storyModel extends model $this->dao->update(TABLE_STORYREVIEW)->set('result')->eq($this->post->result)->set('reviewDate')->eq($now)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->andWhere('reviewer')->eq($this->app->user->account)->exec(); /* Update the story status by review rules. */ - $reviewerList = $this->dao->select('reviewer,result')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->fetchPairs('reviewer', 'result'); - $reviewedBy = explode(',', trim($story->reviewedBy, ',')); + $reviewerList = $this->getReviewerPairs($storyID, $oldStory->version); + $reviewedBy = explode(',', trim($story->reviewedBy, ',')); if(!array_diff(array_keys($reviewerList), $reviewedBy)) { - $story->status = $this->setStatusByReviewRules($reviewerList); + $status = $this->setStatusByReviewRules($reviewerList); + $story->status = $status ? $status : $oldStory->status; if($story->status == 'closed') { $story->closedBy = $this->app->user->account; @@ -1261,29 +1262,35 @@ class storyModel extends model $actions = array(); $this->loadModel('action'); - $oldStories = $this->getByList($storyIdList); + $oldStories = $this->getByList($storyIdList); + $hasResult = $this->dao->select('story,version,result')->from(TABLE_STORYREVIEW)->where('story')->in($storyIdList)->andWhere('reviewer')->eq($this->app->user->account)->andWhere('result')->ne('')->orderBy('version')->fetchAll('story'); + $reviewerList = $this->dao->select('story,reviewer,result,version')->from(TABLE_STORYREVIEW)->where('story')->in($storyIdList)->orderBy('version')->fetchGroup('story', 'reviewer'); foreach($storyIdList as $storyID) { $oldStory = $oldStories[$storyID]; if($oldStory->status != 'draft' and $oldStory->status != 'changed') continue; - $hasResult = $this->dao->select('result')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->andWhere('reviewer')->eq($this->app->user->account)->fetch('result'); - if($hasResult) continue; + if(isset($hasResult[$storyID])) continue; $story = new stdClass(); $story->reviewedDate = $now; $story->lastEditedBy = $this->app->user->account; $story->lastEditedDate = $now; $story->reviewedBy = $oldStory->reviewedBy . ',' . $this->app->user->account; + $story->status = $oldStory->status; $this->dao->update(TABLE_STORYREVIEW)->set('result')->eq($result)->set('reviewDate')->eq($now)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->andWhere('reviewer')->eq($this->app->user->account)->exec(); /* Update the story status by review rules. */ - $reviewerList = $this->dao->select('reviewer,result')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->fetchPairs('reviewer', 'result'); - $reviewedBy = explode(',', trim($story->reviewedBy, ',')); - if(!array_diff(array_keys($reviewerList), $reviewedBy)) + $reviewedBy = explode(',', trim($story->reviewedBy, ',')); + if(!array_diff(array_keys($reviewerList[$storyID]), $reviewedBy)) { - $status = $this->setStatusByReviewRules($reviewerList); + $reviewerPairs = array(); + foreach($reviewerList[$storyID] as $reviewer => $reviewInfo) $reviewerPairs[$reviewer] = $reviewInfo->result; + $reviewerPairs[$this->app->user->account] = $result; + + $status = $this->setStatusByReviewRules($reviewerPairs); $story->status = $status ? $status : $oldStory->status; + if($story->status == 'closed') { $story->closedBy = $this->app->user->account; @@ -1297,14 +1304,9 @@ class storyModel extends model $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq($storyID)->exec(); $this->setStage($storyID); - $reasonParam = $result == 'reject' ? ',' . $reason : ''; - $reviewers = $this->dao->select('reviewer,result')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($oldStory->version)->fetchAll('reviewer'); - $reviewedBy = explode(',', trim($story->reviewedBy, ',')); - $actions[$storyID] = $this->action->create('story', $storyID, 'Reviewed', '', ucfirst($result) . $reasonParam); - - if($story->status == 'closed') $this->action->create('story', $storyID, 'ReviewClosed'); - if($story->status == 'active') $this->action->create('story', $storyID, 'PassReviewed'); - if(!array_diff(array_keys($reviewers), $reviewedBy) and ($story->status == 'draft' || $story->status == 'changed')) $this->action->create('story', $storyID, 'ClarifyReviewed'); + $story->id = $storyID; + $story->version = $oldStory->version; + $actions[$storyID] = $this->recordReviewAction($story, $result, $reason); } return $actions; @@ -4220,6 +4222,19 @@ class storyModel extends model } } + /** + * Get story reviewer pairs. + * + * @param int $storyID + * @param int version + * @access public + * @return array + */ + public function getReviewerPairs($storyID, $version) + { + return $this->dao->select('reviewer,result')->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->andWhere('version')->eq($version)->fetchPairs('reviewer', 'result'); + } + /** * Set story status by review rules. * @@ -4229,6 +4244,7 @@ class storyModel extends model */ public function setStatusByReviewRules($reviewerList) { + $status = ''; $passCount = 0; $rejectCount = 0; $reviewRule = $this->config->story->reviewRules; @@ -4252,4 +4268,30 @@ class storyModel extends model return $status; } + + /** + * Record story review actions. + * + * @param object $story + * @param string $result + * @param string $reason + * @access public + * @return int + */ + public function recordReviewAction($story, $result, $reason) + { + $reasonParam = $result == 'reject' ? ',' . $reason : ''; + $reviewers = $this->getReviewerPairs($story->id, $story->version); + $reviewedBy = explode(',', trim($story->reviewedBy, ',')); + + $comment = isset($_POST['comment']) ? $this->post->comment : ''; + $actionID = $this->loadModel('action')->create('story', $story->id, 'Reviewed', $comment, ucfirst($result) . $reasonParam); + + if($story->status == 'closed') $this->action->create('story', $story->id, 'ReviewClosed'); + if($story->status == 'active') $this->action->create('story', $story->id, 'PassReviewed'); + if(!array_diff(array_keys($reviewers), $reviewedBy) and ($story->status == 'draft' || $story->status == 'changed')) $this->action->create('story', $story->id, 'ClarifyReviewed'); + + return $actionID; + } + } diff --git a/module/story/view/view.html.php b/module/story/view/view.html.php index 0304e64e90..2f38ee0ae5 100644 --- a/module/story/view/view.html.php +++ b/module/story/view/view.html.php @@ -501,7 +501,7 @@ id $case->title'>" . html::a($this->createLink('testcase', 'view', "caseID=$case->id", '', true), "[C] #$case->id $case->title") . ''; + echo "
  • " . html::a($this->createLink('testcase', 'view', "caseID=$case->id", '', true), "[C] #$case->id $case->title", '',"data-toggle='modal'") . '
  • '; } ?> diff --git a/module/testtask/control.php b/module/testtask/control.php index 755885865e..0c4a35f008 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -244,7 +244,7 @@ class testtask extends control $executions = empty($productID) ? array() : $this->loadModel('product')->getExecutionPairsByProduct($productID, 0, 'id_desc', $projectID); $builds = empty($productID) ? array() : $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk', true); - $testreports = empty($build) ? array() : $this->dao->select('id,title')->from(TABLE_TESTREPORT)->where('builds')->like('%' . $build . '%')->fetchPairs('id','title'); + $testreports = $this->testtask->getTestReportPairsByBuild($build); /* Set menu. */ $productID = $this->product->saveState($productID, $this->products); @@ -750,7 +750,7 @@ class testtask extends control $projectID = $this->lang->navGroup->testtask == 'qa' ? 0 : $this->session->project; $executions = empty($productID) ? array() : $this->product->getExecutionPairsByProduct($productID, 0, 'id_desc', $projectID); $builds = empty($productID) ? array() : $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk', true); - $testreports = $this->dao->select('id,title')->from(TABLE_TESTREPORT)->where('builds')->like('%' . $task->build . '%')->fetchPairs('id','title'); + $testreports = $this->testtask->getTestReportPairsByBuild($task->build); $this->view->task = $task; $this->view->executions = $executions; @@ -1451,7 +1451,7 @@ class testtask extends control public function ajaxGetTestReports($buildID) { /* Testreport list. */ - $pairs = $this->dao->select('id,title')->from(TABLE_TESTREPORT)->where('builds')->like('%' . $buildID . '%')->fetchPairs('id','title'); + $pairs = $this->testtask->getTestReportPairsByBuild($buildID); die(html::select('testreport', $pairs, '', "class='form-control chosen'")); } } diff --git a/module/testtask/model.php b/module/testtask/model.php index 075602b660..f9ef55c25e 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -492,6 +492,20 @@ class testtaskModel extends model ->fetchAll(); } + /** + * Get test report pairs by build. + * + * @param string $build + * @access public + * @return array + */ + public function getTestReportPairsByBuild($build = '') + { + if(empty($build)) return array(); + + return $this->dao->select('id,title')->from(TABLE_TESTREPORT)->where("CONCAT(',', builds, ',')")->like("%,$build,%")->fetchPairs('id','title'); + } + /** * Get related test tasks. * diff --git a/module/testtask/view/browse.html.php b/module/testtask/view/browse.html.php index a2beb118cd..47294aecae 100644 --- a/module/testtask/view/browse.html.php +++ b/module/testtask/view/browse.html.php @@ -105,9 +105,9 @@ $status = $this->session->testTaskVersionStatus; echo '
    '; common::printIcon('testtask', 'cases', "taskID=$task->id", $task, 'list', 'sitemap'); common::printIcon('testtask', 'linkCase', "taskID=$task->id&type=all¶m=myQueryID", $task, 'list', 'link'); - common::printIcon('testreport', 'browse', "objectID=$task->product&objectType=product&extra=$task->id", $task, 'list','flag'); + common::printIcon('testreport', 'browse', "objectID=$task->product&objectType=product&extra=$task->id", $task, 'list', 'flag'); echo '
    '; - common::printIcon('testtask', 'view', "taskID=$task->id", '', 'list', 'list-alt','','iframe',true, "data-width='90%'"); + common::printIcon('testtask', 'view', "taskID=$task->id", '', 'list', 'list-alt', '', 'iframe', true, "data-width='90%'"); common::printIcon('testtask', 'edit', "taskID=$task->id", $task, 'list'); if(common::hasPriv('testtask', 'delete', $task)) { diff --git a/module/testtask/view/edit.html.php b/module/testtask/view/edit.html.php index 888e3ae0c3..73ddc6c136 100644 --- a/module/testtask/view/edit.html.php +++ b/module/testtask/view/edit.html.php @@ -36,7 +36,7 @@ testtask->build;?> - build, "class='form-control chosen'");?> + build, "class='form-control chosen' onchange='loadTestReports(this.value)'");?> diff --git a/module/todo/config.php b/module/todo/config.php index 70433368b4..91e5d79ecf 100644 --- a/module/todo/config.php +++ b/module/todo/config.php @@ -27,11 +27,16 @@ $config->todo->custom = new stdclass(); $config->todo->custom->batchCreateFields = 'type,pri,desc,beginAndEnd'; $config->todo->custom->batchEditFields = 'pri,beginAndEnd,status'; -$config->todo->moduleList = array('bug', 'task', 'story', 'review', 'testtask'); +$config->todo->moduleList = array('bug', 'task', 'story', 'testtask'); $config->todo->getUserObjectsMethod = array(); $config->todo->getUserObjectsMethod['bug'] = 'ajaxGetUserBugs'; $config->todo->getUserObjectsMethod['task'] = 'ajaxGetUserTasks'; $config->todo->getUserObjectsMethod['story'] = 'ajaxGetUserStories'; $config->todo->getUserObjectsMethod['testtask'] = 'ajaxGetUserTestTasks'; -$config->todo->getUserObjectsMethod['review'] = 'ajaxGetUserReviews'; + +$config->todo->objectList = array(); +$config->todo->objectList['bug'] = 'bugs'; +$config->todo->objectList['task'] = 'tasks'; +$config->todo->objectList['story'] = 'stories'; +$config->todo->objectList['testtask'] = 'testtasks'; diff --git a/module/todo/control.php b/module/todo/control.php index 8072fff7b3..e938ff903e 100644 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -24,7 +24,6 @@ class todo extends control $this->loadModel('task'); $this->loadModel('bug'); $this->loadModel('my')->setMenu(); - if(!isset($this->config->qcVersion)) unset($this->lang->todo->typeList['review']); } /** @@ -194,6 +193,7 @@ class todo extends control $bugs = $this->bug->getUserBugPairs($account); $tasks = $this->task->getUserTaskPairs($account, $status); $storys = $this->loadModel('story')->getUserStoryPairs($account); + if(isset($this->config->bizVersion) or isset($this->config->maxVersion)) $this->view->feedbacks = $this->loadModel('feedback')->getUserFeedbackPairs($account); if(isset($this->config->maxVersion)) { $issues = $this->loadModel('issue')->getUserIssuePairs($account); @@ -203,7 +203,7 @@ class todo extends control $testtasks = $this->loadModel('testtask')->getUserTestTaskPairs($account); $reviews = array(); - if(isset($this->config->qcVersion)) $reviews = $this->loadModel('review')->getUserReviewPairs($account); + if(isset($this->config->qcVersion) or isset($this->config->maxVersion)) $reviews = $this->loadModel('review')->getUserReviewPairs($account); $allTodos = $this->todo->getList($type, $account, $status); if($this->post->todoIDList) $todoIDList = $this->post->todoIDList; diff --git a/module/todo/lang/de.php b/module/todo/lang/de.php index 26dffdeb3c..7d1eb36eaa 100644 --- a/module/todo/lang/de.php +++ b/module/todo/lang/de.php @@ -97,7 +97,6 @@ $lang->todo->typeList['cycle'] = 'Wiederkehrend'; $lang->todo->typeList['bug'] = 'Bug'; $lang->todo->typeList['task'] = 'Aufgabe'; $lang->todo->typeList['story'] = 'Story'; -$lang->todo->typeList['review'] = 'Review'; $lang->todo->typeList['testtask'] = 'Testtask'; $lang->todo->confirmDelete = "Möchten Sie diesen ToDo löschen?"; diff --git a/module/todo/lang/en.php b/module/todo/lang/en.php index 15fa7ac310..2028431127 100644 --- a/module/todo/lang/en.php +++ b/module/todo/lang/en.php @@ -98,7 +98,6 @@ $lang->todo->typeList['cycle'] = 'Recur'; $lang->todo->typeList['bug'] = 'Bug'; $lang->todo->typeList['task'] = 'Task'; $lang->todo->typeList['story'] = 'Story'; -$lang->todo->typeList['review'] = 'Review'; $lang->todo->typeList['testtask'] = 'Testtask'; $lang->todo->confirmDelete = "Do you want to delete this todo?"; diff --git a/module/todo/lang/fr.php b/module/todo/lang/fr.php index 89ccead940..dbd582426a 100644 --- a/module/todo/lang/fr.php +++ b/module/todo/lang/fr.php @@ -97,7 +97,6 @@ $lang->todo->typeList['cycle'] = 'Récur'; $lang->todo->typeList['bug'] = 'Bug'; $lang->todo->typeList['task'] = 'Tâche'; $lang->todo->typeList['story'] = 'Story'; -$lang->todo->typeList['review'] = 'Review'; $lang->todo->typeList['testtask'] = 'Testtask'; $lang->todo->confirmDelete = "Voulez-vous supprimer cette entrée de l'agenda ?"; diff --git a/module/todo/lang/vi.php b/module/todo/lang/vi.php index 7230793679..9a3a86806d 100644 --- a/module/todo/lang/vi.php +++ b/module/todo/lang/vi.php @@ -97,7 +97,6 @@ $lang->todo->typeList['cycle'] = 'Lặp lại'; $lang->todo->typeList['bug'] = 'Bug'; $lang->todo->typeList['task'] = 'Nhiệm vụ'; $lang->todo->typeList['story'] = 'Câu chuyện'; -$lang->todo->typeList['review'] = 'Review'; $lang->todo->typeList['testtask'] = 'Testtask'; $lang->todo->confirmDelete = "Bạn có muốn xóa việc này?"; diff --git a/module/todo/lang/zh-cn.php b/module/todo/lang/zh-cn.php index 29a5f6b1c2..6121619b1d 100644 --- a/module/todo/lang/zh-cn.php +++ b/module/todo/lang/zh-cn.php @@ -98,7 +98,6 @@ $lang->todo->typeList['cycle'] = '周期'; $lang->todo->typeList['bug'] = 'Bug'; $lang->todo->typeList['task'] = '任务'; $lang->todo->typeList['story'] = $lang->SRCommon; -$lang->todo->typeList['review'] = '评审'; $lang->todo->typeList['testtask'] = '测试单'; $lang->todo->confirmDelete = "您确定要删除这条待办吗?"; diff --git a/module/todo/model.php b/module/todo/model.php index 67dd7b7327..d3aca615f3 100644 --- a/module/todo/model.php +++ b/module/todo/model.php @@ -39,44 +39,9 @@ class todoModel extends model ->remove(implode(',', $this->config->todo->moduleList) . ',uid') ->get(); - if(!isset($todo->pri)) + if(!isset($todo->pri) and in_array($this->post->type, $this->config->todo->moduleList) and $this->post->type !== 'review') { - if($this->post->type == 'task') - { - $todo->pri = $this->dao->select('pri')->from(TABLE_TASK)->where('id')->eq($this->post->idvalue)->fetch('pri'); - } - elseif($this->post->type == 'bug') - { - $todo->pri = $this->dao->select('pri')->from(TABLE_BUG)->where('id')->eq($this->post->idvalue)->fetch('pri'); - } - elseif($this->post->type == 'story') - { - $todo->pri = $this->dao->select('pri')->from(TABLE_STORY)->where('id')->eq($this->post->idvalue)->fetch('pri'); - } - elseif($this->post->type == 'testtask') - { - $todo->pri = $this->dao->select('pri')->from(TABLE_TESTTASK)->where('id')->eq($this->post->idvalue)->fetch('pri'); - } - elseif($this->post->type == 'issue' and isset($this->config->maxVersion)) - { - $todo->pri = $this->dao->select('pri')->from(TABLE_ISSUE)->where('id')->eq($this->post->idvalue)->fetch('pri'); - } - elseif($this->post->type == 'risk' and isset($this->config->maxVersion)) - { - $todo->pri = $this->dao->select('pri')->from(TABLE_RISK)->where('id')->eq($this->post->idvalue)->fetch('pri'); - } - elseif($this->post->type == 'review' and isset($this->config->maxVersion)) - { - $todo->pri = $this->dao->select('pri')->from(TABLE_REVIEW)->where('id')->eq($this->post->idvalue)->fetch('pri'); - } - elseif($this->post->type == 'feedback' and isset($this->config->maxVersion)) - { - $todo->pri = $this->dao->select('pri')->from(TABLE_FEEDBACK)->where('id')->eq($this->post->idvalue)->fetch('pri'); - } - elseif($this->post->type == 'opportunity' and isset($this->config->maxVersion)) - { - $todo->pri = $this->dao->select('pri')->from(TABLE_OPPORTUNITY)->where('id')->eq($this->post->idvalue)->fetch('pri'); - } + $todo->pri = $this->dao->select('pri')->from($this->config->objectTables[$this->post->type])->where('id')->eq($this->post->idvalue)->fetch('pri'); if($todo->pri == 'high') $todo->pri = 1; if($todo->pri == 'middle') $todo->pri = 2; @@ -155,7 +120,17 @@ class todoModel extends model $validTodos = array(); for($i = 0; $i < $this->config->todo->batchCreate; $i++) { - if($todos->names[$i] != '' || isset($todos->bugs[$i + 1]) || isset($todos->tasks[$i + 1]) || isset($todos->stories[$i + 1]) || isset($todos->issues[$i + 1]) || isset($todos->risks[$i + 1]) || isset($todos->reviews[$i + 1]) || isset($todos->testtasks[$i + 1]) || isset($todos->opportunities[$i + 1])) + $isExist = false; + foreach($this->config->todo->objectList as $objects) + { + if(isset($todos->{$objects}[$i + 1])) + { + $isExist = true; + break; + } + } + + if($todos->names[$i] != '' || $isExist) { $todo = new stdclass(); $todo->account = $this->app->user->account; @@ -178,14 +153,7 @@ class todoModel extends model $todo->private = 0; $todo->idvalue = 0; - if($todo->type == 'bug') $todo->idvalue = isset($todos->bugs[$i + 1]) ? $todos->bugs[$i + 1] : 0; - if($todo->type == 'task') $todo->idvalue = isset($todos->tasks[$i + 1]) ? $todos->tasks[$i + 1] : 0; - if($todo->type == 'story') $todo->idvalue = isset($todos->stories[$i + 1]) ? $todos->stories[$i + 1] : 0; - if($todo->type == 'issue') $todo->idvalue = isset($todos->issues[$i + 1]) ? $todos->issues[$i + 1] : 0; - if($todo->type == 'risk') $todo->idvalue = isset($todos->risks[$i + 1]) ? $todos->risks[$i + 1] : 0; - if($todo->type == 'opportunity') $todo->idvalue = isset($todos->opportunities[$i + 1]) ? $todos->opportunities[$i + 1] : 0; - if($todo->type == 'review') $todo->idvalue = isset($todos->reviews[$i + 1]) ? $todos->reviews[$i + 1] : 0; - if($todo->type == 'testtask') $todo->idvalue = isset($todos->testtasks[$i + 1]) ? $todos->testtasks[$i + 1] : 0; + if(in_array($todo->type, $this->config->todo->moduleList)) $todo->idvalue = isset($todos->{$this->config->todo->objectList[$todo->type]}[$i + 1]) ? $todos->{$this->config->todo->objectList[$todo->type]}[$i + 1] : 0; if($todo->type != 'custom' and $todo->idvalue) { @@ -329,16 +297,11 @@ class todoModel extends model $todo->name = ($todo->type == 'custom' or $todo->type == 'cycle' or $todo->type == 'feedback') ? $data->names[$todoID] : ''; $todo->begin = isset($data->begins[$todoID]) ? $data->begins[$todoID] : 2400; $todo->end = isset($data->ends[$todoID]) ? $data->ends[$todoID] : 2400; - if($todo->type == 'task') $todo->idvalue = isset($data->tasks[$todoID]) ? $data->tasks[$todoID] : 0; - if($todo->type == 'bug') $todo->idvalue = isset($data->bugs[$todoID]) ? $data->bugs[$todoID] : 0; - if($todo->type == 'story') $todo->idvalue = isset($data->storys[$todoID]) ? $data->storys[$todoID] : 0; - if($todo->type == 'issue') $todo->idvalue = isset($data->issues[$todoID]) ? $data->issues[$todoID] : 0; - if($todo->type == 'risk') $todo->idvalue = isset($data->risks[$todoID]) ? $data->risks[$todoID] : 0; - if($todo->type == 'opportunity') $todo->idvalue = isset($data->opportunities[$todoID]) ? $data->opportunities[$todoID] : 0; - if($todo->type == 'review') $todo->idvalue = isset($data->reviews[$todoID]) ? $data->reviews[$todoID] : 0; - if($todo->type == 'testtask') $todo->idvalue = isset($data->testtasks[$todoID]) ? $data->testtasks[$todoID] : 0; - if($todo->type == 'feedback') $todo->idvalue = isset($data->feedbacks[$todoID]) ? $data->feedbacks[$todoID] : 0; + if(in_array($todo->type, $this->config->todo->moduleList)) + { + $todo->idvalue = isset($data->{$this->config->todo->objectList[$todo->type]}[$todoID]) ? $data->{$this->config->todo->objectList[$todo->type]}[$todoID] : 0; + } if($todo->end < $todo->begin) die(js::alert(sprintf($this->lang->error->gt, $this->lang->todo->end, $this->lang->todo->begin))); $todos[$todoID] = $todo; diff --git a/module/todo/view/batchedit.html.php b/module/todo/view/batchedit.html.php index 2786648b85..e3efe5ad05 100644 --- a/module/todo/view/batchedit.html.php +++ b/module/todo/view/batchedit.html.php @@ -73,11 +73,6 @@ { echo html::input("names[$todo->id]", $todo->name, "class='form-control'"); } - elseif($todo->type == 'feedback') - { - echo html::input("names[$todo->id]", $todo->name, "class='form-control'"); - echo html::hidden("feedbacks[$todo->id]", $todo->idvalue, "class='form-control'"); - } elseif($todo->type == 'task') { echo html::select("tasks[$todo->id]", $tasks, $todo->idvalue, 'class="form-control chosen"'); @@ -88,7 +83,7 @@ } elseif($todo->type == 'story') { - echo html::select("storys[$todo->id]", $storys, $todo->idvalue, 'class="form-control chosen"'); + echo html::select("stories[$todo->id]", $storys, $todo->idvalue, 'class="form-control chosen"'); } elseif($todo->type == 'issue') { @@ -110,6 +105,10 @@ { echo html::select("opportunities[$todo->id]", $opportunities, $todo->idvalue, 'class="form-control chosen"'); } + elseif($todo->type == 'feedback') + { + echo html::select("feedbacks[$todo->id]", $feedbacks, $todo->idvalue, 'class="form-control chosen"'); + } ?> diff --git a/module/upgrade/model.php b/module/upgrade/model.php index e52594786d..b51ce64e1b 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -672,7 +672,6 @@ class upgradeModel extends model case '15_0': $this->saveLogs('Execute 15_0'); $this->execSQL($this->getUpgradeFile('15.0')); - $this->updateProjectLifeTime(); $this->adjustBugOfProject(); $this->processBuildTable(); $this->appendExec('15_0'); @@ -4967,19 +4966,6 @@ class upgradeModel extends model return true; } - /** - * Update the lifetime field default value of the zt_project table. - * - * @access public - * @return bool - */ - public function updateProjectLifeTime() - { - $this->dao->update(TABLE_PROJECT)->set('lifetime')->eq('')->where('lifetime')->eq('sprint')->exec(); - - return true; - } - /** * Update the createdVersion field of the zt_product table. *