Merge branch ztflow-wangyuting-dev/bug-63026#wangyuting of zentao/zentaopms (#9040)

This commit is contained in:
刘刚
2025-05-30 10:13:17 +08:00
committed by Gitfox
11 changed files with 49 additions and 25 deletions
+27 -3
View File
@@ -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));
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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' => '');
@@ -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'); // 测试批量修改执行状态为未开始
+1 -1
View File
@@ -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');
+1 -1
View File
@@ -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');
}
+2 -2
View File
@@ -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');
+2 -2
View File
@@ -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');
+1 -1
View File
@@ -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');
+1 -1
View File
@@ -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);
+2 -4
View File
@@ -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');
}