From dd8d9d7c70acc27bff59877f5782c2a455f6c3f4 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Tue, 28 Jan 2020 22:41:38 +0100 Subject: [PATCH 1/3] Fix ignore notification --- src/Module/BaseNotifications.php | 24 ------------------- src/Module/Notifications/Notification.php | 20 ++++++++++++++++ static/routes.config.php | 7 +++--- view/templates/notifications/intros.tpl | 2 +- view/templates/notifications/suggestions.tpl | 2 +- .../frio/templates/notifications/intros.tpl | 4 ++-- 6 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/Module/BaseNotifications.php b/src/Module/BaseNotifications.php index 9a67bb566..4deb2a24c 100644 --- a/src/Module/BaseNotifications.php +++ b/src/Module/BaseNotifications.php @@ -75,30 +75,6 @@ abstract class BaseNotifications extends BaseModule self::$showAll = ($_REQUEST['show'] ?? '') === 'all'; } - public static function post(array $parameters = []) - { - $request_id = DI::args()->get(1); - - if ($request_id === 'all') { - return; - } - - if ($request_id) { - $intro = DI::intro()->selectFirst(['id' => $request_id, 'uid' => local_user()]); - - switch ($_POST['submit']) { - case DI::l10n()->t('Discard'): - $intro->discard(); - break; - case DI::l10n()->t('Ignore'): - $intro->ignore(); - break; - } - - DI::baseUrl()->redirect('notifications/intros'); - } - } - public static function rawContent(array $parameters = []) { // If the last argument of the query is NOT json, return diff --git a/src/Module/Notifications/Notification.php b/src/Module/Notifications/Notification.php index 9b252562c..20530e81a 100644 --- a/src/Module/Notifications/Notification.php +++ b/src/Module/Notifications/Notification.php @@ -19,6 +19,26 @@ class Notification extends BaseModule } } + public static function post(array $parameters = []) + { + $request_id = $parameters['id'] ?? false; + + if (DI::args()->get(1) == 'action' && $request_id) { + $intro = DI::intro()->selectFirst(['id' => $request_id, 'uid' => local_user()]); + + switch ($_POST['submit']) { + case DI::l10n()->t('Discard'): + $intro->discard(); + break; + case DI::l10n()->t('Ignore'): + $intro->ignore(); + break; + } + + DI::baseUrl()->redirect('notifications/intros'); + } + } + public static function rawContent(array $parameters = []) { // @TODO: Replace with parameter from router diff --git a/static/routes.config.php b/static/routes.config.php index c081dba66..2dd6da1bf 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -184,9 +184,10 @@ return [ ], '/notification' => [ - '[/]' => [Module\Notifications\Notification::class, [R::GET]], - '/view/{id:\d+}' => [Module\Notifications\Notification::class, [R::GET]], - '/mark/all' => [Module\Notifications\Notification::class, [R::GET]], + '[/]' => [Module\Notifications\Notification::class, [R::GET]], + '/view/{id:\d+}' => [Module\Notifications\Notification::class, [R::GET]], + '/mark/all' => [Module\Notifications\Notification::class, [R::GET]], + '/action/{id:\d+}' => [Module\Notifications\Notification::class, [ R::POST]], ], '/objects/{guid}' => [Module\Objects::class, [R::GET]], diff --git a/view/templates/notifications/intros.tpl b/view/templates/notifications/intros.tpl index 808f155b9..4ad96c727 100644 --- a/view/templates/notifications/intros.tpl +++ b/view/templates/notifications/intros.tpl @@ -12,7 +12,7 @@
{{$lbl_knowyou}} {{$knowyou}}
{{$note}}
-
+ {{if $discard}}{{/if}}
diff --git a/view/templates/notifications/suggestions.tpl b/view/templates/notifications/suggestions.tpl index d7bb7b601..ac5c2e9c2 100644 --- a/view/templates/notifications/suggestions.tpl +++ b/view/templates/notifications/suggestions.tpl @@ -8,7 +8,7 @@ {{$fullname}}
{{$note}}
-
+
diff --git a/view/theme/frio/templates/notifications/intros.tpl b/view/theme/frio/templates/notifications/intros.tpl index 4bab6fa96..879920af3 100644 --- a/view/theme/frio/templates/notifications/intros.tpl +++ b/view/theme/frio/templates/notifications/intros.tpl @@ -13,7 +13,7 @@