From 9608164cc32b038c62cc9abea96f562b6adaf6b4 Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Mon, 14 Oct 2024 16:57:12 +0000 Subject: [PATCH 1/5] Prevents adding multiple requests for same authorization by a member --- .../src/Services/DefaultAuthorizationManager.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/plugins/Activities/src/Services/DefaultAuthorizationManager.php b/app/plugins/Activities/src/Services/DefaultAuthorizationManager.php index ed01d143..c500766c 100644 --- a/app/plugins/Activities/src/Services/DefaultAuthorizationManager.php +++ b/app/plugins/Activities/src/Services/DefaultAuthorizationManager.php @@ -50,6 +50,20 @@ public function request( return false; } } + //Checking for existing pending requests + $existingRequests = $table + ->find() + ->where([ + "member_id" => $requesterId, + "activity_id" => $activityId, + "status" => Authorization::PENDING_STATUS + ]) + ->count(); + if ($existingRequests > 0) { + return false; + } + + $auth = $table->newEmptyEntity(); $auth->member_id = $requesterId; $auth->activity_id = $activityId; @@ -534,4 +548,4 @@ private function saveAuthorizationApproval( } // endregion -} +} \ No newline at end of file From 17be562cc65b29e30e4ac44b15ebfea9c0b05f1a Mon Sep 17 00:00:00 2001 From: Chris Thompson <=> Date: Wed, 16 Oct 2024 17:14:52 +0000 Subject: [PATCH 2/5] =?UTF-8?q?Authorizations=20Queues=20handles=20=C3=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AuthorizationApprovalsController.php | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/plugins/Activities/src/Controller/AuthorizationApprovalsController.php b/app/plugins/Activities/src/Controller/AuthorizationApprovalsController.php index c9ef8521..75305da9 100644 --- a/app/plugins/Activities/src/Controller/AuthorizationApprovalsController.php +++ b/app/plugins/Activities/src/Controller/AuthorizationApprovalsController.php @@ -26,6 +26,7 @@ class AuthorizationApprovalsController extends AppController public function index() { $search = $this->request->getQuery("search"); + $search = $search ? trim($search) : null; $query = $this->AuthorizationApprovals @@ -58,11 +59,26 @@ public function index() ), ]) ->group("Approvers.id"); + if ($search) { + //detect th and replace with Þ + $nsearch = $search; + if (preg_match("/th/", $search)) { + $nsearch = str_replace("th", "Þ", $search); + } + //detect Þ and replace with th + $usearch = $search; + if (preg_match("/Þ/", $search)) { + $usearch = str_replace("Þ", "th", $search); + } $query = $query->where([ "OR" => [ - "Approvers.sca_name LIKE" => "%" . $search . "%", - "Approvers.email_address LIKE" => "%" . $search . "%", + ["Approvers.sca_name LIKE" => "%" . $search . "%"], + ["Approvers.sca_name LIKE" => "%" . $nsearch . "%"], + ["Approvers.sca_name LIKE" => "%" . $usearch . "%"], + ["Approvers.email_address LIKE" => "%" . $search . "%"], + ["Approvers.email_address LIKE" => "%" . $nsearch . "%"], + ["Approvers.email_address LIKE" => "%" . $usearch . "%"], ], ]); } @@ -281,4 +297,4 @@ public function deny(AuthorizationManagerInterface $maService, $id = null) return $this->redirect($this->referer()); } -} \ No newline at end of file +} From 677586ded37270b56bd3ae3503af69b021974940 Mon Sep 17 00:00:00 2001 From: Chris Thompson <=> Date: Wed, 16 Oct 2024 22:57:55 +0000 Subject: [PATCH 3/5] added Alert that triggers ajax request to extend session if clicked within 5 minutes --- app/config/routes.php | 4 ++- app/src/Controller/SessionsController.php | 25 +++++++++++++ .../layout/TwitterBootstrap/dashboard.php | 15 +++++--- .../layout/TwitterBootstrap/view_record.php | 36 ++++++++++++++++--- app/webroot/js/sessionExtender.js | 15 ++++++++ 5 files changed, 86 insertions(+), 9 deletions(-) create mode 100644 app/src/Controller/SessionsController.php create mode 100644 app/webroot/js/sessionExtender.js diff --git a/app/config/routes.php b/app/config/routes.php index 74f45f5d..2b3d802b 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -82,8 +82,10 @@ * You can remove these routes once you've connected the * routes you want in your application. */ + $builder->fallbacks(); }); + $routes->connect('/keepalive', ['controller' => 'Sessions', 'action' => 'keepalive']); $routes->scope('/images', function ($routes) { $routes->registerMiddleware('glide', new \ADmad\Glide\Middleware\GlideMiddleware([ // Run this middleware only for URLs starting with specified string. Default null. @@ -157,4 +159,4 @@ * }); * ``` */ -}; \ No newline at end of file +}; diff --git a/app/src/Controller/SessionsController.php b/app/src/Controller/SessionsController.php new file mode 100644 index 00000000..ff64cbc8 --- /dev/null +++ b/app/src/Controller/SessionsController.php @@ -0,0 +1,25 @@ +request->getSession(); + // if ($session->check('count')) { + // $session->write(['count' => $session->read('count') + 1]); + // } else { + // $session->write(['count' => 1]); + // } + $response = $this->response; + $response = $response->withStringBody('My Body'); + $response = $response->withType('application/json') + ->withStringBody(json_encode(['response' => 'Session extended'])); + return $response; + } +} diff --git a/app/templates/layout/TwitterBootstrap/dashboard.php b/app/templates/layout/TwitterBootstrap/dashboard.php index aa0eb78d..82a5883f 100644 --- a/app/templates/layout/TwitterBootstrap/dashboard.php +++ b/app/templates/layout/TwitterBootstrap/dashboard.php @@ -22,6 +22,13 @@ ?> fetch("tb_body_attrs") ?>> + Html->script('sessionExtender') + ?> +