diff --git a/module/execution/model.php b/module/execution/model.php index daa498aaba..e511cf7b1a 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2112,22 +2112,22 @@ class executionModel extends model } /** - * Get related executions + * 获取执行关联的产品下的执行列表。 + * Get related executions. * * @param int $executionID * @access public * @return array */ - public function getRelatedExecutions($executionID) + public function getRelatedExecutions(int $executionID): array { $products = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->eq((int)$executionID)->fetchAll('product'); - // $products = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->fetchAll('product'); if(!$products) return array(); - $products = array_keys($products); + return $this->dao->select('t1.id, t1.name')->from(TABLE_EXECUTION)->alias('t1') ->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2') ->on('t1.id = t2.project') - ->where('t2.product')->in($products) + ->where('t2.product')->in(array_keys($products)) ->andWhere('t1.id')->ne((int)$executionID) ->andWhere('t1.deleted')->eq(0) ->orderBy('t1.id') @@ -2153,7 +2153,8 @@ class executionModel extends model } /** - * Check the privilege. + * 获取受限执行id并保存到session中。 + * Get limited execution id and save it to session. * * @access public * @return bool|string @@ -2171,8 +2172,8 @@ class executionModel extends model ->orderBy('root asc') ->fetchPairs('root', 'root'); - $_SESSION['limitedExecutions'] = implode(',', $executions); - return $_SESSION['limitedExecutions']; + $this->session->set('limitedExecutions', implode(',', $executions)); + return $this->session->limitedExecutions; } /** diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index 46d694063c..de416f0838 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -920,8 +920,7 @@ class executionTest */ public function getLimitedExecutionTest() { - $this->executionModel->getProductGroupList(); - return isset($_SESSION['limitedExecutions']) ? $_SESSION['limitedExecutions'] : true; + return $this->executionModel->getLimitedExecution(); } /** diff --git a/module/execution/test/model/getlimitedexecution.php b/module/execution/test/model/getlimitedexecution.php index c713a2fd3f..9707e993c5 100755 --- a/module/execution/test/model/getlimitedexecution.php +++ b/module/execution/test/model/getlimitedexecution.php @@ -2,18 +2,28 @@ config('execution')->gen(10); +zdTable('user')->gen(5); + +$team = zdTable('team'); +$team->type->range('execution'); +$team->root->range('101-103'); +$team->gen(10); + +su('admin'); /** title=测试 executionModel->getLimitedExecution(); +timeout=0 cid=1 -pid=1 - -获取所有受限制的执行ID >> 1 */ -$execution = new executionTest(); +global $app; -r($execution->getLimitedExecutionTest()) && p() && e('1'); // 获取所有受限制的执行ID +$execution = new executionTest(); +r($execution->getLimitedExecutionTest()) && p() && e('1'); // 判断管理员 + +su('user4'); +r($execution->getLimitedExecutionTest()) && p() && e('103'); // 判断非管理员 diff --git a/module/execution/test/model/getrelatedexecutions.php b/module/execution/test/model/getrelatedexecutions.php index f7d320a001..ddadf0942e 100755 --- a/module/execution/test/model/getrelatedexecutions.php +++ b/module/execution/test/model/getrelatedexecutions.php @@ -37,15 +37,8 @@ su('admin'); /** title=测试executionModel->getRelatedExecutionsTest(); +timeout=0 cid=1 -pid=1 - -查询敏捷执行关联查询 >> 项目1 -查询瀑布执行关联查询 >> 项目3 -查询看板执行关联查询 >> 项目2 -查询敏捷执行关联统计 >> 2 -查询瀑布执行关联统计 >> 3 -查询看板执行关联统计 >> 2 */