|
@@ -31,6 +31,7 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
|
|
|
|
|
'PROJECT__ID' => [ '@type' => "xsd:int" ],
|
|
'PROJECT__ID' => [ '@type' => "xsd:int" ],
|
|
|
'PROJECT__L_APPOITMENT_USER' => [ '@type' => "xsd:string" ],
|
|
'PROJECT__L_APPOITMENT_USER' => [ '@type' => "xsd:string" ],
|
|
|
|
|
+ 'USER__IS_ACTIVE' => [ '@type' => "xsd:int" ],
|
|
|
|
|
|
|
|
// 'idZasob' => [ '@type' => 'xsd:integer' ],
|
|
// 'idZasob' => [ '@type' => 'xsd:integer' ],
|
|
|
// 'idDatabase' => [ '@type' => 'xsd:integer' ],
|
|
// 'idDatabase' => [ '@type' => 'xsd:integer' ],
|
|
@@ -69,6 +70,7 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
`L_APPOITMENT_INFO` varchar(255) NOT NULL default '',
|
|
`L_APPOITMENT_INFO` varchar(255) NOT NULL default '',
|
|
|
`PROJECT__ID` int(11) NOT NULL DEFAULT 0,
|
|
`PROJECT__ID` int(11) NOT NULL DEFAULT 0,
|
|
|
`PROJECT__L_APPOITMENT_USER` varchar(255) NOT NULL default '',
|
|
`PROJECT__L_APPOITMENT_USER` varchar(255) NOT NULL default '',
|
|
|
|
|
+ `USER__IS_ACTIVE` tinyint(1) NOT NULL DEFAULT 0,
|
|
|
|
|
|
|
|
PRIMARY KEY (`feature_id`),
|
|
PRIMARY KEY (`feature_id`),
|
|
|
KEY `namespace` (`namespace`),
|
|
KEY `namespace` (`namespace`),
|
|
@@ -115,6 +117,7 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
$tablesList = [];
|
|
$tablesList = [];
|
|
|
$tablesList[] = '_PRZYPOMNIJ_ITEMS'; // to check if tables exists
|
|
$tablesList[] = '_PRZYPOMNIJ_ITEMS'; // to check if tables exists
|
|
|
$tablesList[] = '_PRZYPOMNIJ_PROJECT_TREE'; // to check if tables exists
|
|
$tablesList[] = '_PRZYPOMNIJ_PROJECT_TREE'; // to check if tables exists
|
|
|
|
|
+ $tablesList[] = '_PRZYPOMNIJ_ACTIVE_USERS'; // to check if tables exists
|
|
|
$tablesList[] = 'IN7_MK_BAZA_DYSTRYBUCJI';
|
|
$tablesList[] = 'IN7_MK_BAZA_DYSTRYBUCJI';
|
|
|
$tablesList[] = 'IN7_DZIENNIK_KORESP';
|
|
$tablesList[] = 'IN7_DZIENNIK_KORESP';
|
|
|
$tablesList[] = 'CRM_PROCES';
|
|
$tablesList[] = 'CRM_PROCES';
|
|
@@ -148,7 +151,18 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
self::_createProjectsTreeTable();
|
|
self::_createProjectsTreeTable();
|
|
|
}
|
|
}
|
|
|
if (self::_isProjectsOwnerChanged()) {
|
|
if (self::_isProjectsOwnerChanged()) {
|
|
|
- self::_updateProjectsTree();
|
|
|
|
|
|
|
+ self::_updateProjectsTreeTable();
|
|
|
|
|
+ }
|
|
|
|
|
+ // $tablesUpdateDates = array_map(function ($value) { return 1; }, $tablesUpdateDates); // moved to mass update
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!array_key_exists('_PRZYPOMNIJ_ACTIVE_USERS', $tablesUpdateDates)
|
|
|
|
|
+ || $tablesUpdateDates['ADMIN_USERS']
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if (!array_key_exists('_PRZYPOMNIJ_ACTIVE_USERS', $tablesUpdateDates)) {
|
|
|
|
|
+ self::_createUsersTable();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (self::_isUsersChanged()) {
|
|
|
|
|
+ self::_updateUsersStatusTable();
|
|
|
}
|
|
}
|
|
|
// $tablesUpdateDates = array_map(function ($value) { return 1; }, $tablesUpdateDates); // moved to mass update
|
|
// $tablesUpdateDates = array_map(function ($value) { return 1; }, $tablesUpdateDates); // moved to mass update
|
|
|
}
|
|
}
|
|
@@ -157,6 +171,7 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
$tablesToUpdate = array_keys(
|
|
$tablesToUpdate = array_keys(
|
|
|
array_filter($tablesUpdateDates, function ($value) { return $value; })
|
|
array_filter($tablesUpdateDates, function ($value) { return $value; })
|
|
|
);
|
|
);
|
|
|
|
|
+ $tablesToUpdate = array_keys($tablesToUpdate, function ($tableName) { return ( '_PRZYPOMNIJ_' !== substr($tableName, 0, strlen('_PRZYPOMNIJ_')) ); });
|
|
|
DBG::log($tablesToUpdate, 'array', "DBG::Przypomnij: \$tablesToUpdate");
|
|
DBG::log($tablesToUpdate, 'array', "DBG::Przypomnij: \$tablesToUpdate");
|
|
|
foreach ($tablesToUpdate as $tableName) self::_updateForTable($tableName);
|
|
foreach ($tablesToUpdate as $tableName) self::_updateForTable($tableName);
|
|
|
|
|
|
|
@@ -165,6 +180,12 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
) {
|
|
) {
|
|
|
self::_updateLAppUserByProjectsTree();
|
|
self::_updateLAppUserByProjectsTree();
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!array_key_exists('_PRZYPOMNIJ_ACTIVE_USERS', $tablesUpdateDates)
|
|
|
|
|
+ || $tablesUpdateDates['ADMIN_USERS']
|
|
|
|
|
+ || !empty($tablesToUpdate) // update if anything updates
|
|
|
|
|
+ ) {
|
|
|
|
|
+ self::_updateUserStatus();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
DB::getPDO()->insertOrUpdate('CRM_CONFIG', [
|
|
DB::getPDO()->insertOrUpdate('CRM_CONFIG', [
|
|
|
'CONF_KEY' => $confKeyLastUpdateDate,
|
|
'CONF_KEY' => $confKeyLastUpdateDate,
|
|
@@ -312,6 +333,41 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ static function _createUsersTable() {
|
|
|
|
|
+ DB::getPDO()->execSql("
|
|
|
|
|
+ CREATE TABLE IF NOT EXISTS `_PRZYPOMNIJ_ACTIVE_USERS` (
|
|
|
|
|
+ `ADM_ACCOUNT` varchar(20) NOT NULL,
|
|
|
|
|
+ UNIQUE KEY `ADM_ACCOUNT` (`ADM_ACCOUNT`)
|
|
|
|
|
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin2;
|
|
|
|
|
+ ");
|
|
|
|
|
+ }
|
|
|
|
|
+ static function _isUsersChanged() {
|
|
|
|
|
+ return ( DB::getPDO()->fetchValue("
|
|
|
|
|
+ select count(1) as total
|
|
|
|
|
+ -- u.ID as u__ID, u.ADM_ACCOUNT as u__ADM_ACCOUNT, t.*
|
|
|
|
|
+ from ADMIN_USERS u
|
|
|
|
|
+ left join _PRZYPOMNIJ_ACTIVE_USERS t on ( t.ADM_ACCOUNT = u.ADM_ACCOUNT )
|
|
|
|
|
+ where t.ADM_ACCOUNT is null
|
|
|
|
|
+ ") > 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ static function _updateUsersStatusTable() {
|
|
|
|
|
+ DB::getPDO()->execSql(" truncate table `_PRZYPOMNIJ_ACTIVE_USERS` ");
|
|
|
|
|
+ DB::getPDO()->execSql("
|
|
|
|
|
+ insert into `_PRZYPOMNIJ_ACTIVE_USERS` (`ADM_ACCOUNT`)
|
|
|
|
|
+ select `ADM_ACCOUNT`
|
|
|
|
|
+ from `ADMIN_USERS`
|
|
|
|
|
+ where A_STATUS = 'NORMAL'
|
|
|
|
|
+ ");
|
|
|
|
|
+ }
|
|
|
|
|
+ static function _updateUserStatus() {
|
|
|
|
|
+ DB::getPDO()->execSql("
|
|
|
|
|
+ update `_PRZYPOMNIJ_ITEMS` as i
|
|
|
|
|
+ left join `_PRZYPOMNIJ_ACTIVE_USERS` as u on ( u.ADM_ACCOUNT = i.L_APPOITMENT_USER )
|
|
|
|
|
+ set i.USER__IS_ACTIVE = IF(u.ADM_ACCOUNT is null, 0, 1)
|
|
|
|
|
+ where i.L_APPOITMENT_USER != ''
|
|
|
|
|
+ ");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
static function _createProjectsTreeTable() {
|
|
static function _createProjectsTreeTable() {
|
|
|
DB::getPDO()->execSql("
|
|
DB::getPDO()->execSql("
|
|
|
CREATE TABLE IF NOT EXISTS `_PRZYPOMNIJ_PROJECT_TREE` (
|
|
CREATE TABLE IF NOT EXISTS `_PRZYPOMNIJ_PROJECT_TREE` (
|
|
@@ -336,7 +392,7 @@ class Schema_PrzypomnijStorageAcl extends Core_AclSimpleSchemaBase {
|
|
|
)
|
|
)
|
|
|
") > 0);
|
|
") > 0);
|
|
|
}
|
|
}
|
|
|
- static function _updateProjectsTree() {
|
|
|
|
|
|
|
+ static function _updateProjectsTreeTable() {
|
|
|
DB::getPDO()->execSql(" truncate table `_PRZYPOMNIJ_PROJECT_TREE` ");
|
|
DB::getPDO()->execSql(" truncate table `_PRZYPOMNIJ_PROJECT_TREE` ");
|
|
|
DB::getPDO()->execSql("
|
|
DB::getPDO()->execSql("
|
|
|
insert into `_PRZYPOMNIJ_PROJECT_TREE` (`ID_PROJECT`,`P_ID`,`_l_app_user`,`L_APPOITMENT_USER`)
|
|
insert into `_PRZYPOMNIJ_PROJECT_TREE` (`ID_PROJECT`,`P_ID`,`_l_app_user`,`L_APPOITMENT_USER`)
|