diff --git a/src/app/home/controllers/HomeController.php b/src/app/home/controllers/HomeController.php index 41ecb61096b8291c32fe6d58cc4a57e0743f1e0e..6ef5149c4825a53cfdcf86ae4f695509ccea5ce8 100644 --- a/src/app/home/controllers/HomeController.php +++ b/src/app/home/controllers/HomeController.php @@ -76,8 +76,9 @@ class HomeController } $lastResources = ResModel::getLastResources([ - 'select' => ['res_letterbox.res_id', 'res_letterbox.subject', 'res_letterbox.creation_date'], - 'number' => 5 + 'select' => ['res_letterbox.res_id', 'res_letterbox.subject', 'res_letterbox.creation_date', 'mlb_coll_ext.alt_identifier'], + 'limit' => 5, + 'userId' => $GLOBALS['userId'] ]); return $response->withJson(['regroupedBaskets' => $regroupedBaskets, 'assignedBaskets' => $assignedBaskets, 'lastResources' => $lastResources]); diff --git a/src/app/resource/models/ResModelAbstract.php b/src/app/resource/models/ResModelAbstract.php index c9349218e167362ac69342fc7fc086e45fcfa89c..0df913febbf19d714684636d17b76ce3e66253b3 100644 --- a/src/app/resource/models/ResModelAbstract.php +++ b/src/app/resource/models/ResModelAbstract.php @@ -171,24 +171,25 @@ abstract class ResModelAbstract public static function getLastResources(array $aArgs) { - ValidatorModel::notEmpty($aArgs, ['number', 'select']); - ValidatorModel::intType($aArgs, ['number']); + ValidatorModel::notEmpty($aArgs, ['limit', 'userId', 'select']); + ValidatorModel::intType($aArgs, ['limit']); + ValidatorModel::stringType($aArgs, ['userId']); ValidatorModel::arrayType($aArgs, ['select']); $resources = DatabaseModel::select([ 'select' => $aArgs['select'], 'table' => ['history, res_letterbox, mlb_coll_ext'], 'where' => [ + 'history.user_id = ?', 'history.table_name IN (?)', 'history.record_id IS NOT NULL', 'history.record_id != ?', - 'CAST(history.record_id AS INT) = res_letterbox.res_id', - 'mlb_coll_ext.res_id = res_letterbox.res_id', 'history.event_id != ?', 'history.event_id NOT LIKE ?', - 'history.table_name IN (?)', 'res_letterbox.status != ?' + 'CAST(history.record_id AS INT) = res_letterbox.res_id', + 'mlb_coll_ext.res_id = res_letterbox.res_id', 'res_letterbox.status != ?' ], - 'data' => ['none', 'linkup', 'attach%', ['res_letterbox', 'res_view_letterbox'], 'DEL'], - 'group_by' => ['res_letterbox.res_id'], + 'data' => [$aArgs['userId'], ['res_letterbox', 'res_view_letterbox'], 'none', 'linkup', 'attach%', 'DEL'], + 'group_by' => ['res_letterbox.res_id', 'mlb_coll_ext.alt_identifier'], 'order_by' => ['MAX(history.event_date) DESC'], - 'limit' => $aArgs['number'] + 'limit' => $aArgs['limit'] ]); return $resources; diff --git a/src/core/controllers/CoreController.php b/src/core/controllers/CoreController.php index 69072df558cd84ea47b1eeed9a6d275ab29f3ed8..b029bf4bdaf1577da4d564c7efdbecc9f4941a9a 100644 --- a/src/core/controllers/CoreController.php +++ b/src/core/controllers/CoreController.php @@ -29,6 +29,7 @@ class CoreController $aInit = []; $aInit['coreUrl'] = str_replace('rest/', '', \Url::coreurl()); $aInit['applicationName'] = CoreConfigModel::getApplicationName(); + $aInit['applicationMinorVersion'] = CoreConfigModel::getApplicationVersion()['applicationMinorVersion']; $aInit['lang'] = CoreConfigModel::getLanguage(); $aInit['user'] = UserModel::getByUserId(['userId' => $GLOBALS['userId'], 'select' => ['id', 'user_id', 'firstname', 'lastname']]); $aInit['user']['groups'] = UserModel::getGroupsByUserId(['userId' => $GLOBALS['userId']]); @@ -36,8 +37,6 @@ class CoreController $aInit['scriptsToinject'] = []; $scriptsToInject = []; - $appVersion = CoreConfigModel::getApplicationVersion(); - $aInit['applicationMinorVersion'] = $appVersion['applicationMinorVersion']; $scripts = scandir('dist'); foreach ($scripts as $value) { if (strstr($value, 'runtime.') !== false || strstr($value, 'main.') !== false || strstr($value, 'vendor.') !== false || strstr($value, 'scripts.') !== false) { diff --git a/src/core/models/CoreConfigModel.php b/src/core/models/CoreConfigModel.php index a6241714ba1a700a0eaf1c86688e909c18d9064d..5a6ad9c26c45b43889339acaefab99db3ea9779c 100644 --- a/src/core/models/CoreConfigModel.php +++ b/src/core/models/CoreConfigModel.php @@ -67,12 +67,12 @@ class CoreConfigModel if ($loadedXml) { return [ - 'applicationVersion' => (string) $loadedXml->databaseVersion, - 'applicationMinorVersion' => (string) $loadedXml->databaseMinorVersion, - ]; + 'applicationVersion' => (string) $loadedXml->databaseVersion, + 'applicationMinorVersion' => (string) $loadedXml->databaseMinorVersion, + ]; } - return ''; + return []; } public static function getLanguage()