|
|
@@ -1,5 +1,10 @@
|
|
|
<?php
|
|
|
|
|
|
+Lib::loadClass('DB');
|
|
|
+Lib::loadClass('UsersHelper');
|
|
|
+Lib::loadClass('ProcesHelper');
|
|
|
+Lib::loadClass('TableAcl');
|
|
|
+Lib::loadClass('SchemaReader');
|
|
|
|
|
|
class UserAcl {
|
|
|
|
|
|
@@ -34,7 +39,6 @@ class UserAcl {
|
|
|
}
|
|
|
$this->_groups = array();
|
|
|
|
|
|
- Lib::loadClass('UsersHelper');
|
|
|
$this->_groups = UsersHelper::get_group_by_user($this->_user_id);
|
|
|
|
|
|
$this->_cache_save('_groups', $this->_groups);
|
|
|
@@ -46,7 +50,6 @@ class UserAcl {
|
|
|
if (!empty($this->_proces_ids)) {
|
|
|
return $this->_proces_ids;
|
|
|
}
|
|
|
- Lib::loadClass('DB');
|
|
|
$db = DB::getDB();
|
|
|
$groups = $this->fetchGroups();
|
|
|
if (empty($groups)) {
|
|
|
@@ -73,7 +76,6 @@ class UserAcl {
|
|
|
return $this->_proces_tree_flat;
|
|
|
}
|
|
|
|
|
|
- Lib::loadClass('DB');
|
|
|
$db = DB::getDB();
|
|
|
$sql = "select p.`ID`, p.`PARENT_ID`
|
|
|
from `CRM_PROCES` as p
|
|
|
@@ -164,7 +166,6 @@ class UserAcl {
|
|
|
|
|
|
$map = $this->getUsedProcesMap();
|
|
|
if (!empty($map)) {
|
|
|
- Lib::loadClass('DB');
|
|
|
$db = DB::getDB();
|
|
|
$sql = "select `ID` from `CRM_PROCES` where `TYPE`='PROCES_INIT' and `ID` in (" . implode(",", array_keys($map)) . ") ";
|
|
|
$res = $db->query($sql);
|
|
|
@@ -207,7 +208,6 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- Lib::loadClass('DB');
|
|
|
$db = DB::getDB();
|
|
|
|
|
|
//$TREE_CRM_WSKAZNIK = array();
|
|
|
@@ -300,7 +300,6 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
|
|
|
echo '<p>{User id: '.$this->_user_id.'}</p>';
|
|
|
|
|
|
- Lib::loadClass('DB');
|
|
|
$db = DB::getDB();
|
|
|
|
|
|
$ID_ZASOBOW_USERA = array();
|
|
|
@@ -705,7 +704,6 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
|
|
|
public function getTablesAcl() {
|
|
|
$tbls = array();
|
|
|
- Lib::loadClass('TableAcl');
|
|
|
$tblIds = $this->_cache_read('foundTables');
|
|
|
foreach ($tblIds as $vTableID) {
|
|
|
$tbls[$vTableID] = TableAcl::getInstance($vTableID);
|
|
|
@@ -719,7 +717,6 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
}
|
|
|
|
|
|
public function getTableAcl($tableID) {
|
|
|
- Lib::loadClass('TableAcl');
|
|
|
return TableAcl::getInstance($tableID);
|
|
|
}
|
|
|
|
|
|
@@ -759,11 +756,9 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
private function _fetchPerms($type, $force = false) {
|
|
|
$db = DB::getDB();
|
|
|
|
|
|
- Lib::loadClass('TableAcl');
|
|
|
-
|
|
|
$foundTools = array();// TODO: rename to $foundTools
|
|
|
$foundUrls = array();// TODO: old ['MENU_SELECT_PROCES_DATA']['MENU_COLUMN']
|
|
|
- $foundTables = array();// TODO: old $CRM_WSKAZNIK_PROCES_WSKAZNIK_TABELA_KONFIG, $TREE_CRM_WSKAZNIK_CONF, ...
|
|
|
+ $foundTbls = array();// TODO: old $CRM_WSKAZNIK_PROCES_WSKAZNIK_TABELA_KONFIG, $TREE_CRM_WSKAZNIK_CONF, ...
|
|
|
$foundMap = array();
|
|
|
$procesID = 0;// if 0 - All, alse perms by procesID
|
|
|
|
|
|
@@ -775,7 +770,9 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
}
|
|
|
|
|
|
$usedProcesListIds = array();
|
|
|
+ $schemaReader = new SchemaReader();
|
|
|
if ($type == 'All') {
|
|
|
+ $schemaReader->getAll();
|
|
|
$usedProcesListIds = $this->getUsedProcesIds();
|
|
|
} else if (is_numeric($type) && $type > 0) {
|
|
|
$procesID = (int)$type;
|
|
|
@@ -784,6 +781,49 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
if (empty($usedProcesListIds)) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ {// fetch from schema files
|
|
|
+ if ($schemaReader->hasProcessConfigs()) {
|
|
|
+ foreach ($schemaReader->getProcessConfigs() as $process) {
|
|
|
+ if('1' == V::get('DBG_SCH', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">process (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($process);echo'</pre>';}
|
|
|
+ if ($process->hasAccess()) {
|
|
|
+ $tables = $process->getTables();
|
|
|
+ if('1' == V::get('DBG_SCH', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$tables (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($tables);echo'</pre>';}
|
|
|
+ foreach ($tables as $table) {
|
|
|
+ $tblUri = $table->getUri();
|
|
|
+ $zasobTblInfo = ProcesHelper::getZasobTableInfoByUri($tblUri);
|
|
|
+ if('1' == V::get('DBG_SCH', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">table('.$table->getLabel().') $zasobTblInfo (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($zasobTblInfo);echo'</pre>';}
|
|
|
+ if ($zasobTblInfo) {
|
|
|
+
|
|
|
+ if (!array_key_exists($zasobTblInfo->ID, $foundTbls)) {
|
|
|
+ $tblAcl = new TableAcl($zasobTblInfo->ID);
|
|
|
+ $tblAcl->setDB($zasobTblInfo->P__ID);
|
|
|
+ $tblAcl->setName($table->getName());
|
|
|
+ $tblAcl->setLabel($table->getLabel());
|
|
|
+ $tblAcl->setOpis($table->getDescription());
|
|
|
+ $foundTbls[$zasobTblInfo->ID] = $tblAcl;
|
|
|
+ }
|
|
|
+
|
|
|
+ $fldsInfo = ProcesHelper::getZasobTableFieldsInfo($zasobTblInfo->ID);
|
|
|
+ foreach ($table->getFields() as $field) {
|
|
|
+ $fldInfo = V::get($field->getName(), null, $fldsInfo);
|
|
|
+ if ($fldInfo) {
|
|
|
+ if (!$foundTbls[$zasobTblInfo->ID]->hasField($r->ID_ZASOB)) {
|
|
|
+ $foundTbls[$zasobTblInfo->ID]->addField($fldInfo->ID, $fldInfo->DESC, $fldInfo->OPIS, $fldInfo->SORT_PRIO, $fldInfo->DESC_PL);
|
|
|
+ }
|
|
|
+
|
|
|
+ $foundTbls[$zasobTblInfo->ID]->setFieldPerms($fldInfo->ID, $field->getPerms());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if('1' == V::get('DBG_SCH', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$foundTbls (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($foundTbls);echo'</pre>';}
|
|
|
+ }// fetch from schema files
|
|
|
+
|
|
|
+ {// fetch from DB
|
|
|
$sql = "select t1.`ID_PROCES`
|
|
|
, t1.`ID` as ID_WSKAZNIK
|
|
|
, t1.`ID_ZASOB`
|
|
|
@@ -829,20 +869,20 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
else {
|
|
|
if ($r->PARENT_TYPE == 'TABELA') {
|
|
|
// t3 - KOMORKA, t4 - TABELA, t5 - DATABASE
|
|
|
- if (!array_key_exists($r->ZASOB_PARENT_ID, $foundTables)) {
|
|
|
- $foundTables[$r->ZASOB_PARENT_ID] = new TableAcl($r->ZASOB_PARENT_ID);
|
|
|
- $foundTables[$r->ZASOB_PARENT_ID]->setDB($r->ID_BAZY_KONFIG);
|
|
|
- $foundTables[$r->ZASOB_PARENT_ID]->setName($r->PARENT_ZASOB_DESC);
|
|
|
- $foundTables[$r->ZASOB_PARENT_ID]->setLabel($r->PARENT_ZASOB_DESC_PL);
|
|
|
- $foundTables[$r->ZASOB_PARENT_ID]->setOpis($r->PARENT_ZASOB_OPIS);
|
|
|
+ if (!array_key_exists($r->ZASOB_PARENT_ID, $foundTbls)) {
|
|
|
+ $foundTbls[$r->ZASOB_PARENT_ID] = new TableAcl($r->ZASOB_PARENT_ID);
|
|
|
+ $foundTbls[$r->ZASOB_PARENT_ID]->setDB($r->ID_BAZY_KONFIG);
|
|
|
+ $foundTbls[$r->ZASOB_PARENT_ID]->setName($r->PARENT_ZASOB_DESC);
|
|
|
+ $foundTbls[$r->ZASOB_PARENT_ID]->setLabel($r->PARENT_ZASOB_DESC_PL);
|
|
|
+ $foundTbls[$r->ZASOB_PARENT_ID]->setOpis($r->PARENT_ZASOB_OPIS);
|
|
|
}
|
|
|
|
|
|
- if (!$foundTables[$r->ZASOB_PARENT_ID]->hasField($r->ID_ZASOB)) {
|
|
|
- $foundTables[$r->ZASOB_PARENT_ID]->addField($r->ID_ZASOB, $r->ZASOB_DESC, $r->ZASOB_OPIS, $r->z__SORT_PRIO, $r->ZASOB_DESC_PL);
|
|
|
+ if (!$foundTbls[$r->ZASOB_PARENT_ID]->hasField($r->ID_ZASOB)) {
|
|
|
+ $foundTbls[$r->ZASOB_PARENT_ID]->addField($r->ID_ZASOB, $r->ZASOB_DESC, $r->ZASOB_OPIS, $r->z__SORT_PRIO, $r->ZASOB_DESC_PL);
|
|
|
}
|
|
|
|
|
|
if (!empty($r->FORM_TREAT)) {
|
|
|
- $foundTables[$r->ZASOB_PARENT_ID]->setFieldPerms($r->ID_ZASOB, $r->FORM_TREAT);
|
|
|
+ $foundTbls[$r->ZASOB_PARENT_ID]->setFieldPerms($r->ID_ZASOB, $r->FORM_TREAT);
|
|
|
}
|
|
|
|
|
|
if (!$procesID) {
|
|
|
@@ -851,6 +891,7 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }// fetch from DB
|
|
|
|
|
|
// build $foundMap
|
|
|
if (!$procesID) {
|
|
|
@@ -868,7 +909,7 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
}
|
|
|
|
|
|
$this->_cache_save('foundUrls', $foundUrls);
|
|
|
- $this->_cache_save('foundTables', $foundTables);
|
|
|
+ $this->_cache_save('foundTables', $foundTbls);
|
|
|
$this->_cache_save('permsByProcesID', $procesID);
|
|
|
$this->_cache_save('foundMap', $foundMap);
|
|
|
}
|