From 78e5ab03e4ac124c4d5259c5f6587e2ac3710f05 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Fri, 23 Mar 2018 15:26:10 +0100 Subject: [PATCH] [FEAT] #257 Header informations --- rest/index.php | 1 + src/app/user/controllers/UserController.php | 3 --- src/core/controllers/CoreController.php | 9 +++++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/rest/index.php b/rest/index.php index 2ab3fdbff25..b4ca97ca328 100755 --- a/rest/index.php +++ b/rest/index.php @@ -109,6 +109,7 @@ $app = new \Slim\App(['settings' => ['displayErrorDetails' => true]]); //Initialize $app->get('/initialize', \SrcCore\controllers\CoreController::class . ':initialize'); +$app->get('/headerInformations', \SrcCore\controllers\CoreController::class . ':getHeaderInformations'); //Actions $app->get('/actions', \Action\controllers\ActionController::class . ':get'); diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index b5205479c93..4de16894238 100644 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -22,10 +22,7 @@ use Entity\models\ListTemplateModel; use Group\models\GroupModel; use History\controllers\HistoryController; use History\models\HistoryModel; -use Notification\controllers\NotificationController; use Notification\controllers\NotificationsEventsController; -use Notification\models\NotificationModel; -use Notification\models\NotificationsEventsModel; use Parameter\models\ParameterModel; use Respect\Validation\Validator; use Slim\Http\Request; diff --git a/src/core/controllers/CoreController.php b/src/core/controllers/CoreController.php index 91ae96b27c9..9226c3a582c 100644 --- a/src/core/controllers/CoreController.php +++ b/src/core/controllers/CoreController.php @@ -19,6 +19,7 @@ use Group\models\ServiceModel; use Slim\Http\Request; use Slim\Http\Response; use SrcCore\models\CoreConfigModel; +use User\models\UserModel; class CoreController { @@ -48,6 +49,14 @@ class CoreController return $response->withJson($aInit); } + public static function getHeaderInformations(Request $request, Response $response) + { + $user = UserModel::getByUserId(['userId' => $GLOBALS['userId'], 'select' => ['id', 'user_id', 'firstname', 'lastname']]); + $user['groups'] = UserModel::getGroupsByUserId(['userId' => $user['user_id']]); + + return $response->withJson($user); + } + public static function getAdministration(Request $request, Response $response) { if ($GLOBALS['userId'] == 'superadmin') { -- GitLab