Sfoglia il codice sorgente

fixed bug when user without groups login

Piotr Labudda 8 anni fa
parent
commit
297884997b

+ 22 - 20
SE/se-lib/Schema/UserObjectStorageAcl.php

@@ -43,14 +43,14 @@ class Schema_UserObjectStorageAcl extends Core_AclSimpleSchemaBase {
   public function getIdUser() { return $this->idUser; }
   public function getIdUser() { return $this->idUser; }
   public function setIdProcesFilter($idProcesFilter) { $this->idProcesFilter = intval($idProcesFilter); }
   public function setIdProcesFilter($idProcesFilter) { $this->idProcesFilter = intval($idProcesFilter); }
   public function getIdProcesFilter() { return $this->idProcesFilter; }
   public function getIdProcesFilter() { return $this->idProcesFilter; }
-  public function updateCacheFeatures() {
-    $dbName = DB::getPDO()->getDatabaseName();
+	public function updateCacheFeatures() {
+	    $dbName = DB::getPDO()->getDatabaseName();
 		$idDatabase = DB::getPDO()->getZasobId();
 		$idDatabase = DB::getPDO()->getZasobId();
-    $sqlIdProces = ($this->idProcesFilter > 0) ? $this->idProcesFilter : 'NULL';
+	    $sqlIdProces = ($this->idProcesFilter > 0) ? $this->idProcesFilter : 'NULL';
 		$sqlWhereAndIdProces = ($this->idProcesFilter > 0) ? "and c.ID_PROCES = {$this->idProcesFilter}" : "and c.ID_PROCES is NULL";
 		$sqlWhereAndIdProces = ($this->idProcesFilter > 0) ? "and c.ID_PROCES = {$this->idProcesFilter}" : "and c.ID_PROCES is NULL";
 		$sqlNoPrefixWhereAndIdProces = ($this->idProcesFilter > 0) ? "and ID_PROCES = {$this->idProcesFilter}" : "and ID_PROCES is NULL";
 		$sqlNoPrefixWhereAndIdProces = ($this->idProcesFilter > 0) ? "and ID_PROCES = {$this->idProcesFilter}" : "and ID_PROCES is NULL";
-    $sqlIdProcesListSql = $this->getUsedUserProcesIdsSql();
-    DB::getPDO()->execSql("
+	    $sqlIdProcesListSql = $this->getUsedUserProcesIdsSql();
+	    DB::getPDO()->execSql("
 			create table if not exists `{$this->_rootTableName}` (
 			create table if not exists `{$this->_rootTableName}` (
 				`ID_USER` int(11) NOT NULL,
 				`ID_USER` int(11) NOT NULL,
 				`ID_TABLE` int(11) NOT NULL,
 				`ID_TABLE` int(11) NOT NULL,
@@ -65,21 +65,22 @@ class Schema_UserObjectStorageAcl extends Core_AclSimpleSchemaBase {
 			) ENGINE=MyISAM  DEFAULT CHARSET=latin2
 			) ENGINE=MyISAM  DEFAULT CHARSET=latin2
 		");
 		");
 		DB::getPDO()->execSql(" delete from `{$this->_rootTableName}` where ID_USER = {$this->idUser} {$sqlNoPrefixWhereAndIdProces} ");
 		DB::getPDO()->execSql(" delete from `{$this->_rootTableName}` where ID_USER = {$this->idUser} {$sqlNoPrefixWhereAndIdProces} ");
-    DB::getPDO()->execSql(" delete from `{$this->_rootTableName}` where ID_USER = {$this->idUser} {$sqlNoPrefixWhereAndIdProces} ");
-		DB::getPDO()->execSql("
-			insert into `{$this->_rootTableName}` (ID_USER, A_LAST_SYNC, ID_PROCES, ID_TABLE, db, name, label, opis)
-			select {$this->idUser}
-				, NOW()
-				, {$sqlIdProces}
-				, tpvg.`ID_TABLE`
-				, tpvg.`ID_DATABASE` as `db`
-				, tpvg.`TABLE_NAME` as `name`
-				, tpvg.`TABLE_LABEL` as `label`
-				, tpvg.`TABLE_DESCRIPTION` as `opis`
-			from `CRM_PROCES_idx_TABLE_TO_PROCES_GROUPED_VIEW` as tpvg
-			where tpvg.`ID_PROCES` in({$sqlIdProcesListSql})
-			group by tpvg.`ID_TABLE`
-		");
+		if ($sqlIdProcesListSql) {
+			DB::getPDO()->execSql("
+				insert into `{$this->_rootTableName}` (ID_USER, A_LAST_SYNC, ID_PROCES, ID_TABLE, db, name, label, opis)
+				select {$this->idUser}
+					, NOW()
+					, {$sqlIdProces}
+					, tpvg.`ID_TABLE`
+					, tpvg.`ID_DATABASE` as `db`
+					, tpvg.`TABLE_NAME` as `name`
+					, tpvg.`TABLE_LABEL` as `label`
+					, tpvg.`TABLE_DESCRIPTION` as `opis`
+				from `CRM_PROCES_idx_TABLE_TO_PROCES_GROUPED_VIEW` as tpvg
+				where tpvg.`ID_PROCES` in({$sqlIdProcesListSql})
+				group by tpvg.`ID_TABLE`
+			");
+		}
 		DB::getPDO()->execSql("
 		DB::getPDO()->execSql("
 			update `{$this->_rootTableName}` c
 			update `{$this->_rootTableName}` c
 				join `information_schema`.`TABLES` t on(t.TABLE_NAME = c.name and t.TABLE_SCHEMA = '{$dbName}')
 				join `information_schema`.`TABLES` t on(t.TABLE_NAME = c.name and t.TABLE_SCHEMA = '{$dbName}')
@@ -98,6 +99,7 @@ class Schema_UserObjectStorageAcl extends Core_AclSimpleSchemaBase {
 			";
 			";
 		}
 		}
 		$idUserGroupList = $this->getUsedUserGroupIds();
 		$idUserGroupList = $this->getUsedUserGroupIds();
+		if (empty($idUserGroupList)) return null;
 		$sqlIdUserGroupList = implode(",", $idUserGroupList);
 		$sqlIdUserGroupList = implode(",", $idUserGroupList);
 		return "
 		return "
 			select gi.`ID_PROCES`
 			select gi.`ID_PROCES`

+ 17 - 14
SE/se-lib/Schema/UserUrlActionStorageAcl.php

@@ -58,20 +58,22 @@ class Schema_UserUrlActionStorageAcl extends Core_AclSimpleSchemaBase {
 			) ENGINE=MyISAM  DEFAULT CHARSET=latin2
 			) ENGINE=MyISAM  DEFAULT CHARSET=latin2
 		");
 		");
 		DB::getPDO()->execSql(" delete from `{$this->_rootTableName}` where ID_USER = {$this->idUser} {$sqlNoPrefixWhereAndIdProces} ");
 		DB::getPDO()->execSql(" delete from `{$this->_rootTableName}` where ID_USER = {$this->idUser} {$sqlNoPrefixWhereAndIdProces} ");
-    $sqlIdProcesListSql = $this->getUsedUserProcesIdsSql();
-		DB::getPDO()->execSql("
-  		insert into `{$this->_rootTableName}` (ID_USER, A_LAST_SYNC, ID_PROCES, ID_URL, link, label, opis)
-  		select {$this->idUser}
-      		, NOW()
-      		, {$sqlIdProces}
-      		, upvg.`ID_URL`
-      		, upvg.`URL_LINK` as `link`
-      		, upvg.`URL_LABEL` as `label`
-      		, upvg.`URL_DESC` as `opis`
-  		from `CRM_PROCES_idx_URL_TO_PROCES_VIEW` as upvg
-  		where upvg.`ID_PROCES` in({$sqlIdProcesListSql})
-  		group by upvg.`ID_URL`
-		");
+	    $sqlIdProcesListSql = $this->getUsedUserProcesIdsSql();
+		if ($sqlIdProcesListSql) {
+			DB::getPDO()->execSql("
+		  		insert into `{$this->_rootTableName}` (ID_USER, A_LAST_SYNC, ID_PROCES, ID_URL, link, label, opis)
+		  		select {$this->idUser}
+		      		, NOW()
+		      		, {$sqlIdProces}
+		      		, upvg.`ID_URL`
+		      		, upvg.`URL_LINK` as `link`
+		      		, upvg.`URL_LABEL` as `label`
+		      		, upvg.`URL_DESC` as `opis`
+		  		from `CRM_PROCES_idx_URL_TO_PROCES_VIEW` as upvg
+		  		where upvg.`ID_PROCES` in({$sqlIdProcesListSql})
+		  		group by upvg.`ID_URL`
+			");
+		}
 	}
 	}
   public function getUsedUserProcesIdsSql() {
   public function getUsedUserProcesIdsSql() {
 		if ($this->idProcesFilter > 0) {
 		if ($this->idProcesFilter > 0) {
@@ -82,6 +84,7 @@ class Schema_UserUrlActionStorageAcl extends Core_AclSimpleSchemaBase {
 			";
 			";
 		}
 		}
 		$idUserGroupList = $this->getUsedUserGroupIds();
 		$idUserGroupList = $this->getUsedUserGroupIds();
+		if (empty($idUserGroupList)) return null;
 		$sqlIdUserGroupList = implode(",", $idUserGroupList);
 		$sqlIdUserGroupList = implode(",", $idUserGroupList);
 		return "
 		return "
 			select gi.`ID_PROCES`
 			select gi.`ID_PROCES`

+ 3 - 0
SE/se-lib/UserAcl.php

@@ -376,6 +376,7 @@ class UserAcl {
 
 
 	public function getPermsForTable($idTable) {
 	public function getPermsForTable($idTable) {
 		$sqlIdProcesListSql = $this->getUsedUserProcesIdsSql();
 		$sqlIdProcesListSql = $this->getUsedUserProcesIdsSql();
+		if (!$sqlIdProcesListSql) return [];
 		$tableCellToProcesSql = <<<SQL
 		$tableCellToProcesSql = <<<SQL
 			select z.`ID` as `ID_CELL`
 			select z.`ID` as `ID_CELL`
 					, z.`DESC` as `CELL_NAME`
 					, z.`DESC` as `CELL_NAME`
@@ -434,6 +435,7 @@ SQL;
 		}
 		}
 
 
 		$idUserGroupList = $this->getUsedUserGroupIds();
 		$idUserGroupList = $this->getUsedUserGroupIds();
+		if (empty($idUserGroupList)) return null;
 		$sqlIdUserGroupList = implode(",", $idUserGroupList);
 		$sqlIdUserGroupList = implode(",", $idUserGroupList);
 		return "
 		return "
 			select gi.`ID_PROCES`
 			select gi.`ID_PROCES`
@@ -508,6 +510,7 @@ SQL;
 		}
 		}
 
 
 		$sqlIdProcesListSql = $this->getUsedUserProcesIdsSql();
 		$sqlIdProcesListSql = $this->getUsedUserProcesIdsSql();
+		if (!$sqlIdProcesListSql) return [];
 		$fetchUsedProcesInitListSql = <<<SQL
 		$fetchUsedProcesInitListSql = <<<SQL
 			select p.`ID`, p.`DESC`
 			select p.`ID`, p.`DESC`
 				from `CRM_PROCES` p
 				from `CRM_PROCES` p