Explorar o código

fixed get acl by namespace, fixed table label

Piotr Labudda %!s(int64=9) %!d(string=hai) anos
pai
achega
f45fca0270
Modificáronse 3 ficheiros con 44 adicións e 46 borrados
  1. 0 43
      SE/se-lib/Core/AclBase.php
  2. 41 0
      SE/se-lib/Core/AclHelper.php
  3. 3 3
      SE/se-lib/Route/ViewTableAjax.php

+ 0 - 43
SE/se-lib/Core/AclBase.php

@@ -589,47 +589,4 @@ class Core_AclBase {
     return $deleted;
   }
 
-  public static function getAclByNamespace($namespace, $forceTblAclInit) {
-		$userAcl = User::getAcl();
-		$userAcl->fetchGroups();
-		if ('http' != substr($namespace, 0, 4)) $namespace = Api_WfsNs::getBaseWfsUri() . '/' . $namespace;//Request::getHostUri() . '/' . $namespace;
-
-		$baseNsUri = Api_WfsNs::getBaseWfsUri();
-		if ("{$baseNsUri}/" == substr($namespace, 0, strlen($baseNsUri) + 1)) {
-			$schemaNs = substr($namespace, strlen($baseNsUri) + 1);
-			$ns = explode('/', $schemaNs);// "http://biuro.biall-net.pl/wfs/  default_db/{$nazwa_tabeli}/{$nazwa_obj}
-			$sourceName = array_shift($ns);// remove first element - source name
-			if ('default_db' == $sourceName || 'p5_default_db' == $sourceName) {
-				$sourceName = 'default_db';
-				$objName = $ns[0];
-				if (1 == count($ns)) {
-					$acl = $userAcl->getObjectAcl($sourceName, $objName);
-					if (!$acl) throw new Exception("Could not get acl for '{$schemaNs}'");
-					$acl->init($forceTblAclInit);
-					return $acl;
-				}
-				else throw new Exception("Nieznany namespace default_db: '{$schemaNs}'", 501);
-			}
-			else if ('default_objects' == $sourceName || 'SystemObjects' == $sourceName || 'p5_objects' == $sourceName) {
-				$sourceName = 'objects';
-				$objName = $ns[0];
-				if (1 == count($ns)) {
-					$acl = $userAcl->getObjectAcl($sourceName, $objName);
-					if (!$acl) throw new Exception("Could not get acl for '{$schemaNs}'");
-					$acl->init($forceTblAclInit);
-					return $acl;
-				}
-				else throw new Exception("Nieznany namespace SystemObjects: '{$schemaNs}'", 501);
-			}
-			else if ('zasob_' == substr($sourceName, 0, 6)) {
-				$dbName = substr($sourceName, 6);
-				throw new Exception("TODO db[{$dbName}] namespace '{$schemaNs}'", 501);
-			}
-			else throw new Exception("Nieznany namespace '{$schemaNs}'", 501);
-		}
-		else throw new HttpException("Zasoby zewnętrzenj systemu nie są jeszcze zaimplementowane", 501);
-
-		throw new HttpException("TODO L.".__LINE__." ns({$namespace})", 501);
-	}
-
 }

+ 41 - 0
SE/se-lib/Core/AclHelper.php

@@ -18,4 +18,45 @@ class Core_AclHelper {// Helper class for Acl
     return false;
   }
 
+  public static function getAclByNamespace($namespace, $forceTblAclInit) {
+		if ('http' != substr($namespace, 0, 4)) $namespace = Api_WfsNs::getBaseWfsUri() . '/' . $namespace;//Request::getHostUri() . '/' . $namespace;
+
+		$baseNsUri = Api_WfsNs::getBaseWfsUri();
+		if ("{$baseNsUri}/" == substr($namespace, 0, strlen($baseNsUri) + 1)) {
+			$schemaNs = substr($namespace, strlen($baseNsUri) + 1);
+			$ns = explode('/', $schemaNs);// "http://biuro.biall-net.pl/wfs/  default_db/{$nazwa_tabeli}/{$nazwa_obj}
+			$sourceName = array_shift($ns);// remove first element - source name
+			if ('default_db' == $sourceName || 'p5_default_db' == $sourceName) {
+				$sourceName = 'default_db';
+				$objName = $ns[0];
+				if (1 == count($ns)) {
+					$acl = User::getAcl()->getObjectAcl($sourceName, $objName);
+					if (!$acl) throw new Exception("Could not get acl for '{$schemaNs}'");
+					$acl->init($forceTblAclInit);
+					return $acl;
+				}
+				else throw new Exception("Nieznany namespace default_db: '{$schemaNs}'", 501);
+			}
+			else if ('default_objects' == $sourceName || 'SystemObjects' == $sourceName || 'p5_objects' == $sourceName) {
+				$sourceName = 'objects';
+				$objName = $ns[0];
+				if (1 == count($ns)) {
+					$acl = User::getAcl()->getObjectAcl($sourceName, $objName);
+					if (!$acl) throw new Exception("Could not get acl for '{$schemaNs}'");
+					$acl->init($forceTblAclInit);
+					return $acl;
+				}
+				else throw new Exception("Nieznany namespace SystemObjects: '{$schemaNs}'", 501);
+			}
+			else if ('zasob_' == substr($sourceName, 0, 6)) {
+				$dbName = substr($sourceName, 6);
+				throw new Exception("TODO db[{$dbName}] namespace '{$schemaNs}'", 501);
+			}
+			else throw new Exception("Nieznany namespace '{$schemaNs}'", 501);
+		}
+		else throw new HttpException("Zasoby zewnętrzenj systemu nie są jeszcze zaimplementowane", 501);
+
+		throw new HttpException("TODO L.".__LINE__." ns({$namespace})", 501);
+	}
+
 }

+ 3 - 3
SE/se-lib/Route/ViewTableAjax.php

@@ -7,7 +7,7 @@ Lib::loadClass('TableAjax');
 Lib::loadClass('Response');
 Lib::loadClass('UI');
 Lib::loadClass('Api_WfsNs');
-Lib::loadClass('Core_AclBase');
+Lib::loadClass('Core_AclHelper');
 
 class Route_ViewTableAjax extends RouteBase {
 
@@ -21,7 +21,7 @@ class Route_ViewTableAjax extends RouteBase {
 				if (!$typeName) throw new Exception("Wrong param typeName");
 				$namespace = Api_WfsNs::getBaseWfsUri() . '/' . str_replace(':', '/', $typeName);
 			}
-			$acl = Core_AclBase::getAclByNamespace($namespace, $forceTblAclInit = ('1' == V::get('_force', '', $_GET)));
+			$acl = Core_AclHelper::getAclByNamespace($namespace, $forceTblAclInit = ('1' == V::get('_force', '', $_GET)));
 
 			$forceFilterInit = array();
 			$filterInit = new stdClass();
@@ -42,7 +42,7 @@ class Route_ViewTableAjax extends RouteBase {
 
 			$tbl = new TableAjax($acl);
 			$tblLabel = $typeName;
-			if ('p5_default_db:' == substr($typeName, 0, 14)) {
+			if ('default_db' == $acl->getSourceName()) {
 				$tblLabel = array();
 				$zasobObj = ProcesHelper::getZasobTableInfo($acl->getID());
 				if (!$zasobObj) throw new Exception("Zasob TABELA ID=" . $acl->getID() . " nie istnieje");