Ver Fonte

added try to load Acl by schema tables

Piotr Labudda há 9 anos atrás
pai
commit
9bcd02ce30
1 ficheiros alterados com 19 adições e 1 exclusões
  1. 19 1
      SE/se-lib/Core/AclHelper.php

+ 19 - 1
SE/se-lib/Core/AclHelper.php

@@ -46,7 +46,25 @@ class Core_AclHelper {// Helper class for Acl
   public static function getAclByTypeName($typeName, $forceTblAclInit = false) {// TODO: replace getAclFromTypeName in WFS
     return self::getAclByNamespace(str_replace(':', '/', $typeName), $forceTblAclInit);
 	}
-  public static function getAclByNamespace($namespace, $forceTblAclInit = false) {
+  public static function getAclByNamespace($namespace, $forceTblAclInit = false) { // TODO: mv to ACL
+    try {
+      Lib::loadClass('SchemaFactory');
+      $objItem = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace, ['propertyName'=>"*,field"]);
+      DBG::log($objItem, 'array', "DBG objItem({$namespace})");
+      if (!$objItem['idZasob']) throw new Exception("Missing idZasob for namespace '{$namespace}'");
+      if (!in_array($objItem['_type'], [
+        // 'TableAcl', // TODO: TEST - to replace TableAcl by AntAcl
+        'AntAcl',
+      ])) throw new Exception("Not Implemented acl type '{$objItem['_type']}'");
+      // TODO: check if isActive and isStructInstalled // TODO: modify Acl.isActive to admin settings
+
+      Lib::loadClass('AntAclBase');
+      $acl = AntAclBase::buildInstance($objItem['idZasob'], $objItem);
+      return $acl;
+    } catch (Exception $e) {
+      DBG::log($e);
+    }
+
     $ns = self::parseNamespaceUrl($namespace);
 
     DBG::log($ns, 'array', "parseNamespaceUrl({$namespace})");