From 88005d150634b3cd7e2015b87e2c80416b9dc7fa Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Mon, 8 Jul 2013 01:56:11 +0000 Subject: [PATCH] + add note for getTaskTreeMenu. --- module/tree/model.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/module/tree/model.php b/module/tree/model.php index b3d70108df..dd9f0dc084 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -288,6 +288,7 @@ class treeModel extends model public function getTaskTreeMenu($rootID, $productID = 0, $startModule = 0, $userFunc, $extra = '') { $extra = array('projectID' => $rootID, 'productID' => $productID, 'tip' => true); + /* If createdVersion <= 4.1, go to getTreeMenu(). */ $createdVersion = $this->dao->select('openedVersion')->from(TABLE_PROJECT) ->where('id')->eq($rootID) @@ -311,8 +312,11 @@ class treeModel extends model } $manage = $userFunc[1] == 'createTaskManageLink' ? true : false; + + /* if not manage, only get linked modules and ignore others. */ if(!$manage) $projectModules = $this->getTaskTreeModules($rootID, true); + /* Get module according to product. */ foreach($products as $id => $product) { $extra['productID'] = $id; @@ -335,7 +339,9 @@ class treeModel extends model $stmt = $this->dbh->query($query); while($module = $stmt->fetch()) { + /* if not manage, ignore unused modules. */ if(!$manage and !isset($projectModules[$module->id])) continue; + $linkHtml = call_user_func($userFunc, 'task', $module, $extra); if(isset($treeMenu[$module->id]) and !empty($treeMenu[$module->id])) @@ -348,14 +354,14 @@ class treeModel extends model { if(isset($treeMenu[$module->parent]) and !empty($treeMenu[$module->parent])) { - $treeMenu[$module->parent] .= "
  • $linkHtml\n"; + $treeMenu[$module->parent] .= "
  • $linkHtml\n"; } else { - $treeMenu[$module->parent] = "
  • $linkHtml\n"; + $treeMenu[$module->parent] = "
  • $linkHtml\n"; } } - $treeMenu[$module->parent] .= "
  • \n"; + $treeMenu[$module->parent] .= "\n"; } $lastMenu = "\n"; @@ -376,17 +382,22 @@ class treeModel extends model { $projectModules = array(); $field = $parent ? 'path' : 'id'; + + /* Get story paths of this project. */ $paths = $this->dao->select('t3.' . $field) ->from(TABLE_PROJECTSTORY)->alias('t1') ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') ->leftJoin(TABLE_MODULE)->alias('t3')->on('t2.module = t3.id') ->where('t1.project')->eq($projectID) ->fetchPairs(); + + /* Add task paths of this project.*/ $paths += $this->dao->select($field)->from(TABLE_MODULE) ->where('root')->eq($projectID) ->andWhere('type')->eq('task') ->fetchPairs(); + /* Get all modules from paths. */ foreach($paths as $path) { $modules = explode(',', $path);