This commit is contained in:
wangyidong
2015-11-23 15:18:42 +08:00
parent 57ef7bad74
commit 103919866f
4 changed files with 28 additions and 3 deletions
+25
View File
@@ -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.
*