|
|
@@ -29,6 +29,30 @@ class Route_Storage_AclUsage extends RouteBase {
|
|
|
$rootTableName = $acl->getRootTableName();
|
|
|
$idTable = $acl->getID();
|
|
|
|
|
|
+ $renderProcesLink = function ($idProces) {
|
|
|
+ return UI::h('a', [
|
|
|
+ 'href' => "procesy5.php?task=CRM_PROCES&filtr_id={$idProces}",
|
|
|
+ 'class' => "btn btn-xs btn-link", 'style' => "padding:0",
|
|
|
+ ], "{$idProces}");
|
|
|
+ };
|
|
|
+ $renderPermCell = function ($value) {
|
|
|
+ return ($value)
|
|
|
+ ? UI::h('span', [ 'class' => "label label-success" ], $value)
|
|
|
+ : UI::h('span', [ 'class' => "label label-danger" ], $value);
|
|
|
+ };
|
|
|
+ $permCols = [ 'PERM_R', 'PERM_W', 'PERM_X', 'PERM_C', 'PERM_S', 'PERM_O', 'PERM_V', 'PERM_E' ];
|
|
|
+ $labelPermCols = [ 'PERM_R' => 'R', 'PERM_W' => 'W', 'PERM_X' => 'X', 'PERM_C' => 'C', 'PERM_S' => 'S', 'PERM_O' => 'O', 'PERM_V' => 'V', 'PERM_E' => 'E' ];
|
|
|
+ $helpPermCols = [
|
|
|
+ 'PERM_R' => 'Odczyt',
|
|
|
+ 'PERM_W' => 'Zapis',
|
|
|
+ 'PERM_X' => 'Wykonanie',
|
|
|
+ 'PERM_C' => 'Tworzenie',
|
|
|
+ 'PERM_S' => 'Zapis pomimo braku uprawnień do rekordu',
|
|
|
+ 'PERM_O' => 'Tylko własne dane',
|
|
|
+ 'PERM_V' => 'Odczyt pomimo braku uprawnień do rekordu',
|
|
|
+ 'PERM_E' => 'Export',
|
|
|
+ ];
|
|
|
+
|
|
|
echo UI::h('details', ['style'=>"margin-bottom:24px; padding:0 10px; background-color:#eee", 'open' => "open"], [
|
|
|
UI::h('summary', ['style'=>"font-size:1.4em; line-height:2em; cursor:pointer; outline:none"], [
|
|
|
"Uprawnienia obiektu '{$namespace}' ",
|
|
|
@@ -73,13 +97,17 @@ class Route_Storage_AclUsage extends RouteBase {
|
|
|
UI::startTag('details');
|
|
|
echo UI::h('summary', ['style'=>"cursor:pointer; margin-bottom:12px"], "Wszystkie powiązania komórek z procesami - szczegóły");
|
|
|
UI::table([
|
|
|
- 'rows' => array_map(function ($row) {
|
|
|
+ 'cols_label' => $labelPermCols,
|
|
|
+ 'cols_help' => $helpPermCols,
|
|
|
+ 'rows' => array_map(function ($row) use ($renderProcesLink, $renderPermCell, $permCols) {
|
|
|
$splitPos = (strlen($row['TABLE_DESCRIPTION']) > 20) ? strpos($row['TABLE_DESCRIPTION'], ' ', 20) : 20;
|
|
|
if ($splitPos > 30) $splitPos = 20;
|
|
|
$row['TABLE_DESCRIPTION'] = UI::h('details', [], [
|
|
|
UI::h('summary', [ 'style' => "white-space:nowrap" ], substr($row['TABLE_DESCRIPTION'], 0, $splitPos)),
|
|
|
UI::h('p', [], substr($row['TABLE_DESCRIPTION'], $splitPos)),
|
|
|
]);
|
|
|
+ $row['ID_PROCES'] = $renderProcesLink($row['ID_PROCES']);
|
|
|
+ foreach ($permCols as $colPerm) $row[ $colPerm ] = $renderPermCell( $row[$colPerm] );
|
|
|
return $row;
|
|
|
}, $aclTableRows)
|
|
|
]);
|
|
|
@@ -94,44 +122,34 @@ class Route_Storage_AclUsage extends RouteBase {
|
|
|
$databaseName = DB::getPDO( $acl->getDatabaseID() )->getDatabaseName();
|
|
|
UI::table([
|
|
|
'caption' => "Powiązania komórek z procesem",
|
|
|
+ 'cols_label' => $labelPermCols,
|
|
|
+ 'cols_help' => $helpPermCols,
|
|
|
'rows' => array_map(
|
|
|
- function ($row) use ($aclTableRows, $idTable) {
|
|
|
+ function ($row) use ($aclTableRows, $idTable, $renderProcesLink, $renderPermCell, $permCols) {
|
|
|
$fieldName = $row['COLUMN_NAME'];
|
|
|
- $item = [];
|
|
|
- $item['name'] = $fieldName;
|
|
|
- $item['typ'] = UI::h('details', [], [
|
|
|
- UI::h('summary', ['style'=>"cursor:pointer"], $row['DATA_TYPE']),
|
|
|
- UI::h('p', [], $row['COLUMN_TYPE']),
|
|
|
- ]);
|
|
|
- $item['w procesie'] = array();
|
|
|
- $item['id_zasob'] = 0;
|
|
|
- $item['PERM_R'] = 0;
|
|
|
- $item['PERM_W'] = 0;
|
|
|
- $item['PERM_X'] = 0;
|
|
|
- $item['PERM_C'] = 0;
|
|
|
- $item['PERM_S'] = 0;
|
|
|
- $item['PERM_O'] = 0;
|
|
|
- $item['PERM_V'] = 0;
|
|
|
- $item['PERM_E'] = 0;
|
|
|
+ $item = [
|
|
|
+ 'name' => $fieldName,
|
|
|
+ 'typ' => UI::h('details', [], [
|
|
|
+ UI::h('summary', ['style'=>"cursor:pointer"], $row['DATA_TYPE']),
|
|
|
+ UI::h('p', [], $row['COLUMN_TYPE']),
|
|
|
+ ]),
|
|
|
+ 'w procesie' => [],
|
|
|
+ 'idZasob' => 0,
|
|
|
+ ];
|
|
|
+ foreach ($permCols as $colPerm) $item[$colPerm] = '';
|
|
|
foreach ($aclTableRows as $aclInfo) {
|
|
|
if (strtolower($aclInfo['CELL_NAME']) == strtolower($row['COLUMN_NAME'])) {
|
|
|
$item['w procesie'][] = $aclInfo['ID_PROCES'];
|
|
|
- $item['id_zasob'] = $aclInfo['ID_CELL'];
|
|
|
- $item['PERM_R'] += $aclInfo['PERM_R'];
|
|
|
- $item['PERM_W'] += $aclInfo['PERM_W'];
|
|
|
- $item['PERM_X'] += $aclInfo['PERM_X'];
|
|
|
- $item['PERM_C'] += $aclInfo['PERM_C'];
|
|
|
- $item['PERM_S'] += $aclInfo['PERM_S'];
|
|
|
- $item['PERM_O'] += $aclInfo['PERM_O'];
|
|
|
- $item['PERM_V'] += $aclInfo['PERM_V'];
|
|
|
- $item['PERM_E'] += $aclInfo['PERM_E'];
|
|
|
+ $item['idZasob'] = $aclInfo['ID_CELL'];
|
|
|
+ foreach ($permCols as $colPerm) $item[$colPerm] += $aclInfo[$colPerm];
|
|
|
}
|
|
|
}
|
|
|
$item['w procesie'] = (empty($item['w procesie']))
|
|
|
- ? "<i style=\"color:red\">Brak</i>"
|
|
|
- : UI::h('span', ['style'=>"white-space:nowrap"], implode(", ", $item['w procesie']));
|
|
|
- if (!$item['id_zasob']) $item['id_zasob'] = DB::getPDO()->fetchValue("select ID from CRM_LISTA_ZASOBOW where `DESC` = '{$fieldName}' and PARENT_ID = {$idTable} limit 1");
|
|
|
- $item['id_zasob'] = ($item['id_zasob']) ? $item['id_zasob'] : UI::h('i', ['style'=>"color:silver"], "Brak");
|
|
|
+ ? "<i style=\"color:red\">Brak</i>"
|
|
|
+ : UI::h('span', ['style'=>"white-space:nowrap"], implode(", ", array_map($renderProcesLink, $item['w procesie'])));
|
|
|
+ if (!$item['idZasob']) $item['idZasob'] = DB::getPDO()->fetchValue("select ID from CRM_LISTA_ZASOBOW where `DESC` = '{$fieldName}' and PARENT_ID = {$idTable} limit 1");
|
|
|
+ $item['idZasob'] = ($item['idZasob']) ? $item['idZasob'] : UI::h('i', ['style'=>"color:silver"], "Brak");
|
|
|
+ foreach ($permCols as $colPerm) $item[$colPerm] = $renderPermCell($item[$colPerm]);
|
|
|
return $item;
|
|
|
}, DB::getPDO()->fetchAll("
|
|
|
select t.COLUMN_NAME, t.DATA_TYPE, t.COLUMN_TYPE
|
|
|
@@ -153,39 +171,34 @@ class Route_Storage_AclUsage extends RouteBase {
|
|
|
and ID_PROCES in({$csvIdProces})
|
|
|
group by ID_PROCES
|
|
|
");
|
|
|
- $userIdProces = array(); foreach ($rows as $row) $userIdProces[] = $row['ID_PROCES'];
|
|
|
- $userTablePerms = array();
|
|
|
- foreach ($aclTableRows as $row) {
|
|
|
- if (!in_array($row['ID_PROCES'], $userIdProces)) continue;
|
|
|
- if (array_key_exists($row['CELL_NAME'], $userTablePerms)) {
|
|
|
- $userTablePerms[ $row['CELL_NAME'] ]['w procesie'] .= ",{$row['ID_PROCES']}";
|
|
|
- $userTablePerms[ $row['CELL_NAME'] ][ 'PERM_R' ] += $row['PERM_R'];
|
|
|
- $userTablePerms[ $row['CELL_NAME'] ][ 'PERM_W' ] += $row['PERM_W'];
|
|
|
- $userTablePerms[ $row['CELL_NAME'] ][ 'PERM_X' ] += $row['PERM_X'];
|
|
|
- $userTablePerms[ $row['CELL_NAME'] ][ 'PERM_C' ] += $row['PERM_C'];
|
|
|
- $userTablePerms[ $row['CELL_NAME'] ][ 'PERM_S' ] += $row['PERM_S'];
|
|
|
- $userTablePerms[ $row['CELL_NAME'] ][ 'PERM_O' ] += $row['PERM_O'];
|
|
|
- $userTablePerms[ $row['CELL_NAME'] ][ 'PERM_V' ] += $row['PERM_V'];
|
|
|
- $userTablePerms[ $row['CELL_NAME'] ][ 'PERM_E' ] += $row['PERM_E'];
|
|
|
- } else {
|
|
|
- $userTablePerms[ $row['CELL_NAME'] ] = [
|
|
|
+ $userIdProces = array_map( V::makePick('ID_PROCES', 0, 'int'), $rows );
|
|
|
+ $userTablePerms = array_reduce($aclTableRows, function ($ret, $row) use ($userIdProces, $permCols) {
|
|
|
+ $idProces = (int)$row['ID_PROCES'];
|
|
|
+ if (!$idProces) return $ret;
|
|
|
+ if (!in_array($idProces, $userIdProces)) return $ret;
|
|
|
+ if (!array_key_exists($row['CELL_NAME'], $ret)) {
|
|
|
+ $ret[ $row['CELL_NAME'] ] = [
|
|
|
'fieldName' => $row['CELL_NAME'],
|
|
|
- 'zasob' => $row['ID_CELL'],
|
|
|
- 'w procesie' => "{$row['ID_PROCES']}",
|
|
|
- 'PERM_R' => $row['PERM_R'],
|
|
|
- 'PERM_W' => $row['PERM_W'],
|
|
|
- 'PERM_X' => $row['PERM_X'],
|
|
|
- 'PERM_C' => $row['PERM_C'],
|
|
|
- 'PERM_S' => $row['PERM_S'],
|
|
|
- 'PERM_O' => $row['PERM_O'],
|
|
|
- 'PERM_V' => $row['PERM_V'],
|
|
|
- 'PERM_E' => $row['PERM_E'],
|
|
|
+ 'idZasob' => $row['ID_CELL'],
|
|
|
+ 'w procesie' => [],
|
|
|
];
|
|
|
+ foreach ($permCols as $colPerm) $ret[ $row['CELL_NAME'] ][ $colPerm ] = '';
|
|
|
}
|
|
|
- }
|
|
|
+ $ret[ $row['CELL_NAME'] ]['w procesie'] []= $row['ID_PROCES'];
|
|
|
+ foreach ($permCols as $colPerm) $ret[ $row['CELL_NAME'] ][ $colPerm ] += $row[ $colPerm ];
|
|
|
+ return $ret;
|
|
|
+ }, []);
|
|
|
UI::table([
|
|
|
'caption' => "Uprawniena dla usera '{$userLogin}'",
|
|
|
- 'rows' => $userTablePerms
|
|
|
+ 'cols_label' => $labelPermCols,
|
|
|
+ 'cols_help' => $helpPermCols,
|
|
|
+ 'rows' => array_map(function ($item) use ($renderProcesLink, $renderPermCell, $permCols) {
|
|
|
+ sort($item['w procesie']);
|
|
|
+ $item['w procesie'] = array_unique($item['w procesie'], SORT_NUMERIC);
|
|
|
+ $item['w procesie'] = implode(", ", array_map($renderProcesLink, $item['w procesie']));
|
|
|
+ foreach ($permCols as $colPerm) $item[$colPerm] = $renderPermCell($item[$colPerm]);
|
|
|
+ return $item;
|
|
|
+ }, $userTablePerms),
|
|
|
]);
|
|
|
} else UI::alert('warning', "Brak przypisanych procesów");
|
|
|
} catch (Exception $e) {
|