From 450aa98ce0e7c68434fb595c254db98ce40bb85e Mon Sep 17 00:00:00 2001 From: leiyong <1549684884@qq.com> Date: Mon, 1 Feb 2021 08:17:23 +0800 Subject: [PATCH] * Fix bug. --- module/build/control.php | 8 ++++---- module/issue/control.php | 6 +++--- module/program/control.php | 9 +++++++-- module/program/model.php | 8 ++++---- module/project/control.php | 7 +++++-- module/projectrelease/control.php | 7 +++---- module/release/control.php | 6 +++--- module/risk/control.php | 5 +++-- module/testtask/control.php | 5 +++++ module/weekly/control.php | 2 +- 10 files changed, 38 insertions(+), 25 deletions(-) diff --git a/module/build/control.php b/module/build/control.php index 1729efc776..c461cd5d61 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -161,6 +161,9 @@ class build extends control */ public function view($buildID, $type = 'story', $link = 'false', $param = '', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 100, $pageID = 1) { + $build = $this->build->getByID((int)$buildID, true); + if(!$build) die(js::error($this->lang->notFound) . js::locate('back')); + /* Set session and load modules. */ if($type == 'story')$this->session->set('storyList', $this->app->getURI(true)); if($type == 'bug') $this->session->set('bugList', $this->app->getURI(true)); @@ -172,10 +175,7 @@ class build extends control $this->app->loadClass('pager', $static = true); if($this->app->getViewType() == 'mhtml') $recPerPage = 10; - /* Get build, product and bugs. */ - $build = $this->build->getByID((int)$buildID, true); - if(!$build) die(js::error($this->lang->notFound) . js::locate('back')); - + /* Get product and bugs. */ $product = $this->loadModel('product')->getById($build->product); if($product->type != 'normal') $this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); diff --git a/module/issue/control.php b/module/issue/control.php index fc21e5e381..c4bb3f7fd0 100644 --- a/module/issue/control.php +++ b/module/issue/control.php @@ -489,11 +489,11 @@ class issue extends control { /* Set actions and get issue by id. */ $issue = $this->issue->getByID($issueID); - $this->session->PRJ = $issue->PRJ; - - $this->commonAction($issueID, 'issue'); if(!$issue) die(js::error($this->lang->notFound) . js::locate('back')); + $this->session->PRJ = $issue->PRJ; + $this->commonAction($issueID, 'issue'); + $this->view->title = $this->lang->issue->common . $this->lang->colon . $issue->title; $this->view->position[] = $this->lang->issue->common; $this->view->position[] = $this->lang->issue->basicInfo; diff --git a/module/program/control.php b/module/program/control.php index e640bb9a17..b2f3404488 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -110,6 +110,9 @@ class program extends control */ public function PGMProduct($programID = 0, $browseType = 'noclosed', $orderBy = 'order_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1) { + $program = $this->program->getPGMByID($programID); + if(empty($program) || $program->type != 'program') die(js::error($this->lang->notFound) . js::locate('back')); + $this->lang->navGroup->program = 'program'; $this->lang->program->switcherMenu = $this->program->getPGMSwitcher($programID, true); $this->lang->program->mainMenuAction = $this->program->getPGMMainAction(); @@ -122,7 +125,6 @@ class program extends control /* Get the top programID. */ if($programID) { - $program = $this->program->getPGMByID($programID); $path = explode(',', $program->path); $path = array_filter($path); $programID = current($path); @@ -763,6 +765,9 @@ class program extends control */ public function index($projectID = 0) { + $project = $this->program->getPRJByID($projectID); + if(empty($project) || $project->type != 'project') die(js::error($this->lang->notFound) . js::locate('back')); + $this->lang->navGroup->program = 'project'; $projectID = $this->program->savePRJState($projectID, $this->program->getPRJPairs()); @@ -771,7 +776,7 @@ class program extends control $this->view->title = $this->lang->program->common . $this->lang->colon . $this->lang->program->PRJIndex; $this->view->position[] = $this->lang->program->PRJIndex; - $this->view->project = $this->program->getPRJByID($projectID); + $this->view->project = $project; $this->display(); } diff --git a/module/program/model.php b/module/program/model.php index aaea645f0e..bd98e12390 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -102,7 +102,7 @@ class programModel extends model */ public function getPGMByID($programID = 0) { - return $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($programID)->fetch(); + return $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($programID)->andWhere('`type`')->eq('program')->fetch(); } /** @@ -828,7 +828,7 @@ class programModel extends model $currentProjectName = $this->lang->program->common; if($projectID) { - $currentProject = $this->project->getById($projectID); + $currentProject = $this->getPRJById($projectID); $currentProjectName = $currentProject->name; } @@ -919,9 +919,9 @@ class programModel extends model */ public function getPRJByID($projectID) { - if(!$projectID) return false; + $project = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->andWhere('`type`')->eq('project')->fetch(); + if(!$project) return false; - $project = $this->dao->findById($projectID)->from(TABLE_PROJECT)->fetch(); if($project->end == '0000-00-00') $project->end = ''; return $project; } diff --git a/module/project/control.php b/module/project/control.php index 71d3c3ff99..fea591bc8a 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -1618,9 +1618,12 @@ class project extends control */ public function view($executionID) { - $this->app->loadLang('program'); $execution = $this->project->getById($executionID, true); - if(!$execution) die(js::error($this->lang->notFound) . js::locate('back')); + + if(empty($execution) || strpos('stage,sprint', $execution->type) === false) die(js::error($this->lang->notFound) . js::locate('back')); + + $this->app->loadLang('program'); + $this->session->PRJ = $execution->project; /* Project not found to prevent searching for .*/ if(!isset($this->projects[$execution->id])) $this->projects = $this->project->getExecutionPairs($execution->project, 'all', 'nocode'); diff --git a/module/projectrelease/control.php b/module/projectrelease/control.php index 44e6d208dd..1174072739 100644 --- a/module/projectrelease/control.php +++ b/module/projectrelease/control.php @@ -42,11 +42,10 @@ class projectrelease extends control public function commonAction($productID = 0, $branch = 0) { $this->lang->product->menu = $this->lang->product->viewMenu; - $this->lang->product->switcherMenu = $this->loadModel('product')->getSwitcher($productID); + $this->lang->product->switcherMenu = $this->product->getSwitcher($productID); /* Get product and product list by project. */ - $this->loadModel('product'); - $products = $this->loadModel('product')->getProductPairsByProject($this->session->PRJ); + $products = $this->product->getProductPairsByProject($this->session->PRJ); if(!$productID) $productID = key($products); $product = $this->product->getById($productID); @@ -54,7 +53,7 @@ class projectrelease extends control $this->view->product = $product; $this->view->branches = (isset($product->type) and $product->type == 'normal') ? array() : $this->loadModel('branch')->getPairs($productID); $this->view->branch = $branch; - $this->view->project = $this->loadModel('project')->getById($this->session->PRJ); + $this->view->project = $this->loadModel('program')->getPRJById($this->session->PRJ); } /** diff --git a/module/release/control.php b/module/release/control.php index 0e9cf2037c..2aa17b3662 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -140,6 +140,9 @@ class release extends control */ public function view($releaseID, $type = 'story', $link = 'false', $param = '', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 100, $pageID = 1) { + $release = $this->release->getById((int)$releaseID, true); + if(!$release) die(js::error($this->lang->notFound) . js::locate('back')); + if($type == 'story') $this->session->set('storyList', $this->app->getURI(true)); if($type == 'bug' or $type == 'leftBug') $this->session->set('bugList', $this->app->getURI(true)); @@ -150,9 +153,6 @@ class release extends control $this->app->loadClass('pager', $static = true); if($this->app->getViewType() == 'mhtml') $recPerPage = 10; - $release = $this->release->getById((int)$releaseID, true); - if(!$release) die(js::error($this->lang->notFound) . js::locate('back')); - $storyPager = new pager($type == 'story' ? $recTotal : 0, $recPerPage, $type == 'story' ? $pageID : 1); $stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($release->stories)->andWhere('deleted')->eq(0) ->beginIF($type == 'story')->orderBy($orderBy)->fi() diff --git a/module/risk/control.php b/module/risk/control.php index be1916bf87..97e77b2109 100644 --- a/module/risk/control.php +++ b/module/risk/control.php @@ -133,14 +133,15 @@ class risk extends control */ public function view($riskID) { - $this->loadModel('action'); $risk = $this->risk->getById($riskID); + if(empty($risk)) die(js::error($this->lang->notFound) . js::locate('back')); + $this->session->PRJ = $risk->PRJ; $this->view->title = $this->lang->risk->common . $this->lang->colon . $this->lang->risk->view; $this->view->position[] = $this->lang->risk->view; $this->view->risk = $risk; - $this->view->actions = $this->action->getList('risk', $riskID); + $this->view->actions = $this->loadModel('action')->getList('risk', $riskID); $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->display(); diff --git a/module/testtask/control.php b/module/testtask/control.php index 9d0cfa42fc..a609f65a3c 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -197,6 +197,11 @@ class testtask extends control /* Get test task, and set menu. */ $task = $this->testtask->getById($taskID, true); if(!$task) die(js::error($this->lang->notFound) . js::locate('back')); + + /* When the session changes, you need to query the related products again. */ + if($this->session->PRJ != $task->PRJ) $this->view->products = $this->products = $this->product->getProductPairsByProject($task->PRJ); + $this->session->PRJ = $task->PRJ; + $productID = $task->product; $buildID = $task->build; diff --git a/module/weekly/control.php b/module/weekly/control.php index a49dee74b5..afbd1bc95e 100644 --- a/module/weekly/control.php +++ b/module/weekly/control.php @@ -46,7 +46,7 @@ class weekly extends control $this->view->sv = $this->weekly->getSV($this->view->ev, $this->view->pv); $this->view->cv = $this->weekly->getCV($this->view->ev, $this->view->ac); - $this->view->program = $this->loadModel('project')->getByID($program); + $this->view->program = $this->loadModel('program')->getPRJByID($program); $this->view->weekSN = $this->weekly->getWeekSN($this->view->program->begin, $date); $this->view->monday = $this->weekly->getThisMonday($date); $this->view->lastDay = $this->weekly->getLastDay($date);