From 5d2a6582226977c4cc182d034c336cb18bb03d98 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 21 Aug 2014 01:54:42 +0000 Subject: [PATCH] * fix a bug. --- module/bug/control.php | 16 ++++++++-------- module/doc/control.php | 4 ++-- module/story/control.php | 15 ++++++++------- module/testcase/control.php | 15 ++++++++------- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 7fd8cf5192..62f747a926 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -220,20 +220,20 @@ class bug extends control $response['message'] = ''; $bugResult = $this->bug->create(); - $bugID = $bugResult['id']; - if($bugResult['status'] == 'existed') - { - $response['locate'] = $this->createLink('bug', 'view', "bugID=$bugID"); - $this->send($response); - } - - if(dao::isError()) + if(!$bugResult or dao::isError()) { $response['result'] = 'fail'; $response['message'] = dao::getError(); $this->send($response); } + $bugID = $bugResult['id']; + if($bugResult['status'] == 'existed') + { + $response['locate'] = $this->createLink('bug', 'view', "bugID=$bugID"); + $this->send($response); + } + $actionID = $this->action->create('bug', $bugID, 'Opened'); $this->sendmail($bugID, $actionID); diff --git a/module/doc/control.php b/module/doc/control.php index aefd03d82a..eeaf16dbb7 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -250,10 +250,10 @@ class doc extends control if(!empty($_POST)) { $docResult = $this->doc->create(); - $docID = $docResult['id']; + if(!$docResult or dao::isError()) die(js::error(dao::getError())); + $docID = $docResult['id']; if($docResult['status'] == 'existed') die(js::locate($this->createLink('doc', 'view', "docID=$docID"), 'parent')); - if(dao::isError()) die(js::error(dao::getError())); $this->action->create('doc', $docID, 'Created'); if($from == 'product') $link = $this->createLink('product', 'doc', "productID={$this->post->product}"); diff --git a/module/story/control.php b/module/story/control.php index fa64fcbdec..2a46f856c5 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -43,7 +43,14 @@ class story extends control $response['message'] = ''; $storyResult = $this->story->create($projectID, $bugID); - $storyID = $storyResult['id']; + if(!$storyResult or dao::isError()) + { + $response['result'] = 'fail'; + $response['message'] = dao::getError(); + $this->send($response); + } + + $storyID = $storyResult['id']; if($storyResult['status'] == 'existed') { if($projectID == 0) @@ -57,12 +64,6 @@ class story extends control $this->send($response); } - if(dao::isError()) - { - $response['result'] = 'fail'; - $response['message'] = dao::getError(); - $this->send($response); - } if($bugID == 0) { $actionID = $this->action->create('story', $storyID, 'Opened', ''); diff --git a/module/testcase/control.php b/module/testcase/control.php index 2c171aa5ec..eae794fd9e 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -227,19 +227,20 @@ class testcase extends control $response['message'] = ''; $caseResult = $this->testcase->create($bugID); - $caseID = $caseResult['id']; + if(!$caseResult or dao::isError()) + { + $response['result'] = 'fail'; + $response['message'] = dao::getError(); + $this->send($response); + } + + $caseID = $caseResult['id']; if($caseResult['status'] == 'existed') { $response['locate'] = $this->createLink('testcase', 'view', "caseID=$caseID"); $this->send($response); } - if(dao::isError()) - { - $response['result'] = 'fail'; - $response['message'] = dao::getError(); - $this->send($response); - } $this->loadModel('action'); $this->action->create('case', $caseID, 'Opened'); $response['locate'] = $this->createLink('testcase', 'browse', "productID=$_POST[product]&browseType=byModule¶m=$_POST[module]");