|
|
@@ -231,6 +231,75 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Fix objects AntAcl which struct is not installed
|
|
|
+ $listAntAclObjectsToFix = DB::getPDO()->fetchAll("
|
|
|
+ select t.*
|
|
|
+ from `CRM_#CACHE_ACL_OBJECT` t
|
|
|
+ where t._type = 'AntAcl'
|
|
|
+ and t.idZasob is not NULL
|
|
|
+ and t.hasStruct = 1
|
|
|
+ and t.isStructInstalled = 0
|
|
|
+ ");
|
|
|
+ if (!empty($listAntAclObjectsToFix)) {
|
|
|
+ UI::alert('info', "Fix AntAcl objects which is not installed (total: ".count($listAntAclObjectsToFix).")");
|
|
|
+ foreach ($listAntAclObjectsToFix as $antAclInfo) {
|
|
|
+ $namespace = $antAclInfo['namespace'];
|
|
|
+ DBG::nicePrint($antAclInfo, "\$antAclInfo ({$namespace})");
|
|
|
+ $zasobyStruct = DB::getPDO()->fetchAll("
|
|
|
+ select z.ID, z.`DESC`
|
|
|
+ from `CRM_LISTA_ZASOBOW` z
|
|
|
+ where z.PARENT_ID = :parent_id
|
|
|
+ and z.`TYPE` = 'KOMORKA'
|
|
|
+ ", [ ':parent_id' => $antAclInfo['idZasob'] ]);
|
|
|
+ DBG::nicePrint($zasobyStruct, "\$zasobyStruct ({$namespace})");
|
|
|
+
|
|
|
+ ob_start();
|
|
|
+ Lib::loadClass('Schema_SystemObjectFieldStorageAcl');
|
|
|
+ $objFieldAcl = new Schema_SystemObjectFieldStorageAcl();
|
|
|
+ $objFieldAcl->updateCache($namespace);
|
|
|
+ $reinstallLog = ob_get_clean();
|
|
|
+ // DBG::nicePrint($reinstallLog, "\$reinstallLog ({$namespace})");
|
|
|
+
|
|
|
+ $fieldCacheStruct = DB::getPDO()->fetchAll("
|
|
|
+ select t.namespace, t.fieldNamespace
|
|
|
+ from `CRM_#CACHE_ACL_OBJECT_FIELD` t
|
|
|
+ where t.objectNamespace = :namespace
|
|
|
+ and t.idZasob is NULL
|
|
|
+ ", [ ':namespace' => $namespace ]);
|
|
|
+ DBG::nicePrint($fieldCacheStruct, "\$fieldCacheStruct ({$namespace})");
|
|
|
+
|
|
|
+ $fieldsToFix = [];
|
|
|
+ foreach ($fieldCacheStruct as $cacheField) {
|
|
|
+ $fieldName = $cacheField['fieldNamespace'];
|
|
|
+ foreach ($zasobyStruct as $fieldZasob) {
|
|
|
+ if ($fieldZasob['DESC'] === $fieldName) {
|
|
|
+ $fieldsToFix[] = [
|
|
|
+ 'idZasob' => $fieldZasob['ID'],
|
|
|
+ 'namespace' => $cacheField['namespace'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ DBG::nicePrint($fieldsToFix, "\$fieldsToFix ({$namespace})");
|
|
|
+
|
|
|
+ foreach ($fieldsToFix as $fixField) {
|
|
|
+ $affected = SchemaFactory::loadDefaultObject('SystemObjectField')->updateItem([
|
|
|
+ 'namespace' => $fixField['namespace'],
|
|
|
+ 'idZasob' => $fixField['idZasob']
|
|
|
+ ]);
|
|
|
+ if (!$affected) UI::alert('warning', "field ({$fixField['namespace']}) update idZasob failed");
|
|
|
+ }
|
|
|
+
|
|
|
+ $affected = SchemaFactory::loadDefaultObject('SystemObject')->updateItem([
|
|
|
+ 'namespace' => $namespace,
|
|
|
+ 'isObjectActive' => 1
|
|
|
+ ]);
|
|
|
+ ($affected)
|
|
|
+ ? UI::alert('success', "object ({$namespace}) activated")
|
|
|
+ : UI::alert('warning', "object ({$namespace}) activation failed");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// // foreach ... DB::getPDO($idDatabase)->fetchAll(select real _rootTableName)
|
|
|
// foreach (Core_AclHelper::getCustomAclList() as $typeName) {
|
|
|
// $ns = Core_AclHelper::parseTypeName($typeName);
|