diff --git a/lib/base/dao/dao.class.php b/lib/base/dao/dao.class.php index 561a7e434b..58e7b792b4 100644 --- a/lib/base/dao/dao.class.php +++ b/lib/base/dao/dao.class.php @@ -163,6 +163,15 @@ class baseDAO */ public $autoLang; + /** + * 是否自动增加isTpl条件。 + * If auto add isTpl statement. + * + * @var bool + * @access public + */ + public $autoTpl; + /** * 是否自动过滤模板数据。 * If auto filter template data. @@ -253,7 +262,6 @@ class baseDAO $this->dbh = $dbh; $this->cache = $app->cache; $this->slaveDBH = $slaveDBH ? $slaveDBH : false; - $this->filterTpl(true); $this->reset(); } @@ -313,6 +321,20 @@ class baseDAO /** * 设置是否过滤模板数据。 + * Set autoTpl item. + * + * @param bool $autoTpl + * @access public + * @return void + */ + public function setAutoTpl($autoTpl) + { + $this->autoTpl = $autoTpl; + return $this; + } + + /** + * 设置是否全局过滤模板数据。 * Set if filter template data. * * @param bool $filterTpl @@ -340,6 +362,7 @@ class baseDAO $this->setMode(''); $this->setMethod(''); $this->setAutoLang(isset($this->config->framework->autoLang) and $this->config->framework->autoLang); + $this->setAutoTpl(true); } //-----根据请求的方式,调用sql类相应的方法(Call according method of sql class by query method. -----// @@ -844,6 +867,7 @@ class baseDAO * 处理sql语句,替换表和字段。 * Process the sql, replace the table, fields. * + * @param string $setIsTpl * @access public * @return string the sql string after process. */ @@ -882,7 +906,7 @@ class baseDAO $sql .= '(`' . implode('`,`', array_keys($values)) . '`)' . ' VALUES(' . implode(',', $values) . ')'; } - elseif($this->method == 'select' && dao::$filterTpl) + elseif($this->method == 'select' && dao::$filterTpl && $this->autoTpl) { /* 过滤模板类型的数据 */ foreach(array('project', 'task') as $table) @@ -1292,7 +1316,7 @@ class baseDAO */ public function fetch($field = '') { - dao::$filterTpl = false; // 获取单个记录时,不过滤模板数据。 + $this->setAutoTpl(false); $sql = $this->processSQL(); $key = $this->createCacheKey('fetch', md5($sql)); diff --git a/module/doc/model.php b/module/doc/model.php index ec02f17058..a6e9230989 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1411,7 +1411,7 @@ class docModel extends model } if($type == 'project') { - $projects = $this->loadModel('project')->getListByCurrentUser('*', false); + $projects = $this->loadModel('project')->getListByCurrentUser('*'); $involvedProjects = $this->project->getInvolvedListByCurrentUser(); $spaceID = $this->project->checkAccess($spaceID, $projects); diff --git a/module/execution/model.php b/module/execution/model.php index 072dab3d84..d296b65654 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -591,7 +591,7 @@ class executionModel extends model public function batchChangeStatus(array $executionIdList, string $status): array { /* Sort the IDs, the child stage comes first, and the parent stage follows. */ - $executionList = $this->dao->select('id,name,status,grade,deliverable')->from(TABLE_EXECUTION)->where('id')->in($executionIdList)->filterTpl(false)->orderBy('grade_desc')->fetchAll('id'); + $executionList = $this->dao->select('id,name,status,grade,deliverable')->from(TABLE_EXECUTION)->where('id')->in($executionIdList)->orderBy('grade_desc')->fetchAll('id'); $this->loadModel('programplan'); $message = array('byChild' => '', 'byDeliverable' => ''); diff --git a/module/execution/test/model/batchchangestatus.php b/module/execution/test/model/batchchangestatus.php index ea15e585a1..afb2a81e76 100755 --- a/module/execution/test/model/batchchangestatus.php +++ b/module/execution/test/model/batchchangestatus.php @@ -24,15 +24,17 @@ title=测试executionModel->batchChangeStatus(); cid=1 pid=1 -测试批量修改执行状态为进行中 >> empty -测试批量修改执行状态为未开始 >> empty -测试批量修改执行状态为已挂起 >> empty -测试批量修改执行状态为已关闭 >> '阶段a子1' +- 测试批量修改执行状态为进行中属性byChild @'阶段a子1' +- 测试批量修改执行状态为未开始属性byChild @~~ +- 测试批量修改执行状态为已挂起属性byChild @~~ +- 测试批量修改执行状态为已关闭属性byChild @N/A +- 测试批量修改执行状态为未开始属性byChild @N/A */ $execution = new executionTest(); -r($execution->batchChangeStatusObject(array(4), 'doing')) && p('') && e('empty'); // 测试批量修改执行状态为进行中 -r($execution->batchChangeStatusObject(array(2), 'wait')) && p('') && e('empty'); // 测试批量修改执行状态为未开始 -r($execution->batchChangeStatusObject(array(5), 'suspended')) && p('') && e('empty'); // 测试批量修改执行状态为已挂起 -r($execution->batchChangeStatusObject(array(3), 'closed')) && p('') && e("'阶段a子1'"); // 测试批量修改执行状态为已关闭 +r($execution->batchChangeStatusObject(array(4), 'doing')) && p('byChild') && e("'阶段a子1'"); // 测试批量修改执行状态为进行中 +r($execution->batchChangeStatusObject(array(2), 'wait')) && p('byChild') && e('~~'); // 测试批量修改执行状态为未开始 +r($execution->batchChangeStatusObject(array(5), 'suspended')) && p('byChild') && e('~~'); // 测试批量修改执行状态为已挂起 +r($execution->batchChangeStatusObject(array(3), 'closed')) && p('byChild') && e('N/A'); // 测试批量修改执行状态为已关闭 +r($execution->batchChangeStatusObject(array(3), 'wait')) && p('byChild') && e('N/A'); // 测试批量修改执行状态为未开始 diff --git a/module/my/model.php b/module/my/model.php index 1d868d3767..65a24a1280 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -1511,7 +1511,7 @@ class myModel extends model ->beginIF($type == 'undone')->andWhere('t1.status')->eq('normal')->fi() ->beginIF($type == 'ownbyme')->andWhere('t1.PO')->eq($this->app->user->account)->fi() ->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->products)->fi() - ->filterTpl(false) + ->setAutoTpl(false) ->orderBy('t1.order_asc') ->fetchAll('id'); diff --git a/module/pivot/tao.php b/module/pivot/tao.php index 7633b7a363..f2222a8246 100644 --- a/module/pivot/tao.php +++ b/module/pivot/tao.php @@ -79,7 +79,7 @@ class pivotTao extends pivotModel ->beginIF($productID)->andWhere('t1.id')->eq($productID)->fi() ->beginIF($productStatus)->andWhere('t1.status')->eq($productStatus)->fi() ->beginIF($productType)->andWhere('t1.type')->eq($productType)->fi() - ->filterTpl(false) + ->setAutoTpl(false) ->orderBy('t2.order_asc, t1.line_desc, t1.order_asc') ->fetchAll('id'); } diff --git a/module/product/model.php b/module/product/model.php index f0cd44d2bc..0f143b857e 100755 --- a/module/product/model.php +++ b/module/product/model.php @@ -90,7 +90,7 @@ class productModel extends model ->andWhere('t1.shadow')->eq(0) ->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->products)->fi() ->beginIF($this->config->vision != 'or')->andWhere("FIND_IN_SET('{$this->config->vision}', t1.vision)")->fi() - ->filterTpl(false) + ->setAutoTpl(false) ->orderBy('t1.order_asc') ->fetchAll('id'); } @@ -1654,7 +1654,7 @@ class productModel extends model ->andWhere("FIND_IN_SET('{$this->app->user->account}', t1.reviewers)") ->andWhere('t1.reviewStatus')->eq('doing') ->fi() - ->filterTpl(false) + ->setAutoTpl(false) ->orderBy("{$programOrder}t1.line_desc, t1.order_asc") ->beginIF($limit > 0)->limit($limit)->fi() ->fetchAll('id'); diff --git a/module/product/tao.php b/module/product/tao.php index 714b6f7eb5..3ee8d2f95e 100644 --- a/module/product/tao.php +++ b/module/product/tao.php @@ -65,7 +65,7 @@ class productTao extends productModel ->beginIF(!$this->app->user->admin && $this->config->vision != 'lite' && $this->app->rawModule != 'repo')->andWhere('t1.id')->in($this->app->user->view->products)->fi() ->markRight(1) ->beginIF($append)->orWhere('(t1.id')->in($append)->markRight(1)->fi() - ->filterTpl(false) + ->setAutoTpl(false) ->orderBy("isClosed,t2.order_asc,t1.line_desc,t1.order_asc") ->fetchPairs('id', 'name'); } @@ -151,7 +151,7 @@ class productTao extends productModel return $this->dao->select('t1.*')->from(TABLE_PRODUCT)->alias('t1') ->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id') ->where('t1.id')->in($productIDs) - ->filterTpl(false) + ->setAutoTpl(false) ->orderBy('t2.order_asc, t1.line_desc, t1.order_asc') ->page($pager) ->fetchAll('id'); diff --git a/module/program/model.php b/module/program/model.php index ae746cc2fd..89f2b90e1a 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -110,7 +110,7 @@ class programModel extends model ->beginIF($mode == 'assign')->andWhere('t1.program')->eq($programID)->fi() ->beginIF(strpos($status, 'noclosed') !== false)->andWhere('t1.status')->ne('closed')->fi() ->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($views)->fi() - ->filterTpl(false) + ->setAutoTpl(false) ->orderBy('t2.order_asc,t1.line_desc,t1.order_asc'); if(!$withProgram) return $dao->fetchPairs('id', 'name'); diff --git a/module/project/control.php b/module/project/control.php index fe76dbbec2..2346ecf8a9 100755 --- a/module/project/control.php +++ b/module/project/control.php @@ -104,7 +104,7 @@ class project extends control $project = $this->project->fetchByID($projectID); /* Query user's project and program. */ - $projects = $this->project->getListByCurrentUser('*', !$project->isTpl); + $projects = $this->project->getListByCurrentUser('*'); $involvedProjects = $this->project->getInvolvedListByCurrentUser(); $programs = $this->loadModel('program')->getPairs(true); diff --git a/module/project/model.php b/module/project/model.php index 4831e68f6b..796db1349f 100755 --- a/module/project/model.php +++ b/module/project/model.php @@ -47,7 +47,7 @@ class projectModel extends model return $this->dao->select('id, project, type, parent, path, openedBy, PO, PM, QD, RD, acl')->from(TABLE_PROJECT) ->where('acl')->in($acl) ->beginIF($type)->andWhere('type')->in($type)->fi() - ->filterTpl(false) + ->setAutoTpl(false) ->fetchAll('id'); } @@ -69,18 +69,16 @@ class projectModel extends model * Get project list by current user. * * @param string $fields - * @param bool $filterTpl * @access public * @return array */ - public function getListByCurrentUser(string $fields = '*', bool $filterTpl = true) :array + public function getListByCurrentUser(string $fields = '*') :array { return $this->dao->select($fields)->from(TABLE_PROJECT) ->where('type')->eq('project') ->beginIF($this->config->vision)->andWhere('vision')->eq($this->config->vision)->fi() ->andWhere('deleted')->eq(0) ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->projects)->fi() - ->filterTpl($filterTpl) ->orderBy('order_asc,id_desc') ->fetchAll('id'); }