diff --git a/framework/control.class.php b/framework/control.class.php index 7e05dcf79a..6f35d7c367 100644 --- a/framework/control.class.php +++ b/framework/control.class.php @@ -35,26 +35,29 @@ class control extends baseControl if(!isset($this->config->bizVersion)) return false; /* Code for task #9224. Set requiredFields for workflow. */ - $fields = $this->loadModel('workflowaction')->getFields($this->moduleName, $this->methodName); - $layouts = $this->loadModel('workflowlayout')->getFields($this->moduleName, $this->methodName); - $notEmptyRule = $this->loadModel('workflowrule')->getByTypeAndRule('system', 'notempty'); - - foreach($fields as $field) + if($this->dbh) { + $fields = $this->loadModel('workflowaction')->getFields($this->moduleName, $this->methodName); + $layouts = $this->loadModel('workflowlayout')->getFields($this->moduleName, $this->methodName); + $notEmptyRule = $this->loadModel('workflowrule')->getByTypeAndRule('system', 'notempty'); - if($notEmptyRule && strpos(",$field->rules,", ",$notEmptyRule->id,") !== false) + foreach($fields as $field) { - if(!isset($this->config->{$this->moduleName})) $this->config->{$this->moduleName} = new stdclass(); - if(!isset($this->config->{$this->moduleName}->{$this->methodName})) $this->config->{$this->moduleName}->{$this->methodName} = new stdclass(); - if(!isset($this->config->{$this->moduleName}->{$this->methodName}->requiredFields)) $this->config->{$this->moduleName}->{$this->methodName}->requiredFields = ''; - $this->config->{$this->moduleName}->{$this->methodName}->requiredFields .= ",{$field->field}"; - } - } - if(isset($this->config->{$this->moduleName}) and isset($this->config->{$this->moduleName}->exportFields)) - { - $exportFields = $this->dao->select('*')->from(TABLE_WORKFLOWFIELD)->where('module')->eq($this->moduleName)->andWhere('canExport')->eq('1')->andWhere('buildin')->eq('0')->fetchAll('field'); - foreach($exportFields as $field) $this->config->{$this->moduleName}->exportFields .= ",{$field->field}"; + if($notEmptyRule && strpos(",$field->rules,", ",$notEmptyRule->id,") !== false) + { + if(!isset($this->config->{$this->moduleName})) $this->config->{$this->moduleName} = new stdclass(); + if(!isset($this->config->{$this->moduleName}->{$this->methodName})) $this->config->{$this->moduleName}->{$this->methodName} = new stdclass(); + if(!isset($this->config->{$this->moduleName}->{$this->methodName}->requiredFields)) $this->config->{$this->moduleName}->{$this->methodName}->requiredFields = ''; + $this->config->{$this->moduleName}->{$this->methodName}->requiredFields .= ",{$field->field}"; + } + } + + if(isset($this->config->{$this->moduleName}) and isset($this->config->{$this->moduleName}->exportFields)) + { + $exportFields = $this->dao->select('*')->from(TABLE_WORKFLOWFIELD)->where('module')->eq($this->moduleName)->andWhere('canExport')->eq('1')->andWhere('buildin')->eq('0')->fetchAll('field'); + foreach($exportFields as $field) $this->config->{$this->moduleName}->exportFields .= ",{$field->field}"; + } } }