From 96e460c47dbb7dcb67a3880fecf061c24634b053 Mon Sep 17 00:00:00 2001 From: daitingting Date: Mon, 9 May 2022 06:41:35 +0000 Subject: [PATCH 1/2] * Finish task #53549. --- framework/model.class.php | 15 --------------- module/bug/model.php | 16 +++++++++------- module/build/model.php | 2 ++ module/caselib/model.php | 2 ++ module/execution/model.php | 15 ++++++++------- module/product/model.php | 6 ++++-- module/productplan/model.php | 6 +++--- module/program/model.php | 2 ++ module/project/model.php | 10 ++++++++-- module/story/model.php | 26 ++++++++++++++------------ module/task/model.php | 22 +++++++++++----------- module/testcase/model.php | 12 +++++------- module/testsuite/model.php | 2 ++ module/testtask/model.php | 6 ++++++ 14 files changed, 76 insertions(+), 66 deletions(-) diff --git a/framework/model.class.php b/framework/model.class.php index db11f1d62e..267fbc1edf 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -249,21 +249,6 @@ class model extends baseModel return $this->loadModel('workflowfield')->getExportFields($this->app->getModuleName()); } - /** - * Check flow rule. - * - * @param object $field - * @param string $value - * @access public - * @return bool|string - */ - public function checkFlowRule($field, $value) - { - if(!isset($this->config->bizVersion)) return false; - - return $this->loadModel('flow')->checkRule($field, $value); - } - /** * Execute Hooks * diff --git a/module/bug/model.php b/module/bug/model.php index 139ce507bf..dabf7a5e65 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -94,6 +94,7 @@ class bugModel extends model ->autoCheck() ->checkIF($bug->notifyEmail, 'notifyEmail', 'email') ->batchCheck($this->config->bug->create->requiredFields, 'notempty') + ->checkFlow() ->exec(); if(!dao::isError()) @@ -225,8 +226,6 @@ class bugModel extends model if(is_array($bug->{$extendField->field})) $bug->{$extendField->field} = join(',', $bug->{$extendField->field}); $bug->{$extendField->field} = htmlSpecialString($bug->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $bug->{$extendField->field}); - if($message) return print(js::alert($message)); } /* Required field check. */ @@ -282,6 +281,7 @@ class bugModel extends model $this->dao->insert(TABLE_BUG)->data($bug) ->autoCheck() ->batchCheck($this->config->bug->create->requiredFields, 'notempty') + ->checkFlow() ->exec(); if(dao::isError()) return false; @@ -717,6 +717,7 @@ class bugModel extends model ->checkIF($bug->notifyEmail, 'notifyEmail', 'email') ->checkIF($bug->resolution == 'duplicate', 'duplicateBug', 'notempty') ->checkIF($bug->resolution == 'fixed', 'resolvedBuild','notempty') + ->checkFlow() ->where('id')->eq((int)$bugID) ->exec(); @@ -827,8 +828,6 @@ class bugModel extends model if(is_array($bug->{$extendField->field})) $bug->{$extendField->field} = join(',', $bug->{$extendField->field}); $bug->{$extendField->field} = htmlSpecialString($bug->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $bug->{$extendField->field}); - if($message) return print(js::alert($message)); } $bugs[$bugID] = $bug; @@ -845,6 +844,7 @@ class bugModel extends model ->batchCheck($this->config->bug->edit->requiredFields, 'notempty') ->checkIF($bug->resolvedBy, 'resolution', 'notempty') ->checkIF($bug->resolution == 'duplicate', 'duplicateBug', 'notempty') + ->checkFlow() ->where('id')->eq((int)$bugID) ->exec(); @@ -940,6 +940,7 @@ class bugModel extends model $this->dao->update(TABLE_BUG) ->data($bug) ->autoCheck() + ->checkFlow() ->where('id')->eq($bugID)->exec(); if(!dao::isError()) return common::createChanges($oldBug, $bug); @@ -970,7 +971,7 @@ class bugModel extends model ->join('mailto', ',') ->get(); - $this->dao->update(TABLE_BUG)->data($bug)->where('id')->eq($bugID)->exec(); + $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->checkFlow()->where('id')->eq($bugID)->exec(); if(!dao::isError()) { @@ -1100,6 +1101,7 @@ class bugModel extends model ->batchCheck($this->config->bug->resolve->requiredFields, 'notempty') ->checkIF($bug->resolution == 'duplicate', 'duplicateBug', 'notempty') ->checkIF($bug->resolution == 'fixed', 'resolvedBuild','notempty') + ->checkFlow() ->where('id')->eq((int)$bugID) ->exec(); @@ -1324,7 +1326,7 @@ class bugModel extends model ->remove('comment,files,labels') ->get(); - $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->where('id')->eq((int)$bugID)->exec(); + $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->checkFlow()->where('id')->eq((int)$bugID)->exec(); $this->dao->update(TABLE_BUG)->set('activatedCount = activatedCount + 1')->where('id')->eq((int)$bugID)->exec(); if($solveBuild) @@ -1372,7 +1374,7 @@ class bugModel extends model ->remove('comment') ->get(); - $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->where('id')->eq((int)$bugID)->exec(); + $this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->checkFlow()->where('id')->eq((int)$bugID)->exec(); if($oldBug->execution) { $this->loadModel('kanban'); diff --git a/module/build/model.php b/module/build/model.php index 323ae85c58..389e00e42a 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -300,6 +300,7 @@ class buildModel extends model ->autoCheck() ->batchCheck($this->config->build->create->requiredFields, 'notempty') ->check('name', 'unique', "product = {$build->product} AND branch = {$build->branch} AND deleted = '0'") + ->checkFlow() ->exec(); if(!dao::isError()) @@ -336,6 +337,7 @@ class buildModel extends model ->batchCheck($this->config->build->edit->requiredFields, 'notempty') ->where('id')->eq($buildID) ->check('name', 'unique', "id != $buildID AND product = {$build->product} AND branch = {$build->branch} AND deleted = '0'") + ->checkFlow() ->exec(); if(isset($build->branch) and $oldBuild->branch != $build->branch) $this->dao->update(TABLE_RELEASE)->set('branch')->eq($build->branch)->where('build')->eq($buildID)->exec(); if(!dao::isError()) diff --git a/module/caselib/model.php b/module/caselib/model.php index 25bc2b146c..aab29936bf 100644 --- a/module/caselib/model.php +++ b/module/caselib/model.php @@ -102,6 +102,7 @@ class caselibModel extends model $this->dao->update(TABLE_TESTSUITE)->data($lib) ->autoCheck() ->batchcheck($this->config->caselib->edit->requiredFields, 'notempty') + ->checkFlow() ->where('id')->eq($libID) ->exec(); if(!dao::isError()) @@ -186,6 +187,7 @@ class caselibModel extends model $this->dao->insert(TABLE_TESTSUITE)->data($lib) ->batchcheck($this->config->caselib->create->requiredFields, 'notempty') ->check('name', 'unique', "deleted = '0'") + ->checkFlow() ->exec(); if(!dao::isError()) { diff --git a/module/execution/model.php b/module/execution/model.php index 6a1901eba2..228e171349 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -378,6 +378,7 @@ class executionModel extends model ->checkIF($sprint->begin != '', 'begin', 'date') ->checkIF($sprint->end != '', 'end', 'date') ->checkIF($sprint->end != '', 'end', 'ge', $sprint->begin) + ->checkFlow() ->exec(); /* Add the creater to the team. */ @@ -514,6 +515,7 @@ class executionModel extends model ->checkIF($execution->end != '', 'end', 'ge', $execution->begin) ->checkIF((!empty($execution->name) and $this->config->systemMode == 'new'), 'name', 'unique', "id != $executionID and type in ('sprint','stage') and `project` = $executionProject") ->checkIF(!empty($execution->code), 'code', 'unique', "id != $executionID and type in ('sprint','stage')") + ->checkFlow() ->where('id')->eq($executionID) ->limit(1) ->exec(); @@ -669,13 +671,6 @@ class executionModel extends model if(is_array($executions[$executionID]->{$extendField->field})) $executions[$executionID]->{$extendField->field} = join(',', $executions[$executionID]->{$extendField->field}); $executions[$executionID]->{$extendField->field} = htmlSpecialString($executions[$executionID]->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $executions[$executionID]->{$extendField->field}); - - if($message) - { - dao::$errors['message'][] = $message; - return false; - } } } @@ -705,6 +700,7 @@ class executionModel extends model ->checkIF($execution->end != '', 'end', 'ge', $execution->begin) ->checkIF((!empty($execution->name) and $this->config->systemMode == 'new'), 'name', 'unique', "id != $executionID and type in ('sprint','stage') and `project` = $projectID") ->checkIF(!empty($execution->code), 'code', 'unique', "id != $executionID and type in ('sprint','stage')") + ->checkFlow() ->where('id')->eq($executionID) ->limit(1) ->exec(); @@ -767,6 +763,7 @@ class executionModel extends model ->autoCheck() ->check($this->config->execution->start->requiredFields, 'notempty') ->checkIF($execution->realBegan != '', 'realBegan', 'le', helper::today()) + ->checkFlow() ->where('id')->eq((int)$executionID) ->exec(); @@ -799,6 +796,7 @@ class executionModel extends model $this->dao->update(TABLE_EXECUTION)->data($execution) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$executionID) ->exec(); @@ -825,6 +823,7 @@ class executionModel extends model $this->dao->update(TABLE_EXECUTION)->data($execution) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$executionID) ->exec(); @@ -859,6 +858,7 @@ class executionModel extends model $this->dao->update(TABLE_EXECUTION)->data($execution) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$executionID) ->exec(); @@ -928,6 +928,7 @@ class executionModel extends model ->check($this->config->execution->close->requiredFields,'notempty') ->checkIF($execution->realEnd != '', 'realEnd', 'le', helper::today()) ->checkIF($execution->realEnd != '', 'realEnd', 'ge', $oldExecution->realBegan) + ->checkFlow() ->where('id')->eq((int)$executionID) ->exec(); diff --git a/module/product/model.php b/module/product/model.php index 21eee5e278..4080a98d00 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -609,6 +609,7 @@ class productModel extends model ->batchCheck($this->config->product->create->requiredFields, 'notempty') ->checkIF((!empty($product->name) and $this->config->systemMode == 'new'), 'name', 'unique', "`program` = $programID") ->checkIF(!empty($product->code), 'code', 'unique') + ->checkFlow() ->exec(); if(!dao::isError()) @@ -717,6 +718,7 @@ class productModel extends model ->batchCheck($this->config->product->edit->requiredFields, 'notempty') ->checkIF((!empty($product->name) and $this->config->systemMode == 'new'), 'name', 'unique', "id != $productID and `program` = $programID") ->checkIF(!empty($product->code), 'code', 'unique', "id != $productID") + ->checkFlow() ->where('id')->eq($productID) ->exec(); @@ -771,8 +773,6 @@ class productModel extends model if(is_array($products[$productID]->{$extendField->field})) $products[$productID]->{$extendField->field} = join(',', $products[$productID]->{$extendField->field}); $products[$productID]->{$extendField->field} = htmlSpecialString($products[$productID]->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $products[$productID]->{$extendField->field}); - if($message) return print(js::alert($message)); } } if(dao::isError()) return print(js::error(dao::getError())); @@ -789,6 +789,7 @@ class productModel extends model ->autoCheck() ->batchCheck($this->config->product->edit->requiredFields , 'notempty') ->checkIF((!empty($product->name) and $this->config->systemMode == 'new'), 'name', 'unique', "id != $productID and `program` = $programID") + ->checkFlow() ->where('id')->eq($productID) ->exec(); if(dao::isError()) return print(js::error('product#' . $productID . dao::getError(true))); @@ -825,6 +826,7 @@ class productModel extends model $this->dao->update(TABLE_PRODUCT)->data($product) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$productID) ->exec(); diff --git a/module/productplan/model.php b/module/productplan/model.php index b389bc6c81..92c920cbc9 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -432,6 +432,7 @@ class productplanModel extends model ->autoCheck() ->batchCheck($this->config->productplan->create->requiredFields, 'notempty') ->checkIF(!$this->post->future && !empty($_POST['begin']) && !empty($_POST['end']), 'end', 'ge', $plan->begin) + ->checkFlow() ->exec(); if(!dao::isError()) { @@ -512,6 +513,7 @@ class productplanModel extends model ->autoCheck() ->batchCheck($this->config->productplan->edit->requiredFields, 'notempty') ->checkIF(!$this->post->future && !empty($_POST['begin']) && !empty($_POST['end']), 'end', 'ge', $plan->begin) + ->checkFlow() ->where('id')->eq((int)$planID) ->exec(); if(dao::isError()) return false; @@ -651,8 +653,6 @@ class productplanModel extends model if(is_array($plan->{$extendField->field})) $plan->{$extendField->field} = join(',', $plan->{$extendField->field}); $plan->{$extendField->field} = htmlSpecialString($plan->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $plan->{$extendField->field}); - if($message) return print(js::alert($message)); } $plans[$planID] = $plan; @@ -695,7 +695,7 @@ class productplanModel extends model if($change) { if($parentID > 0 and !isset($parents[$parentID])) $parents[$parentID] = $parentID; - $this->dao->update(TABLE_PRODUCTPLAN)->data($plan)->autoCheck()->where('id')->eq($planID)->exec(); + $this->dao->update(TABLE_PRODUCTPLAN)->data($plan)->autoCheck()->checkFlow()->where('id')->eq($planID)->exec(); if(dao::isError()) return print(js::error(dao::getError())); $changes[$planID] = $change; } diff --git a/module/program/model.php b/module/program/model.php index baff7f83d0..b1932bf963 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -657,6 +657,7 @@ class programModel extends model ->checkIF($program->end != '', 'end', 'date') ->checkIF($program->end != '', 'end', 'gt', $program->begin) ->checkIF(!empty($program->name), 'name', 'unique', "`type`='program' and `parent` = $program->parent") + ->checkFlow() ->exec(); if(!dao::isError()) @@ -755,6 +756,7 @@ class programModel extends model ->checkIF($program->end != '', 'end', 'date') ->checkIF($program->end != '', 'end', 'gt', $program->begin) ->checkIF(!empty($program->name), 'name', 'unique', "id!=$programID and `type`='program' and `parent` = $program->parent") + ->checkFlow() ->where('id')->eq($programID) ->limit(1) ->exec(); diff --git a/module/project/model.php b/module/project/model.php index ab4804577c..86ef1e72d8 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -913,6 +913,7 @@ class projectModel extends model ->checkIF(!empty($project->name), 'name', 'unique', "`type`='project' and `parent` = $project->parent and `model` = '{$project->model}'") ->checkIF(!empty($project->code), 'code', 'unique', "`type`='project' and `model` = '{$project->model}'") ->checkIF($project->end != '', 'end', 'gt', $project->begin) + ->checkFlow() ->exec(); /* Add the creater to the team. */ @@ -1145,6 +1146,7 @@ class projectModel extends model ->checkIF($project->end != '', 'end', 'gt', $project->begin) ->checkIF(!empty($project->name), 'name', 'unique', "id != $projectID and `type` = 'project' and `parent` = $project->parent and `model` = '{$project->model}'") ->checkIF(!empty($project->code), 'code', 'unique', "id != $projectID and `type` = 'project' and `model` = '{$project->model}'") + ->checkFlow() ->where('id')->eq($projectID) ->exec(); @@ -1267,8 +1269,6 @@ class projectModel extends model if(is_array($projects[$projectID]->{$extendField->field})) $projects[$projectID]->{$extendField->field} = join(',', $projects[$projectID]->{$extendField->field}); $projects[$projectID]->{$extendField->field} = htmlSpecialString($projects[$projectID]->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $projects[$projectID]->{$extendField->field}); - if($message) hepler::end(js::alert($message)); } } if(dao::isError()) return print(js::error(dao::getError())); @@ -1286,6 +1286,7 @@ class projectModel extends model ->checkIF($project->end != '', 'end', 'gt', $project->begin) ->checkIF(!empty($project->name), 'name', 'unique', "id != $projectID and `type`='project' and `parent` = $parentID and `model` = '{$project->model}'") ->checkIF(!empty($project->code), 'code', 'unique', "id != $projectID and `type`='project' and `model` = '{$project->model}'") + ->checkFlow() ->where('id')->eq($projectID) ->exec(); @@ -1328,6 +1329,7 @@ class projectModel extends model ->autoCheck() ->check($this->config->project->start->requiredFields, 'notempty') ->checkIF($project->realBegan != '', 'realBegan', 'le', helper::today()) + ->checkFlow() ->where('id')->eq((int)$projectID) ->exec(); @@ -1357,6 +1359,7 @@ class projectModel extends model $this->dao->update(TABLE_PROJECT)->data($project) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$projectID) ->exec(); @@ -1382,6 +1385,7 @@ class projectModel extends model $this->dao->update(TABLE_PROJECT)->data($project) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$projectID) ->exec(); @@ -1417,6 +1421,7 @@ class projectModel extends model $this->dao->update(TABLE_PROJECT)->data($project) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$projectID) ->exec(); @@ -1486,6 +1491,7 @@ class projectModel extends model ->check($this->config->project->close->requiredFields, 'notempty') ->checkIF($project->realEnd != '', 'realEnd', 'le', helper::today()) ->checkIF($project->realEnd != '', 'realEnd', 'ge', $oldProject->realBegan) + ->checkFlow() ->where('id')->eq((int)$projectID) ->exec(); diff --git a/module/story/model.php b/module/story/model.php index 1877c18449..4d5e1f58e9 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -247,6 +247,7 @@ class storyModel extends model ->autoCheck() ->checkIF($story->notifyEmail, 'notifyEmail', 'email') ->batchCheck($requiredFields, 'notempty') + ->checkFlow() ->exec(); if(!dao::isError()) @@ -514,8 +515,6 @@ class storyModel extends model if(is_array($story->{$extendField->field})) $story->{$extendField->field} = join(',', $story->{$extendField->field}); $story->{$extendField->field} = htmlSpecialString($story->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $story->{$extendField->field}); - if($message) return print(js::alert($message)); } foreach(explode(',', $this->config->story->create->requiredFields) as $field) @@ -538,7 +537,7 @@ class storyModel extends model foreach($data as $i => $story) { - $this->dao->insert(TABLE_STORY)->data($story)->autoCheck()->exec(); + $this->dao->insert(TABLE_STORY)->data($story)->autoCheck()->checkFlow()->exec(); if(dao::isError()) { echo js::error(dao::getError()); @@ -693,6 +692,7 @@ class storyModel extends model $this->dao->update(TABLE_STORY)->data($story, 'spec,verify') ->autoCheck() ->batchCheck($this->config->story->change->requiredFields, 'notempty') + ->checkFlow() ->where('id')->eq((int)$storyID)->exec(); if(!dao::isError()) @@ -864,6 +864,7 @@ class storyModel extends model ->checkIF(isset($story->closedReason) and $story->closedReason == 'done', 'stage', 'notempty') ->checkIF(isset($story->closedReason) and $story->closedReason == 'duplicate', 'duplicateStory', 'notempty') ->checkIF($story->notifyEmail, 'notifyEmail', 'email') + ->checkFlow() ->where('id')->eq((int)$storyID)->exec(); if(!dao::isError()) @@ -1245,8 +1246,6 @@ class storyModel extends model if(is_array($story->{$extendField->field})) $story->{$extendField->field} = join(',', $story->{$extendField->field}); $story->{$extendField->field} = htmlSpecialString($story->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $story->{$extendField->field}); - if($message) return print(js::alert($message)); } $stories[$storyID] = $story; @@ -1261,6 +1260,7 @@ class storyModel extends model ->checkIF($story->closedBy, 'closedReason', 'notempty') ->checkIF($story->closedReason == 'done', 'stage', 'notempty') ->checkIF($story->closedReason == 'duplicate', 'duplicateStory', 'notempty') + ->checkFlow() ->where('id')->eq((int)$storyID) ->exec(); if($story->title != $oldStory->title) @@ -1353,6 +1353,7 @@ class storyModel extends model ->batchCheck($this->config->story->review->requiredFields, 'notempty') ->checkIF($this->post->result == 'reject', 'closedReason', 'notempty') ->checkIF($this->post->result == 'reject' and $this->post->closedReason == 'duplicate', 'duplicateStory', 'notempty') + ->checkFlow() ->where('id')->eq($storyID)->exec(); if($this->post->result == 'revert') { @@ -1576,6 +1577,7 @@ class storyModel extends model ->autoCheck() ->batchCheck($this->config->story->close->requiredFields, 'notempty') ->checkIF($story->closedReason == 'duplicate', 'duplicateStory', 'notempty') + ->checkFlow() ->where('id')->eq($storyID)->exec(); /* Update parent story status and stage. */ @@ -1975,13 +1977,13 @@ class storyModel extends model $assignedTo = $this->post->assignedTo; if($assignedTo == $oldStory->assignedTo) return array(); - $story = new stdclass(); - $story->lastEditedBy = $this->app->user->account; - $story->lastEditedDate = $now; - $story->assignedTo = $assignedTo; - $story->assignedDate = $now; + $story = fixer::input('post') + ->add('lastEditedBy', $this->app->user->account) + ->add('lastEditedDate', $now) + ->add('assignedDate', $now) + ->get(); - $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec(); + $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->checkFlow()->where('id')->eq((int)$storyID)->exec(); if(!dao::isError()) return common::createChanges($oldStory, $story); return false; } @@ -2042,7 +2044,7 @@ class storyModel extends model ->setDefault('activatedDate', $now) ->remove('comment') ->get(); - $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq($storyID)->exec(); + $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->checkFlow()->where('id')->eq($storyID)->exec(); if($this->post->status == 'active') $this->dao->delete()->from(TABLE_STORYREVIEW)->where('story')->eq($storyID)->exec(); diff --git a/module/task/model.php b/module/task/model.php index bf0961a34f..c25ac00dd2 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -138,6 +138,7 @@ class taskModel extends model ->batchCheck($requiredFields, 'notempty') ->checkIF($task->estimate != '', 'estimate', 'float') ->checkIF(!helper::isZeroDate($task->deadline), 'deadline', 'ge', $task->estStarted) + ->checkFlow() ->exec(); if(dao::isError()) return false; @@ -363,12 +364,6 @@ class taskModel extends model if(is_array($data[$i]->{$extendField->field})) $data[$i]->{$extendField->field} = join(',', $data[$i]->{$extendField->field}); $data[$i]->{$extendField->field} = htmlSpecialString($data[$i]->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $data[$i]->{$extendField->field}); - if($message) - { - dao::$errors['message'][] = sprintf($message); - return false; - } } } @@ -423,6 +418,7 @@ class taskModel extends model $this->dao->insert(TABLE_TASK)->data($task) ->autoCheck() ->checkIF($task->estimate != '', 'estimate', 'float') + ->checkFlow() ->exec(); if(dao::isError()) return false; @@ -1048,6 +1044,7 @@ class taskModel extends model ->batchCheckIF($task->status == 'done', 'canceledBy, canceledDate', 'empty') ->batchCheckIF($task->closedReason == 'cancel', 'finishedBy, finishedDate', 'empty') + ->checkFlow() ->where('id')->eq((int)$taskID)->exec(); if(!dao::isError()) @@ -1217,8 +1214,6 @@ class taskModel extends model if(is_array($task->{$extendField->field})) $task->{$extendField->field} = join(',', $task->{$extendField->field}); $task->{$extendField->field} = htmlSpecialString($task->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $task->{$extendField->field}); - if($message) return print(js::alert($message)); } if(isset($data->consumeds[$taskID])) @@ -1353,6 +1348,7 @@ class taskModel extends model ->batchCheckIF($task->status == 'done', 'canceledBy, canceledDate', 'empty') ->batchCheckIF($task->closedReason == 'cancel', 'finishedBy, finishedDate', 'empty') + ->checkFlow() ->where('id')->eq((int)$taskID) ->exec(); if(dao::isError()) @@ -1469,6 +1465,7 @@ class taskModel extends model ->data($task) ->autoCheck() ->check('left', 'float') + ->checkFlow() ->where('id')->eq($taskID) ->exec(); @@ -1555,6 +1552,7 @@ class taskModel extends model $this->dao->update(TABLE_TASK)->data($task) ->autoCheck() ->check('consumed,left', 'float') + ->checkFlow() ->where('id')->eq((int)$taskID)->exec(); if($oldTask->parent > 0) @@ -1825,6 +1823,7 @@ class taskModel extends model $this->dao->update(TABLE_TASK)->data($task) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$taskID) ->exec(); @@ -1863,7 +1862,7 @@ class taskModel extends model ->remove('comment') ->get(); - $this->dao->update(TABLE_TASK)->data($task)->autoCheck()->where('id')->eq((int)$taskID)->exec(); + $this->dao->update(TABLE_TASK)->data($task)->autoCheck()->checkFlow()->where('id')->eq((int)$taskID)->exec(); if($oldTask->parent > 0) $this->updateParentStatus($taskID); @@ -1901,7 +1900,7 @@ class taskModel extends model ->remove('comment') ->get(); - $this->dao->update(TABLE_TASK)->data($task)->autoCheck()->where('id')->eq((int)$taskID)->exec(); + $this->dao->update(TABLE_TASK)->data($task)->autoCheck()->checkFlow()->where('id')->eq((int)$taskID)->exec(); if(!dao::isError()) { @@ -1945,7 +1944,7 @@ class taskModel extends model ->remove('comment') ->get(); - $this->dao->update(TABLE_TASK)->data($task)->autoCheck()->where('id')->eq((int)$taskID)->exec(); + $this->dao->update(TABLE_TASK)->data($task)->autoCheck()->checkFlow()->where('id')->eq((int)$taskID)->exec(); if($oldTask->fromBug) $this->dao->update(TABLE_BUG)->set('toTask')->eq(0)->where('id')->eq($oldTask->fromBug)->exec(); if($oldTask->parent > 0) $this->updateParentStatus($taskID); if($oldTask->parent == '-1') @@ -2027,6 +2026,7 @@ class taskModel extends model $this->dao->update(TABLE_TASK)->data($task) ->autoCheck() ->batchCheck($this->config->task->activate->requiredFields, 'notempty') + ->checkFlow() ->where('id')->eq((int)$taskID) ->exec(); diff --git a/module/testcase/model.php b/module/testcase/model.php index 0b316b941f..94a36ec02d 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -64,7 +64,7 @@ class testcaseModel extends model /* Value of story may be showmore. */ $case->story = (int)$case->story; - $this->dao->insert(TABLE_CASE)->data($case)->autoCheck()->batchCheck($this->config->testcase->create->requiredFields, 'notempty')->exec(); + $this->dao->insert(TABLE_CASE)->data($case)->autoCheck()->batchCheck($this->config->testcase->create->requiredFields, 'notempty')->checkFlow()->exec(); if(!$this->dao->isError()) { $caseID = $this->dao->lastInsertID(); @@ -174,8 +174,6 @@ class testcaseModel extends model if(is_array($data[$i]->{$extendField->field})) $data[$i]->{$extendField->field} = join(',', $data[$i]->{$extendField->field}); $data[$i]->{$extendField->field} = htmlSpecialString($data[$i]->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $data[$i]->{$extendField->field}); - if($message) return print(js::alert($message)); } foreach(explode(',', $this->config->testcase->create->requiredFields) as $field) @@ -191,6 +189,7 @@ class testcaseModel extends model $this->dao->insert(TABLE_CASE)->data($case) ->autoCheck() ->batchCheck($this->config->testcase->create->requiredFields, 'notempty') + ->checkFlow() ->exec(); if(dao::isError()) @@ -737,7 +736,7 @@ class testcaseModel extends model array_splice($requiredFieldsArr, $fieldIndex, 1); $requiredFields = implode(',', $requiredFieldsArr); } - $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->batchCheck($requiredFields, 'notempty')->where('id')->eq((int)$caseID)->exec(); + $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->batchCheck($requiredFields, 'notempty')->checkFlow()->where('id')->eq((int)$caseID)->exec(); if(!$this->dao->isError()) { $isLibCase = ($oldCase->lib and empty($oldCase->product)); @@ -843,7 +842,7 @@ class testcaseModel extends model ->join('reviewedBy', ',') ->get(); - $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->where('id')->eq($caseID)->exec(); + $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->checkFlow()->where('id')->eq($caseID)->exec(); if(dao::isError()) return false; @@ -967,8 +966,6 @@ class testcaseModel extends model if(is_array($case->{$extendField->field})) $case->{$extendField->field} = join(',', $case->{$extendField->field}); $case->{$extendField->field} = htmlSpecialString($case->{$extendField->field}); - $message = $this->checkFlowRule($extendField, $case->{$extendField->field}); - if($message) return print(js::alert($message)); } $cases[$caseID] = $case; @@ -983,6 +980,7 @@ class testcaseModel extends model $this->dao->update(TABLE_CASE)->data($case) ->autoCheck() ->batchCheck($this->config->testcase->edit->requiredFields, 'notempty') + ->checkFlow() ->where('id')->eq($caseID) ->exec(); diff --git a/module/testsuite/model.php b/module/testsuite/model.php index a0d52b572f..0e636d720a 100644 --- a/module/testsuite/model.php +++ b/module/testsuite/model.php @@ -71,6 +71,7 @@ class testsuiteModel extends model $suite = $this->loadModel('file')->processImgURL($suite, $this->config->testsuite->editor->create['id'], $this->post->uid); $this->dao->insert(TABLE_TESTSUITE)->data($suite) ->batchcheck($this->config->testsuite->create->requiredFields, 'notempty') + ->checkFlow() ->exec(); if(!dao::isError()) { @@ -157,6 +158,7 @@ class testsuiteModel extends model $this->dao->update(TABLE_TESTSUITE)->data($suite) ->autoCheck() ->batchcheck($this->config->testsuite->edit->requiredFields, 'notempty') + ->checkFlow() ->where('id')->eq($suiteID) ->exec(); if(!dao::isError()) diff --git a/module/testtask/model.php b/module/testtask/model.php index 6e8562b065..079992d200 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -44,6 +44,7 @@ class testtaskModel extends model ->checkIF($task->begin != '', 'begin', 'date') ->checkIF($task->end != '', 'end', 'date') ->checkIF($task->end != '', 'end', 'ge', $task->begin) + ->checkFlow() ->exec(); if(!dao::isError()) @@ -739,6 +740,7 @@ class testtaskModel extends model ->autoCheck() ->batchcheck($this->config->testtask->edit->requiredFields, 'notempty') ->checkIF($task->end != '', 'end', 'ge', $task->begin) + ->checkFlow() ->where('id')->eq($taskID) ->exec(); if(!dao::isError()) @@ -765,6 +767,7 @@ class testtaskModel extends model $this->dao->update(TABLE_TESTTASK)->data($testtask) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$taskID) ->exec(); @@ -801,6 +804,7 @@ class testtaskModel extends model $testtask = $this->loadModel('file')->processImgURL($testtask, $this->config->testtask->editor->close['id'], $this->post->uid); $this->dao->update(TABLE_TESTTASK)->data($testtask) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$taskID) ->exec(); @@ -827,6 +831,7 @@ class testtaskModel extends model $this->dao->update(TABLE_TESTTASK)->data($testtask) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$taskID) ->exec(); @@ -849,6 +854,7 @@ class testtaskModel extends model $this->dao->update(TABLE_TESTTASK)->data($testtask) ->autoCheck() + ->checkFlow() ->where('id')->eq((int)$taskID) ->exec(); From e30acad1f2cba5f5ac24b405360f09bf61e1e8fa Mon Sep 17 00:00:00 2001 From: daitingting Date: Mon, 9 May 2022 07:56:17 +0000 Subject: [PATCH 2/2] * Add id for checking unique field. --- framework/control.class.php | 2 -- lib/dao/dao.class.php | 6 +++--- module/bug/model.php | 7 +++++++ module/build/model.php | 1 + module/caselib/model.php | 1 + module/execution/model.php | 7 +++++++ module/product/model.php | 3 +++ module/productplan/model.php | 2 ++ module/program/model.php | 1 + module/project/model.php | 7 +++++++ module/release/model.php | 3 +++ module/story/model.php | 7 +++++++ module/task/model.php | 9 +++++++++ module/testcase/model.php | 3 +++ module/testsuite/model.php | 1 + module/testtask/model.php | 13 ++++++++++++- 16 files changed, 67 insertions(+), 6 deletions(-) diff --git a/framework/control.class.php b/framework/control.class.php index a545295b65..021fc7fa28 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -42,8 +42,6 @@ class control extends baseControl /* Code for task #9224. Set requiredFields for workflow. */ if($this->dbh and (defined('IN_USE') or (defined('RUN_MODE') and RUN_MODE == 'api'))) { - $this->checkRequireFlowField(); - if(isset($this->config->{$this->moduleName}) and strpos($this->methodName, 'export') !== false) { if(isset($this->config->{$this->moduleName}->exportFields) or isset($this->config->{$this->moduleName}->list->exportFields)) diff --git a/lib/dao/dao.class.php b/lib/dao/dao.class.php index 7718671118..7b99d5f16b 100644 --- a/lib/dao/dao.class.php +++ b/lib/dao/dao.class.php @@ -47,14 +47,14 @@ class dao extends baseDAO $module = $app->getmodulename(); $method = $app->getmethodname(); - $flowaction = $this->dbh->query("select * from " . table_workflowaction . " where `module` = '{$module}' and `action` = '{$method}' and `buildin` = '1' and `extensiontype` = 'extend'")->fetch(pdo::fetch_obj); + $flowaction = $this->dbh->query("select * from " . TABLE_WORKFLOWACTION . " where `module` = '{$module}' and `action` = '{$method}' and `buildin` = '1' and `extensiontype` = 'extend'")->fetch(PDO::FETCH_OBJ); if(!$flowaction) return $this; - $flowfields = $this->dbh->query("select t2.name,t2.rules,t2.control,t2.field,t1.layoutrules from " . table_workflowlayout . " as t1 left join " . table_workflowfield . " as t2 on t1.module = t2.module and t1.field = t2.field where t1.module = '{$module}' and t1.action = '{$method}' and t1.readonly = '0'")->fetchall(); + $flowfields = $this->dbh->query("select t2.name,t2.rules,t2.control,t2.field,t1.layoutrules from " . TABLE_WORKFLOWLAYOUT . " as t1 left join " . TABLE_WORKFLOWFIELD . " as t2 on t1.module = t2.module and t1.field = t2.field where t1.module = '{$module}' and t1.action = '{$method}' and t1.readonly = '0'")->fetchall(); if(!$flowfields) return $this; $rules = array(); - $rawrules = $this->dbh->query("select * from " . table_workflowrule)->fetchall(); + $rawrules = $this->dbh->query("select * from " . TABLE_WORKFLOWRULE)->fetchall(); foreach($rawrules as $rule) $rules[$rule->id] = $rule; foreach($flowfields as $key => $field) diff --git a/module/bug/model.php b/module/bug/model.php index dabf7a5e65..5df7ce7a40 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -675,6 +675,7 @@ class bugModel extends model } $now = helper::now(); $bug = fixer::input('post') + ->add('id', $bugID) ->cleanInt('product,module,severity,project,execution,story,task,branch') ->stripTags($this->config->bug->editor->edit['id'], $this->config->allowedTags) ->setDefault('product,module,execution,story,task,duplicateBug,branch', 0) @@ -789,6 +790,7 @@ class bugModel extends model $oldBug = $oldBugs[$bugID]; $bug = new stdclass(); + $bug->id = $bugID; $bug->lastEditedBy = $this->app->user->account; $bug->lastEditedDate = $now; $bug->type = $data->types[$bugID]; @@ -930,6 +932,7 @@ class bugModel extends model $now = helper::now(); $oldBug = $this->getById($bugID); $bug = fixer::input('post') + ->add('id', $bugID) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->setDefault('assignedDate', $now) @@ -963,6 +966,7 @@ class bugModel extends model $oldBug = $this->getById($bugID); $bug = fixer::input('post') + ->add('id', $bugID) ->setDefault('confirmed', 1) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) @@ -1028,6 +1032,7 @@ class bugModel extends model $now = helper::now(); $oldBug = $this->getById($bugID); $bug = fixer::input('post') + ->add('id', $bugID) ->add('status', 'resolved') ->add('confirmed', 1) ->setDefault('lastEditedBy', $this->app->user->account) @@ -1312,6 +1317,7 @@ class bugModel extends model ->setDefault('lastEditedDate', $now) ->setDefault('activatedDate', $now) ->setDefault('activatedCount', (int)$oldBug->activatedCount) + ->add('id', $bugID) ->add('resolution', '') ->add('status', 'active') ->add('resolvedDate', '0000-00-00') @@ -1363,6 +1369,7 @@ class bugModel extends model $now = helper::now(); $oldBug = $this->getById($bugID); $bug = fixer::input('post') + ->add('id', $bugID) ->add('assignedTo', 'closed') ->add('status', 'closed') ->add('confirmed', 1) diff --git a/module/build/model.php b/module/build/model.php index 389e00e42a..b72d747ec6 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -325,6 +325,7 @@ class buildModel extends model $buildID = (int)$buildID; $oldBuild = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->eq($buildID)->fetch(); $build = fixer::input('post')->stripTags($this->config->build->editor->edit['id'], $this->config->allowedTags) + ->add('id', $buildID) ->setIF(!isset($_POST['branch']), 'branch', $oldBuild->branch) ->setDefault('product', $oldBuild->product) ->cleanInt('product,branch,execution') diff --git a/module/caselib/model.php b/module/caselib/model.php index aab29936bf..d4adfab1ea 100644 --- a/module/caselib/model.php +++ b/module/caselib/model.php @@ -94,6 +94,7 @@ class caselibModel extends model $oldLib = $this->dao->select("*")->from(TABLE_TESTSUITE)->where('id')->eq((int)$libID)->fetch(); $lib = fixer::input('post') ->stripTags($this->config->caselib->editor->edit['id'], $this->config->allowedTags) + ->add('id', $libID) ->add('lastEditedBy', $this->app->user->account) ->add('lastEditedDate', helper::now()) ->remove('uid') diff --git a/module/execution/model.php b/module/execution/model.php index 228e171349..7439711471 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -469,6 +469,7 @@ class executionModel extends model /* Get the data from the post. */ $execution = fixer::input('post') + ->add('id', $executionID) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', helper::now()) ->setIF(helper::isZeroDate($this->post->begin), 'begin', '') @@ -621,6 +622,7 @@ class executionModel extends model $executionID = (int)$executionID; $executions[$executionID] = new stdClass(); + $executions[$executionID]->id = $executionID; $executions[$executionID]->name = $executionName; $executions[$executionID]->code = $executionCode; $executions[$executionID]->PM = $data->PMs[$executionID]; @@ -753,6 +755,7 @@ class executionModel extends model $now = helper::now(); $execution = fixer::input('post') + ->add('id', $executionID) ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) @@ -786,6 +789,7 @@ class executionModel extends model $now = helper::now(); $execution = fixer::input('post') + ->add('id', $executionID) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->remove('comment') @@ -816,6 +820,7 @@ class executionModel extends model $now = helper::now(); $execution = fixer::input('post') + ->add('id', $executionID) ->setDefault('status', 'suspended') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) @@ -843,6 +848,7 @@ class executionModel extends model $now = helper::now(); $execution = fixer::input('post') + ->add('id', $executionID) ->setDefault('realEnd', '') ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) @@ -913,6 +919,7 @@ class executionModel extends model $now = helper::now(); $execution = fixer::input('post') + ->add('id', $executionID) ->setDefault('status', 'closed') ->setDefault('closedBy', $this->app->user->account) ->setDefault('closedDate', $now) diff --git a/module/product/model.php b/module/product/model.php index 4080a98d00..2f1239d04d 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -684,6 +684,7 @@ class productModel extends model if($oldProduct->bind) $this->config->product->edit->requiredFields = 'name'; $product = fixer::input('post') + ->add('id', $productID) ->callFunc('name', 'trim') ->setDefault('line', 0) ->setIF(!isset($_POST['whitelist']), 'whitelist', '') @@ -766,6 +767,7 @@ class productModel extends model $products[$productID]->status = $data->statuses[$productID]; $products[$productID]->desc = strip_tags($this->post->descs[$productID], $this->config->allowedTags); $products[$productID]->acl = $data->acls[$productID]; + $products[$productID]->id = $productID; foreach($extendFields as $extendField) { @@ -821,6 +823,7 @@ class productModel extends model $oldProduct = $this->getById($productID); $now = helper::now(); $product= fixer::input('post') + ->add('id', $productID) ->setDefault('status', 'closed') ->remove('comment')->get(); diff --git a/module/productplan/model.php b/module/productplan/model.php index 92c920cbc9..ad2d763bec 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -476,6 +476,7 @@ class productplanModel extends model $plan = fixer::input('post')->stripTags($this->config->productplan->editor->edit['id'], $this->config->allowedTags) ->setIF($this->post->future or empty($_POST['begin']), 'begin', $this->config->productplan->future) ->setIF($this->post->future or empty($_POST['end']), 'end', $this->config->productplan->future) + ->add('id', $planID) ->remove('delta,uid,future') ->get(); @@ -640,6 +641,7 @@ class productplanModel extends model $plan->end = isset($data->end[$planID]) ? $data->end[$planID] : ''; $plan->status = isset($data->status[$planID]) ? $data->status[$planID] : $oldPlans[$planID]->status; $plan->parent = $oldPlans[$planID]->parent; + $plan->id = $planID; if(empty($plan->title)) return print(js::alter(sprintf($this->lang->productplan->errorNoTitle, $planID))); if($plan->begin > $plan->end and !empty($plan->end)) return print(js::alert(sprintf($this->lang->productplan->beginGeEnd, $planID))); diff --git a/module/program/model.php b/module/program/model.php index b1932bf963..f5bd3cdb18 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -690,6 +690,7 @@ class programModel extends model $oldProgram = $this->dao->findById($programID)->from(TABLE_PROGRAM)->fetch(); $program = fixer::input('post') + ->add('id', $programID) ->setDefault('team', $this->post->name) ->setDefault('end', '') ->setIF($this->post->begin == '0000-00-00', 'begin', '') diff --git a/module/project/model.php b/module/project/model.php index 86ef1e72d8..04a76c89f2 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1067,6 +1067,7 @@ class projectModel extends model $_POST['products'] = isset($_POST['products']) ? array_filter($_POST['products']) : $linkedProducts; $project = fixer::input('post') + ->add('id', $projectID) ->callFunc('name', 'trim') ->setDefault('team', substr($this->post->name, 0, 30)) ->setDefault('lastEditedBy', $this->app->user->account) @@ -1239,6 +1240,7 @@ class projectModel extends model $projects[$projectID] = new stdClass(); if(isset($data->parents[$projectID])) $projects[$projectID]->parent = $data->parents[$projectID]; + $projects[$projectID]->id = $projectID; $projects[$projectID]->name = $projectName; $projects[$projectID]->PM = $data->PMs[$projectID]; $projects[$projectID]->begin = $data->begins[$projectID]; @@ -1320,6 +1322,7 @@ class projectModel extends model $now = helper::now(); $project = fixer::input('post') + ->add('id', $projectID) ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) @@ -1352,6 +1355,7 @@ class projectModel extends model $now = helper::now(); $project = fixer::input('post') + ->add('id', $projectID) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->remove('comment') @@ -1377,6 +1381,7 @@ class projectModel extends model { $oldProject = $this->getById($projectID); $project = fixer::input('post') + ->add('id', $projectID) ->setDefault('status', 'suspended') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', helper::now()) @@ -1405,6 +1410,7 @@ class projectModel extends model $now = helper::now(); $project = fixer::input('post') + ->add('id', $projectID) ->setDefault('realEnd','') ->setDefault('status', 'doing') ->setDefault('lastEditedBy', $this->app->user->account) @@ -1476,6 +1482,7 @@ class projectModel extends model $now = helper::now(); $project = fixer::input('post') + ->add('id', $projectID) ->setDefault('status', 'closed') ->setDefault('closedBy', $this->app->user->account) ->setDefault('closedDate', $now) diff --git a/module/release/model.php b/module/release/model.php index 128917fcf9..b0965abe8c 100644 --- a/module/release/model.php +++ b/module/release/model.php @@ -192,6 +192,7 @@ class releaseModel extends model ->autoCheck() ->batchCheck($this->config->release->create->requiredFields, 'notempty') ->check('name', 'unique', "product = '{$release->product}' AND branch = '{$release->branch}' AND deleted = '0'"); + ->checkFlow() if(dao::isError()) { @@ -248,6 +249,7 @@ class releaseModel extends model $branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq((int)$this->post->build)->fetch('branch'); $release = fixer::input('post')->stripTags($this->config->release->editor->edit['id'], $this->config->allowedTags) + ->add('id', $releaseID) ->add('branch', (int)$branch) ->join('mailto', ',') ->setIF(!$this->post->marker, 'marker', 0) @@ -269,6 +271,7 @@ class releaseModel extends model ->autoCheck() ->batchCheck($this->config->release->edit->requiredFields, 'notempty') ->check('name', 'unique', "id != '$releaseID' AND product = '{$release->product}' AND branch = '$branch' AND deleted = '0'") + ->checkFlow() ->where('id')->eq((int)$releaseID) ->exec(); if(!dao::isError()) diff --git a/module/story/model.php b/module/story/model.php index 4d5e1f58e9..eb728e444e 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -675,6 +675,7 @@ class storyModel extends model $story = fixer::input('post') ->callFunc('title', 'trim') ->setDefault('lastEditedBy', $this->app->user->account) + ->add('id', $storyID) ->add('lastEditedDate', $now) ->setIF($specChanged, 'version', $oldStory->version + 1) ->setIF($specChanged and $oldStory->status == 'active' and $this->post->needNotReview == false, 'status', 'changed') @@ -772,6 +773,7 @@ class storyModel extends model ->cleanFloat('estimate') ->setDefault('assignedDate', $oldStory->assignedDate) ->setDefault('lastEditedBy', $this->app->user->account) + ->add('id', $storyID) ->add('lastEditedDate', $now) ->setDefault('plan,notifyEmail', '') ->setDefault('status', $oldStory->status) @@ -1210,6 +1212,7 @@ class storyModel extends model $oldStory = $oldStories[$storyID]; $story = new stdclass(); + $story->id = $storyID; $story->lastEditedBy = $this->app->user->account; $story->lastEditedDate = $now; $story->status = $oldStory->status; @@ -1330,6 +1333,7 @@ class storyModel extends model ->removeIF($this->post->result == 'reject' and $this->post->closedReason != 'duplicate', 'duplicateStory') ->removeIF($this->post->result == 'reject' and $this->post->closedReason != 'subdivided', 'childStories') ->add('reviewedBy', $oldStory->reviewedBy . ',' . $this->app->user->account) + ->add('id', $storyID) ->remove('result,preVersion,comment') ->get(); @@ -1550,6 +1554,7 @@ class storyModel extends model $oldStory = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch(); $now = helper::now(); $story = fixer::input('post') + ->add('id', $storyID) ->add('assignedTo', 'closed') ->add('status', 'closed') ->add('stage', 'closed') @@ -1978,6 +1983,7 @@ class storyModel extends model if($assignedTo == $oldStory->assignedTo) return array(); $story = fixer::input('post') + ->add('id', $storyID) ->add('lastEditedBy', $this->app->user->account) ->add('lastEditedDate', $now) ->add('assignedDate', $now) @@ -2031,6 +2037,7 @@ class storyModel extends model $oldStory = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch(); $now = helper::now(); $story = fixer::input('post') + ->add('id', $storyID) ->add('closedBy', '') ->add('closedReason', '') ->add('closedDate', '0000-00-00') diff --git a/module/task/model.php b/module/task/model.php index c25ac00dd2..fca1b01bf0 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -904,6 +904,7 @@ class taskModel extends model $now = helper::now(); $task = fixer::input('post') + ->add('id', $taskID) ->setDefault('story, estimate, left, consumed', 0) ->setDefault('realStarted', '0000-00-00 00:00:00') ->setIF(is_numeric($this->post->estimate), 'estimate', (float)$this->post->estimate) @@ -1167,6 +1168,7 @@ class taskModel extends model $oldTask = $oldTasks[$taskID]; $task = new stdclass(); + $task->id = $taskID; $task->color = $data->colors[$taskID]; $task->name = $data->names[$taskID]; $task->module = isset($data->modules[$taskID]) ? $data->modules[$taskID] : 0; @@ -1433,6 +1435,7 @@ class taskModel extends model $now = helper::now(); $task = fixer::input('post') + ->add('id', $taskID) ->cleanFloat('left') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) @@ -1499,6 +1502,7 @@ class taskModel extends model $now = helper::now(); $task = fixer::input('post') + ->add('id', $taskID) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', $now) ->setDefault('status', 'doing') @@ -1725,6 +1729,7 @@ class taskModel extends model } $task = fixer::input('post') + ->add('id', $taskID) ->setIF(is_numeric($this->post->consumed), 'consumed', (float)$this->post->consumed) ->setIF(!$this->post->realStarted and helper::isZeroDate($oldTask->realStarted), 'realStarted', $now) ->setDefault('left', 0) @@ -1856,6 +1861,7 @@ class taskModel extends model $oldTask = $this->getById($taskID); $task = fixer::input('post') + ->add('id', $taskID) ->setDefault('status', 'pause') ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', helper::now()) @@ -1889,6 +1895,7 @@ class taskModel extends model $now = helper::now(); $task = fixer::input('post') + ->add('id', $taskID) ->setDefault('status', 'closed') ->setDefault('assignedTo', 'closed') ->setDefault('assignedDate', $now) @@ -1934,6 +1941,7 @@ class taskModel extends model $now = helper::now(); $task = fixer::input('post') + ->add('id', $taskID) ->setDefault('status', 'cancel') ->setDefault('assignedTo', $oldTask->openedBy) ->setDefault('assignedDate', $now) @@ -1994,6 +2002,7 @@ class taskModel extends model $oldTask = $this->getById($taskID); if($oldTask->parent == '-1') $this->config->task->activate->requiredFields = ''; $task = fixer::input('post') + ->add('id', $taskID) ->setIF(is_numeric($this->post->left), 'left', (float)$this->post->left) ->setDefault('left', 0) ->setDefault('status', 'doing') diff --git a/module/testcase/model.php b/module/testcase/model.php index 94a36ec02d..b8bc0a7575 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -714,6 +714,7 @@ class testcaseModel extends model $version = $stepChanged ? $oldCase->version + 1 : $oldCase->version; $case = fixer::input('post') + ->add('id', $caseID) ->add('version', $version) ->setIF($this->post->story != false and $this->post->story != $oldCase->story, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story)) ->setIF(!$this->post->linkCase, 'linkCase', '') @@ -834,6 +835,7 @@ class testcaseModel extends model $now = helper::now(); $status = $this->getStatus('review', $oldCase); $case = fixer::input('post') + ->add('id', $caseID) ->remove('result,comment') ->setDefault('reviewedDate', substr($now, 0, 10)) ->setDefault('lastEditedBy', $this->app->user->account) @@ -946,6 +948,7 @@ class testcaseModel extends model foreach($caseIDList as $caseID) { $case = new stdclass(); + $case->id = $caseID; $case->lastEditedBy = $this->app->user->account; $case->lastEditedDate = $now; $case->pri = $data->pris[$caseID]; diff --git a/module/testsuite/model.php b/module/testsuite/model.php index 0e636d720a..b0a9708dca 100644 --- a/module/testsuite/model.php +++ b/module/testsuite/model.php @@ -150,6 +150,7 @@ class testsuiteModel extends model $oldSuite = $this->dao->select("*")->from(TABLE_TESTSUITE)->where('id')->eq((int)$suiteID)->fetch(); $suite = fixer::input('post') ->stripTags($this->config->testsuite->editor->edit['id'], $this->config->allowedTags) + ->add('id', $suiteID) ->add('lastEditedBy', $this->app->user->account) ->add('lastEditedDate', helper::now()) ->remove('uid') diff --git a/module/testtask/model.php b/module/testtask/model.php index 079992d200..b573fc2f85 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -734,8 +734,15 @@ class testtaskModel extends model public function update($taskID) { $oldTask = $this->dao->select("*")->from(TABLE_TESTTASK)->where('id')->eq((int)$taskID)->fetch(); - $task = fixer::input('post')->stripTags($this->config->testtask->editor->edit['id'], $this->config->allowedTags)->join('mailto', ',')->join('type', ',')->remove('files,labels,uid,comment,contactListMenu')->get(); + $task = fixer::input('post') + ->add('id') + ->stripTags($this->config->testtask->editor->edit['id'], $this->config->allowedTags) + ->join('mailto', ',') + ->join('type', ',') + ->remove('files,labels,uid,comment,contactListMenu') + ->get(); $task = $this->loadModel('file')->processImgURL($task, $this->config->testtask->editor->edit['id'], $this->post->uid); + $this->dao->update(TABLE_TESTTASK)->data($task) ->autoCheck() ->batchcheck($this->config->testtask->edit->requiredFields, 'notempty') @@ -743,6 +750,7 @@ class testtaskModel extends model ->checkFlow() ->where('id')->eq($taskID) ->exec(); + if(!dao::isError()) { $this->file->updateObjectID($this->post->uid, $taskID, 'testtask'); @@ -762,6 +770,7 @@ class testtaskModel extends model { $oldTesttask = $this->getById($taskID); $testtask = fixer::input('post') + ->add('id', $taskID) ->setDefault('status', 'doing') ->remove('comment')->get(); @@ -784,6 +793,7 @@ class testtaskModel extends model { $oldTesttask = $this->getById($taskID); $testtask = fixer::input('post') + ->add('id', $taskID) ->setDefault('status', 'done') ->stripTags($this->config->testtask->editor->close['id'], $this->config->allowedTags) ->join('mailto', ',') @@ -826,6 +836,7 @@ class testtaskModel extends model { $oldTesttask = $this->getById($taskID); $testtask = fixer::input('post') + ->add('id', $taskID) ->setDefault('status', 'blocked') ->remove('comment')->get();