From aa30a0c6afa578a7befceb504dcdcc1e3d097279 Mon Sep 17 00:00:00 2001 From: Martin Francis Date: Sat, 2 Mar 2024 21:43:57 -0500 Subject: [PATCH] 2.63.0 Preparations for CLE Panner mode --- src/Controller/Web/Admin/Info.php | 3 ++- src/Controller/Web/Users/Collection.php | 7 ++--- src/Controller/Web/Users/User.php | 11 +++----- src/Controller/Web/Users/UserLogsessions.php | 2 +- src/Controller/Web/Users/YourProfile.php | 2 +- src/Repository/ModeRepository.php | 28 +++++++++++++------- 6 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/Controller/Web/Admin/Info.php b/src/Controller/Web/Admin/Info.php index 61cfa81c..53b1c44b 100644 --- a/src/Controller/Web/Admin/Info.php +++ b/src/Controller/Web/Admin/Info.php @@ -2,6 +2,7 @@ namespace App\Controller\Web\Admin; use App\Controller\Web\Base; +use App\Entity\User as UserEntity; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -28,7 +29,7 @@ public function controller( $_locale, $system ) { - if (!$this->parameters['isAdmin']) { + if (!((int)$this->parameters['access'] & UserEntity::MASTER)) { $this->session->set('route', 'admin/info'); return $this->redirectToRoute('logon', ['system' => $system]); } diff --git a/src/Controller/Web/Users/Collection.php b/src/Controller/Web/Users/Collection.php index d9ade21a..f07e7d63 100644 --- a/src/Controller/Web/Users/Collection.php +++ b/src/Controller/Web/Users/Collection.php @@ -41,11 +41,8 @@ public function users( Form $form ) { if (!((int)$this->parameters['access'] & UserEntity::MASTER)) { - if ((int)$this->parameters['access'] === 0) { - $this->session->set('route', 'admin/users'); - return $this->redirectToRoute('logon', ['system' => $system]); - } - throw $this->createAccessDeniedException('You do not have access to this page'); + $this->session->set('route', 'admin/info'); + return $this->redirectToRoute('logon', ['system' => $system]); } $this->session->set('route', ''); $options = [ diff --git a/src/Controller/Web/Users/User.php b/src/Controller/Web/Users/User.php index e5415de7..0e0b6b24 100644 --- a/src/Controller/Web/Users/User.php +++ b/src/Controller/Web/Users/User.php @@ -43,12 +43,9 @@ public function user( Request $request, UserViewForm $userViewForm ) { - if (!((int)$this->parameters['access'])) { - if ((int)$this->parameters['access'] === 0) { - $this->session->set('route', 'user?id=' . $id); - return $this->redirectToRoute('logon', ['system' => $system]); - } - throw $this->createAccessDeniedException('You do not have access to this page'); + if (!((int)$this->parameters['access'] & UserEntity::MASTER)) { + $this->session->set('route', 'admin/info'); + return $this->redirectToRoute('logon', ['system' => $system]); } $this->session->set('route', ''); $operation = $id; @@ -109,7 +106,7 @@ public function user( return new Response("", Response::HTTP_OK, [ 'content-type' => 'text/html' ]); } $this->session->set('reloadOpener', 1); - return $this->redirectToRoute('admin/user', ['system' => $system, 'id' => $id]); + return $this->redirectToRoute('user', ['system' => $system, 'id' => $id]); } $parameters = [ diff --git a/src/Controller/Web/Users/UserLogsessions.php b/src/Controller/Web/Users/UserLogsessions.php index 86883521..4e5867f4 100644 --- a/src/Controller/Web/Users/UserLogsessions.php +++ b/src/Controller/Web/Users/UserLogsessions.php @@ -47,7 +47,7 @@ public function logSessions( return $this->redirectToRoute('logon', ['system' => $system]); } if (!$user = $this->getValidUser($id)) { - return $this->redirectToRoute('admin/users', ['system' => $system]); + return $this->redirectToRoute('users', ['system' => $system]); } $isAdmin = $this->parameters['isAdmin']; diff --git a/src/Controller/Web/Users/YourProfile.php b/src/Controller/Web/Users/YourProfile.php index 29fe9ccf..c240f08e 100644 --- a/src/Controller/Web/Users/YourProfile.php +++ b/src/Controller/Web/Users/YourProfile.php @@ -41,7 +41,7 @@ public function profile( UserProfileForm $userProfileForm ) { if ((int)$this->parameters['access'] === 0) { - $this->session->set('route', 'admin/profile'); + $this->session->set('route', 'profile'); return $this->redirectToRoute('logon', ['system' => $system]); } diff --git a/src/Repository/ModeRepository.php b/src/Repository/ModeRepository.php index 76772384..56f8f842 100755 --- a/src/Repository/ModeRepository.php +++ b/src/Repository/ModeRepository.php @@ -130,6 +130,14 @@ class ModeRepository 'title' => 'Logon', 'url'=> false ], + 'logoff' => [ + 'access' => User::USER | User::CLE | User::AWARDS | User::ADMIN | User::MASTER, + 'admin' => true, + 'guest' => false, + 'menu' => 'Logoff', + 'title' => 'Log Off', + 'url'=> false + ], 'help' => [ 'access' => User::ALL, 'admin' => true, @@ -149,7 +157,7 @@ class ModeRepository 'url'=> false ], 'admin/info' => [ - 'access' => User::ADMIN | User::MASTER, + 'access' => User::MASTER, 'admin' => true, 'guest' => false, 'menu' => 'Info', @@ -176,7 +184,7 @@ class ModeRepository 'access' => User::MASTER, 'admin' => true, 'guest' => false, - 'menu' => 'Donations', + 'menu' => 'Gift', 'title' => 'Gifts received', 'url'=> false ], @@ -188,20 +196,22 @@ class ModeRepository 'title' => 'Admin Help', 'url'=> false ], - 'profile' => [ - 'access' => User::USER | User::CLE | User::AWARDS | User::ADMIN | User::MASTER, +/* + 'clePlanner' => [ + 'access' => User::CLE | User::MASTER, 'admin' => true, 'guest' => false, - 'menu' => 'Your Profile', - 'title' => 'Edit your profile', + 'menu' => 'CLE Planner', + 'title' => 'View loggings for various ranges', 'url'=> false ], - 'logoff' => [ +*/ + 'profile' => [ 'access' => User::USER | User::CLE | User::AWARDS | User::ADMIN | User::MASTER, 'admin' => true, 'guest' => false, - 'menu' => 'Logoff', - 'title' => 'Log Off', + 'menu' => 'Your Profile', + 'title' => 'Edit your profile', 'url'=> false ], ]