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 a2483329c9..6f1efbf6f1 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..f81ae7dc27 100644 --- a/module/caselib/model.php +++ b/module/caselib/model.php @@ -103,6 +103,7 @@ class caselibModel extends model ->autoCheck() ->batchcheck($this->config->caselib->edit->requiredFields, 'notempty') ->where('id')->eq($libID) + ->checkFlow() ->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..e953850e3c 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. */ @@ -515,6 +516,7 @@ class executionModel extends model ->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')") ->where('id')->eq($executionID) + ->checkFlow() ->limit(1) ->exec();