From 103919866f835e12f2de67b2a3df2fc0be83a8ae Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 23 Nov 2015 15:18:42 +0800 Subject: [PATCH] * fix bug #755. --- module/bug/model.php | 2 +- module/story/model.php | 2 +- module/task/model.php | 2 +- module/tree/model.php | 25 +++++++++++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index 5552f10970..e3c0207712 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1090,7 +1090,7 @@ class bugModel extends model { $datas = $this->dao->select('module as name, count(module) as value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('module')->orderBy('value DESC')->fetchAll('name'); if(!$datas) return array(); - $modules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in(array_keys($datas))->fetchPairs(); + $modules = $this->loadModel('tree')->getModulesName(array_keys($datas)); foreach($datas as $moduleID => $data) $data->name = isset($modules[$moduleID]) ? $modules[$moduleID] : '/'; return $datas; } diff --git a/module/story/model.php b/module/story/model.php index 35e4e29423..5938ae499f 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1662,7 +1662,7 @@ class storyModel extends model ->beginIF($this->session->storyQueryCondition != false)->where($this->session->storyQueryCondition)->fi() ->groupBy('module')->orderBy('value DESC')->fetchAll('name'); if(!$datas) return array(); - $modules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in(array_keys($datas))->fetchPairs(); + $modules = $this->loadModel('tree')->getModulesName(array_keys($datas)); foreach($datas as $moduleID => $data) $data->name = isset($modules[$moduleID]) ? $modules[$moduleID] : '/'; return $datas; } diff --git a/module/task/model.php b/module/task/model.php index 966ddae8ea..f202f5c598 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -1161,7 +1161,7 @@ class taskModel extends model ->orderBy('value DESC') ->fetchAll('name'); if(!$datas) return array(); - $modules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in(array_keys($datas))->fetchPairs(); + $modules = $this->loadModel('tree')->getModulesName(array_keys($datas)); foreach($datas as $moduleID => $data) $data->name = isset($modules[$moduleID]) ? $modules[$moduleID] : '/'; return $datas; } diff --git a/module/tree/model.php b/module/tree/model.php index 558b23feeb..3b5960deac 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -1030,6 +1030,31 @@ class treeModel extends model return empty($module) ? 0 : $module->id; } + /** + * Get modules name. + * + * @param array $moduleIdList + * @param bool $allPath + * @access public + * @return array + */ + public function getModulesName($moduleIdList, $allPath = true) + { + if(!$allPath) return $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in($moduleIdList)->fetchPairs('id', 'name'); + + $modules = $this->dao->select('id, name, path')->from(TABLE_MODULE)->where('id')->in($moduleIdList)->fetchAll('path'); + $allModules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in(join(array_keys($modules)))->fetchPairs('id', 'name'); + $modulePairs = array(); + foreach($modules as $module) + { + $paths = explode(',', trim($module->path, ',')); + $moduleName = ''; + foreach($paths as $path) $moduleName .= '/' . $allModules[$path]; + $modulePairs[$module->id] = $moduleName; + } + return $modulePairs; + } + /** * Update modules' order. *