diff --git a/module/block/control.php b/module/block/control.php index 12e549dca1..20a9c21acd 100644 --- a/module/block/control.php +++ b/module/block/control.php @@ -1142,7 +1142,7 @@ class block extends control */ public function printCmmiGanttBlock() { - $products = $this->loadModel('product')->getPairs(); + $products = $this->loadModel('product')->getPairs('', $this->session->program); $productID = isset($this->session->product) ? 0 : $this->session->product; if(!$productID) $productID = key($products); @@ -1163,7 +1163,7 @@ class block extends control $this->session->set('issueList', $uri); if(preg_match('/[^a-zA-Z0-9_]/', $this->params->type)) die(); $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->view->issues = $this->loadModel('issue')->getBlockIssues($this->params->type, $this->viewType == 'json' ? 0 : (int)$this->params->num, $this->params->orderBy); + $this->view->issues = $this->loadModel('issue')->getBlockIssues($this->session->program, $this->params->type, $this->viewType == 'json' ? 0 : (int)$this->params->num, $this->params->orderBy); } /** @@ -1177,7 +1177,7 @@ class block extends control $uri = $this->app->getURI(true); $this->session->set('riskList', $uri); $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->view->risks = $this->loadModel('risk')->getBlockRisks($this->params->type, $this->viewType == 'json' ? 0 : (int)$this->params->num, $this->params->orderBy); + $this->view->risks = $this->loadModel('risk')->getBlockRisks($this->session->program, $this->params->type, $this->viewType == 'json' ? 0 : (int)$this->params->num, $this->params->orderBy); } /** @@ -1502,7 +1502,7 @@ class block extends control $normal = 0; $closed = 0; - $products = $this->loadModel('product')->getList(); + $products = $this->loadModel('product')->getList($this->session->program); foreach($products as $product) { if(!$this->product->checkPriv($product->id)) continue; diff --git a/module/branch/control.php b/module/branch/control.php index 199b17cf42..9dd7de50a0 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -26,7 +26,7 @@ class branch extends control die(js::reload('parent')); } - $products = $this->loadModel('product')->getPairs('nocode'); + $products = $this->loadModel('product')->getPairs('nocode' , $this->session->program); $this->product->setMenu($products, $productID); $position[] = html::a($this->createLink('product', 'browse', "productID=$productID"), $products[$productID]); diff --git a/module/budget/control.php b/module/budget/control.php index e303abcfaa..426717880c 100644 --- a/module/budget/control.php +++ b/module/budget/control.php @@ -34,7 +34,7 @@ class budget extends control $this->view->title = $this->lang->budget->common . $this->lang->budget->list; $this->view->position[] = $this->lang->budget->common . $this->lang->budget->list; - $this->view->budgets = $this->budget->getList($orderBy, $pager); + $this->view->budgets = $this->budget->getList($this->session->program, $orderBy, $pager); $this->view->orderBy = $orderBy; $this->view->pager = $pager; $this->view->modules = $this->loadModel('tree')->getOptionMenu(0, $viewType = 'subject', $startModuleID = 0); @@ -69,10 +69,10 @@ class budget extends control $this->view->position[] = $this->lang->budget->common . $this->lang->budget->summary; $this->view->subjectStructure = $getSubjectStructure; $this->view->isChildren = $isChildren; - $this->view->subjects = $this->budget->getSubjects(); - $this->view->stages = $this->budget->getStages(); + $this->view->subjects = $this->budget->getSubjects($this->session->program); + $this->view->stages = $this->budget->getStages($this->session->program); $this->view->stagePairs = $this->loadModel('programplan')->getPlanPairsForBudget($this->session->program); - $this->view->summary = $this->budget->getSummary(); + $this->view->summary = $this->budget->getSummary($this->session->program); $this->view->modules = $this->loadModel('tree')->getOptionMenu(0, $viewType = 'subject', $startModuleID = 0); $this->display(); } @@ -159,7 +159,7 @@ class budget extends control */ public function view($budgetID) { - $this->view->stages = $this->budget->getStages(); + $this->view->stages = $this->budget->getStages($this->session->program); $this->view->subjects = $this->budget->getSubjectOption(); $this->view->stages = $this->loadModel('programplan')->getPlanPairsForBudget($this->session->program); $this->view->budget = $this->budget->getByID($budgetID); diff --git a/module/budget/model.php b/module/budget/model.php index 5ae8df526b..f110feb865 100644 --- a/module/budget/model.php +++ b/module/budget/model.php @@ -51,15 +51,16 @@ class budgetModel extends model /** * Get budget list. * + * @param int $programID * @param varchar $orderBy * @param pager $object * @access public * @return object */ - public function getList($orderBy = 'id_desc', $pager = null) + public function getList($programID, $orderBy = 'id_desc', $pager = null) { return $this->dao->select('*')->from(TABLE_BUDGET) - ->where('program')->eq($this->session->program) + ->where('program')->eq($programID) ->andWhere('deleted')->eq(0) ->orderBy($orderBy) ->page($pager) @@ -69,13 +70,14 @@ class budgetModel extends model /** * Get stages. * + * @param int $programID * @access public * @return array */ - public function getStages() + public function getStages($programID) { return $this->dao->select('stage')->from(TABLE_BUDGET) - ->where('program')->eq($this->session->program) + ->where('program')->eq($programID) ->andWhere('deleted')->eq(0) ->orderBy('stage_asc') ->fetchPairs(); @@ -84,13 +86,14 @@ class budgetModel extends model /** * Get subjects. * + * @param int $programID * @access public * @return array */ - public function getSubjects() + public function getSubjects($programID) { return $this->dao->select('subject')->from(TABLE_BUDGET) - ->where('program')->eq($this->session->program) + ->where('program')->eq($programID) ->andWhere('deleted')->eq(0) ->orderBy('subject_asc') ->fetchPairs(); @@ -104,7 +107,7 @@ class budgetModel extends model */ public function getSubjectStructure() { - $subjects = $this->getSubjects(); + $subjects = $this->getSubjects($this->session->program); $structure = array(); foreach($subjects as $subjectID) @@ -126,13 +129,14 @@ class budgetModel extends model /** * Get summary. * + * @param int $programID * @access public * @return array */ - public function getSummary() + public function getSummary($programID) { $budgets = $this->dao->select('*')->from(TABLE_BUDGET) - ->where('program')->eq($this->session->program) + ->where('program')->eq($programID) ->andWhere('deleted')->eq(0) ->fetchAll(); diff --git a/module/bug/control.php b/module/bug/control.php index c0d99a60cb..2addbfaa14 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -29,7 +29,7 @@ class bug extends control $this->loadModel('action'); $this->loadModel('story'); $this->loadModel('task'); - $this->view->products = $this->products = $this->product->getPairs('nocode'); + $this->view->products = $this->products = $this->product->getPairs('nocode', $this->session->program); if(empty($this->products)) die($this->locate($this->createLink('product', 'showErrorNone', "fromModule=bug"))); } @@ -122,7 +122,7 @@ class bug extends control $pager = pager::init($recTotal, $recPerPage, $pageID); /* Get projects. */ - $projects = $this->loadModel('project')->getPairs('empty|withdelete'); + $projects = $this->loadModel('project')->getPairs('empty|withdelete', $this->session->program); /* Get bugs. */ $bugs = $this->bug->getBugs($productID, $projects, $branch, $browseType, $moduleID, $queryID, $sort, $pager); @@ -588,7 +588,7 @@ class bug extends control { session_write_close(); $this->lang->set('menugroup.bug', 'repo'); - $repos = $this->loadModel('repo')->getRepoPairs(); + $repos = $this->loadModel('repo')->getRepoPairs($this->session->program); $this->repo->setMenu($repos); $this->lang->bug->menu = $this->lang->repo->menu; } @@ -1514,8 +1514,8 @@ class bug extends control /* Get users, products and projects. */ $users = $this->loadModel('user')->getPairs('noletter'); - $products = $this->loadModel('product')->getPairs('nocode'); - $projects = $this->loadModel('project')->getPairs('all|nocode'); + $products = $this->loadModel('product')->getPairs('nocode', $this->session->program); + $projects = $this->loadModel('project')->getPairs('all|nocode', $this->session->program); /* Get related objects id lists. */ $relatedProductIdList = array(); diff --git a/module/bug/model.php b/module/bug/model.php index fb33d6153c..5260cf80af 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1692,7 +1692,7 @@ class bugModel extends model { $datas = $this->dao->select('project as name, count(project) as value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('project')->orderBy('value DESC')->fetchAll('name'); if(!$datas) return array(); - $projects = $this->loadModel('project')->getPairs(); + $projects = $this->loadModel('project')->getPairs('', $this->session->program); $maxLength = 12; if(common::checkNotCN()) $maxLength = 22; diff --git a/module/build/control.php b/module/build/control.php index a682cd3324..951d36e937 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -40,7 +40,7 @@ class build extends control $this->loadModel('user'); /* Set menu. */ - $this->project->setMenu($this->project->getPairs(), $projectID); + $this->project->setMenu($this->project->getPairs('', $this->session->program), $projectID); /* Get stories and bugs. */ $orderBy = 'status_asc, stage_asc, id_desc'; @@ -101,7 +101,7 @@ class build extends control $this->loadModel('project'); /* Set menu. */ - $this->project->setMenu($this->project->getPairs(), $build->project); + $this->project->setMenu($this->project->getPairs('', $this->session->program), $build->project); /* Get stories and bugs. */ $orderBy = 'status_asc, stage_asc, id_desc'; @@ -192,8 +192,8 @@ class build extends control $stages = $this->dao->select('*')->from(TABLE_STORYSTAGE)->where('story')->in($build->stories)->andWhere('branch')->eq($build->branch)->fetchPairs('story', 'stage'); foreach($stages as $storyID => $stage)$stories[$storyID]->stage = $stage; - $this->loadModel('project')->setMenu($this->project->getPairs(), $build->project, $buildID); - $projects = $this->project->getPairs('empty'); + $this->loadModel('project')->setMenu($this->project->getPairs('', $this->session->program), $build->project, $buildID); + $projects = $this->project->getPairs('empty', $this->session->program); $this->view->title = "BUILD #$build->id $build->name - " . $projects[$build->project]; $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$build->project"), $projects[$build->project]); @@ -389,7 +389,7 @@ class build extends control $this->session->set('storyList', inlink('view', "buildID=$buildID&type=story&link=true¶m=" . helper::safe64Encode("&browseType=$browseType&queryID=$param"))); $build = $this->build->getById($buildID); $product = $this->loadModel('product')->getById($build->product); - $this->loadModel('project')->setMenu($this->project->getPairs(), $build->project); + $this->loadModel('project')->setMenu($this->project->getPairs('', $this->session->program), $build->project); $this->loadModel('story'); $this->loadModel('tree'); $this->loadModel('product'); @@ -508,7 +508,7 @@ class build extends control /* Set menu. */ $build = $this->build->getByID($buildID); $product = $this->loadModel('product')->getByID($build->product); - $this->loadModel('project')->setMenu($this->project->getPairs(), $build->project); + $this->loadModel('project')->setMenu($this->project->getPairs('', $this->session->program), $build->project); /* Load pager. */ $this->app->loadClass('pager', $static = true); diff --git a/module/design/control.php b/module/design/control.php index f428c86177..06b2992687 100644 --- a/module/design/control.php +++ b/module/design/control.php @@ -28,7 +28,7 @@ class design extends control { /* Save session for design list and process product id. */ $this->session->set('designList', $this->app->getURI(true)); - $productID = $this->loadModel('product')->saveState($productID, $this->product->getPairs('nocode')); + $productID = $this->loadModel('product')->saveState($productID, $this->product->getPairs('nocode', $this->session->program)); $this->design->setProductMenu($productID); /* Build the search form. */ @@ -39,7 +39,7 @@ class design extends control /* Init pager and get designs. */ $this->app->loadClass('pager', $static = true); $pager = pager::init($recTotal, $recPerPage, $pageID); - $designs = $this->design->getList($productID, $type, $queryID, $orderBy, $pager); + $designs = $this->design->getList($this->session->program, $productID, $type, $queryID, $orderBy, $pager); $this->view->title = $this->lang->design->browse; $this->view->position[] = $this->lang->design->browse; @@ -83,7 +83,7 @@ class design extends control $this->send($response); } - $productID = $this->loadModel('product')->saveState($productID, $this->product->getPairs('nocode')); + $productID = $this->loadModel('product')->saveState($productID, $this->product->getPairs('nocode', $this->session->program)); $this->design->setProductMenu($productID); $this->view->title = $this->lang->design->create; @@ -91,7 +91,7 @@ class design extends control $this->view->users = $this->loadModel('user')->getPairs('noclosed'); $this->view->stories = $this->loadModel('story')->getProductStoryPairs($productID); - $this->view->products = $this->loadModel('product')->getPairs(); + $this->view->products = $this->loadModel('product')->getPairs('', $this->session->program); $this->view->productID = $productID; $this->view->program = $this->loadModel('project')->getByID($this->session->program); @@ -197,7 +197,7 @@ class design extends control $this->view->position[] = $this->lang->design->edit; $this->view->design = $design; - $this->view->products = $this->loadModel('product')->getPairs(); + $this->view->products = $this->loadModel('product')->getPairs('', $this->session->program); $this->view->program = $this->loadModel('project')->getByID($this->session->program); $this->view->stories = $this->loadModel('story')->getProductStoryPairs($design->product); @@ -226,7 +226,7 @@ class design extends control $begin = $begin ? date('Y-m-d', strtotime($begin)) : $program->begin; $end = $end ? date('Y-m-d', strtotime($end)) : helper::today(); - $repos = $this->loadModel('repo')->getRepoPairs(); + $repos = $this->loadModel('repo')->getRepoPairs($this->session->program); $repoID = $repoID ? $repoID : key($repos); $repo = $repoID ? $this->loadModel('repo')->getRepoByID($repoID) : ''; diff --git a/module/design/model.php b/module/design/model.php index b84f121786..009ec8dfbd 100644 --- a/module/design/model.php +++ b/module/design/model.php @@ -216,7 +216,7 @@ class designModel extends model { $programID = $this->session->program; $program = $this->loadModel('project')->getByID($programID); - $products = $this->loadModel('product')->getPairs($programID); + $products = $this->loadModel('product')->getPairs('', $programID); $productID = in_array($productID, array_keys($products)) ? $productID : key($products); $productID = $this->loadModel('product')->saveState($productID, $products); @@ -286,6 +286,7 @@ class designModel extends model * Get design list. * * @param int $productID + * @param int $programID * @param string $type * @param int $param * @param string $orderBy @@ -293,17 +294,17 @@ class designModel extends model * @access public * @return array */ - public function getList($productID = 0, $type = 'all', $param = 0, $orderBy = 'id_desc', $pager = null) + public function getList($programID = 0, $productID = 0, $type = 'all', $param = 0, $orderBy = 'id_desc', $pager = null) { if($type == 'bySearch') { - $designs = $this->getBySearch($param, $orderBy, $pager); + $designs = $this->getBySearch($programID, $param, $orderBy, $pager); } else { $designs = $this->dao->select('*')->from(TABLE_DESIGN) ->where('deleted')->eq(0) - ->beginIF($this->session->program)->andWhere('program')->eq($this->session->program)->fi() + ->beginIF($programID)->andWhere('program')->eq($programID)->fi() ->beginIF($type != 'all')->andWhere('type')->in($type)->fi() ->andWhere('product')->eq($productID) ->orderBy($orderBy) @@ -324,13 +325,14 @@ class designModel extends model /** * Get designs by search. * + * @param int $programID * @param string $queryID * @param string $orderBy * @param int $pager * @access public * @return object */ - public function getBySearch($queryID = 0, $orderBy = 'id_desc', $pager = null) + public function getBySearch($programID = 0, $queryID = 0, $orderBy = 'id_desc', $pager = null) { if($queryID) { @@ -355,7 +357,7 @@ class designModel extends model $designs = $this->dao->select('*')->from(TABLE_DESIGN) ->where($designQuery) ->andWhere('deleted')->eq('0') - ->andWhere('program')->eq($this->session->program) + ->andWhere('program')->eq($programID) ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); diff --git a/module/doc/control.php b/module/doc/control.php index d3c635c567..b2d425559a 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -111,7 +111,7 @@ class doc extends control $this->lang->navGroup->doc = 'program'; $this->lang->doc->menu = $this->lang->product->menu; $this->lang->doc->menuOrder = $this->lang->product->menuOrder; - $this->product->setMenu($this->product->getPairs(), $lib->product); + $this->product->setMenu($this->product->getPairs('', $this->session->program), $lib->product); $this->lang->set('menugroup.doc', 'product'); } elseif($from == 'project') @@ -119,7 +119,7 @@ class doc extends control $this->lang->navGroup->doc = 'program'; $this->lang->doc->menu = $this->lang->project->menu; $this->lang->doc->menuOrder = $this->lang->project->menuOrder; - $this->project->setMenu($this->project->getPairs('nocode'), $lib->project); + $this->project->setMenu($this->project->getPairs('nocode', $this->session->program), $lib->project); $this->lang->set('menugroup.doc', 'project'); } else @@ -210,8 +210,8 @@ class doc extends control } } $libTypeList = $this->lang->doc->libTypeList; - $products = $this->product->getPairs('nocode'); - $projects = $this->project->getPairs('nocode'); + $products = $this->product->getPairs('nocode', $this->session->program); + $projects = $this->project->getPairs('nocode', $this->session->program); if(empty($products)) unset($libTypeList['product']); if(empty($projects)) unset($libTypeList['project']); @@ -328,7 +328,7 @@ class doc extends control $this->lang->navGroup->doc = 'program'; $this->lang->doc->menu = $this->lang->product->menu; $this->lang->doc->menuOrder = $this->lang->product->menuOrder; - $this->product->setMenu($this->product->getPairs(), $lib->product); + $this->product->setMenu($this->product->getPairs('', $this->session->program), $lib->product); $this->lang->set('menugroup.doc', 'product'); $this->lang->modulePageActions = common::hasPriv('doc', 'createLib') ? html::a(helper::createLink('doc', 'createLib'), " " . $this->lang->doc->createLib, '', "class='btn btn-secondary iframe' data-width='70%'") : ''; @@ -338,7 +338,7 @@ class doc extends control $this->lang->navGroup->doc = 'program'; $this->lang->doc->menu = $this->lang->project->menu; $this->lang->doc->menuOrder = $this->lang->project->menuOrder; - $this->project->setMenu($this->project->getPairs('nocode'), $lib->project); + $this->project->setMenu($this->project->getPairs('nocode', $this->session->program), $lib->project); $this->lang->set('menugroup.doc', 'project'); $this->lang->modulePageActions = common::hasPriv('doc', 'createLib') ? html::a(helper::createLink('doc', 'createLib'), " " . $this->lang->doc->createLib, '', "class='btn btn-secondary iframe' data-width='70%'") : ''; @@ -749,7 +749,7 @@ class doc extends control $this->lang->navGroup->doc = 'program'; $this->lang->doc->menu = $this->lang->product->menu; $this->lang->doc->menuOrder = $this->lang->product->menuOrder; - $this->product->setMenu($this->product->getPairs(), $objectID); + $this->product->setMenu($this->product->getPairs('', $this->session->program), $objectID); $this->lang->set('menugroup.doc', 'product'); } elseif($this->from == 'project') @@ -757,7 +757,7 @@ class doc extends control $this->lang->navGroup->doc = 'program'; $this->lang->doc->menu = $this->lang->project->menu; $this->lang->doc->menuOrder = $this->lang->project->menuOrder; - $this->project->setMenu($this->project->getPairs('nocode'), $objectID); + $this->project->setMenu($this->project->getPairs('nocode', $this->session->program), $objectID); $this->lang->set('menugroup.doc', 'project'); } else @@ -843,7 +843,7 @@ class doc extends control $this->lang->navGroup->doc = 'program'; $this->lang->doc->menu = $this->lang->product->menu; $this->lang->doc->menuOrder = $this->lang->product->menuOrder; - $this->product->setMenu($this->product->getPairs(), $objectID); + $this->product->setMenu($this->product->getPairs('', $this->session->program), $objectID); $this->lang->set('menugroup.doc', 'product'); } elseif($from == 'project') @@ -851,7 +851,7 @@ class doc extends control $this->lang->navGroup->doc = 'program'; $this->lang->doc->menu = $this->lang->project->menu; $this->lang->doc->menuOrder = $this->lang->project->menuOrder; - $this->project->setMenu($this->project->getPairs('nocode'), $objectID); + $this->project->setMenu($this->project->getPairs('nocode', $this->session->program), $objectID); $this->lang->set('menugroup.doc', 'project'); } else diff --git a/module/doc/model.php b/module/doc/model.php index 6a1621cb47..6dc1252e5b 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -171,8 +171,8 @@ class docModel extends model if(strpos($extra, 'withObject') !== false) { - $products = $this->loadModel('product')->getPairs(); - $projects = $this->loadModel('project')->getPairs(); + $products = $this->loadModel('product')->getPairs('', $this->session->program); + $projects = $this->loadModel('project')->getPairs('', $this->session->program); } $libPairs = array(); @@ -752,8 +752,8 @@ class docModel extends model { $this->config->doc->search['actionURL'] = $actionURL; $this->config->doc->search['queryID'] = $queryID; - $this->config->doc->search['params']['product']['values'] = array(''=>'') + $this->loadModel('product')->getPairs('nocode') + array('all'=>$this->lang->doc->allProduct); - $this->config->doc->search['params']['project']['values'] = array(''=>'') + $this->loadModel('project')->getPairs('nocode') + array('all'=>$this->lang->doc->allProject); + $this->config->doc->search['params']['product']['values'] = array(''=>'') + $this->loadModel('product')->getPairs('nocode', $this->session->program) + array('all'=>$this->lang->doc->allProduct); + $this->config->doc->search['params']['project']['values'] = array(''=>'') + $this->loadModel('project')->getPairs('nocode', $this->session->program) + array('all'=>$this->lang->doc->allProject); $this->config->doc->search['params']['lib']['values'] = array(''=>'', $libID => ($libID ? $libs[$libID] : 0), 'all' => $this->lang->doclib->all); /* Get the modules. */ diff --git a/module/issue/control.php b/module/issue/control.php index 9b4bec3063..d236313248 100644 --- a/module/issue/control.php +++ b/module/issue/control.php @@ -43,7 +43,7 @@ class issue extends control $this->view->param = $param; $this->view->orderBy = $orderBy; $this->view->browseType = $browseType; - $this->view->issueList = $this->issue->getIssueList($browseType, $queryID, $orderBy, $pager); + $this->view->issueList = $this->issue->getIssueList($this->session->program, $browseType, $queryID, $orderBy, $pager); $this->view->users = $this->loadModel('user')->getPairs('noletter|pofirst|nodeleted'); $this->display(); @@ -368,9 +368,9 @@ class issue extends control $this->view->members = $members; $this->view->moduleOptionMenu = $moduleOptionMenu; - $this->view->projects = $this->loadModel('project')->getPairs(); + $this->view->projects = $this->loadModel('project')->getPairs('', $this->session->program); $this->view->program = $this->loadModel('project')->getById($this->session->program); - $this->view->products = $this->loadModel('product')->getPairs(); + $this->view->products = $this->loadModel('product')->getPairs('', $this->session->program); $this->view->productID = $this->session->product; $this->view->moduleID = 0; $this->view->branch = 0; diff --git a/module/issue/model.php b/module/issue/model.php index 84548c0aa0..c48964e828 100644 --- a/module/issue/model.php +++ b/module/issue/model.php @@ -32,7 +32,7 @@ class issueModel extends model ->stripTags($this->config->issue->editor->create['id'], $this->config->allowedTags) ->get(); - $this->dao->insert(TABLE_ISSUE)->data($data)->batchCheck($this->config->issue->create->requiredFieldsm, 'notempty')->exec(); + $this->dao->insert(TABLE_ISSUE)->data($data)->batchCheck($this->config->issue->create->requiredFields, 'notempty')->exec(); $issueID = $this->dao->lastInsertID(); $this->loadModel('file')->saveUpload('issue', $issueID); @@ -75,6 +75,7 @@ class issueModel extends model /** * Get issue list. * + * @param int $programID * @param string $browseType * @param int $queryID * @param string $orderBy @@ -82,7 +83,7 @@ class issueModel extends model * @access public * @return object */ - public function getIssueList($browseType = 'all', $queryID = 0, $orderBy = 'id_desc', $pager = null) + public function getIssueList($programID = 0, $browseType = 'all', $queryID = 0, $orderBy = 'id_desc', $pager = null) { $issueQuery = ''; if($browseType == 'bysearch') @@ -98,8 +99,8 @@ class issueModel extends model } $issueList = $this->dao->select('*')->from(TABLE_ISSUE) - ->where('program')->eq($this->session->program) - ->andWhere('deleted')->eq('0') + ->where('deleted')->eq('0') + ->beginIF($programID)->andWhere('program')->eq($programID)->fi() ->beginIF($browseType == 'open')->andWhere('status')->eq('active')->fi() ->beginIF($browseType == 'assignto')->andWhere('assignedTo')->eq($this->app->user->account)->fi() ->beginIF($browseType == 'closed')->andWhere('status')->eq('closed')->fi() @@ -116,17 +117,18 @@ class issueModel extends model /** * getBlockIssues * + * @param int $programID * @param string $browseType * @param int $limit * @param string $orderBy * @access public * @return array */ - public function getBlockIssues($browseType = 'all', $limit = 15, $orderBy = 'id_desc') + public function getBlockIssues($programID = 0, $browseType = 'all', $limit = 15, $orderBy = 'id_desc') { $issueList = $this->dao->select('*')->from(TABLE_ISSUE) - ->where('program')->eq($this->session->program) - ->andWhere('deleted')->eq('0') + ->where('deleted')->eq('0') + ->beginIF($programID)->andWhere('program')->eq($programID)->fi() ->beginIF($browseType == 'open')->andWhere('status')->eq('active')->fi() ->beginIF($browseType == 'assignto')->andWhere('assignedTo')->eq($this->app->user->account)->fi() ->beginIF($browseType == 'closed')->andWhere('status')->eq('closed')->fi() diff --git a/module/job/control.php b/module/job/control.php index 8052970aa5..8b63fa36df 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -73,7 +73,7 @@ class job extends control $this->view->position[] = html::a(inlink('browse'), $this->lang->ci->job); $this->view->position[] = $this->lang->job->create; - $repoList = $this->loadModel('repo')->getList(); + $repoList = $this->loadModel('repo')->getList($this->session->program); $repoPairs = array(0 => ''); $repoTypes = array(); foreach($repoList as $repo) @@ -84,7 +84,7 @@ class job extends control } $this->view->repoPairs = $repoPairs; $this->view->repoTypes = $repoTypes; - $this->view->products = array(0 => '') + $this->loadModel('product')->getPairs(); + $this->view->products = array(0 => '') + $this->loadModel('product')->getPairs('', $this->session->program); $this->view->jkHostList = $this->loadModel('jenkins')->getPairs(); $this->display(); @@ -114,7 +114,7 @@ class job extends control $repo = $this->loadModel('repo')->getRepoByID($job->repo); $this->view->repo = $this->loadModel('repo')->getRepoByID($job->repo); - $repoList = $this->repo->getList(); + $repoList = $this->repo->getList($this->session->program); $repoPairs = array(0 => '', $repo->id => $repo->name); $repoTypes[$repo->id] = $repo->SCM; foreach($repoList as $repo) @@ -128,7 +128,7 @@ class job extends control $this->view->repoTypes = $repoTypes; $this->view->repoType = zget($repoTypes, $job->repo, 'Git'); $this->view->job = $job; - $this->view->products = array(0 => '') + $this->loadModel('product')->getPairs(); + $this->view->products = array(0 => '') + $this->loadModel('product')->getPairs('', $this->session->program); $this->view->jkHostList = $this->loadModel('jenkins')->getPairs(); $this->view->jkJobs = $this->jenkins->getTasks($job->jkHost); diff --git a/module/product/control.php b/module/product/control.php index fdf45fcc32..07a7216429 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -30,7 +30,7 @@ class product extends control $this->loadModel('user'); /* Get all products, if no, goto the create page. */ - $this->products = $this->product->getPairs('nocode'); + $this->products = $this->product->getPairs('nocode', $this->session->program); if(empty($this->products) and strpos(',create,index,showerrornone,', $this->methodName) === false and $this->app->getViewType() != 'mhtml') $this->locate($this->createLink('product', 'create')); $this->view->products = $this->products; } @@ -834,7 +834,7 @@ class product extends control $this->session->set('productList', $this->app->getURI(true)); /* Get all product list. Locate to the create product page if there is no product. */ - $this->products = $this->product->getPairs(); + $this->products = $this->product->getPairs('', $this->session->program); if(empty($this->products) and strpos('create|view', $this->methodName) === false) $this->locate($this->createLink('product', 'create')); /* Get current product. */ diff --git a/module/product/model.php b/module/product/model.php index 3f65c7781b..4e2dcd1eb8 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -254,17 +254,18 @@ class productModel extends model /** * Get products. * + * @param int $programID * @param string $status * @param int $limit * @param int $line * @access public * @return array */ - public function getList($status = 'all', $limit = 0, $line = 0) + public function getList($programID = 0, $status = 'all', $limit = 0, $line = 0) { return $this->dao->select('*')->from(TABLE_PRODUCT) ->where('deleted')->eq(0) - ->beginIF($this->session->program)->andWhere('program')->eq($this->session->program)->fi() + ->beginIF($programID)->andWhere('program')->eq($programID)->fi() ->beginIF($line > 0)->andWhere('line')->eq($line)->fi() ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi() ->beginIF($status == 'noclosed')->andWhere('status')->ne('closed')->fi() @@ -285,9 +286,10 @@ class productModel extends model * Get product pairs. * * @param string $mode + * @param string $programID * @return array */ - public function getPairs($mode = '') + public function getPairs($mode = '', $programID = 0) { if(defined('TUTORIAL')) return $this->loadModel('tutorial')->getProductPairs(); @@ -295,7 +297,7 @@ class productModel extends model $products = $this->dao->select('*, IF(INSTR(" closed", status) < 2, 0, 1) AS isClosed') ->from(TABLE_PRODUCT) ->where('deleted')->eq(0) - ->beginIF($this->session->program)->andWhere('program')->eq($this->session->program)->fi() + ->beginIF($programID)->andWhere('program')->eq($programID)->fi() ->beginIF(strpos($mode, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi() ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi() ->orderBy($orderBy) @@ -357,7 +359,7 @@ class productModel extends model */ public function getOrderedProducts($status, $num = 0) { - $products = $this->getList($status); + $products = $this->getList($this->session->program, $status); if(empty($products)) return $products; $lines = $this->loadModel('tree')->getLinePairs($useShort = true); @@ -903,7 +905,7 @@ class productModel extends model $this->loadModel('story'); $this->loadModel('bug'); - $products = $this->getList($status, $limit = 0, $line); + $products = $this->getList($this->session->program, $status, $limit = 0, $line); $products = $this->dao->select('*')->from(TABLE_PRODUCT) ->where('id')->in(array_keys($products)) ->orderBy($orderBy) diff --git a/module/productplan/control.php b/module/productplan/control.php index 6e782c3e99..892f0e7811 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -30,7 +30,7 @@ class productplan extends control $this->view->branch = $branch; $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($productID); $this->view->position[] = html::a($this->createLink('product', 'browse', "productID={$productID}&branch=$branch"), $product->name); - $this->product->setMenu($this->product->getPairs(), $productID, $branch); + $this->product->setMenu($this->product->getPairs('', $this->session->program), $productID, $branch); } /** @@ -214,7 +214,7 @@ class productplan extends control $this->session->set('productPlanList', $this->app->getURI(true)); $this->commonAction($productID, $branch); - $products = $this->product->getPairs(); + $products = $this->product->getPairs('', $this->session->program); $this->view->title = $products[$productID] . $this->lang->colon . $this->lang->productplan->browse; $this->view->position[] = $this->lang->productplan->browse; $this->view->productID = $productID; @@ -264,7 +264,7 @@ class productplan extends control $sort = $this->loadModel('common')->appendOrder($orderBy); $this->commonAction($plan->product, $plan->branch); - $products = $this->product->getPairs(); + $products = $this->product->getPairs('', $this->session->program); $bugPager = new pager(0, $recPerPage, $type == 'bug' ? $pageID : 1); $storyPager = new pager(0, $recPerPage, $type == 'story' ? $pageID : 1); @@ -377,7 +377,7 @@ class productplan extends control $this->loadModel('tree'); $plan = $this->productplan->getByID($planID); $this->commonAction($plan->product, $plan->branch); - $products = $this->product->getPairs(); + $products = $this->product->getPairs('', $this->session->program); /* Load pager. */ $this->app->loadClass('pager', $static = true); @@ -515,7 +515,7 @@ class productplan extends control $this->loadModel('bug'); $plan = $this->productplan->getByID($planID); $this->commonAction($plan->product, $plan->branch); - $products = $this->product->getPairs('nocode'); + $products = $this->product->getPairs('nocode', $this->session->program); $productID = $plan->product; $queryID = ($browseType == 'bysearch') ? (int)$param : 0; diff --git a/module/program/control.php b/module/program/control.php index 57f059f349..0db2c9ea6b 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -720,7 +720,7 @@ class program extends control public function ajaxGetEnterLink($programID = 0) { $program = $this->project->getByID($programID); - $programProjects = $this->project->getPairs(); + $programProjects = $this->project->getPairs('', $this->session->program); $programProject = key($programProjects); if($program->template == 'cmmi') diff --git a/module/programplan/control.php b/module/programplan/control.php index d3e60fbfba..8dc6fbd4a9 100644 --- a/module/programplan/control.php +++ b/module/programplan/control.php @@ -28,7 +28,7 @@ class programplan extends control */ public function commonAction($programID, $productID = 0, $extra = '') { - $products = $this->loadModel('product')->getPairs($programID); + $products = $this->loadModel('product')->getPairs('', $programID); $productID = $this->product->saveState($productID, $products); $this->product->setMenu($products, $productID, 0, 0, '', $extra); $this->productID = $productID; @@ -159,7 +159,7 @@ class programplan extends control $this->app->loadLang('stage'); $this->view->title = $this->lang->programplan->edit; $this->view->position[] = $this->lang->programplan->edit; - $this->view->parentStage = $this->programplan->getParentStageList($planID, $plan->product); + $this->view->parentStage = $this->programplan->getParentStageList($this->session->program, $planID, $plan->product); $this->view->plan = $plan; $this->view->isParent = $this->programplan->isParent($planID); $this->view->isCreateTask = $this->programplan->isCreateTask($planID); diff --git a/module/programplan/model.php b/module/programplan/model.php index 1683b7fb16..4b649f6b2f 100644 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -876,12 +876,13 @@ class programplanModel extends model /** * Get parent stage list. * + * @param int $programID * @param int $planID * @param int $productID * @access public * @return array */ - public function getParentStageList($planID, $productID) + public function getParentStageList($programID, $planID, $productID) { $projects = $this->getProjectsByProduct($productID); unset($projects[$planID]); @@ -889,7 +890,7 @@ class programplanModel extends model $parentStage = $this->dao->select('id,name')->from(TABLE_PROJECT) ->where('id')->in($projects) ->andWhere('type')->eq('project') - ->andWhere('program')->eq($this->session->program) + ->andWhere('program')->eq($programID) ->andWhere('parent')->eq(0) ->andWhere('deleted')->eq('0') ->fetchPairs('id'); diff --git a/module/project/control.php b/module/project/control.php index 61e57d84fd..9908c5a7a1 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -23,7 +23,7 @@ class project extends control parent::__construct($moduleName, $methodName); if($this->methodName != 'computeburn') { - $this->projects = $this->project->getPairs('nocode'); + $this->projects = $this->project->getPairs('nocode', $this->session->program); if(!$this->projects and $this->methodName != 'index' and $this->methodName != 'create' and $this->app->getViewType() != 'mhtml') $this->locate($this->createLink('project', 'create')); if(!$this->projects and $this->methodName != 'index' and $this->methodName != 'create' and $this->app->getViewType() == 'mhtml') $this->locate($this->createLink('project', 'index')); } @@ -506,7 +506,7 @@ class project extends control $this->app->session->set('projectList', $uri); $this->loadModel('bug'); - $projects = $this->project->getPairs('nocode'); + $projects = $this->project->getPairs('nocode', $this->session->program); $this->project->setMenu($projects, $projectID); /* Load pager. */ @@ -925,7 +925,7 @@ class project extends control $this->view->orderBy = $orderBy; $this->view->tasks = $productTasks; $this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter'); - $this->view->products = $this->loadModel('product')->getPairs(); + $this->view->products = $this->loadModel('product')->getPairs('', $this->session->program); $this->display(); } @@ -1149,7 +1149,7 @@ class project extends control $this->view->position[] = $this->view->title; $this->view->projects = array('' => '') + $this->projects; $this->view->groups = $this->loadModel('group')->getPairs(); - $this->view->allProducts = array(0 => '') + $this->loadModel('product')->getPairs('noclosed|nocode'); + $this->view->allProducts = array(0 => '') + $this->loadModel('product')->getPairs('noclosed|nocode', $this->session->program); $this->view->acl = $acl; $this->view->plan = $plan; $this->view->name = $name; @@ -1222,7 +1222,7 @@ class project extends control $position[] = html::a($browseProjectLink, $project->name); $position[] = $this->lang->project->edit; - $allProducts = array(0 => '') + $this->loadModel('product')->getPairs('noclosed|nocode'); + $allProducts = array(0 => '') + $this->loadModel('product')->getPairs('noclosed|nocode', $this->session->program); $linkedProducts = $this->project->getProducts($project->id); $linkedBranches = array(); foreach($linkedProducts as $product) @@ -1881,7 +1881,7 @@ class project extends control $position[] = html::a($browseProjectLink, $project->name); $position[] = $this->lang->project->manageProducts; - $allProducts = $this->product->getPairs('noclosed|nocode'); + $allProducts = $this->product->getPairs('noclosed|nocode', $this->session->program); $linkedProducts = $this->project->getProducts($project->id); $linkedBranches = array(); // Merge allProducts and linkedProducts for closed product. @@ -2386,7 +2386,7 @@ class project extends control $this->view->title = $this->lang->project->allProject; $this->view->position[] = $this->lang->project->allProject; $this->view->projectStats = $this->project->getProjectStats($status == 'byproduct' ? 'all' : $status, $productID, 0, 30, $orderBy, $pager); - $this->view->products = array(0 => $this->lang->product->select) + $this->loadModel('product')->getPairs(); + $this->view->products = array(0 => $this->lang->product->select) + $this->loadModel('product')->getPairs('', $this->session->program); $this->view->productID = $productID; $this->view->projectID = $projectID; $this->view->pager = $pager; @@ -2585,7 +2585,7 @@ class project extends control $this->view->cases = $cases; $this->view->story = $story; $this->view->users = $users; - $this->view->projects = $this->loadModel('project')->getPairs('nocode'); + $this->view->projects = $this->loadModel('project')->getPairs('nocode', $this->session->program); $this->view->actions = $this->loadModel('action')->getList('story', $storyID); $this->view->modulePath = $modulePath; $this->view->version = $version == 0 ? $story->version : $version; diff --git a/module/project/model.php b/module/project/model.php index 4b49294fa6..1179c83b51 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -94,7 +94,7 @@ class projectModel extends model $this->session->set('project', $projectID); - $products = $this->loadModel('product')->getPairs($program->id); + $products = $this->loadModel('product')->getPairs('', $program->id); /* Unset story, bug, build and testtask if type is ops. */ if($project and $project->type == 'ops') @@ -222,7 +222,7 @@ class projectModel extends model */ public function tree() { - $products = $this->loadModel('product')->getPairs('nocode'); + $products = $this->loadModel('product')->getPairs('nocode', $this->session->program); $productGroup = $this->getProductGroupList(); $projectTree = "