|
|
@@ -6,6 +6,7 @@ Lib::loadClass('Typespecial');
|
|
|
Lib::loadClass('ProcesHelper');
|
|
|
Lib::loadClass('Schema_TableFactory');
|
|
|
Lib::loadClass('DataSourceFactory');
|
|
|
+Lib::loadClass('SchemaFactory');
|
|
|
|
|
|
/**
|
|
|
* $_SESSION['TableAcl_cache'][$tableID] = array(
|
|
|
@@ -923,16 +924,44 @@ class TableAcl extends Core_AclBase {
|
|
|
if (array_key_exists($idTable, $_cache)) {
|
|
|
return $_cache[$idTable];
|
|
|
}
|
|
|
+
|
|
|
if (!empty($_SESSION['TableAcl_cache'][$idTable])) {
|
|
|
$tableAcl = new TableAcl($idTable);
|
|
|
$tableAcl->fromArray($_SESSION['TableAcl_cache'][$idTable]);
|
|
|
$_cache[$idTable] = $tableAcl;
|
|
|
return $_cache[$idTable];
|
|
|
}
|
|
|
+ if (!empty($_SESSION['AntAcl_cache'][$idTable])) {
|
|
|
+ try {
|
|
|
+ $objectList = SchemaFactory::loadDefaultObject('SystemObject')->getItems([
|
|
|
+ 'propertyName' => "*,field",
|
|
|
+ 'f_idZasob' => "={$idTable}",
|
|
|
+ ]);
|
|
|
+ if (empty($objectList)) throw new Exception("Acl [{$idTable}] not exists in SystemObject"); // TODO: update Storage object list?
|
|
|
+
|
|
|
+ $objItem = reset($objectList);
|
|
|
+ DBG::log($objItem, 'array', "DBG objItem({$namespace})");
|
|
|
+ if (!in_array($objItem['_type'], [
|
|
|
+ // 'TableAcl', // TODO: TEST - to replace TableAcl by AntAcl or use object with namespace + '/tableName'?
|
|
|
+ 'AntAcl',
|
|
|
+ ])) throw new Exception("Not Implemented acl type '{$objItem['_type']}'");
|
|
|
+ if (!$objItem['isObjectActive']) {
|
|
|
+ if (!$objItem['hasStruct']) throw new Exception("namespace has no structure '{$namespace}'");
|
|
|
+ if (!$objItem['isStructInstalled']) throw new Exception("namespace structure not installed '{$namespace}'");
|
|
|
+ throw new Exception("namespace is not activated '{$namespace}'");
|
|
|
+ }
|
|
|
+
|
|
|
+ Lib::loadClass('AntAclBase');
|
|
|
+ $_cache[$idTable] = AntAclBase::buildInstance($objItem['idZasob'], $objItem);
|
|
|
+ return $_cache[$idTable];
|
|
|
+ } catch (Exception $e) {
|
|
|
+ DBG::log($e);
|
|
|
+ }
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public static function buildInstance($idTable, $tableConfig) {
|
|
|
+ public static function buildInstance($idTable, $tableConfig) { // TODO: move outside - app session cache?
|
|
|
static $_cache;
|
|
|
if (!$_cache) $_cache = array();
|
|
|
if (array_key_exists($idTable, $_cache)) {
|
|
|
@@ -965,10 +994,17 @@ class TableAcl extends Core_AclBase {
|
|
|
// }
|
|
|
// }
|
|
|
if (empty($tableConfig)) throw new Exception("Brak danych konfiguracyjnych do tabeli nr {$idTable} #TACL" . __LINE__);
|
|
|
- $obj = new TableAcl($idTable);
|
|
|
- $obj->fromArray($tableConfig);
|
|
|
- $obj->getRootTableName();
|
|
|
- $obj->save();
|
|
|
+
|
|
|
+ $type = (false !== strpos($tableConfig['name'], '/')) ? 'AntAcl' : 'TableAcl'; // TODO: fix naive check this // $type = DB::getPDO()->fetchValue(" select o._type from `CRM_#CACHE_ACL_OBJECT` o where o.idZasob = '{$idTable}' limit 1 ");
|
|
|
+ if ('AntAcl' === $type) {
|
|
|
+ DBG::log("TODO: AntAcl save config in TableAcl::buildInstance [{$idTable}] '{$tableConfig['name']}'");
|
|
|
+ $_SESSION['AntAcl_cache'][$idTable] = true;
|
|
|
+ } else { // TableAcl
|
|
|
+ $obj = new TableAcl($idTable);
|
|
|
+ $obj->fromArray($tableConfig);
|
|
|
+ $obj->getRootTableName();
|
|
|
+ $obj->save();
|
|
|
+ }
|
|
|
$_cache[$idTable] = $obj;
|
|
|
return $_cache[$idTable];
|
|
|
}
|