Piotr Labudda 8 лет назад
Родитель
Сommit
f586bb97d4
3 измененных файлов с 25 добавлено и 21 удалено
  1. 1 19
      SE/se-lib/ACL.php
  2. 23 1
      SE/se-lib/InstanceConfig.php
  3. 1 1
      SE/se-lib/Route/Storage/AclReinstall.php

+ 1 - 19
SE/se-lib/ACL.php

@@ -518,25 +518,7 @@ class ACL {
 	}
 
 	public static function getRootNamespace($namespace) { // TODO: works only for relative urls! - mv to Acl->getRootNamespace
-		Lib::loadClass('SchemaFactory');
-		try {
-			$objectItem = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace);
-		} catch (Exception $e) {
-			throw new Exception("Object not installed '{$namespace}'");
-		}
-		if (!$objectItem['isStructInstalled']) throw new Exception("Object structure not installed '{$namespace}'");
-
-		if ($objectItem['idDatabase'] != DB::getPDO()->getZasobId()) {
-			if ('StorageAcl' === $objectItem['_type']) {
-				DBG::log("getRootNamespace...");
-				return $objectItem['namespace'];
-			}
-			else {
-				throw new Exception("Only default_db supported"); // TODO: support more Sources
-			}
-		}
-
-		return "default_db/{$objectItem['_rootTableName']}";
+		return InstanceConfig::getRootNamespace($namespace);
 	}
 	public static function getNamespaceSiblings($namespace) {
 		return InstanceConfig::getNamespaceSiblings($namespace);

+ 23 - 1
SE/se-lib/InstanceConfig.php

@@ -72,12 +72,34 @@ class InstanceConfig {
 		return DB::getPDO()->fetchFirst("
 			select c.*
 			from `CRM_INSTANCE_CONFIG` c
-			where c.namespace = :namespace'{$namespace}'
+			where c.namespace = :namespace
 		", [
 			':namespace' => $namespace
 		]);
 	}
 
+	static function getRootNamespace($namespace) { // TODO: works only for relative urls! - mv to Acl->getRootNamespace
+		Lib::loadClass('SchemaFactory');
+		try {
+			$objectItem = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace);
+		} catch (Exception $e) {
+			throw new Exception("Object not installed '{$namespace}'");
+		}
+		if (!$objectItem['isStructInstalled']) throw new Exception("Object structure not installed '{$namespace}'");
+
+		if ($objectItem['idDatabase'] != DB::getPDO()->getZasobId()) {
+			if ('StorageAcl' === $objectItem['_type']) {
+				DBG::log("getRootNamespace...");
+				return $objectItem['namespace'];
+			}
+			else {
+				throw new Exception("Only default_db supported"); // TODO: support more Sources
+			}
+		}
+
+		return "default_db/{$objectItem['_rootTableName']}";
+	}
+
 	static function getNamespaceSiblings($namespace) {
 		return array_map(function ($row) {
 			return $row['namespace'];

+ 1 - 1
SE/se-lib/Route/Storage/AclReinstall.php

@@ -277,7 +277,7 @@ class Route_Storage_AclReinstall extends RouteBase {
 		try {
 			$dbgInfo = [
 				'idInstance' => ACL::getInstanceId($namespace),
-				'rootInstance' => ACL::getRootNamespace($namespace),
+				// 'rootInstance' => InstanceConfig::getRootNamespace($namespace),
 				// 'conf' => InstanceConfig::fetchInstanceConfig($namespace),
 				// 'table' => ACL::getInstanceTable($namespace), // Object structure not installed 'default_db/{tableName}'
 			];