diff --git a/module/product/control.php b/module/product/control.php index 9fb1944731..0536959547 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -375,12 +375,13 @@ class product extends control */ public function view($productID) { - $this->product->setMenu($this->products, $productID); - $product = $this->product->getStatByID($productID); - $product->desc = $this->loadModel('file')->setImgSize($product->desc); if(!$product) die(js::error($this->lang->notFound) . js::locate('back')); + $product->desc = $this->loadModel('file')->setImgSize($product->desc); + + $this->product->setMenu($this->products, $productID); + $actions = $this->dao->select('*')->from(TABLE_ACTION)->where('product')->like("%,$productID,%")->orderBy('date_desc')->limit(6)->fetchAll(); if($actions) $this->loadModel('action')->transformActions($actions); diff --git a/module/product/model.php b/module/product/model.php index fc2f900c07..8a88879390 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -726,7 +726,7 @@ class productModel extends model public function getStatByID($productID) { $product = $this->getById($productID); - if(!$this->checkPriv($product)) return false; + if(!$product || !$this->checkPriv($product)) return false; $stories = $this->dao->select('product, status, count(status) AS count')->from(TABLE_STORY)->where('deleted')->eq(0)->andWhere('product')->eq($productID)->groupBy('product, status')->fetchAll('status'); /* Padding the stories to sure all status have records. */ foreach(array_keys($this->lang->story->statusList) as $status) diff --git a/module/productplan/control.php b/module/productplan/control.php index 00ee35f7d2..b199c067f4 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -226,6 +226,9 @@ class productplan extends control */ public function view($planID = 0, $type = 'story', $orderBy = 'id_desc', $link = 'false', $param = '') { + $plan = $this->productplan->getByID($planID, true); + if(!$plan) die(js::error($this->lang->notFound) . js::locate('back')); + $this->session->set('storyList', $this->app->getURI(true) . '&type=' . 'story'); $this->session->set('bugList', $this->app->getURI(true) . '&type=' . 'bug'); @@ -239,8 +242,6 @@ class productplan extends control /* Append id for secend sort. */ $sort = $this->loadModel('common')->appendOrder($orderBy); - $plan = $this->productplan->getByID($planID, true); - if(!$plan) die(js::error($this->lang->notFound) . js::locate('back')); $this->commonAction($plan->product, $plan->branch); $products = $this->product->getPairs(); diff --git a/module/productplan/model.php b/module/productplan/model.php index 285845031f..758298a47c 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -24,6 +24,8 @@ class productplanModel extends model public function getByID($planID, $setImgSize = false) { $plan = $this->dao->findByID((int)$planID)->from(TABLE_PRODUCTPLAN)->fetch(); + if(!$plan) return false; + $plan = $this->loadModel('file')->replaceImgURL($plan, 'desc'); if($setImgSize) $plan->desc = $this->file->setImgSize($plan->desc); return $plan; diff --git a/module/testreport/control.php b/module/testreport/control.php index b5612412c5..f42f97fc9a 100644 --- a/module/testreport/control.php +++ b/module/testreport/control.php @@ -354,6 +354,8 @@ class testreport extends control public function view($reportID, $from = 'product') { $report = $this->testreport->getById($reportID); + if(!$report) die(js::error($this->lang->notFound) . js::locate('back')); + $project = $this->project->getById($report->project); if($from == 'product' and is_numeric($report->product)) { diff --git a/module/testreport/model.php b/module/testreport/model.php index 7f00d9c1ea..799300f20b 100644 --- a/module/testreport/model.php +++ b/module/testreport/model.php @@ -158,6 +158,8 @@ class testreportModel extends model public function getById($reportID) { $report = $this->dao->select('*')->from(TABLE_TESTREPORT)->where('id')->eq($reportID)->fetch(); + if(!$report) return false; + $report = $this->loadModel('file')->replaceImgURL($report, 'report'); $report->files = $this->file->getByObject('testreport', $reportID); return $report; diff --git a/module/testtask/model.php b/module/testtask/model.php index 5b782a3aa7..8dfff46215 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -265,6 +265,8 @@ class testtaskModel extends model ->fetch(); } + if(!$task) return false; + $task = $this->loadModel('file')->replaceImgURL($task, 'desc'); if($setImgSize) $task->desc = $this->loadModel('file')->setImgSize($task->desc); return $task;