From d3dc4ebe430c97912c53a97afd0893ba7489e1c6 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Tue, 17 May 2022 06:00:26 +0000 Subject: [PATCH] * Fix bug. --- framework/model.class.php | 2 +- module/bug/control.php | 3 ++- module/build/control.php | 9 ++++++--- module/caselib/control.php | 6 ++++-- module/execution/control.php | 10 +++++++--- module/product/control.php | 9 ++++++--- module/productplan/control.php | 10 +++++++--- module/project/control.php | 12 +++++++++--- module/projectrelease/control.php | 12 +++++++++--- module/release/control.php | 11 ++++++++--- module/story/control.php | 3 ++- module/task/control.php | 3 ++- module/testcase/control.php | 6 ++++-- module/testsuite/control.php | 9 ++++++--- module/testtask/control.php | 22 +++++++++++++++------- 15 files changed, 88 insertions(+), 39 deletions(-) diff --git a/framework/model.class.php b/framework/model.class.php index 71eddbd925..c62d23a153 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -293,6 +293,6 @@ class model extends baseModel } $flow = $this->loadModel('workflow')->getByModule($moduleName); - if($flow && $action) $this->loadModel('workflowhook')->execute($flow, $action, $objectID); + if($flow && $action) return $this->loadModel('workflowhook')->execute($flow, $action, $objectID); } } diff --git a/module/bug/control.php b/module/bug/control.php index 673201721f..d02f8cc38d 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -397,7 +397,8 @@ class bug extends control $this->action->create('todo', $output['todoID'], 'finished', '', "BUG:$bugID"); } - $this->executeHooks($bugID); + $message = $this->executeHooks($bugID); + if($message) $this->lang->saveSuccess = $message; /* Return bug id when call the API. */ if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $bugID)); diff --git a/module/build/control.php b/module/build/control.php index b918fdf58e..1105dc34a3 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -38,7 +38,8 @@ class build extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('build', $buildID, 'opened'); - $this->executeHooks($buildID); + $message = $this->executeHooks($buildID); + if($message) $this->lang->saveSuccess = $message; if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $buildID)); if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadExecutionBuilds($executionID, $buildID)")); // Code for task #5126. @@ -130,7 +131,8 @@ class build extends control if(!empty($changes)) $this->action->logHistory($actionID, $changes); } - $this->executeHooks($buildID); + $message = $this->executeHooks($buildID); + if($message) $this->lang->saveSuccess = $message; return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "buildID=$buildID"))); } @@ -316,7 +318,8 @@ class build extends control $build = $this->build->getById($buildID); $this->build->delete(TABLE_BUILD, $buildID); - $this->executeHooks($buildID); + $message = $this->executeHooks($buildID); + if($message) $response['message'] = $message; /* if ajax request, send result. */ if($this->server->ajax) diff --git a/module/caselib/control.php b/module/caselib/control.php index 586b756ccb..dc8d4b19cc 100644 --- a/module/caselib/control.php +++ b/module/caselib/control.php @@ -92,7 +92,8 @@ class caselib extends control $this->action->logHistory($actionID, $changes); } - $this->executeHooks($libID); + $message = $this->executeHooks($libID); + if($message) $response['message'] = $message; $response['locate'] = inlink('view', "libID=$libID"); return $this->send($response); @@ -130,7 +131,8 @@ class caselib extends control { $this->caselib->delete($libID); - $this->executeHooks($libID); + $message = $this->executeHooks($libID); + if($message) $response['message'] = $message; /* if ajax request, send result. */ if($this->server->ajax) diff --git a/module/execution/control.php b/module/execution/control.php index d7811ba665..931dae318e 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1379,7 +1379,8 @@ class execution extends control $this->loadModel('action')->create($this->objectType, $executionID, 'opened', '', join(',', $_POST['products'])); - $this->executeHooks($executionID); + $message = $this->executeHooks($executionID); + if($message) $this->lang->saveSuccess = $message; if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $executionID)); @@ -1553,7 +1554,9 @@ class execution extends control $this->productplan->linkProject($projectID, $newPlans); } - $this->executeHooks($executionID); + $message = $this->executeHooks($executionID); + if($message) $this->lang->saveSuccess = $message; + if($_POST['status'] == 'doing') $this->loadModel('common')->syncPPEStatus($executionID); if($execution->type == 'kanban') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "executionID=$executionID"))); @@ -2549,7 +2552,8 @@ class execution extends control $this->execution->updateUserView($executionID); $this->session->set('execution', ''); - $this->executeHooks($executionID); + $message = $this->executeHooks($executionID); + if($message) $this->lang->saveSuccess = $message; if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess)); return print(js::reload('parent')); diff --git a/module/product/control.php b/module/product/control.php index 401edefb9b..bd126a5de8 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -364,7 +364,8 @@ class product extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('product', $productID, 'opened'); - $this->executeHooks($productID); + $message = $this->executeHooks($productID); + if($message) $this->lang->saveSuccess = $message; if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $productID)); $tab = $this->app->tab; @@ -518,7 +519,8 @@ class product extends control $this->action->logHistory($actionID, $changes); } - $this->executeHooks($productID); + $message = $this->executeHooks($productID); + if($message) $this->lang->saveSuccess = $message; $moduleName = $programID ? 'program' : 'product'; $methodName = $programID ? 'product' : 'view'; @@ -778,7 +780,8 @@ class product extends control $this->product->delete(TABLE_PRODUCT, $productID); $this->dao->update(TABLE_DOCLIB)->set('deleted')->eq(1)->where('product')->eq($productID)->exec(); $this->session->set('product', ''); - $this->executeHooks($productID); + $message = $this->executeHooks($productID); + if($message) $this->lang->saveSuccess = $message; if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess)); return print(js::locate($this->createLink('product', 'all'), 'parent')); diff --git a/module/productplan/control.php b/module/productplan/control.php index aaa4f4238b..41654bb9a1 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -64,7 +64,8 @@ class productplan extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('productplan', $planID, 'opened'); - $this->executeHooks($planID); + $message = $this->executeHooks($planID); + if($message) $this->lang->saveSuccess = $message; if($parent > 0) $this->productplan->updateParentStatus($parent); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); @@ -132,7 +133,8 @@ class productplan extends control $actionID = $this->loadModel('action')->create('productplan', $planID, 'edited'); $this->action->logHistory($actionID, $changes); } - $this->executeHooks($planID); + $message = $this->executeHooks($planID); + if($message) $this->lang->saveSuccess = $message; return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "planID=$planID"))); } @@ -246,7 +248,8 @@ class productplan extends control { $this->productplan->delete(TABLE_PRODUCTPLAN, $planID); if($plan->parent > 0) $this->productplan->changeParentField($planID); - $this->executeHooks($planID); + $message = $this->executeHooks($planID); + if($message) $this->lang->saveSuccess = $message; /* if ajax request, send result. */ if($this->server->ajax) @@ -401,6 +404,7 @@ class productplan extends control $planStories = $this->story->getPlanStories($planID, 'all', $type == 'story' ? $sort : 'id_desc', $storyPager); $this->executeHooks($planID); + if($plan->parent > 0) $this->view->parentPlan = $this->productplan->getById($plan->parent); if($plan->parent == '-1') $this->view->childrenPlans = $this->productplan->getChildren($plan->id); diff --git a/module/project/control.php b/module/project/control.php index bb048bcf56..192d536883 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -429,7 +429,9 @@ class project extends control } } - $this->executeHooks($projectID); + $message = $this->executeHooks($projectID); + if($message) $this->lang->saveSuccess = $message; + if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $projectID)); if($this->app->tab == 'program') @@ -588,7 +590,9 @@ class project extends control $this->loadModel('productplan')->linkProject($projectID, $newPlans); } - $this->executeHooks($projectID); + $message = $this->executeHooks($projectID); + if($message) $this->lang->saveSuccess = $message; + if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); $locateLink = ($this->session->projectList and $from != 'view') ? $this->session->projectList : inLink('view', "projectID=$projectID"); @@ -1726,7 +1730,9 @@ class project extends control $url = $this->createLink('project', 'browse'); if($this->app->tab == 'program') $url = $this->createLink('program', 'browse'); - $this->executeHooks($projectID); + $message = $this->executeHooks($projectID); + if($message) $this->lang->saveSuccess = $message; + if(empty($executionIdList)) { if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess)); diff --git a/module/projectrelease/control.php b/module/projectrelease/control.php index 63eefdf16a..eb2ffe6ede 100644 --- a/module/projectrelease/control.php +++ b/module/projectrelease/control.php @@ -109,7 +109,9 @@ class projectrelease extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('release', $releaseID, 'opened'); - $this->executeHooks($releaseID); + $message = $this->executeHooks($releaseID); + if($message) $this->lang->saveSuccess = $message; + if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $releaseID)); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "releaseID=$releaseID"))); @@ -161,7 +163,10 @@ class projectrelease extends control $actionID = $this->loadModel('action')->create('release', $releaseID, 'Edited', $fileAction); if(!empty($changes)) $this->action->logHistory($actionID, $changes); } - $this->executeHooks($releaseID); + + $message = $this->executeHooks($releaseID); + if($message) $this->lang->saveSuccess = $message; + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "releaseID=$releaseID"))); } @@ -328,7 +333,8 @@ class projectrelease extends control $build = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->eq((int)$release->build)->fetch(); if(empty($build->execution)) $this->loadModel('build')->delete(TABLE_BUILD, $build->id); - $this->executeHooks($releaseID); + $message = $this->executeHooks($releaseID); + if($message) $response['message'] = $message; /* if ajax request, send result. */ if($this->server->ajax) diff --git a/module/release/control.php b/module/release/control.php index 4f167c7fa7..105f01bf84 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -72,7 +72,8 @@ class release extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('release', $releaseID, 'opened'); - $this->executeHooks($releaseID); + $message = $this->executeHooks($releaseID); + if($message) $this->lang->saveSuccess = $message; if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $releaseID)); if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadProductBuilds($productID)")); @@ -126,7 +127,10 @@ class release extends control $actionID = $this->loadModel('action')->create('release', $releaseID, 'Edited', $fileAction); if(!empty($changes)) $this->action->logHistory($actionID, $changes); } - $this->executeHooks($releaseID); + + $message = $this->executeHooks($releaseID); + if($message) $this->lang->saveSuccess = $message; + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "releaseID=$releaseID"))); } $this->loadModel('story'); @@ -285,7 +289,8 @@ class release extends control $build = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->eq((int)$release->build)->fetch(); if(empty($build->execution)) $this->loadModel('build')->delete(TABLE_BUILD, $build->id); - $this->executeHooks($releaseID); + $message = $this->executeHooks($releaseID); + if($message) $response['message'] = $message; /* if ajax request, send result. */ if($this->server->ajax) diff --git a/module/story/control.php b/module/story/control.php index 1fb8b8e976..f5fa0cdcf3 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -178,7 +178,8 @@ class story extends control $this->action->create('todo', $todoID, 'finished', '', "STORY:$storyID"); } - $this->executeHooks($storyID); + $message = $this->executeHooks($storyID); + if($message) $this->lang->saveSuccess = $message; if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $storyID)); diff --git a/module/task/control.php b/module/task/control.php index d9d0637b80..8043ecc732 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -162,7 +162,8 @@ class task extends control $this->action->create('todo', $todoID, 'finished', '', "TASK:$taskID"); } - $this->executeHooks($taskID); + $message = $this->executeHooks($taskID); + if($message) $this->lang->saveSuccess = $message; /* Return task id when call the API. */ if($this->viewType == 'json' or (defined('RUN_MODE') && RUN_MODE == 'api')) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $taskID)); diff --git a/module/testcase/control.php b/module/testcase/control.php index 2071f20d2e..98d478bc86 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -343,7 +343,8 @@ class testcase extends control /* If the story is linked project, make the case link the project. */ $this->testcase->syncCase2Project($caseResult['caseInfo'], $caseID); - $this->executeHooks($caseID); + $message = $this->executeHooks($caseID); + if($message) $this->lang->saveSuccess = $message; if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $caseID)); /* If link from no head then reload. */ @@ -1173,7 +1174,8 @@ class testcase extends control $case = $this->testcase->getById($caseID); $this->testcase->delete(TABLE_CASE, $caseID); - $this->executeHooks($caseID); + $message = $this->executeHooks($caseID); + if($message) $response['message'] = $message; /* if ajax request, send result. */ if($this->server->ajax) diff --git a/module/testsuite/control.php b/module/testsuite/control.php index 037d25161c..d27e771410 100644 --- a/module/testsuite/control.php +++ b/module/testsuite/control.php @@ -118,7 +118,8 @@ class testsuite extends control } $actionID = $this->loadModel('action')->create('testsuite', $suiteID, 'opened'); - $this->executeHooks($suiteID); + $message = $this->executeHooks($suiteID); + if($message) $response['message'] = $message; if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $suiteID)); @@ -221,7 +222,8 @@ class testsuite extends control $this->action->logHistory($actionID, $changes); } - $this->executeHooks($suiteID); + $messgae = $this->executeHooks($suiteID); + if($message) $response['message'] = $message; $response['locate'] = inlink('view', "suiteID=$suiteID"); return $this->send($response); @@ -263,7 +265,8 @@ class testsuite extends control $this->testsuite->delete($suiteID); - $this->executeHooks($suiteID); + $message = $this->executeHooks($suiteID); + if($message) $response['message'] = $message; /* if ajax request, send result. */ if($this->server->ajax) diff --git a/module/testtask/control.php b/module/testtask/control.php index 13b8418a7e..d295f3639d 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -217,7 +217,9 @@ class testtask extends control if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('testtask', $taskID, 'opened'); - $this->executeHooks($taskID); + $message = $this->executeHooks($taskID); + if($message) $this->lang->saveSuccess = $message; + if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $taskID)); $task = $this->dao->findById($taskID)->from(TABLE_TESTTASK)->fetch(); @@ -726,7 +728,8 @@ class testtask extends control $this->action->logHistory($actionID, $changes); } - $this->executeHooks($taskID); + $message = $this->executeHooks($taskID); + if($message) $this->lang->saveSuccess = $message; $link = isonlybody() ? 'parent' : $this->session->testtaskList; return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $link)); @@ -788,7 +791,8 @@ class testtask extends control $this->action->logHistory($actionID, $changes); } - $this->executeHooks($taskID); + $message = $this->executeHooks($taskID); + if($message) $this->lang->saveSuccess = $message; if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('testtask', 'view', "taskID=$taskID"))); @@ -830,7 +834,8 @@ class testtask extends control $this->action->logHistory($actionID, $changes); } - $this->executeHooks($taskID); + $message = $this->executeHooks($taskID); + if($message) $this->lang->saveSuccess = $message; if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('testtask', 'view', "taskID=$taskID"))); @@ -872,7 +877,8 @@ class testtask extends control $this->action->logHistory($actionID, $changes); } - $this->executeHooks($taskID); + $message = $this->executeHooks($taskID); + if($message) $this->lang->saveSuccess = $message; if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent.parent')); return $this->send(array('result' => 'success', 'message' => $this->lang->success, 'locate' => $this->createLink('testtask', 'view', "taskID=$taskID"))); @@ -915,7 +921,8 @@ class testtask extends control $this->action->logHistory($actionID, $changes); } - $this->executeHooks($taskID); + $message = $this->executeHooks($taskID); + if($message) $this->lang->saveSuccess = $message; if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('testtask', 'view', "taskID=$taskID"))); @@ -956,7 +963,8 @@ class testtask extends control $task = $this->testtask->getByID($taskID); $this->testtask->delete(TABLE_TESTTASK, $taskID); - $this->executeHooks($taskID); + $message = $this->executeHooks($taskID); + if($message) $response['message'] = $message; /* if ajax request, send result. */ if($this->server->ajax)