* Code for task #6484.

This commit is contained in:
Yagami
2019-11-26 10:44:43 +08:00
parent 37d0e1d89a
commit 994823a24c
5 changed files with 33 additions and 22 deletions
+25 -13
View File
@@ -26,27 +26,39 @@ class treeModel extends model
}
/**
* Get module path by ID.
* Get all module pairs with path.
*
* @param int $moduleID
* @access public
* @return object
*/
public function getModulePathByID($moduleID)
public function getAllModulePairs($type = 'task')
{
$module = $this->dao->findById((int)$moduleID)->from(TABLE_MODULE)->fetch();
if($module->parent == '0') return '/' . $module->name;
$modules = $this->dao->select('*')->from(TABLE_MODULE)
->where('type')->eq('story')
->beginIF($type == 'task')->orWhere('type')->eq('task')->fi()
->beginIF($type == 'bug')->orWhere('type')->eq('bug')->fi()
->beginIF($type == 'case')->orWhere('type')->eq('case')->fi()
->andWhere('deleted')->eq('0')
->fetchAll();
$path = substr($module->path, 1, -1);
$modules = $this->dao->select('id,name')->from(TABLE_MODULE)->where('id')->in($path)->orderBy('grade')->fetchPairs();
$modulePath = '';
foreach($modules as $moduleName)
$pairs = array();
foreach($modules as $module)
{
$modulePath .= '/' . $moduleName;
if($module->parent == '0')
{
$pairs[$module->id] = '/' . $module->name;
continue;
}
$path = substr($module->path, 1, -1);
$relatedModules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in($path)->orderBy('grade')->fetchPairs();
$modulePath = '';
foreach($relatedModules as $moduleName) $modulePath .= '/' . $moduleName;
$pairs[$module->id] = $modulePath;
}
return $modulePath;
return $pairs;
}
/**