Przeglądaj źródła

added system object field sortPrio, reinstall update sortPrio from Zasoby

Piotr Labudda 8 lat temu
rodzic
commit
12781ff86e

+ 27 - 1
SE/se-lib/Schema/SystemObjectFieldStorageAcl.php

@@ -24,6 +24,7 @@ class Schema_SystemObjectFieldStorageAcl extends Core_AclSimpleSchemaBase {
 			'isActive' => [ '@type' => 'xsd:integer' ], // installed
 			'description' => [ '@type' => 'xsd:string' ],
 			'isLocal' => [ '@type' => 'xsd:integer', '@comment' => "is in _rootTableName" ],
+			'sortPrio' => [ '@type' => 'xsd:integer' ],
 			// 'A_RECORD_CREATE_AUTHOR' => [ '@type' => 'xsd:string' , '@label' => 'autor' ],
 			// 'A_RECORD_CREATE_DATE' => [ '@type' => 'xsd:date' , '@label' => 'utworzono' ],
 			// 'A_RECORD_UPDATE_AUTHOR' => [ '@type' => 'xsd:string' , '@label' => 'zaktualizował' ],
@@ -33,7 +34,7 @@ class Schema_SystemObjectFieldStorageAcl extends Core_AclSimpleSchemaBase {
 	// public $_rootTableName = 'CRM_LISTA_ZASOBOW';
 	public $_rootTableName = 'CRM_#CACHE_ACL_OBJECT_FIELD';
 	public $_enumRootTableName = 'CRM_#CACHE_ACL_OBJECT_FIELD_enum';
-	public $_version = '2';
+	public $_version = '3';
 
 	public function __construct($simpleSchema = null) {
 		parent::__construct($simpleSchema);
@@ -56,6 +57,7 @@ class Schema_SystemObjectFieldStorageAcl extends Core_AclSimpleSchemaBase {
 					`isActive` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'installed',
 					`description` varchar(255) DEFAULT '',
 					`isLocal` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is in _rootTableName',
+					`sortPrio` int(11) NOT NULL DEFAULT 0,
 					UNIQUE KEY `idZasob` (idZasob),
 					PRIMARY KEY (`namespace`),
 					KEY `isActive` (isActive)
@@ -71,6 +73,23 @@ class Schema_SystemObjectFieldStorageAcl extends Core_AclSimpleSchemaBase {
 			} catch (Exception $e) {
 				DBG::log($e);
 			}
+			try {
+				DB::getPDO()->execSql(" ALTER TABLE `{$this->_rootTableName}` ADD `sortPrio` int(11) NOT NULL DEFAULT 0 AFTER `isLocal` ");
+				DB::getPDO()->execSql("
+					UPDATE `{$this->_rootTableName}`
+					SET sortPrio = idZasob
+					WHERE idZasob > 0
+				");
+				DB::getPDO()->execSql("
+					UPDATE `{$this->_rootTableName}` c
+						LEFT JOIN `CRM_LISTA_ZASOBOW` z on ( z.ID = c.idZasob )
+					SET c.sortPrio = z.SORT_PRIO
+					WHERE c.idZasob > 0
+						and z.ID is not null
+				");
+			} catch (Exception $e) {
+				DBG::log($e);
+			}
 			DB::getPDO()->execSql("
 				create table if not exists `{$this->_enumRootTableName}` (
 					`namespace` varchar(255) DEFAULT '' COMMENT 'concat obj ns / field ns / value',
@@ -152,6 +171,13 @@ class Schema_SystemObjectFieldStorageAcl extends Core_AclSimpleSchemaBase {
 			where t.objectNamespace = '{$objectItem['namespace']}'
 			and t._rootTableName = '{$objectItem['_rootTableName']}'
 		");
+
+		DB::getPDO()->execSql("
+			UPDATE `{$this->_rootTableName}` t
+				LEFT JOIN `CRM_LISTA_ZASOBOW` z on ( z.ID = t.idZasob )
+			SET t.sortPrio = IF(z.ID is not null, z.SORT_PRIO, 0)
+			WHERE t.objectNamespace = '{$objectItem['namespace']}'
+		");
 	}
 
 	public function updateCacheAntAcl($item) {

+ 3 - 1
SE/se-lib/Schema/SystemObjectStorageAcl.php

@@ -498,7 +498,9 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
 						'__backRef' => [
 							'namespace' => 'default_objects/SystemObject',
 							'primaryKey' => $item['namespace']
-						]
+						],
+						'order_by' => 'sortPrio',
+						'order_dir' => 'asc',
 					]);
 				}
 			}