From ed5f700a86c1887adc3f0cdbfece242566ef1361 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 19 Dec 2019 08:17:01 +0800 Subject: [PATCH] * finish task #6694. --- module/bug/control.php | 21 +++++++++++++++------ module/bug/model.php | 26 ++++++++++++++++++-------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 3b5c385af1..d48e71ddd4 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -548,6 +548,7 @@ class bug extends control /* Judge bug exits or not. */ $bug = $this->bug->getById($bugID, true); if(!$bug) die(js::error($this->lang->notFound) . js::locate('back')); + $this->bug->checkBugProjectPriv($bug); /* Update action. */ if($bug->assignedTo == $this->app->user->account) $this->loadModel('action')->read('bug', $bugID); @@ -645,6 +646,7 @@ class bug extends control $productID = $bug->product; $projectID = $bug->project; $currentModuleID = $bug->module; + $this->bug->checkBugProjectPriv($bug); /* Set the menu. */ $this->bug->setMenu($this->products, $productID, $bug->branch); @@ -828,6 +830,7 @@ class bug extends control public function assignTo($bugID) { $bug = $this->bug->getById($bugID); + $this->bug->checkBugProjectPriv($bug); /* Set menu. */ $this->bug->setMenu($this->products, $bug->product, $bug->branch); @@ -961,8 +964,9 @@ class bug extends control die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent')); } - $bug = $this->bug->getById($bugID); - $productID = $bug->product; + $bug = $this->bug->getById($bugID); + $productID = $bug->product; + $this->bug->checkBugProjectPriv($bug); $this->bug->setMenu($this->products, $productID, $bug->branch); $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->confirmBug; @@ -1045,6 +1049,7 @@ class bug extends control if(!isset($users[$assignedTo])) $assignedTo = $this->bug->getModuleOwner($bug->module, $productID); unset($this->lang->bug->resolutionList['tostory']); + $this->bug->checkBugProjectPriv($bug); $this->bug->setMenu($this->products, $productID, $bug->branch); $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->resolve; @@ -1111,8 +1116,9 @@ class bug extends control die(js::locate($this->createLink('bug', 'view', "bugID=$bugID"), 'parent')); } - $bug = $this->bug->getById($bugID); - $productID = $bug->product; + $bug = $this->bug->getById($bugID); + $productID = $bug->product; + $this->bug->checkBugProjectPriv($bug); $this->bug->setMenu($this->products, $productID, $bug->branch); $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->activate; @@ -1157,8 +1163,9 @@ class bug extends control } } - $bug = $this->bug->getById($bugID); - $productID = $bug->product; + $bug = $this->bug->getById($bugID); + $productID = $bug->product; + $this->bug->checkBugProjectPriv($bug); $this->bug->setMenu($this->products, $productID, $bug->branch); $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->close; @@ -1185,6 +1192,7 @@ class bug extends control /* Get bug and queryID. */ $bug = $this->bug->getById($bugID); $queryID = ($browseType == 'bySearch') ? (int)$param : 0; + $this->bug->checkBugProjectPriv($bug); /* Set the menu. */ $this->bug->setMenu($this->products, $bug->product, $bug->branch); @@ -1287,6 +1295,7 @@ class bug extends control public function confirmStoryChange($bugID) { $bug = $this->bug->getById($bugID); + $this->bug->checkBugProjectPriv($bug); $this->dao->update(TABLE_BUG)->set('storyVersion')->eq($bug->latestStoryVersion)->where('id')->eq($bugID)->exec(); $this->loadModel('action')->create('bug', $bugID, 'confirmed', '', $bug->latestStoryVersion); die(js::reload('parent')); diff --git a/module/bug/model.php b/module/bug/model.php index f8ccd91c35..b43886640d 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -400,6 +400,24 @@ class bugModel extends model return $bug; } + /** + * Check bug project priv. + * + * @param object $bug + * @access public + * @return void + */ + public function checkBugProjectPriv($bug) + { + if($bug->project and !$this->loadModel('project')->checkPriv($bug->project)) + { + echo(js::alert($this->lang->bug->projectAccessDenied)); + $loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login"; + if(strpos($this->server->http_referer, $loginLink) !== false) die(js::locate(helper::createLink('bug', 'index'))); + die(js::locate('back')); + } + } + /** * Get bugs of a module. * @@ -464,14 +482,6 @@ class bugModel extends model ->where('t1.id')->eq((int)$bugID)->fetch(); if(!$bug) return false; - if($bug->project and !$this->loadModel('project')->checkPriv($bug->project)) - { - echo(js::alert($this->lang->bug->projectAccessDenied)); - $loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login"; - if(strpos($this->server->http_referer, $loginLink) !== false) die(js::locate(inlink('index'))); - die(js::locate('back')); - } - $bug = $this->loadModel('file')->replaceImgURL($bug, 'steps'); if($setImgSize) $bug->steps = $this->file->setImgSize($bug->steps); foreach($bug as $key => $value) if(strpos($key, 'Date') !== false and !(int)substr($value, 0, 4)) $bug->$key = '';