| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- Lib::loadClass('User');
- Lib::loadClass('SchemaReader');
- class SchemaReaderProcess {
- private $_version;
- private $_date;
- private $_access = array();
- private $_accessGroups = array();
- private $_steps = array();
- private $_resourcesTable = array();
- private $_resources = array();
- public function __construct() {
- }
- public function parseIniConfig($config) {
- $configData = $config->getData();
- $this->_version = $config->get('version', 'CONFIG');
- $this->_date = $config->get('date', 'CONFIG');
- if('1' == V::get('DBG_SCH', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$configData (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($configData);echo'</pre>';}
- $configSections = array_keys($configData);
- if (in_array('ACCESS', $configSections)) {
- if (array_key_exists('HAS_ACCESS', $configData['ACCESS'])) {
- $this->_access = $configData['ACCESS']['HAS_ACCESS'];
- if (!is_array($this->_access)) $this->_access = array($this->_access);
- }
- if (array_key_exists('GROUPS', $configData['ACCESS'])) {
- $this->_accessGroups = $configData['ACCESS']['GROUPS'];
- if (!is_array($this->_accessGroups)) $this->_accessGroups = array($this->_accessGroups);
- }
- }
- $this->_steps = array();
- foreach ($configSections as $section) {
- if ('STEP' == substr($section, 0, 4)) {
- $sectionParts = explode(':', $section);
- $sectionPartsCnt = count($sectionParts);
- if ($sectionPartsCnt == 2) {// eg. [STEP:1]
- $stepNr = $sectionParts[1];
- $step = SchemaReader::buildProcessStepFromIni($stepNr, $configData[$section]);
- if ($step) {
- $this->_steps[$stepNr] = $step;
- }
- }
- }
- }
- if('1' == V::get('DBG_SCH', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$this->_steps:1 (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->_steps);echo'</pre>';}
- foreach ($configSections as $section) {
- if ('STEP' == substr($section, 0, 4)) {
- $sectionParts = explode(':', $section);
- $sectionPartsCnt = count($sectionParts);
- if ($sectionPartsCnt > 3) {// eg. [STEP:1:RESOURCE:1]
- $stepNr = $sectionParts[1];
- $resourceUri = V::get('uri', '', $configData[$section]);
- if (!$resourceUri) continue;
- $resource = SchemaReader::buildFromIni($resourceUri, $configData[$section]);
- if ($resource && array_key_exists($stepNr, $this->_steps)) {
- $this->_steps[$stepNr]->addResource($resource);
- }
- }
- }
- }
- if('1' == V::get('DBG_SCH', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$this->_steps:2 (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->_steps);echo'</pre>';}
- $this->_resourcesTable = array();
- foreach ($this->_steps as $step) {
- $stepTbls = $step->getTables();
- foreach ($stepTbls as $tblUri => $tbl) {
- if (array_key_exists($tblUri, $this->_resourcesTable)) {
- $this->_resourcesTable[$tblUri]->mergeFields($tbl);
- } else {
- $this->_resourcesTable[$tblUri] = $tbl;
- }
- }
- }
- if('1' == V::get('DBG_SCH', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">this->_resourcesTable (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->_resourcesTable);echo'</pre>';}
- return true;
- }
- public function hasTables() {
- return !empty($this->_resourcesTable);
- }
- public function getTables() {
- return $this->_resourcesTable;
- }
- public function hasAccess() {
- if (!empty($this->_access)) {
- foreach ($this->_access as $accessName) {
- if (User::hasAccess($accessName)) {
- return true;
- }
- }
- }
- if (!empty($this->_accessGroups)) {
- foreach ($this->_accessGroups as $accessGroup) {
- if (User::hasGroup($accessGroup)) {
- return true;
- }
- }
- }
- return false;
- }
- }
|