diff --git a/module/execution/control.php b/module/execution/control.php index b347f3f0c7..f3b5ec6af4 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1045,6 +1045,9 @@ class execution extends control */ public function create(int $projectID = 0, int $executionID = 0, int $copyExecutionID = 0, int $planID = 0, string $confirm = 'no', int $productID = 0, string $extra = '') { + $project = empty($projectID) ? null : $this->loadModel('project')->fetchByID($projectID); + if(!empty($project->isTpl)) define('AUTOTPL', false); + if($this->app->tab == 'doc') unset($this->lang->doc->menu->execution['subMenu']); if($this->app->tab == 'project') $this->project->setMenu($projectID); diff --git a/module/execution/model.php b/module/execution/model.php index 0f9d44910d..8121b47177 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -150,6 +150,7 @@ class executionModel extends model /* 模板执行不显示1.5级导航。 */ $this->config->hasDropmenuApps = array_diff($this->config->hasDropmenuApps, array('project', 'execution')); + $this->lang->switcherMenu = ''; unset($this->lang->execution->menu->kanban); unset($this->lang->execution->menu->burn); @@ -239,9 +240,9 @@ class executionModel extends model } /* 项目模板不校验访问权限。 */ - $isTpl = $this->dao->select('isTpl')->from(TABLE_EXECUTION)->where('id')->eq($executionID)->fetch('isTpl'); + $isTpl = $this->dao->select('isTpl')->from(TABLE_EXECUTION)->where('id')->eq($executionID)->andWhere('id')->in($this->app->user->view->sprints)->fetch('isTpl'); /* If the execution doesn't exist in the list, use the first execution in the list. */ - if(!$isTpl && !isset($executions[$executionID])) + if(empty($isTpl) && !isset($executions[$executionID])) { /* Check execution. */ if($executionID) @@ -1482,7 +1483,7 @@ class executionModel extends model { /* Construct the query SQL at search executions. */ $executionQuery = $browseType == 'bySearch' ? $this->getExecutionQuery($param) : ''; - if($projectID) $project = $this->dao->select('model,isTpl')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch(); + $projectModel = $this->dao->select('model')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch('model'); return $this->dao->select('t1.*,t2.name projectName, t2.model as projectModel')->from(TABLE_EXECUTION)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') @@ -1491,9 +1492,8 @@ class executionModel extends model ->andWhere('t1.deleted')->eq('0') ->andWhere('t1.vision')->eq($this->config->vision) ->andWhere('t1.multiple')->eq('1') - ->beginIF(!empty($project->isTpl))->andWhere('t1.isTpl')->eq('1')->fi() - ->beginIF(!empty($project->model) && $project->model == 'ipd')->andWhere('t1.enabled')->eq('on')->fi() - ->beginIF(!$this->app->user->admin && empty($project->isTpl))->andWhere('t1.id')->in($this->app->user->view->sprints)->fi() + ->beginIF($projectModel == 'ipd')->andWhere('t1.enabled')->eq('on')->fi() + ->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->sprints)->fi() ->beginIF(!empty($executionQuery))->andWhere($executionQuery)->fi() ->beginIF($productID)->andWhere('t3.product')->eq($productID)->fi() ->beginIF($projectID)->andWhere('t1.project')->eq($projectID)->fi() diff --git a/module/execution/test/model/checkaccess.php b/module/execution/test/model/checkaccess.php index 44ddc79b0c..bc1cbeb1e6 100755 --- a/module/execution/test/model/checkaccess.php +++ b/module/execution/test/model/checkaccess.php @@ -12,13 +12,20 @@ title=测试 executionModel::checkAccess; timeout=0 cid=1 +- 不传入ID @101 +- 传入存在ID的值 @106 +- 不传入ID,读取session信息 @101 +- 传入不存在的ID @101 +- 传入不存在的ID @101 + */ $executions = array(101 => 101, 102 => 102, 106 => 106); -$idList = array(0, 106, 110); +$idList = array(0, 106, 110, 120); $executionTester = new executionTest(); r($executionTester->checkAccessTest($idList[0], $executions)) && p() && e('101'); //不传入ID r($executionTester->checkAccessTest($idList[1], $executions)) && p() && e('106'); //传入存在ID的值 r($executionTester->checkAccessTest($idList[0], $executions)) && p() && e('101'); //不传入ID,读取session信息 r($executionTester->checkAccessTest($idList[2], $executions)) && p() && e('101'); //传入不存在的ID +r($executionTester->checkAccessTest($idList[3], $executions)) && p() && e('101'); //传入不存在的ID diff --git a/module/execution/zen.php b/module/execution/zen.php index e7931f610a..ce6bab3272 100644 --- a/module/execution/zen.php +++ b/module/execution/zen.php @@ -950,6 +950,7 @@ class executionZen extends execution ->setDefault('type', $type) ->setDefault('team', $this->post->name) ->setDefault('parent', $this->post->project) + ->setDefault('isTpl', $project->isTpl) ->setIF($this->post->parent, 'parent', $this->post->parent) ->setIF($this->post->heightType == 'auto', 'displayCards', 0) ->setIF($this->post->acl == 'open', 'whitelist', '') @@ -2278,6 +2279,8 @@ class executionZen extends execution if($this->app->tab == 'project') return $this->config->vision != 'lite' ? $this->createLink('project', 'index', "projectID=$projectID") : $this->createLink('project', 'execution', "status=all&projectID=$projectID"); return inlink('kanban', "executionID=$executionID"); } + $execution = $this->execution->fetchByID($executionID); + if(!empty($execution->isTpl)) return inlink('task', "executionID=$executionID"); return inlink('create', "projectID=$projectID&executionID=$executionID"); } diff --git a/module/programplan/zen.php b/module/programplan/zen.php index 98e0e7c8df..b14ba0d9af 100644 --- a/module/programplan/zen.php +++ b/module/programplan/zen.php @@ -86,6 +86,7 @@ class programplanZen extends programplan $plan->order = (int)array_shift($orders); $plan->hasProduct = $project->hasProduct; $plan->parent = $parentID ? $parentID : $projectID; + $plan->isTpl = $project->isTpl; if($plan->id && isset($oldPlans[$plan->id])) $plan->parent = $oldPlans[$plan->id]->parent; if(!empty($plan->percent) && $plan->type != 'stage') $plan->percent = 0; // 非阶段类型,工作量占比为0 diff --git a/module/project/model.php b/module/project/model.php index 31eec0d3c0..fc84dbdbc5 100755 --- a/module/project/model.php +++ b/module/project/model.php @@ -218,8 +218,8 @@ class projectModel extends model } /* 项目模板不校验访问权限。 */ - $isTpl = $this->dao->select('isTpl')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch('isTpl'); - if(!$isTpl && !isset($projects[$projectID])) + $isTpl = $this->dao->select('isTpl')->from(TABLE_PROJECT)->where('id')->eq($projectID)->andWhere('id')->in($this->app->user->view->projects)->fetch('isTpl'); + if(empty($isTpl) && !isset($projects[$projectID])) { if($projectID && strpos(",{$this->app->user->view->projects},", ",{$projectID},") === false && !empty($projects)) { diff --git a/module/project/test/model/checkaccess.php b/module/project/test/model/checkaccess.php index b811532c9e..6ee1d38747 100755 --- a/module/project/test/model/checkaccess.php +++ b/module/project/test/model/checkaccess.php @@ -11,14 +11,21 @@ title=测试 programModel::checkAccess; timeout=0 cid=1 +- 不传入ID @10 +- 传入存在ID的值 @11 +- 不传入ID,读取session信息 @11 +- 传入正确的ID @14 +- 传入不存在的ID @0 + */ global $tester; $tester->loadModel('project'); $projects = array(10 => 10, 11 => 11, 14 => 14); -$idList = array(0, 11, 14); +$idList = array(0, 11, 14, 16); r($tester->project->checkAccess($idList[0], $projects)) && p() && e('10'); //不传入ID r($tester->project->checkAccess($idList[1], $projects)) && p() && e('11'); //传入存在ID的值 r($tester->project->checkAccess($idList[0], $projects)) && p() && e('11'); //不传入ID,读取session信息 r($tester->project->checkAccess($idList[2], $projects)) && p() && e('14'); //传入正确的ID +r($tester->project->checkAccess($idList[3], $projects)) && p() && e('0'); //传入不存在的ID diff --git a/module/task/zen.php b/module/task/zen.php index d1e0b165aa..36f5444929 100644 --- a/module/task/zen.php +++ b/module/task/zen.php @@ -699,6 +699,7 @@ class taskZen extends task $task = form::data($formConfig)->setDefault('execution', $executionID) ->setDefault('project', $execution->project) ->setDefault('left', 0) + ->setDefault('isTpl', $execution->isTpl) ->setIF($this->post->estimate, 'left', $this->post->estimate) ->setIF($this->post->mode, 'mode', $this->post->mode) ->setIF($this->post->story, 'storyVersion', $this->post->story ? $this->loadModel('story')->getVersion((int)$this->post->story) : 1)