From c95a839fcb8bdd5212ad43fc9781a88eec44cc67 Mon Sep 17 00:00:00 2001 From: daitingting Date: Thu, 4 Aug 2022 01:39:12 +0000 Subject: [PATCH] * Process createdBy if the field is not createdBy. --- module/upgrade/model.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/module/upgrade/model.php b/module/upgrade/model.php index be2f58deea..ee5c5cebda 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -532,6 +532,8 @@ class upgradeModel extends model $this->processBugLinkBug(); case '17_4': $this->processCreatedInfo(); + $this->updateApproval(); + $this->processCreatedBy(); } $this->deletePatch(); @@ -6813,4 +6815,38 @@ class upgradeModel extends model return !dao::isError(); } + + /** + * Process createdBy of conditions. + * + * @access public + * @return bool + */ + public function processCreatedBy() + { + $this->app->loadLang('workflow'); + $this->app->loadModuleConfig('workflow'); + + $modules = $this->dao->select('module')->from(TABLE_WORKFLOW)->where('buildin')->eq('1')->andWhere('approval')->eq('enabled')->andWhere('module')->in(array_keys($this->config->workflow->buildin->createdBy))->fetchPairs(); + $actions = $this->dao->select('id, module, conditions')->from(TABLE_WORKFLOWACTION)->where('module')->in($modules)->andWhere('action')->in('submit, cancel, edit, delete')->fetchAll('id'); + + foreach($actions as $id => $action) + { + $conditions = json_decode($action->conditions); + if(empty($conditions)) continue; + + foreach($conditions as $index => $condition) + { + foreach($condition->fields as $field) + { + if($field->field == 'createdBy' && zget($this->config->workflow->buildin->createdBy, $action->module, '')) $field->field = zget($this->config->workflow->buildin->createdBy, $action->module); + } + $conditions[$index] = $condition; + } + + $this->dao->update(TABLE_WORKFLOWACTION)->set('conditions')->eq(json_encode($conditions))->where('id')->eq($id)->exec(); + } + + return !dao::isError(); + } }