|
|
@@ -40,8 +40,50 @@ class Route_Storage_AclReinstall extends RouteBase {
|
|
|
'table' => ACL::getInstanceTable($namespace),
|
|
|
], "dbg");
|
|
|
|
|
|
+ $item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace, [ 'propertyName' => '*,field' ]);
|
|
|
+
|
|
|
+ $childRefList = ACL::getChildRefFullList($namespace);
|
|
|
+ DBG::nicePrint($childRefList, '$childRefList');
|
|
|
+ DBG::nicePrint($item, '$item');
|
|
|
+ $activeFields = array_filter($item['field'], function ($field) {
|
|
|
+ return ($field['isActive'] > 0);
|
|
|
+ });
|
|
|
+ $fieldNsList = array_map(function ($field) {
|
|
|
+ return $field['fieldNamespace'];
|
|
|
+ }, $activeFields);
|
|
|
+ DBG::nicePrint($fieldNsList, '$fieldNsList');
|
|
|
+ if ('AntAcl' === $item['_type']) {
|
|
|
+ foreach ($childRefList as $childRef) { // [ namespace, A_STATUS ]
|
|
|
+ if ($childRef['A_STATUS'] !== 'DELETED' && !in_array($childRef['namespace'], $fieldNsList)) {
|
|
|
+ UI::alert('danger', "remove ref config for '{$childRef['namespace']}' ...");
|
|
|
+ if (!$childRef['ID']) throw new Exception("Missing ref config ID");
|
|
|
+ DB::getPDO()->update('CRM_REF_CONFIG', 'ID', $childRef['ID'], [
|
|
|
+ 'A_STATUS' => 'DELETED',
|
|
|
+ 'A_LAST_ACTION_DATE' => 'NOW()',
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ else if ($childRef['A_STATUS'] !== 'DELETED' && in_array($childRef['namespace'], $fieldNsList)) {
|
|
|
+ UI::alert('info', "ref config for '{$childRef['namespace']}' active - OK");
|
|
|
+ }
|
|
|
+ else if ($childRef['A_STATUS'] === 'DELETED' && in_array($childRef['namespace'], $fieldNsList)) {
|
|
|
+ UI::alert('warning', "activate ref config for '{$childRef['namespace']}' ...");
|
|
|
+ if (!$childRef['ID']) throw new Exception("Missing ref config ID");
|
|
|
+ DB::getPDO()->update('CRM_REF_CONFIG', 'ID', $childRef['ID'], [
|
|
|
+ 'A_STATUS' => 'NORMAL',
|
|
|
+ 'A_LAST_ACTION_DATE' => 'NOW()',
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ else if ($childRef['A_STATUS'] === 'DELETED' && !in_array($childRef['namespace'], $fieldNsList)) {
|
|
|
+ UI::alert('info', "ref config for '{$childRef['namespace']}' removed - OK");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ UI::alert('danger', "Not implemented action for '{$childRef['namespace']}'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // TODO: create missing refConfig - field is not in $childRefList
|
|
|
+ }
|
|
|
+
|
|
|
{
|
|
|
- $item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace, [ 'propertyName' => '*,field' ]);
|
|
|
if ('AntAcl' === $item['_type']) {
|
|
|
$dbName = DB::getPDO()->getDatabaseName();
|
|
|
$sqlFunBody = ACL::generateIsInstanceFunctionBody($namespace, $item);
|
|
|
@@ -136,7 +178,7 @@ class Route_Storage_AclReinstall extends RouteBase {
|
|
|
])
|
|
|
: UI::h('p', [ 'style' => "font-style:italic" ], "Brak pól do dodania");
|
|
|
echo (!empty($diffFieldsToRemove))
|
|
|
- ? UI::h('details', [ 'open' => "open", 'style' => "margin:4px 0; background-color:#ccc; border:1px solid #ddd" ], [
|
|
|
+ ? UI::h('details', [ 'open' => "open", 'style' => "margin:4px 0; color:#8a6d3b; background-color:#fcf8e3; border:1px solid #faebcc;" ], [
|
|
|
UI::h('summary', [ 'style' => "padding:4px; outline:none; cursor:pointer" ], "Pola do usunięcia (".count($diffFieldsToRemove)."):"),
|
|
|
UI::h('ul', [], array_map(function ($fieldName) {
|
|
|
return UI::h('li', [], $fieldName);
|