Merge remote-tracking branch 'origin/18.x' into sprint/4352

This commit is contained in:
mayue
2023-09-05 16:14:08 +08:00
909 changed files with 119369 additions and 3823 deletions
+130 -13
View File
@@ -181,7 +181,7 @@ class treeModel extends model
$treeMenu = array();
foreach($branches as $branchID => $branch)
{
$stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule, $branchID, $param));
$stmt = $this->app->dbQuery($this->buildMenuQuery($rootID, $type, $startModule, $branchID, $param));
$modules = array();
while($module = $stmt->fetch())
{
@@ -464,7 +464,7 @@ class treeModel extends model
$lastMenu = '';
$treeMenu = array();
$stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule, $branch));
$stmt = $this->app->dbQuery($this->buildMenuQuery($rootID, $type, $startModule, $branch));
while($module = $stmt->fetch())
{
if(!$onlyGetLinked)
@@ -551,7 +551,7 @@ class treeModel extends model
->andWhere('deleted')->eq(0)
->orderBy('grade desc, `order`, type')
->get();
$stmt = $this->dbh->query($query);
$stmt = $this->app->dbQuery($query);
while($module = $stmt->fetch())
{
if(!$manage and !isset($executionModules[$module->id]) and strpos($extra['extra'], 'allModule') === false) continue;
@@ -576,7 +576,7 @@ class treeModel extends model
->andWhere('deleted')->eq(0)
->orderBy('grade desc, `order`, type')
->get();
$stmt = $this->dbh->query($query);
$stmt = $this->app->dbQuery($query);
while($module = $stmt->fetch()) $this->buildTree($treeMenu, $module, 'task', $userFunc, $extra);
$tree = isset($treeMenu[0]) ? $treeMenu[0] : '';
@@ -604,7 +604,7 @@ class treeModel extends model
if(!$this->isMergeModule($rootID, 'task') or !$products)
{
$extra['tip'] = false;
$stmt = $this->dbh->query($this->buildMenuQuery($rootID, 'task', $startModule = 0));
$stmt = $this->app->dbQuery($this->buildMenuQuery($rootID, 'task', $startModule = 0));
if(empty($products)) $this->config->execution->task->allModule = 1;
return $this->getDataStructure($stmt, 'task');
}
@@ -627,7 +627,7 @@ class treeModel extends model
->andWhere('deleted')->eq(0)
->orderBy('grade desc, `order`, type')
->get();
$stmt = $this->dbh->query($query);
$stmt = $this->app->dbQuery($query);
if($branch == 0) $productTree = $this->getDataStructure($stmt, 'task', $executionModules);
if($branch != 0)
{
@@ -646,7 +646,7 @@ class treeModel extends model
->andWhere('deleted')->eq(0)
->orderBy('grade desc, `order`, type')
->get();
$stmt = $this->dbh->query($query);
$stmt = $this->app->dbQuery($query);
$taskTrees = $this->getDataStructure($stmt, 'task', $executionModules);
foreach($taskTrees as $taskModule) $fullTrees[] = $taskModule;
return $fullTrees;
@@ -662,7 +662,7 @@ class treeModel extends model
*/
public function getTreeStructure($rootID, $type)
{
$stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule = 0));
$stmt = $this->app->dbQuery($this->buildMenuQuery($rootID, $type, $startModule = 0));
return $this->getDataStructure($stmt, $type);
}
@@ -721,7 +721,7 @@ class treeModel extends model
->orderBy('grade desc, `order`, type')
->get();
$treeMenu = array();
$stmt = $this->dbh->query($query);
$stmt = $this->app->dbQuery($query);
while($module = $stmt->fetch())
{
if(isset($executionModules[$module->id])) $this->buildTree($treeMenu, $module, 'bug', $userFunc, $extra, $branch);
@@ -808,7 +808,7 @@ class treeModel extends model
->andWhere('deleted')->eq(0)
->orderBy('grade desc, `order`, type')
->get();
$stmt = $this->dbh->query($query);
$stmt = $this->app->dbQuery($query);
while($module = $stmt->fetch())
{
if(isset($executionModules[$module->id])) $this->buildTree($treeMenu, $module, 'case', $userFunc, $extra, $branch);
@@ -875,7 +875,7 @@ class treeModel extends model
->andWhere('deleted')->eq(0)
->orderBy('grade desc, branch, `order`, type')
->get();
$stmt = $this->dbh->query($query);
$stmt = $this->app->dbQuery($query);
while($module = $stmt->fetch())
{
/* If not manage, ignore unused modules. */
@@ -891,6 +891,34 @@ class treeModel extends model
return $menu;
}
/**
* Get project story tree menu.
*
* @access public
* @return array
*/
public function getHostTreeMenu(): array
{
$menu = array();
/* tree menu. */
$treeMenu = array();
$stmt = $this->dao->select('*')->from(TABLE_MODULE)
->where('type')->eq('host')
->andWhere('deleted')->eq(0)
->orderBy('grade_desc,id_asc')
->query();
while($module = $stmt->fetch())
{
$treeMenu = $this->build20Tree($module, '', 0, array('treeModel', 'createHostLink'));
if($module->parent == 0) $treeMenu->parent = $module->root;
$menu[] = $treeMenu;
}
return $menu;
}
/**
* Build tree.
*
@@ -970,6 +998,73 @@ class treeModel extends model
$treeMenu[$module->parent] .= "</li>\n";
}
/**
* Build tree of version 20.
*
* @param object $module
* @param string $type
* @param int|string $parent
* @param array $userFunc
* @param array $extra
* @param int $branch
* @access public
* @return object|false
*/
public function build20Tree(object $module, string $type, int|string $parent = 0, array $userFunc = array(), array|string $extra = array(), string $branch = 'all'): object|false
{
/* Add for task #1945. check the module has case or no. */
if((isset($extra['rootID']) and isset($extra['branch']) and $branch === 'null') or ($type == 'case' and is_numeric($extra)))
{
static $objects = array();
if(empty($objects))
{
if(is_array($extra))
{
$table = $this->config->objectTables[$type];
$objects = $this->dao->select('module')->from($table)->where('product')->eq((int)$extra['rootID'])->andWhere('branch')->eq($extra['branch'])->fetchAll('module');
}
else
{
$objects = $this->dao->select('t1.*,t2.module')->from(TABLE_TESTRUN)->alias('t1')
->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id')
->where('t1.task')->eq((int)$extra)
->fetchAll('module');
}
}
static $modules = array();
if(empty($modules))
{
$typeCondition = "type='story'";
if($type != 'story') $typeCondition .= " or type='{$type}'";
$modules = $this->dao->select('id,path')->from(TABLE_MODULE)->where('root')->eq($module->root)->andWhere("({$typeCondition})")->fetchPairs('id', 'path');
}
$childModules = array();
foreach($modules as $moduleID => $modulePath)
{
if(strpos($modulePath, $module->path) === 0) $childModules[$moduleID] = $moduleID;
}
$hasObjects = false;
foreach($childModules as $moduleID)
{
if(isset($objects[$moduleID]))
{
$hasObjects = true;
break;
}
}
if(!$hasObjects) return false;
}
if(is_array($extra)) $extra['branchID'] = $branch;
if(empty($extra))
{
$extra = array();
$extra['branchID'] = $branch;
}
return call_user_func($userFunc, $type, $module, $parent, $extra);
}
/**
* Get execution modules.
*
@@ -1438,6 +1533,28 @@ class treeModel extends model
return html::a(helper::createLink('report', 'browsereport', "dimension={$dimension}&module={$module->id}"), $module->name, '', "id='module{$module->id}' title='{$module->name}'");
}
/**
* Create link of a host.
*
* @param string $type
* @param object $module
* @param int $parent
* @param array $extra
* @access public
* @return object
*/
public function createHostLink(string $type, object $module, int $parent = 0, array $extra = array()): object
{
$data = new stdclass();
$data->id = $parent ? uniqid() : $module->id;
$data->parent = $parent ? $parent : $module->parent;
$data->name = $module->name;
$data->url = helper::createLink('host', 'browse', "browseType=bymodule&param={$module->id}");
return $data;
}
/**
* Get sons of a module.
*
@@ -2208,7 +2325,7 @@ class treeModel extends model
public function getProductStructure($rootID, $viewType, $branchID = 'all', $currentModuleID = 0)
{
if($viewType == 'line') $rootID = 0;
$stmt = $this->dbh->query($this->buildMenuQuery($rootID, $viewType, $currentModuleID, $branchID));
$stmt = $this->app->dbQuery($this->buildMenuQuery($rootID, $viewType, $currentModuleID, $branchID));
$trees = $this->getDataStructure($stmt, $viewType);
return $trees;
@@ -2273,7 +2390,7 @@ class treeModel extends model
*/
public function getDocStructure()
{
$stmt = $this->dbh->query($this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('doc')->andWhere('deleted')->eq(0)->orderBy('`grade`_desc, `order`')->get());
$stmt = $this->app->dbQuery($this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('doc')->andWhere('deleted')->eq(0)->orderBy('`grade`_desc, `order`')->get());
$parent = array();
while($module = $stmt->fetch())
{