diff --git a/module/bug/control.php b/module/bug/control.php
index 20ce989145..f63282f597 100644
--- a/module/bug/control.php
+++ b/module/bug/control.php
@@ -535,14 +535,6 @@ class bug extends control
$bug = $this->bug->getById($bugID, true);
if(!$bug) die(js::error($this->lang->notFound) . js::locate('back'));
- if($bug->project and !$this->loadModel('project')->checkPriv($bug->project))
- {
- echo(js::alert($this->lang->project->accessDenied));
- $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'));
- }
-
/* Update action. */
if($bug->assignedTo == $this->app->user->account) $this->loadModel('action')->read('bug', $bugID);
diff --git a/module/bug/lang/en.php b/module/bug/lang/en.php
index a456adea72..d778155281 100644
--- a/module/bug/lang/en.php
+++ b/module/bug/lang/en.php
@@ -177,6 +177,7 @@ $lang->bug->confirmChangeProduct = "Any change to {$lang->productCommon} will c
$lang->bug->confirmDelete = 'Do you want to delete this bug?';
$lang->bug->remindTask = 'This bug has been converted to a task. Do you want to update the status of Task(ID %s)?';
$lang->bug->skipClose = 'Bug %s is active. You cannot close it.';
+$lang->bug->projectAccessDenied = "You access to the {$this->projectCommon} to which this bug belongs is denied!";
/* Template. */
$lang->bug->tplStep = "
[Steps]
";
diff --git a/module/bug/lang/zh-cn.php b/module/bug/lang/zh-cn.php
index 23c5567546..c8e4efe885 100644
--- a/module/bug/lang/zh-cn.php
+++ b/module/bug/lang/zh-cn.php
@@ -177,6 +177,7 @@ $lang->bug->confirmChangeProduct = "修改{$lang->productCommon}会导致相应
$lang->bug->confirmDelete = '您确认要删除该Bug吗?';
$lang->bug->remindTask = '该Bug已经转化为任务,是否更新任务(编号:%s)状态 ?';
$lang->bug->skipClose = 'Bug %s 不是已解决状态,不能关闭。';
+$lang->bug->projectAccessDenied = "您无权访问该Bug所属的{$lang->projectCommon}!";
/* 模板。*/
$lang->bug->tplStep = "[步骤]
";
diff --git a/module/bug/model.php b/module/bug/model.php
index a0fa3f3800..64d3e19972 100644
--- a/module/bug/model.php
+++ b/module/bug/model.php
@@ -464,6 +464,14 @@ 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 = '';
@@ -2297,6 +2305,7 @@ class bugModel extends model
if(strpos($bugQuery, '`closedDate`') !== false) $bugQuery .= " AND `closedDate` != '0000-00-00 00:00:00'";
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where($bugQuery)
+ ->andWhere('project')->in($this->app->user->view->projects)
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
return $bugs;