|
|
@@ -703,9 +703,9 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
|
|
|
if ($key == 'foundTables') {
|
|
|
$tblIds = array();
|
|
|
- foreach ($value as $kID => $vTableAcl) {
|
|
|
- $tblIds[] = $kID;
|
|
|
- $vTableAcl->save();
|
|
|
+ foreach ($value as $idTable => $tableConfig) {
|
|
|
+ $tblIds[] = $idTable;
|
|
|
+ $vTableAcl = TableAcl::buildInstance($idTable, $tableConfig);
|
|
|
}
|
|
|
$value = $tblIds;
|
|
|
}
|
|
|
@@ -733,7 +733,7 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public function getTablesAcl() {
|
|
|
+ public function getTablesAcl() {// TODO: read from `CRM_PROCES_idx_TABLE_TO_USER_VIEW`
|
|
|
$tbls = array();
|
|
|
$tblIds = $this->_cache_read('foundTables');
|
|
|
foreach ($tblIds as $vTableID) {
|
|
|
@@ -742,7 +742,7 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
return $tbls;
|
|
|
}
|
|
|
|
|
|
- public function hasTableAcl($tableID) {
|
|
|
+ public function hasTableAcl($tableID) {// TODO: read from `CRM_PROCES_idx_TABLE_TO_USER_VIEW`
|
|
|
$tbls = $this->_cache_read('foundTables');
|
|
|
return (is_array($tbls) && in_array($tableID, $tbls));
|
|
|
}
|
|
|
@@ -813,6 +813,7 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ IF('123'==V::get('DBG_ACL','',$_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$usedProcesListIds (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): [';echo implode(',', $usedProcesListIds);echo']</pre>';}
|
|
|
{// fetch from schema files
|
|
|
if ($schemaReader->hasProcessConfigs()) {
|
|
|
foreach ($schemaReader->getProcessConfigs() as $process) {
|
|
|
@@ -939,10 +940,91 @@ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (1) {
|
|
|
+ $sqlIdProcesListSql = $this->getUsedUserProcesIdsSql();
|
|
|
+ $userAccessForTables = array();
|
|
|
+ $sql = <<<SQL
|
|
|
+ select tpvg.`ID_TABLE`
|
|
|
+ , tpvg.`ID_DATABASE` as `db`
|
|
|
+ , tpvg.`TABLE_NAME` as `name`
|
|
|
+ , tpvg.`TABLE_LABEL` as `label`
|
|
|
+ , tpvg.`TABLE_DESCRIPTION` as `opis`
|
|
|
+ from `CRM_PROCES_idx_TABLE_TO_PROCES_GROUPED_VIEW` as tpvg
|
|
|
+ where tpvg.`ID_PROCES` in({$sqlIdProcesListSql})
|
|
|
+ group by tpvg.`ID_TABLE`
|
|
|
+SQL;
|
|
|
+ //echo'<pre>$userAccessForTables - $sql ';print_r($sql);echo'</pre>';
|
|
|
+ $db = DB::getDB();
|
|
|
+ $res = $db->query($sql);
|
|
|
+ while ($h = $db->fetch_assoc($res)) {
|
|
|
+ $userAccessForTables[$h['ID_TABLE']] = $h;
|
|
|
+ }
|
|
|
+ //echo'<pre>$userAccessForTables ';print_r($userAccessForTables);echo'</pre>';
|
|
|
+ $foundTbls = $userAccessForTables;
|
|
|
+ }
|
|
|
+
|
|
|
$this->_cache_save('foundUrls', $foundUrls);
|
|
|
$this->_cache_save('foundTables', $foundTbls);
|
|
|
$this->_cache_save('permsByProcesID', $procesID);
|
|
|
$this->_cache_save('foundMap', $foundMap);
|
|
|
}
|
|
|
|
|
|
+ public function getPermsForTable($idTable) {
|
|
|
+ $sqlIdProcesListSql = $this->getUsedUserProcesIdsSql();
|
|
|
+ $tableCellToProcesSql = <<<SQL
|
|
|
+ select z.`ID` as `ID_CELL`
|
|
|
+ , z.`DESC` as `CELL_NAME`
|
|
|
+ , z.`DESC_PL` as `CELL_LABEL`
|
|
|
+ , z.`OPIS` as `CELL_DESC`
|
|
|
+ , z.`SORT_PRIO` as `SORT_PRIO`
|
|
|
+ , zp.`ID` as `ID_TABLE`
|
|
|
+ -- , zp.`DESC` as `TABLE_NAME`
|
|
|
+ -- , wsk.`ID_PROCES` as `ID_PROCES`
|
|
|
+ , sum(IF(przyp.`FORM_TREAT` & 2, 1, 0)) as PERM_R
|
|
|
+ , sum(IF(przyp.`FORM_TREAT` & 4, 1, 0)) as PERM_W
|
|
|
+ , sum(IF(przyp.`FORM_TREAT` & 8, 1, 0)) as PERM_X
|
|
|
+ , sum(IF(przyp.`FORM_TREAT` & 16, 1, 0)) as PERM_C
|
|
|
+ , sum(IF(przyp.`FORM_TREAT` & 32, 1, 0)) as PERM_S
|
|
|
+ , sum(IF(przyp.`FORM_TREAT` & 64, 1, 0)) as PERM_O
|
|
|
+ , sum(IF(przyp.`FORM_TREAT` & 128, 1, 0)) as PERM_V
|
|
|
+ , sum(IF(przyp.`FORM_TREAT` & 256, 1, 0)) as PERM_E
|
|
|
+ from `CRM_LISTA_ZASOBOW` z
|
|
|
+ join `CRM_LISTA_ZASOBOW` zp on(zp.`ID`=z.`PARENT_ID` and zp.`TYPE`='TABELA' and zp.`A_STATUS` in('WAITING','NORMAL'))
|
|
|
+ join `CRM_WSKAZNIK` wsk on(wsk.`ID_ZASOB`=z.`ID` and wsk.`A_STATUS` in('WAITING','NORMAL'))
|
|
|
+ join `CRM_PROCES` p on(p.`ID`=wsk.`ID_PROCES` and p.`A_STATUS` in('WAITING','NORMAL'))
|
|
|
+ join `CRM_PRZYPADEK` as przyp on (przyp.`ID`=wsk.`ID_PRZYPADEK`)
|
|
|
+ where z.`TYPE`='KOMORKA'
|
|
|
+ and z.`A_STATUS` in('WAITING','NORMAL')
|
|
|
+ and zp.`ID`='{$idTable}'
|
|
|
+ and wsk.`ID_PROCES` in({$sqlIdProcesListSql})
|
|
|
+ -- group by z.`ID`, wsk.`ID_PROCES`
|
|
|
+ group by z.`ID`
|
|
|
+ order by z.`SORT_PRIO`
|
|
|
+SQL;
|
|
|
+ //echo'<pre>UserAcl::getPermsForTable('.$idTable.')::$tableCellToProcesSql ';print_r($tableCellToProcesSql);echo'</pre>';
|
|
|
+ $userPermsForTable = array();
|
|
|
+ $db = DB::getDB();
|
|
|
+ $res = $db->query($tableCellToProcesSql);
|
|
|
+ while ($r = $db->fetch($res)) {
|
|
|
+ $userPermsForTable[$r->ID_CELL] = $r;
|
|
|
+ }
|
|
|
+ return $userPermsForTable;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getUsedUserGroupIds() {
|
|
|
+ $idUserGroupList = User::getGroupsIds();
|
|
|
+ // TODO: acl filtr by group ids
|
|
|
+ return $idUserGroupList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getUsedUserProcesIdsSql() {
|
|
|
+ $idUserGroupList = $this->getUsedUserGroupIds();
|
|
|
+ $sqlIdUserGroupList = implode(",", $idUserGroupList);
|
|
|
+ // TODO: acl filtr by proces id
|
|
|
+ return <<<SQL
|
|
|
+ select gi.`ID_PROCES`
|
|
|
+ from `CRM_PROCES_idx_GROUP_to_PROCES` gi
|
|
|
+ where gi.`ID_GROUP` in({$sqlIdUserGroupList})
|
|
|
+SQL;
|
|
|
+ }
|
|
|
}
|