Przeglądaj źródła

updated SystemObject structure - isObjectActive as admin settings

Piotr Labudda 9 lat temu
rodzic
commit
b2f9adaeda

+ 1 - 31
SE/se-lib/AntAclBase.php

@@ -207,35 +207,6 @@ class AntAclBase extends Core_AclBase {
     $acl->_fields = $conf['field']; // TODO: lazyLoading - use getFields() in all functions - TODO: use ACL::getObjectFields
     $acl->_primaryKey = 'ID'; // $conf['primaryKey'];
 
-    //   'idZasob' => '25872',
-    //   'idDatabase' => '36',
-    //   'namespace' => 'default_db/CRM_PROCES/CRM_PROCES',
-    //   '_rootTableName' => 'CRM_PROCES',
-    //   '_type' => 'AntAcl',
-    //   'isActive' => '1',
-    //   'isStructInstalled' => '1',
-    //   'description' => '',
-    //   'name' => 'CRM_PROCES',
-    //   'nsPrefix' => 'default_db__x3A__CRM_PROCES',
-    //   'typeName' => 'default_db__x3A__CRM_PROCES:CRM_PROCES',
-    //   'reinstallLink' => 'https://biuro.biall-net.pl/dev-pl/se-master/index.php?_route=Storage&_task=objectReinstall&namespace=default_db/CRM_PROCES/CRM_PROCES',
-    //   'field' => [
-    //     0 => [
-    //       'namespace' => 'default_db/CRM_PROCES/CRM_PROCES/ID',
-    //       'fieldNamespace' => 'ID',
-    //       'idZasob' => NULL,
-    //       'idDatabase' => '36',
-    //       '_rootTableName' => 'CRM_PROCES',
-    //       'objectNamespace' => 'default_db/CRM_PROCES/CRM_PROCES',
-    //       'xsdType' => 'xsd:int',
-    //       'xsdRestrictions' => '[]',
-    //       'appInfo' => '[]',
-    //       'minOccurs' => '0',
-    //       'maxOccurs' => '1',
-    //       'isActive' => '1',
-    //       'description' => '',
-    //     ),
-
     $_cache[$idZasob] = $acl;
     return $_cache[$idZasob];
   }
@@ -253,8 +224,7 @@ class AntAclBase extends Core_AclBase {
         'propertyName' => 'name', // TODO: SystemObject fix propertyName
         'f__rootTableName' => "={$rootTableName}",
         'f__type' => "=AntAcl",
-        'f_isActive' => "=1",
-        'f_isStructInstalled' => "=1",
+        'f_isObjectActive' => "=1",
       ])
     );
   }

+ 6 - 4
SE/se-lib/Core/AclHelper.php

@@ -53,12 +53,14 @@ class Core_AclHelper {// Helper class for Acl
       DBG::log($objItem, 'array', "DBG objItem({$namespace})");
       if (!$objItem['idZasob']) throw new Exception("Missing idZasob for namespace '{$namespace}'");
       if (!in_array($objItem['_type'], [
-        // 'TableAcl', // TODO: TEST - to replace TableAcl by AntAcl
+        // 'TableAcl', // TODO: TEST - to replace TableAcl by AntAcl or use object with namespace + '/tableName'?
         'AntAcl',
       ])) throw new Exception("Not Implemented acl type '{$objItem['_type']}'");
-      // TODO: check if isActive and isStructInstalled // TODO: modify Acl.isActive to admin settings
-      if (!$objItem['isStructInstalled']) throw new Exception("namespace struct not installed '{$namespace}'");
-      if (!$objItem['isActive']) throw new Exception("namespace is not activated '{$namespace}'");
+      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');
       $acl = AntAclBase::buildInstance($objItem['idZasob'], $objItem);

+ 215 - 74
SE/se-lib/Route/Storage.php

@@ -609,8 +609,9 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 								]
 							]),
 						// 'opis' => $item['description'],
-						'active?' => ($item['isActive']) ? '<span class="label label-success">TAK</span>' : '<span class="text text-muted">nie</span>',
+						'hasStruct' => ($item['hasStruct']) ? '<span class="label label-success">TAK</span>' : '<span class="text text-muted">nie</span>',
 						'installed' => $item['isStructInstalled'] ? '<span class="label label-success">TAK</span>' : '<span class="text text-muted">nie</span>',
