|
|
@@ -328,11 +328,34 @@ class Core_AclHelper {// Helper class for Acl
|
|
|
return [ 'name' => $objName, 'prefix' => $nsPrefix, 'url' => $nsUrl, 'sourceName' => $sourceName ];
|
|
|
}
|
|
|
else if ('zasob_' == substr($sourceName, 0, 6)) {
|
|
|
- $dbName = substr($sourceName, 6);// database id
|
|
|
- throw new Exception("TODO db[{$dbName}] namespace '{$relativeNsUrl}'", 501);
|
|
|
+ $dbName = substr($sourceName, 6);// database id
|
|
|
+ $remotePdo = DB::getPDO($dbName);
|
|
|
+ DBG::log($remotePdo, 'array', '$remotePdo');
|
|
|
+ if (!$remotePdo || $remotePdo->getZasobId() <= 0) throw new Exception("Database [{$dbName}] not exists - namespace '{$relativeNsUrl}'", 501);
|
|
|
+ if (count($nsEx) > 0) throw new Exception("Nieznany namespace {$sourceName}: '{$relativeNsUrl}'", 501);
|
|
|
+ return [ 'name' => $objName, 'prefix' => $sourceName, 'url' => implode('/', [$baseNsUri, $sourceName, $objName]), 'sourceName' => $sourceName ];
|
|
|
}
|
|
|
else throw new Exception("Nieznany namespace '{$relativeNsUrl}'", 501);
|
|
|
}
|
|
|
+ public static function getIdDatabaseFromNamespace($namespace) {
|
|
|
+ $ns = self::parseNamespaceUrl($namespace);
|
|
|
+ if ('default_db' == substr($ns['sourceName'], 0, strlen('default_db'))) {
|
|
|
+ return DB::getPDO()->getZasobId();
|
|
|
+ } else if ('default_objects' == substr($ns['sourceName'], 0, strlen('default_objects'))) {
|
|
|
+ return DB::getPDO()->getZasobId();
|
|
|
+ } else if ('table_objects' == $ns['sourceName']) {
|
|
|
+ if ('default_db' == substr($ns['prefix'], 0, strlen('default_db'))) {
|
|
|
+ return DB::getPDO()->getZasobId();
|
|
|
+ }
|
|
|
+ } else if ('zasob_' == substr($ns['sourceName'], 0, strlen('zasob_'))) {
|
|
|
+ // 'zasob_931', 'zasob_931__x3A__...'
|
|
|
+ $idDatabase = substr($ns['sourceName'], strlen('zasob_'));
|
|
|
+ if (false !== strpos($idDatabase, '_')) $idDatabase = substr($idDatabase, 0, strpos($idDatabase, '_'));
|
|
|
+ if (!$idDatabase || !is_numeric($idDatabase)) throw new Exception("Not implemented idDatabase({$idDatabase})");
|
|
|
+ return $idDatabase;
|
|
|
+ }
|
|
|
+ throw new Exception("Not implemented idDatabase for namespace({$namespace})");
|
|
|
+ }
|
|
|
|
|
|
public static function insertRef($objectName, $pk, $childName, $childPk) {// TODO: $idTransaction
|
|
|
$refTable = self::getRefTable($objectName, $childName);
|