|
@@ -232,57 +232,9 @@ class ACL {
|
|
|
|
|
|
|
|
// $item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($rootObjectNamespace, [ 'propertyName' => '*,field' ]);
|
|
// $item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($rootObjectNamespace, [ 'propertyName' => '*,field' ]);
|
|
|
if (!($rootAcl instanceof AntAclBase)) throw new Exception("Ref allowed only for AntAcl objects");
|
|
if (!($rootAcl instanceof AntAclBase)) throw new Exception("Ref allowed only for AntAcl objects");
|
|
|
- $fieldInfo = $rootAcl->_getField($childName); // throws Exception if field not exists
|
|
|
|
|
|
|
|
|
|
- $refConfig = RefConfig::fetch($rootObjectNamespace, $childName);
|
|
|
|
|
-
|
|
|
|
|
- // TODO: CASE: Obj: A, B not installed, Ref: A->B; Install A / cannot install Ref A->B / require install B first / then go back and reinstall A
|
|
|
|
|
- // TODO: What if primaryKey type != int ?
|
|
|
|
|
- // TODO: require 2 pass for Install every object - first install all base Obj, then reinstall fixes Ref config
|
|
|
|
|
- // \--- TODO: or split Reinstall obj action to: 1. Reinstall base Obj and 2. Install Ref tables
|
|
|
|
|
-
|
|
|
|
|
- if ('view' === $refConfig->source) {
|
|
|
|
|
- $refTableName = "CRM__#REF_TABLE__{$refConfig->id}_VIEW"; // view created by ACL::generateRefSelectSqlByFlatRelationCache
|
|
|
|
|
- if ('WAITING' == $refConfig->status) {
|
|
|
|
|
- if (!($rootAcl instanceof AntAclBase)) throw new Exception("Ref allowed only for AntAcl objects");
|
|
|
|
|
- $fieldInfo = $rootAcl->_getField($childName);
|
|
|
|
|
- $typeField = Type_Field::build($fieldInfo);
|
|
|
|
|
- RefConfig::installRefView($rootObjectNamespace, $childName, $typeField, $refConfig);
|
|
|
|
|
- $refConfig = RefConfig::fetch($rootObjectNamespace, $childName);
|
|
|
|
|
- }
|
|
|
|
|
- } else if ('backRef' === $refConfig->source) {
|
|
|
|
|
- $refTableName = "CRM__#REF_TABLE__{$refConfig->id}_VIEW"; // view created by ACL::generateRefSelectSqlByFlatRelationCache
|
|
|
|
|
- if ('WAITING' == $refConfig->status) {
|
|
|
|
|
- throw new Exception("Install backRef view for '{$rootObjectNamespace}' to '{$childName}'");
|
|
|
|
|
- // if (!($rootAcl instanceof AntAclBase)) throw new Exception("Ref allowed only for AntAcl objects");
|
|
|
|
|
- // $fieldInfo = $rootAcl->_getField($childName);
|
|
|
|
|
- // $typeField = Type_Field::build($fieldInfo);
|
|
|
|
|
- // RefConfig::installRefView($rootObjectNamespace, $childName, $typeField, $refConfig);
|
|
|
|
|
- // $refConfig = RefConfig::fetch($rootObjectNamespace, $childName);
|
|
|
|
|
- }
|
|
|
|
|
- } else if ('table' === $refConfig->source) {
|
|
|
|
|
- $refTableName = "CRM__#REF_TABLE__{$refConfig->id}";
|
|
|
|
|
- if ('WAITING' == $refConfig->status) {
|
|
|
|
|
- RefConfig::createRefTable($rootObjectNamespace, $childName);
|
|
|
|
|
- $refConfig = RefConfig::fetch($rootObjectNamespace, $childName);
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new Exception("Not Implemented ref SOURCE = '{$refConfig->source}'");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if ('0' === (string)$refConfig->version) {
|
|
|
|
|
- DBG::log($refConfig, 'array', "BUG RefConfig VERSION = 0 (ID: {$refConfig->version})");
|
|
|
|
|
- throw new Exception("Wystąpiły błędy w konfiguracji tabeli powiązań - zainstaluj ponownie obiekt");
|
|
|
|
|
- }
|
|
|
|
|
- if ($refConfig->version < RefConfig::$REF_TABLE_VERSION) {
|
|
|
|
|
- if (1 == $refConfig->version) {
|
|
|
|
|
- RefConfig::createRefTable($rootObjectNamespace, $childName);
|
|
|
|
|
- $refConfig = RefConfig::fetch($rootObjectNamespace, $childName);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if ($refConfig->version < RefConfig::$REF_TABLE_VERSION) throw new Exception("TODO: ref table {$refConfig->id} require upgrade - field '{$childName}' in object '{$rootObjectNamespace}'");
|
|
|
|
|
-
|
|
|
|
|
- $cacheRefTables[$cacheKey] = $refTableName;
|
|
|
|
|
|
|
+ $refConfig = RefConfig::getRefConfig($rootObjectNamespace, $childName);
|
|
|
|
|
+ $cacheRefTables[$cacheKey] = $refConfig->tableName;
|
|
|
return $refTableName;
|
|
return $refTableName;
|
|
|
}
|
|
}
|
|
|
public static function getRefSource($rootObjectNamespace, $childName) { // CRM_REF_CONFIG
|
|
public static function getRefSource($rootObjectNamespace, $childName) { // CRM_REF_CONFIG
|