+						'active?' => $item['isObjectActive'] ? '<span class="label label-success">TAK</span>' : '<span class="text text-muted">nie</span>',
 						'menu' => UI::h('div', ['class'=>"p5UI__dropdown-wrap"], [
 							UI::h('button', ['onClick' => "p5UI__dropdown(event, this, 'left bottom')", 'class' => "btn btn-xs btn-default p5UI__dropdown-btn"], [
 								'<i class="glyphicon glyphicon-menu-hamburger"></i>',
@@ -699,26 +700,69 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 				if ($a['fieldNamespace'] < $b['fieldNamespace']) return -1;
 				return 0;
 			});
-			echo UI::h('a', [
-				'href' => $this->getLink('objectReinstall', ['namespace' => $item['namespace']]),
-				'class' => 'btn btn-link pull-right'
-			], "reinstall object");
-			echo ($item['idZasob'] > 0)
-				? UI::h('h3', [], "Nr zasobu {$item['idZasob']}")
-				: UI::h('h3', [], [
-					"Nr zasobu ",
-					UI::hButtonAjax("+ do zasobów", 'addAclObjectToZasobyAjax', [
-						'class' => "btn btn-xs btn-primary",
-						'href' => $this->getLink('addAclObjectToZasobyAjax'),
-						'data' => [
-							'idStorage' => $item['idDatabase'],
-							'namespace' => $item['namespace'],
-						]
-					])
-				]);// TODO: UI::hButtonAjax(...)
 			$thisGetLink = array($this, 'getLink');
 			UI::table([
-				'caption' => UI::h('h3', [], "Struktura obiektu '{$item['namespace']}'"),
+				'caption' => UI::h('span', [], [
+					UI::h('span', [ 'style' => "margin-right:6px;color:#000" ], "Struktura obiektu '{$item['namespace']}'"),
+					' &nbsp; ',
+					( ($item['idZasob'] > 0)
+						? UI::h('span', [ 'title' => "Nr zasobu '{$item['idZasob']}'" ], "[{$item['idZasob']}]")
+						: UI::h('span', [ 'title' => "Brak nr zasobu - dodaj do zasobów" ], [
+							UI::hButtonAjax("+ do zasobów", 'addAclObjectToZasobyAjax', [
+								'class' => "btn btn-xs btn-primary",
+								'href' => $this->getLink('addAclObjectToZasobyAjax'),
+								'data' => [
+									'idStorage' => $item['idDatabase'],
+									'namespace' => $item['namespace'],
+								]
+							])
+						])
+					),
+					' &nbsp; ',
+					( ($item['isObjectActive'] > 0)
+						? UI::h('span', [ 'class' => "label label-success", 'title' => "Namespace active" ], "Active")
+						: UI::h('span', [ 'title' => "Namespace not active" ], [
+							($item['idZasob'] > 0)
+							? UI::hButtonAjax("Aktywuj", 'activateObjectAjax', [
+									'class' => "btn btn-xs btn-primary",
+									'href' => $this->getLink('activateObjectAjax'),
+									'data' => [
+										'namespace' => $item['namespace'],
+									]
+								])
+							: '',
+						])
+					),
+					' &nbsp; ',
+					UI::h('a', [
+						'href' => "index.php?_route=ViewTableAjax&namespace={$item['namespace']}",
+						'class' => "btn btn-md btn-link"
+					], "Przeglądaj tabelę"),
+					' &nbsp; ',
+					( ($item['idZasob'] > 0)
+						? UI::h('a', [
+								'href' => "procesy5.php?task=CRM_LISTA_ZASOBOW&filtr_id={$item['idZasob']}&filtr_ids=%2B&filtr_ob=%2B",
+								'class' => "btn btn-md btn-link",
+								'title' => "Struktura tabeli w drzewie zasobów"
+							], "Zasoby")
+						: ''
+					),
+					' &nbsp; ',
+					( ($item['idZasob'] > 0)
+						? UI::h('a', [
+								'href' => "index.php?FUNCTION_INIT=PROCES_MENU&HEADER_NOT_INIT=YES&_task=PROCES_FOR_TABLE&tblId={$item['idZasob']}",
+								'class' => "btn btn-md btn-link",
+								'title' => "Procesy dla aktualnie przeglądanej tabeli"
+							], "Procesy")
+						: ''
+					),
+					' &nbsp; ',
+					UI::h('a', [
+						'href' => $this->getLink('objectReinstall', ['namespace' => $item['namespace']]),
+						'class' => 'btn btn-link', 'style' => "color:#f00",
+						'title' => "Zainstaluje ponownie obiekt"
+					], "reinstall object"),
+				]),
 				'rows' => array_map(function ($field) use ($item, $thisGetLink) {
 					$tblItem = []; foreach ($field as $k => $v) $tblItem[$k] = $v;
 					$tblItem['namespace'] = UI::h('span', [], [
@@ -733,7 +777,8 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 										'class' => "btn btn-xs btn-primary",
 										'href' => $thisGetLink('addFieldToZasobyAjax'),
 										'data' => [
-											'namespace' => $field['namespace'],
+											'namespace' => $item['namespace'],
+											'fieldNamespace' => $field['namespace'],
 										]
 									])
 								: UI::h('span', ['title'=>"Brak Nr zasobu dla obiektu", 'class'=>"btn btn-xs btn-danger"], "Brak nr zasobu obiektu")
@@ -746,12 +791,10 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 			]);
 			UI::hButtonAjaxOnResponse('addFieldToZasobyAjax', /* payload, n */ "
 				if (!payload.type) return false
-				console.log('TODO: addFieldToZasobyAjax response', payload);
-				if (payload.data && payload.data.id && payload.data.id > 0) { // if ('success' == payload.type) {
-					n.parentNode.replaceChild(document.createTextNode(payload.data.id), n)
-				} else {
-					console.log('TODO: addFieldToZasobyAjax unknown response', payload);
+				if (payload.body && payload.body.id && payload.body.id > 0) { // if ('success' == payload.type) {
+					n.parentNode.replaceChild(document.createTextNode(payload.body.id), n)
 				}
+				jQuery.notify(payload.msg, payload.type)
 			");
 			UI::hButtonAjaxOnResponse('addAclObjectToZasobyAjax', /* payload, n */ "
 				if (!payload.type) return false
@@ -764,6 +807,27 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 					window.location.reload()
 				}
 			");
+			UI::hButtonAjaxOnResponse('activateObjectAjax', /* payload, n */ "
+				jQuery.notify(payload.msg, payload.type)
+				if (!payload.type) return false
+				if ('success' === payload.type || 'info' === payload.type) {
+					if (payload.body && payload.body.isObjectActive && payload.body.isObjectActive > 0) {
+						n.parentNode.replaceChild(document.createTextNode('Active'), n)
+					} else {
+						console.log('TODO: activateObjectAjax unknown response', payload);
+					}
+				}
+			");
+			if ($item['isObjectActive']) {
+				echo UI::hButtonAjax("Dodaj podstawowy proces dla obiektu '{$item['namespace']}' - read only (TODO)", 'addObjectBaseProcesAjax', [
+					'class' => "btn btn-xs btn-default",
+					'href' => $this->getLink('addObjectBaseProcesAjax'),
+					'data' => [ 'namespace' => $item['namespace'] ]
+				]);
+				UI::hButtonAjaxOnResponse('addObjectBaseProcesAjax', /* payload, n */ "
+					jQuery.notify(payload.msg, payload.type)
+				");
+			}
 			DBG::nicePrint($item, '$item');
 		} catch (Exception $e) {
 			UI::alert('danger', "Error #" . $e->getCode() .  "|" . $e->getLine() .  ": " . $e->getMessage());
@@ -993,11 +1057,11 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 			]);
 			echo '<hr>';
 
-			$ajaxAddBaseProcesLink = Request::getPathUri() . "index.php?_route=Storage&_task=addBaseProces&idStorage={$idStorage}&tblName={$tblName}";
-			$onClick = "return p5UI__ButtonAjax(this, 'p5UIBtnAjax:Storage:addBaseProces', { href: '{$ajaxAddBaseProcesLink}' })";
+			$ajaxAddBaseProcesLink = Request::getPathUri() . "index.php?_route=Storage&_task=addTableBaseProces&idStorage={$idStorage}&tblName={$tblName}";
+			$onClick = "return p5UI__ButtonAjax(this, 'p5UIBtnAjax:Storage:addTableBaseProces', { href: '{$ajaxAddBaseProcesLink}' })";
 			UI::tag('a', ['onclick'=>$onClick, 'class'=>"btn btn-xs btn-default", 'href'=>"#"], "Dodaj podstawowy proces dla tabeli '{$tblName}' - read only", true);
 			echo UI::h('script', [], "
-				jQuery(document).on('p5UIBtnAjax:Storage:addBaseProces:ajaxLoaded', function(e, n, payload) {
+				jQuery(document).on('p5UIBtnAjax:Storage:addTableBaseProces:ajaxLoaded', function(e, n, payload) {
 					jQuery.notify(payload.msg, payload.type);
 				});
 			");
@@ -1085,10 +1149,10 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 		];
 	}
 
-	public function addBaseProcesAction() {
-		Response::sendTryCatchJson(array($this, 'addBaseProces'), $_REQUEST);
+	public function addTableBaseProcesAction() {
+		Response::sendTryCatchJson(array($this, 'addTableBaseProces'), $_REQUEST);
 	}
-	public function addBaseProces($args) {
+	public function addTableBaseProces($args) {
 		$return = [
 			'type' => 'error',
 			'msg' => 'todo: F.' . __FUNCTION__ . ' L.' . __LINE__,
@@ -1139,6 +1203,60 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 		return $return;
 	}
 
+	public function addObjectBaseProcesAjaxAction() {
+		Response::sendTryCatchJson(array($this, 'addObjectBaseProcesAjax'), $_REQUEST);
+	}
+	public function addObjectBaseProcesAjax($args) {
+		$return = [
+			'type' => 'error',
+			'msg' => 'todo: F.' . __FUNCTION__ . ' L.' . __LINE__,
+		];
+		$namespace = V::get('namespace', 0, $args);
+		if (empty($namespace)) throw new HttpException("Missing namespace", 400);
+		$item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace, [ 'propertyName' => '*,field' ]);
+		DBG::log($item, 'array', "TODO: addObjectBaseProcesAjax for \$item");
+
+		throw new HttpException("TODO: addObjectBaseProcesAjax('{$namespace}')", 400); // TODO: ...
+
+		// $return['$tableStruct'] = $tableStruct;
+		//
+		// $idTable = $this->fetchTableId($idStorage, $tblName);
+		// if ($idTable <= 0) {
+		// 	UI::alert('warning', "Zasob tabela '{$tblName}' nie istnieje");// TODO: add p5UI btn
+		// 	DBG::table("tblStruct", $tblStruct, __CLASS__, __FUNCTION__, __LINE__);
+		// 	throw new Exception("Zasob tabela '{$tblName}' nie istnieje");
+		// }
+		// $cellZasobList = array();
+		// foreach (DB::getPDO()->fetchAllByKey("
+		// 		select z.ID, z.`DESC`, z.A_STATUS
+		// 		from CRM_LISTA_ZASOBOW z
+		// 		where z.PARENT_ID = '{$idTable}'
+		// 	", $key = 'DESC') as $ind => $row) {
+		// 	$cellZasobList[strtolower($ind)] = $row;
+		// }
+		//
+		// $return['$cellZasobList'] = $cellZasobList;
+
+		// TODO: ACL::modify('default_db/CRM_PROCES/CRM_PROCES_INIT', [ 'ref:...' => $namespace ]);
+		$idProces = DB::getDB()->ADD_NEW_OBJ('CRM_PROCES', (object)[
+			'TYPE' => 'PROCES_INIT',
+			'DESC' => "Proces dla obiektu '{$namespace}'",
+		]);
+		if (!$idProces) throw new Exception("DB ERROR - nie udało się dodać procesu");
+		// TODO: add wskaznik do $item['idZasob']
+		// foreach ($cellZasobList as $loverName => $row) {
+		// 	DB::getDB()->ADD_NEW_OBJ('CRM_WSKAZNIK', (object)[
+		// 		'ID_PROCES' => $idProces,
+		// 		'ID_ZASOB' => $row['ID'],
+		// 		'TYP' => 'P',
+		// 		'ID_PRZYPADEK' => 2
+		// 	]);
+		// }
+		// $return['type'] = 'success';
+		// $return['msg'] = "Utworzono proces {{$idProces}}";
+		// return $return;
+	}
+
 	public function addGeomEtykietaCellsAction() {
 		Response::sendTryCatchJson(array($this, 'addGeomEtykietaCells'), $_REQUEST);
 	}
@@ -1746,65 +1864,54 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 	public function addFieldToZasobyAjax($args) {
 		$namespace = V::get('namespace', '', $args);
 		if (empty($namespace)) throw new HttpException("Missing namespace");
-
-		$fieldItem = SchemaFactory::loadDefaultObject('SystemObjectField')->getItem($namespace);
-		$zasobTableName = substr($fieldItem['objectNamespace'], strlen('default_db/'));
-		$zasobTableName = (false !== strpos($zasobTableName, '/'))
-			? $fieldItem['objectNamespace']
-			: $zasobTableName;
+		$fieldNamespace = V::get('fieldNamespace', '', $args);
+		if (empty($fieldNamespace)) throw new HttpException("Missing fieldNamespace");
+		$fieldItem = SchemaFactory::loadDefaultObject('SystemObjectField')->getItem($fieldNamespace);
+		if (!$fieldItem) throw new HttpException("Field not found '{$fieldNamespace}'", 404);
+		DBG::log($fieldItem, 'array', "\$fieldItem");
+		if ($fieldItem['idZasob'] > 0) throw (new AlertSuccessException("Field already added to Zasoby '{$fieldItem['idZasob']}'"))->setBody([ 'id' => $fieldItem['idZasob'] ]);
+		$objectItem = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace);
+		if (!$objectItem) throw new HttpException("Object not found '{$namespace}'", 404);
+		DBG::log($objectItem, 'array', "\$objectItem");
+		if (!$objectItem['idZasob']) throw new Exception("Missing Object idZasob");
 		$zasobItem = DB::getPDO()->fetchFirst("
 			select zField.ID, zField.`DESC`, zField.`TYPE`, zField.PARENT_ID
 			from CRM_LISTA_ZASOBOW as zField
 				join CRM_LISTA_ZASOBOW as zTable on(zTable.ID = zField.PARENT_ID)
-			where zTable.PARENT_ID = {$fieldItem['idDatabase']}
-				and zTable.`DESC` = '{$zasobTableName}'
+			where zTable.`ID` = '{$objectItem['idZasob']}'
 				and zTable.`TYPE` = 'TABELA'
 				and zField.`DESC` = '{$fieldItem['fieldNamespace']}'
 				and zField.`TYPE` = 'KOMORKA'
 		");
 		if ($zasobItem) {
 			SchemaFactory::loadDefaultObject('SystemObjectField')->updateItem([
-				'namespace' => $namespace,
+				'namespace' => $fieldItem['namespace'],
 				'idZasob' => $zasobItem['ID']
 			]);
-			return [
-				'type' => 'success',
-				'msg' => "Zasob już istnieje",
-				'data' => [
-					'id' => $zasobItem['ID']
-				],
-				'__DBG__' => [
-					$zasobItem,
-					$fieldItem,
-					$args,
-				]
-			];
+			throw (new AlertSuccessException("Zasob już istnieje"))->setBody([ 'id' => $zasobItem['ID'] ]);
 		}
 
-		return [
-			'type' => 'success',
-			'msg' => "TODO: addFieldToZasobyAjax",
-			'data' => [
-				'id' => 123
-			],
-			'__DBG__' => [
-				$zasobItem,
-				$fieldItem,
-				$args,
-			]
-		];
-
-		// throw new Exception("TODO: F.addFieldToZasobyAjax");
-
-		return [
-			'type' => 'success',
-			'msg' => "TODO: addFieldToZasobyAjax",
-			'data' => [
-				'id' => 123
-			],
-			'__DBG__args' => $args
+		$newFieldItem = [
+			'PARENT_ID' => $objectItem['idZasob'],
+			'TYPE' => 'KOMORKA',
+			'DESC' => $fieldItem['fieldNamespace'],
+			'DESC_PL' => $fieldItem['fieldNamespace'],
 		];
+		DBG::log($newFieldItem, 'array', "add new field item");
+		try {
+			$acl = User::getAcl()->getObjectAcl('default_db', 'crm_lista_zasobow');
+		} catch (Exception $e) {
+			throw new Exception("Brak dostępu do tabeli Zasoby");
+		}
+		$createdId = $acl->addItem($newFieldItem);
+		if (!$createdId) throw new Exception("Nie udało się utworzyć nowego rekordu!");
+		SchemaFactory::loadDefaultObject('SystemObjectField')->updateItem([
+			'namespace' => $fieldItem['namespace'],
+			'idZasob' => $createdId
+		]);
+		throw (new AlertSuccessException("Utworzono pomyślnie rekord nr {$createdId}"))->setBody([ 'id' => $createdId ]);
 	}
+
 	public function addCellToZasobyAction() {// sends JSON
 		$response = new stdClass();
 		try {
@@ -1957,4 +2064,38 @@ jQuery(document).on('p5UIBtnAjax:Storage:checkObjectInstallAjax:ajaxLoaded', fun
 		UI::dol();
 	}
 
+	public function activateObjectAjaxAction() {
+		DBG::log($_REQUEST, 'array', '$_REQUEST');
+		Response::sendTryCatchJson(array($this, 'activateObjectAjax'), $_REQUEST);
+	}
+	public function activateObjectAjax($args) {
+		$namespace = V::get('namespace', '', $args);
+		if (empty($namespace)) throw new Exception("Missing param namespace");
+		$item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace, [ 'propertyName' => '*,field' ]);
+		if (empty($item)) throw new HttpException("Namespace not found", 404);
+		DBG::log($item, 'array', "TODO: activateObjectAjax \$item");
+		if ($item['isObjectActive']) throw new AlertSuccessException("Namespace '{$namespace}' already active");
+		if (!$item['hasStruct']) throw new Exception("Missing struct for namespace '{$namespace}'");
+		if (!$item['isStructInstalled']) throw new Exception("Namespace struct not installed '{$namespace}'");
+		$activeFields = array_filter($item['field'], function ($field) {
+			if (!$field['isActive']) return false;
+			if (!$field['idZasob']) return false;
+			return true;
+		});
+		if (empty($activeFields)) throw new Exception("Missing active fields for namespace '{$namespace}'");
+
+		$affected = SchemaFactory::loadDefaultObject('SystemObject')->updateItem([
+      'namespace' => $item['namespace'],
+      'isObjectActive' => 1
+    ]);
+		if ($affected < 0) throw new Exception("Nie udało się aktywować obiektu '{$namespace}'");
+		return [
+			'type' => "success",
+			'msg' => "Aktywowano obiekt '{$namespace}'",
+			'body' => [
+				'isObjectActive' => 1
+			]
+		];
+	}
+
 }

+ 16 - 12
SE/se-lib/Schema/SystemObjectStorageAcl.php

@@ -15,8 +15,9 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
       'namespace' => [ '@type' => 'xsd:string' ],
       '_rootTableName' => [ '@type' => 'xsd:string' ],
       '_type' => [ '@type' => 'xsd:string' ],
-      'isActive' => [ '@type' => 'xsd:integer' ], // 0 - removed, old
+      'hasStruct' => [ '@type' => 'xsd:integer' ], // 0 - removed, old, 1 - has config, structure
       'isStructInstalled' => [ '@type' => 'xsd:integer' ], // installed
+      'isObjectActive' => [ '@type' => 'xsd:integer' ], // (0,1) - admin settings with restrictions: (hasStruct, isStructInstalled, all fields installed and with idZasob)
       'description' => [ '@type' => 'xsd:string' ],
       'name' => [ '@type' => 'p5:string' ],
       'typeName' => [ '@type' => 'p5:string' ],
@@ -97,14 +98,16 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
         `namespace` varchar(255) DEFAULT '',
         `_rootTableName` varchar(255) DEFAULT '',
         `_type` varchar(255) DEFAULT '',
-        `isActive` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'installed',
+        `hasStruct` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'has structure',
+        `isStructInstalled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'has installed structure',
+        `isObjectActive` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'object is active',
         `description` varchar(255) DEFAULT '',
         UNIQUE KEY `idZasob` (idZasob),
         UNIQUE KEY `namespace` (namespace),
-        KEY `isActive` (isActive)
+        KEY `isObjectActive` (isObjectActive)
       ) ENGINE=MyISAM  DEFAULT CHARSET=latin2
     ");
-    DB::getPDO()->execSql(" update `{$this->_rootTableName}` set isActive = 0 ");
+    DB::getPDO()->execSql(" update `{$this->_rootTableName}` set hasStruct = 0 ");
     $idDefDB = DB::getPDO()->getZasobId();
 
     $sourceStorage = SchemaFactory::loadDefaultObject('SystemSource');
@@ -119,26 +122,26 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
               'namespace' => $namespace,
               'idDatabase' => $source['idZasob'],
               '_type' => "StorageAcl",
-              'isActive' => 1
+              'hasStruct' => 1
             ]);
 					} catch (Exception $e) {
 						UI::alert('danger', $e->getMessage());
 					}
 				}
         DB::getPDO()->execSql("
-          insert into `{$this->_rootTableName}` (namespace, idZasob, idDatabase, description, isActive)
+          insert into `{$this->_rootTableName}` (namespace, idZasob, idDatabase, description, hasStruct)
             select concat('{$source['nsPrefix']}/', t.`DESC`)
                 ,  t.ID as idZasob
                 ,  '{$source['idZasob']}' as idDatabase
                 ,  t.`OPIS` as description
-                ,  1 as isActive
+                ,  1 as hasStruct
             from CRM_LISTA_ZASOBOW t
             where t.`TYPE` = 'TABELA'
               and t.A_STATUS in('NORMAL', 'WAITING')
               and t.PARENT_ID = {$source['idZasob']}
               and t.`DESC` not like '%/%'
           on duplicate key update idZasob = t.ID
-                                , isActive = 1
+                                , hasStruct = 1
         ");
       }
       else {
@@ -160,18 +163,18 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
               on duplicate key update _rootTableName = t.TABLE_NAME
             ");
             DB::getPDO()->execSql("
-              insert into `{$this->_rootTableName}` (namespace, idZasob, idDatabase, description, isActive)
+              insert into `{$this->_rootTableName}` (namespace, idZasob, idDatabase, description, hasStruct)
                 select concat('{$source['nsPrefix']}/', t.`DESC`) as namespace
                     , t.ID as idZasob
                     , '{$source['idZasob']}' as idDatabase
                     , t.`OPIS` as description
-                    , 1 as isActive
+                    , 1 as hasStruct
                 from CRM_LISTA_ZASOBOW t
                 where t.`TYPE` = 'TABELA'
                   and t.A_STATUS in('NORMAL', 'WAITING')
                   and t.PARENT_ID = {$source['idZasob']}
               on duplicate key update idZasob = t.ID
-                                    , isActive = 1
+                                    , hasStruct = 1
             ");
           // } else if ('pgsql' == $dbType) {// TODO: use pgsql @see Storage Pgsql getTables from information_schema
           } else {
@@ -210,7 +213,7 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
           'idDatabase' => $idDatabase,
           '_type' => "AntAcl",
           '_rootTableName' => $rootTableName,
-          'isActive' => 1
+          'hasStruct' => 1
         ]);
       } catch (Exception $e) {
         UI::alert('danger', $e->getMessage());
@@ -369,6 +372,7 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
     if (empty($itemPatch)) return 0;
     foreach ($itemPatch as $fieldName => $value) {
       if ('isStructInstalled' == $fieldName) continue;
+      if ('isObjectActive' == $fieldName) continue;
       throw new Exception("Update field '{$fieldName}' not allowed for '{$this->_namespace}'");
     }
     return DB::getPDO()->update($this->_rootTableName, $pkField, $pk, $itemPatch);