From e86f32df2483649c562b6e0887975d19be68e50c Mon Sep 17 00:00:00 2001 From: wangyuting2 <851424971@qq.com> Date: Mon, 9 May 2022 15:58:02 +0800 Subject: [PATCH 1/6] * Adjust feedback menu. --- framework/control.class.php | 2 +- module/bug/model.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/control.class.php b/framework/control.class.php index a545295b65..53e4450604 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -322,7 +322,7 @@ class control extends baseControl if(!isset($this->config->bizVersion)) return false; $moduleName = $this->moduleName; - if($moduleName == 'bug') return $this->$moduleName->buildOperateMenu($object, $type); + if($moduleName == 'bug' || $moduleName == 'feedback') return $this->$moduleName->buildOperateMenu($object, $type); $flow = $this->loadModel('workflow')->getByModule($moduleName); return $this->loadModel('flow')->buildOperateMenu($flow, $object, $type); diff --git a/module/bug/model.php b/module/bug/model.php index 139ce507bf..1cf6470e44 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -2784,6 +2784,7 @@ class bugModel extends model * * @param string $bug * @param string $action + * @param string $module * @access public * @return void */ @@ -3223,7 +3224,7 @@ class bugModel extends model } /** - * Build operateMenu. + * Build bug menu. * * @param object $bug * @param string $type @@ -3260,6 +3261,7 @@ class bugModel extends model $menu .= $this->buildMenu('bug', 'edit', $params, $bug, $type); if($this->app->tab != 'product') $menu .= $this->buildMenu('bug', 'create', $copyParams, $bug, $type, 'copy'); if($type == 'view') $menu .= $this->buildMenu('bug', 'delete', $params, $bug, $type, 'trash', 'hiddenwin', "showinonlybody"); + return $menu; } } From 19631c8b97b5badf015f761f8a3071142969e3a9 Mon Sep 17 00:00:00 2001 From: wangyuting2 <851424971@qq.com> Date: Mon, 9 May 2022 16:14:53 +0800 Subject: [PATCH 2/6] * Adjust return. --- module/bug/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/bug/model.php b/module/bug/model.php index 1cf6470e44..a2483329c9 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -3229,7 +3229,7 @@ class bugModel extends model * @param object $bug * @param string $type * @access public - * @return void + * @return string */ public function buildOperateMenu($bug, $type = 'view') { From 103f3a21c6279b01472c74504873c4044559f370 Mon Sep 17 00:00:00 2001 From: wangyuting2 <851424971@qq.com> Date: Mon, 9 May 2022 16:18:12 +0800 Subject: [PATCH 3/6] * Adjust return value. --- framework/control.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/control.class.php b/framework/control.class.php index 53e4450604..d32fc8af6f 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -90,7 +90,7 @@ class control extends baseControl * Det default priv by workflow. * * @access public - * @return void + * @return bool */ public function setDefaultPrivByWorkflow() { @@ -315,7 +315,7 @@ class control extends baseControl * @param object $object product|project|productplan|release|build|story|task|bug|testtask|testcase|testsuite * @param string $displayOn view|browse * @access public - * @return void + * @return string */ public function buildOperateMenu($object, $type = 'view') { @@ -412,7 +412,7 @@ class control extends baseControl * * @param string $viewFile * @access public - * @return void + * @return bool|string */ public function printViewFile($viewFile) { From a607161591f9f39c403aa62d7bca6024c3b22861 Mon Sep 17 00:00:00 2001 From: wangyuting2 <851424971@qq.com> Date: Mon, 9 May 2022 17:00:41 +0800 Subject: [PATCH 4/6] * 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 | 2 ++ 5 files changed, 15 insertions(+), 22 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 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(); From d577d57a339ea75ee05003d4716a3b13e6879b95 Mon Sep 17 00:00:00 2001 From: daitingting Date: Mon, 9 May 2022 07:56:17 +0000 Subject: [PATCH 5/6] * 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 | 13 +++++++++++++ module/task/model.php | 9 +++++++++ module/testcase/model.php | 3 +++ module/testsuite/model.php | 1 + module/testtask/model.php | 13 ++++++++++++- 16 files changed, 73 insertions(+), 6 deletions(-) diff --git a/framework/control.class.php b/framework/control.class.php index d32fc8af6f..a58b327d6f 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 6f1efbf6f1..a534aded89 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 f81ae7dc27..19e11a3c29 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 e953850e3c..9cc2b97457 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]; @@ -759,6 +761,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) @@ -791,6 +794,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') @@ -820,6 +824,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) @@ -846,6 +851,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) @@ -915,6 +921,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 21eee5e278..4de525f5e5 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -683,6 +683,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', '') @@ -764,6 +765,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) { @@ -820,6 +822,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 b389bc6c81..7eefd49a79 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -475,6 +475,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(); @@ -638,6 +639,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 baff7f83d0..f1868c9348 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -689,6 +689,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 ab4804577c..a17ae091f7 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1066,6 +1066,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) @@ -1237,6 +1238,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]; @@ -1319,6 +1321,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) @@ -1350,6 +1353,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') @@ -1374,6 +1378,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()) @@ -1401,6 +1406,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) @@ -1471,6 +1477,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 1877c18449..4181c473a1 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -676,6 +676,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) @@ -1209,6 +1211,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(); @@ -1549,6 +1553,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') @@ -1981,6 +1986,13 @@ class storyModel extends model $story->assignedTo = $assignedTo; $story->assignedDate = $now; + $story = fixer::input('post') + ->add('id', $storyID) + ->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(); if(!dao::isError()) return common::createChanges($oldStory, $story); return false; @@ -2029,6 +2041,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 bf0961a34f..687c2cde4e 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -908,6 +908,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) @@ -1170,6 +1171,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; @@ -1437,6 +1439,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) @@ -1502,6 +1505,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') @@ -1727,6 +1731,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) @@ -1857,6 +1862,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()) @@ -1890,6 +1896,7 @@ class taskModel extends model $now = helper::now(); $task = fixer::input('post') + ->add('id', $taskID) ->setDefault('status', 'closed') ->setDefault('assignedTo', 'closed') ->setDefault('assignedDate', $now) @@ -1935,6 +1942,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) @@ -1995,6 +2003,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 0b316b941f..ad0f5a2c6b 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -715,6 +715,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', '') @@ -835,6 +836,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) @@ -947,6 +949,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 a0d52b572f..bb3470d280 100644 --- a/module/testsuite/model.php +++ b/module/testsuite/model.php @@ -149,6 +149,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 6e8562b065..ab145e1f10 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -733,14 +733,22 @@ 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') ->checkIF($task->end != '', 'end', 'ge', $task->begin) ->where('id')->eq($taskID) ->exec(); + if(!dao::isError()) { $this->file->updateObjectID($this->post->uid, $taskID, 'testtask'); @@ -760,6 +768,7 @@ class testtaskModel extends model { $oldTesttask = $this->getById($taskID); $testtask = fixer::input('post') + ->add('id', $taskID) ->setDefault('status', 'doing') ->remove('comment')->get(); @@ -781,6 +790,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', ',') @@ -822,6 +832,7 @@ class testtaskModel extends model { $oldTesttask = $this->getById($taskID); $testtask = fixer::input('post') + ->add('id', $taskID) ->setDefault('status', 'blocked') ->remove('comment')->get(); From dceb7ba183546e0c70c50c6b2fc0f0877895bfdb Mon Sep 17 00:00:00 2001 From: wangyuting2 <851424971@qq.com> Date: Mon, 9 May 2022 17:09:24 +0800 Subject: [PATCH 6/6] * Optimize code. --- framework/control.class.php | 1 - module/common/model.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/control.class.php b/framework/control.class.php index a58b327d6f..c7666ca0db 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -324,7 +324,6 @@ class control extends baseControl $flow = $this->loadModel('workflow')->getByModule($moduleName); return $this->loadModel('flow')->buildOperateMenu($flow, $object, $type); - } /** diff --git a/module/common/model.php b/module/common/model.php index bd79bb382d..616bc1d5b4 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1560,6 +1560,7 @@ EOD; * @param string $extraClass * @param bool $onlyBody * @param string $misc + * @Param bool $extraEnabled * @static * @access public * @return void