|
|
@@ -43,14 +43,14 @@ class Schema_UserObjectStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
public function getIdUser() { return $this->idUser; }
|
|
|
public function setIdProcesFilter($idProcesFilter) { $this->idProcesFilter = intval($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();
|
|
|
- $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";
|
|
|
$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}` (
|
|
|
`ID_USER` 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
|
|
|
");
|
|
|
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("
|
|
|
update `{$this->_rootTableName}` c
|
|
|
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();
|
|
|
+ if (empty($idUserGroupList)) return null;
|
|
|
$sqlIdUserGroupList = implode(",", $idUserGroupList);
|
|
|
return "
|
|
|
select gi.`ID_PROCES`
|