瀏覽代碼

fixed code tables struct and struct installed info

Piotr Labudda 8 年之前
父節點
當前提交
7cdcf6348f
共有 1 個文件被更改,包括 52 次插入47 次删除
  1. 52 47
      SE/se-lib/Schema/SystemObjectStorageAcl.php

+ 52 - 47
SE/se-lib/Schema/SystemObjectStorageAcl.php

@@ -80,53 +80,7 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
 				DBG::log($e);
 			}
 
-			{ // Fix hasWriteGroupField, hasReadGroupField, hasOwnerField
-				// public function hasWriteGroupField() { // return $this->hasField('A_ADM_COMPANY');
-				// public function hasReadGroupField() { // return $this->hasField('A_CLASSIFIED');
-				// public function hasOwnerField() { // return $this->hasField('L_APPOITMENT_USER');
-				DB::getPDO()->execSql("
-					CREATE TABLE IF NOT EXISTS `tmp_cache_acl_fields` (
-					  `table_name` varchar(64) NOT NULL DEFAULT '',
-					  `column_name` varchar(64) NOT NULL DEFAULT '',
-					  UNIQUE KEY `table_2` (`table_name`,`column_name`),
-					  KEY `table` (`table_name`)
-					) ENGINE=MyISAM DEFAULT CHARSET=latin2
-				");
-				DB::getPDO()->execSql("
-					CREATE TABLE IF NOT EXISTS `tmp_cache_acl_group_fields` (
-					  `table_name` varchar(64) NOT NULL DEFAULT '',
-					  `has_write` tinyint(1) NOT NULL DEFAULT 0,
-					  `has_read` tinyint(1) NOT NULL DEFAULT 0,
-					  `has_owner` tinyint(1) NOT NULL DEFAULT 0,
-					  UNIQUE KEY `table_name` (`table_name`)
-					) ENGINE=MyISAM DEFAULT CHARSET=latin2
-				");
-				DB::getPDO()->execSql(" TRUNCATE TABLE `tmp_cache_acl_fields` ");
-				DB::getPDO()->execSql(" TRUNCATE TABLE `tmp_cache_acl_group_fields` ");
-				DB::getPDO()->execSql("
-					insert into tmp_cache_acl_group_fields(table_name, has_write, has_read, has_owner)
-						select c.TABLE_NAME as table_name
-							, IF(c.COLUMN_NAME = 'A_ADM_COMPANY', 1, 0) as has_write
-							, IF(c.COLUMN_NAME = 'A_CLASSIFIED', 1, 0) as has_read
-							, IF(c.COLUMN_NAME = 'L_APPOITMENT_USER', 1, 0) as has_owner
-						from information_schema.COLUMNS c
-							where c.TABLE_SCHEMA = 'SES_USERS2'
-						  and c.COLUMN_NAME in ('A_ADM_COMPANY', 'A_CLASSIFIED', 'L_APPOITMENT_USER')
-						ON DUPLICATE KEY UPDATE
-							has_write = has_write + IF(c.COLUMN_NAME = 'A_ADM_COMPANY', 1, 0),
-							has_read = has_read + IF(c.COLUMN_NAME = 'A_CLASSIFIED', 1, 0),
-							has_owner = has_owner + IF(c.COLUMN_NAME = 'L_APPOITMENT_USER', 1, 0)
-				");
-
-				DB::getPDO()->execSql("
-					update `CRM_#CACHE_ACL_OBJECT` c
-						join `tmp_cache_acl_group_fields` t on (t.table_name = c._rootTableName)
-					set
-						c.hasWriteGroupField = t.has_write,
-						c.hasReadGroupField = t.has_read,
-						c.hasOwnerField = t.has_owner
-				");
-			}
+			$this->_fixCoreTablesStructInstalled();
 
 			$dbVersion = 2; $this->updateDBVersion($dbVersion);
 		}
@@ -393,6 +347,57 @@ class Schema_SystemObjectStorageAcl extends Core_AclSimpleSchemaBase {
 		//	 DBG::nicePrint($ns, "TODO: insert zasob PARENT_ID = ?");
 		//	 }
 		// }
+
+		$this->_fixCoreTablesStructInstalled();
+	}
+
+	function _fixCoreTablesStructInstalled() { // Fix hasWriteGroupField, hasReadGroupField, hasOwnerField
+		// TODO: mv to updateCache function - required after clear cache tables
+		// public function hasWriteGroupField() { // return $this->hasField('A_ADM_COMPANY');
+		// public function hasReadGroupField() { // return $this->hasField('A_CLASSIFIED');
+		// public function hasOwnerField() { // return $this->hasField('L_APPOITMENT_USER');
+		DB::getPDO()->execSql("
+			CREATE TABLE IF NOT EXISTS `tmp_cache_acl_fields` (
+			  `table_name` varchar(64) NOT NULL DEFAULT '',
+			  `column_name` varchar(64) NOT NULL DEFAULT '',
+			  UNIQUE KEY `table_2` (`table_name`,`column_name`),
+			  KEY `table` (`table_name`)
+			) ENGINE=MyISAM DEFAULT CHARSET=latin2
+		");
+		DB::getPDO()->execSql("
+			CREATE TABLE IF NOT EXISTS `tmp_cache_acl_group_fields` (
+			  `table_name` varchar(64) NOT NULL DEFAULT '',
+			  `has_write` tinyint(1) NOT NULL DEFAULT 0,
+			  `has_read` tinyint(1) NOT NULL DEFAULT 0,
+			  `has_owner` tinyint(1) NOT NULL DEFAULT 0,
+			  UNIQUE KEY `table_name` (`table_name`)
+			) ENGINE=MyISAM DEFAULT CHARSET=latin2
+		");
+		DB::getPDO()->execSql(" TRUNCATE TABLE `tmp_cache_acl_fields` ");
+		DB::getPDO()->execSql(" TRUNCATE TABLE `tmp_cache_acl_group_fields` ");
+		DB::getPDO()->execSql("
+			insert into tmp_cache_acl_group_fields(table_name, has_write, has_read, has_owner)
+				select c.TABLE_NAME as table_name
+					, IF(c.COLUMN_NAME = 'A_ADM_COMPANY', 1, 0) as has_write
+					, IF(c.COLUMN_NAME = 'A_CLASSIFIED', 1, 0) as has_read
+					, IF(c.COLUMN_NAME = 'L_APPOITMENT_USER', 1, 0) as has_owner
+				from information_schema.COLUMNS c
+					where c.TABLE_SCHEMA = 'SES_USERS2'
+				  and c.COLUMN_NAME in ('A_ADM_COMPANY', 'A_CLASSIFIED', 'L_APPOITMENT_USER')
+				ON DUPLICATE KEY UPDATE
+					has_write = has_write + IF(c.COLUMN_NAME = 'A_ADM_COMPANY', 1, 0),
+					has_read = has_read + IF(c.COLUMN_NAME = 'A_CLASSIFIED', 1, 0),
+					has_owner = has_owner + IF(c.COLUMN_NAME = 'L_APPOITMENT_USER', 1, 0)
+		");
+
+		DB::getPDO()->execSql("
+			update `CRM_#CACHE_ACL_OBJECT` c
+				join `tmp_cache_acl_group_fields` t on (t.table_name = c._rootTableName)
+			set
+				c.hasWriteGroupField = t.has_write,
+				c.hasReadGroupField = t.has_read,
+				c.hasOwnerField = t.has_owner
+		");
 	}
 
 	public function _parseWhere($params = []) {