From 7cbb6731e9d4a47a51231ae55187a36660b096fb Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Mon, 15 Mar 2021 11:09:26 +0800 Subject: [PATCH] * Remove duplicate codes. --- module/execution/model.php | 4 +--- module/testcase/model.php | 37 +++---------------------------------- 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index 3448870df4..347680aafc 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2061,11 +2061,10 @@ class executionModel extends model * @param int $executionID * @param int $productID * @param int $storyID - * @param string $type * @access public * @return void */ - public function linkCases($executionID, $productID, $storyID, $type = '') + public function linkCases($executionID, $productID, $storyID) { $this->loadModel('action'); $linkedCases = $this->dao->select('*')->from(TABLE_PROJECTCASE)->where('project')->eq($executionID)->orderBy('order_desc')->fetchPairs('case', 'order'); @@ -2085,7 +2084,6 @@ class executionModel extends model $this->dao->insert(TABLE_PROJECTCASE)->data($object)->exec(); $action = $executionID == $this->session->PRJ ? 'linked2project' : 'linked2execution'; - if($type) $action = $type == 'project' ? 'linked2project' : 'linked2execution'; $this->action->create('case', $caseID, $action, '', $executionID); } diff --git a/module/testcase/model.php b/module/testcase/model.php index e42ef90d2a..29431acd0c 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -675,7 +675,6 @@ class testcaseModel extends model ->andWhere('`case`')->eq($oldCase->id) ->exec(); } - } } @@ -719,36 +718,6 @@ class testcaseModel extends model } } - /* Process the project and execute the use case. */ - if($case->story != $oldCase->story) - { - $this->loadModel('action'); - $oldProjects = $this->dao->select('t1.project,t2.type')->from(TABLE_PROJECTSTORY)->alias('t1') - ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id') - ->where('t1.story')->eq($oldCase->story) - ->fetchPairs(); - - foreach($oldProjects as $id => $type) - { - $this->dao->delete()->from(TABLE_PROJECTCASE)->where('project')->eq($id)->andWhere('`case`')->eq($caseID)->exec(); - $action = $type == 'project' ? 'unlinkedfromproject' : 'unlinkedfromexecution'; - $this->action->create('case', $caseID, $action, '', $executionID); - } - - if($case->story != 0) - { - $this->loadModel('execution'); - $projects = $this->dao->select('t1.project,t2.type')->from(TABLE_PROJECTSTORY)->alias('t1') - ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id') - ->where('t1.story')->eq($case->story) - ->fetchPairs(); - - foreach($projects as $id => $type) - { - $this->execution->linkCases($id, $case->product, $case->story, $type); - } - } - } /* Join the steps to diff. */ if($stepChanged and $this->post->steps) @@ -1705,8 +1674,8 @@ class testcaseModel extends model /** * Sync case to project. - * - * @param object $case + * + * @param object $case * @param int $caseID * @access public * @return void @@ -1718,7 +1687,7 @@ class testcaseModel extends model $projects = $this->dao->select('project')->from(TABLE_PROJECTSTORY)->where('story')->eq($case->story)->fetchAll('project'); $projects = array_keys($projects); } - elseif($this->lang->navGroup->testcase == 'project' and empty($case->story)) + elseif($this->lang->navGroup->testcase == 'project' and empty($case->story)) { $projects = array($this->session->PRJ); }