From 51e84b63ee8e054f3cb65ba59e15131f8dc507b6 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Thu, 14 Nov 2019 14:25:26 +0800 Subject: [PATCH] * Finish task #6484. --- module/task/control.php | 4 ++-- module/tree/model.php | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/module/task/control.php b/module/task/control.php index c6c47eabff..09a61ba2e9 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -1369,9 +1369,9 @@ class task extends control } /* Get related objects title or names. */ + $this->loadModel('tree'); $relatedStories = $this->dao->select('id,title')->from(TABLE_STORY)->where('id')->in($relatedStoryIdList)->fetchPairs(); $relatedFiles = $this->dao->select('id, objectID, pathname, title')->from(TABLE_FILE)->where('objectType')->eq('task')->andWhere('objectID')->in(@array_keys($tasks))->andWhere('extra')->ne('editor')->fetchGroup('objectID'); - $relatedModules = $this->loadModel('tree')->getTaskOptionMenu($projectID); if($tasks) { @@ -1465,7 +1465,7 @@ class task extends control if(isset($taskLang->priList[$task->pri])) $task->pri = $taskLang->priList[$task->pri]; if(isset($taskLang->statusList[$task->status])) $task->status = $this->processStatus('task', $task); if(isset($taskLang->reasonList[$task->closedReason])) $task->closedReason = $taskLang->reasonList[$task->closedReason]; - if(isset($relatedModules[$task->module])) $task->module = $relatedModules[$task->module] . "(#$task->module)"; + $task->module = $task->module ? $this->tree->getModulePathByID($task->module) : ''; if(isset($users[$task->openedBy])) $task->openedBy = $users[$task->openedBy]; if(isset($users[$task->assignedTo])) $task->assignedTo = $users[$task->assignedTo]; diff --git a/module/tree/model.php b/module/tree/model.php index cf23a2d9fa..385a30691c 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -25,6 +25,30 @@ class treeModel extends model return $this->dao->findById((int)$moduleID)->from(TABLE_MODULE)->fetch(); } + /** + * Get module path by ID. + * + * @param int $moduleID + * @access public + * @return object + */ + public function getModulePathByID($moduleID) + { + $module = $this->dao->findById((int)$moduleID)->from(TABLE_MODULE)->fetch(); + if($module->parent == '0') return '/' . $module->name; + + $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) + { + $modulePath .= '/' . $moduleName; + } + + return $modulePath; + } + /** * Build the sql query. *