diff --git a/module/block/control.php b/module/block/control.php index 1f93eaa279..bd9add77db 100644 --- a/module/block/control.php +++ b/module/block/control.php @@ -1759,7 +1759,7 @@ class block extends control $meetingCount = isset($params->meetingCount) ? isset($params->meetingCount) : 0; $meetings = $this->dao->select('*')->from(TABLE_MEETING) - ->Where('deleted')->eq('0') + ->where('deleted')->eq('0') ->andWhere('(date')->gt($today) ->orWhere('(begin')->gt($now) ->andWhere('date')->eq($today) diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php index 631aa7e937..195cbd8731 100644 --- a/module/product/view/browse.html.php +++ b/module/product/view/browse.html.php @@ -245,7 +245,7 @@ $projectIDParam = $isProjectStory ? "projectID=$projectID&" : '';
- tree->manage, '', "class='btn btn-info btn-wide'");?> + tree->manage, '', "class='btn btn-info btn-wide'");?>
diff --git a/module/tree/control.php b/module/tree/control.php index 1277e71be1..b69e1791da 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -229,13 +229,12 @@ class tree extends control $this->view->position = $position; $this->view->rootID = $rootID; $this->view->viewType = $viewType; - $this->view->modules = $this->tree->getTreeMenu($rootID, $viewType, $rooteModuleID = 0, array('treeModel', 'createManageLink')); $this->view->sons = $this->tree->getSons($rootID, $currentModuleID, $viewType, $branch); $this->view->currentModuleID = $currentModuleID; $this->view->parentModules = $parentModules; $this->view->branch = $branch; $this->view->from = $from; - $this->view->tree = $this->tree->getProductStructure($rootID, $viewType); + $this->view->tree = $this->tree->getProductStructure($rootID, $viewType, $branch); $this->view->canBeChanged = isset($canBeChanged) ? $canBeChanged : true; $this->display(); } diff --git a/module/tree/model.php b/module/tree/model.php index 80cc42458b..c46956a1df 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -62,14 +62,14 @@ class treeModel extends model /** * Build the sql query. * - * @param int $rootID - * @param string $type - * @param int $startModule - * @param int $branch + * @param int $rootID + * @param string $type + * @param int $startModule + * @param string|int $branch * @access public * @return void */ - public function buildMenuQuery($rootID, $type, $startModule = 0, $branch = 0) + public function buildMenuQuery($rootID, $type, $startModule = 0, $branch = 'all') { /* Set the start module. */ $startModulePath = ''; @@ -86,8 +86,11 @@ class treeModel extends model ->beginIF($type == 'task')->andWhere('type')->eq('task')->fi() ->beginIF($type != 'task')->andWhere('type')->in("story,$type")->fi() ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() - ->beginIF($branch === 'null')->andWhere('branch')->eq(0)->fi() - ->beginIF((($branch or $branch === 0) and $branch !== 'null' and $branch !== 'all'))->andWhere("branch")->eq($branch)->fi() + ->beginIF($branch !== 'all') + ->andWhere("(branch")->eq(0) + ->orWhere('branch')->eq($branch) + ->markRight(1) + ->fi() ->andWhere('deleted')->eq(0) ->orderBy('grade desc, `order`, type desc') ->get(); @@ -98,8 +101,11 @@ class treeModel extends model ->where('root')->eq((int)$rootID) ->andWhere('type')->eq($type) ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() - ->beginIF($branch === 'null')->andWhere('branch')->eq(0)->fi() - ->beginIF((($branch or $branch === 0) and $branch !== 'null' and $branch !== 'all'))->andWhere("branch")->eq($branch)->fi() + ->beginIF($branch !== 'all') + ->andWhere('(branch')->eq(0) + ->orWhere('branch')->eq($branch) + ->markRight(1) + ->fi() ->andWhere('deleted')->eq(0) ->orderBy('grade desc, `order`') ->get(); @@ -416,45 +422,16 @@ class treeModel extends model /* Add for task #1945. check the module has case or no. */ if($type == 'case' and !empty($extra)) $this->loadModel('testtask'); - $lastMenu = ''; - $firstBranch = true; - foreach($branches as $branchID => $branch) - { - $treeMenu = array(); - $stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule, $branchID)); - while($module = $stmt->fetch()) $this->buildTree($treeMenu, $module, $type, $userFunc, $extra, $branchID); - if(!empty($extra) and empty($treeMenu)) continue; - ksort($treeMenu); - if((!empty($branchID) or $branchID === 0) and $branch and $branchID !== 'null') - { - $linkHtml = ($type == 'case' and !empty($extra)) ? '' . $branch . '' : $this->createBranchLink($type, $rootID, $branchID, $branch); - $linkHtml = $manage ? html::a(inlink('browse', "root=$rootID&viewType=$type¤tModuleID=0&branch=$branchID"), $branch) : $linkHtml; - if($type == 'story' or $type == 'bug') - { - $branchLink = helper::createLink($this->app->rawModule, $this->app->rawMethod, "productID=$rootID&branch=$branchID&browseType=bybranch" . $extraParams); - if($type == 'story' and $this->app->rawModule == 'projectstory') - { - $projectID = zget($extra, 'projectID', 0); - $branchLink = helper::createLink($this->app->rawModule, $this->app->rawMethod, "projectID=$projectID&productID=$rootID&branch=$branchID&browseType=bybranch" . $extraParams); - } - $linkHtml = html::a($branchLink, $branch, "", "id=branch" . $branchID); - } - if($firstBranch and $product->type != 'normal') - { - $linkHtml = '' . $this->lang->product->branchName[$product->type] . ''; if($lastMenu) $lastMenu = "\n"; + return $lastMenu; } @@ -1326,7 +1303,11 @@ class treeModel extends model ->where('root')->eq((int)$rootID) ->andWhere('parent')->eq((int)$moduleID) ->andWhere('type')->eq($type) - ->andWhere("branch")->eq((int)$branch) + ->andWhere() + ->markLeft(1) + ->where("branch")->eq(0) + ->beginIF($branch != 0)->orWhere("branch")->eq((int)$branch)->fi() + ->markRight(1) ->andWhere('deleted')->eq(0) ->orderBy('`order`') ->fetchAll(); @@ -1334,11 +1315,16 @@ class treeModel extends model /* else get modules of its type and story type. */ if(strpos('task|case|bug', $type) !== false) $type = "$type,story"; + return $this->dao->select('*')->from(TABLE_MODULE) ->where('root')->eq((int)$rootID) ->andWhere('parent')->eq((int)$moduleID) ->andWhere('type')->in($type) - ->andWhere("branch")->eq((int)$branch) + ->andWhere() + ->markLeft(1) + ->where("branch")->eq(0) + ->beginIF($branch != 0)->orWhere("branch")->eq((int)$branch)->fi() + ->markRight(1) ->andWhere('deleted')->eq(0) ->orderBy('`order`, type desc') ->fetchAll(); @@ -1924,42 +1910,20 @@ class treeModel extends model /** * Get full trees. * - * @param int $rootID - * @param string $viewType - * @param int $branch - * @param int $currentModuleID + * @param int $rootID + * @param string $viewType + * @param string|int $branchID + * @param int $currentModuleID * @access public * @return array */ - public function getProductStructure($rootID, $viewType, $branch = 0, $currentModuleID = 0) + public function getProductStructure($rootID, $viewType, $branchID = 'all', $currentModuleID = 0) { if($viewType == 'line') $rootID = 0; + $stmt = $this->dbh->query($this->buildMenuQuery($rootID, $viewType, $currentModuleID, $branchID)); + $trees = $this->getDataStructure($stmt, $viewType); - $branches = array($branch => ''); - $product = $this->loadModel('product')->getById($rootID); - if(strpos('story|bug|case', $viewType) !== false and empty($branch)) - { - if($product->type != 'normal') $branches = array(0 => '') + $this->loadModel('branch')->getPairs($rootID, 'noempty'); - } - - $fullTrees = array(); - if(isset($branches[0])) - { - $stmt = $this->dbh->query($this->buildMenuQuery($rootID, $viewType, $currentModuleID, 'null')); - $fullTrees = $this->getDataStructure($stmt, $viewType); - unset($branches[0]); - } - if($branches) - { - $branchTrees = array(); - foreach($branches as $branchID => $branch) - { - $stmt = $this->dbh->query($this->buildMenuQuery($rootID, $viewType, $currentModuleID, $branchID)); - $branchTrees[] = array('branch' => $branchID, 'id' => 0, 'name' => $branch, 'root' => $rootID, 'actions' => array('sort' => true, 'add' => false, 'edit' => false, 'delete' => false), 'nodeType' => 'branch', 'type' => 'branch', 'children' => $this->getDataStructure($stmt, $viewType)); - } - $fullTrees[] = array('name' => $this->lang->product->branchName[$product->type], 'root' => $rootID, 'type' => 'branch', 'actions' => false, 'children' => $branchTrees); - } - return $fullTrees; + return $trees; } /** diff --git a/module/tree/view/browse.html.php b/module/tree/view/browse.html.php index 385c32c2be..67a4684c2c 100644 --- a/module/tree/view/browse.html.php +++ b/module/tree/view/browse.html.php @@ -154,7 +154,7 @@ if($viewType == 'doc' or $viewType == 'api')
-
+
tree->short}'");?>