[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX][UX] tiki-user_watches.php : Fix UI behavior by adding feedback messages

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68a496c035836_2cd6ca452616@gitlab-sidekiq-low-urgency-cpu-bound-v2-7d84497f66-z44bw.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
7d1d00c4 by Alain Cisirika at 2025-08-19T15:14:34+00:00
[FIX][UX]  tiki-user_watches.php : Fix UI behavior by adding feedback messages
---
* [FIX] Correct ui behavior and add feedback messages to tiki-user_watches.php

See merge request tikiwiki/tiki!8067

- - - - -


2 changed files:

- tiki-user_notifications.php
- tiki-user_watches.php


Changes:

=====================================
tiki-user_notifications.php
=====================================
@@ -29,8 +29,24 @@ $auto_query_args = ['userId', 'view_user'];
 
 $access->check_user($user);
 $access->check_feature('feature_user_watches');
-
 if ($access->checkCsrf()) {
+    $watchFields = [
+        'user_calendar_watch_editor',
+        'user_article_watch_editor',
+        'user_wiki_watch_editor',
+        'user_blog_watch_editor',
+        'user_tracker_watch_editor',
+        'user_comment_watch_editor',
+        'user_category_watch_editor',
+        'user_plugin_approval_watch_editor',
+    ];
+
+    $atLeastOneSet = false;
+    foreach ($watchFields as $field) {
+        if (! empty($_REQUEST[$field])) {
+            $atLeastOneSet = true;
+        }
+    }
     if (isset($_REQUEST['user_calendar_watch_editor']) && $_REQUEST['user_calendar_watch_editor'] == true) {
         $result[] = $tikilib->set_user_preference($user, 'user_calendar_watch_editor', 'y');
     } else {
@@ -75,11 +91,14 @@ if ($access->checkCsrf()) {
         $result[] = $tikilib->set_user_preference($user, 'user_plugin_approval_watch_editor', 'n');
     }
     if (! in_array(false, $result)) {
-        Feedback::success(tr('Notification preferences set'));
+        if (! $atLeastOneSet) {
+            Feedback::warning(tr('Notification preferences updated. No type of notification to watch activated.'));
+        } else {
+            Feedback::success(tr('Notification preferences set successfully'));
+        }
     } else {
         Feedback::error(tr('Errors were encountered when setting notification preferences'));
     }
 }
 
-header('Location: tiki-user_watches.php');
-die;
+$access->redirect('tiki-user_watches.php');


=====================================
tiki-user_watches.php
=====================================
@@ -86,7 +86,8 @@ if (isset($_REQUEST['id'])) {
 if (isset($_REQUEST["add"]) && $access->checkCsrf()) {
     if (isset($_REQUEST['event'])) {
         if (! isset($notification_types[$_REQUEST['event']])) {
-            Feedback::errorPage(tr('Unknown watch type'));
+            Feedback::error(tr('Please select a type to watch'));
+            $access->redirect('tiki-user_watches.php');
         }
         $watch_object = '*';
         $watch_type = $notification_types[$_REQUEST['event']]['type'];
@@ -143,15 +144,19 @@ if (isset($_REQUEST["add"]) && $access->checkCsrf()) {
     }
 }
 // no confirmation needed as it is easy to add back a watch
-if (isset($_REQUEST["delete"]) && isset($_REQUEST['checked']) && $access->checkCsrf()) {
-    $checked = is_array($_REQUEST['checked']) ? $_REQUEST['checked'] : [$_REQUEST['checked']];
-    /* CSRL doesn't work if param as passed not in the uri */
-    foreach ($checked as $item) {
-        $result = $tikilib->remove_user_watch_by_id($item);
-        if ($result && $result->numRows()) {
-            Feedback::success(tr('User watch deleted'));
-        } else {
-            Feedback::error(tr('User watch not deleted'));
+if (isset($_REQUEST["delete"]) && $access->checkCsrf()) {
+    if (empty($_REQUEST["checked"])) {
+        Feedback::error(tr("Please, select at least one item to delete"));
+    } else {
+        $checked = is_array($_REQUEST['checked']) ? $_REQUEST['checked'] : [$_REQUEST['checked']];
+        /* CSRL doesn't work if param as passed not in the uri */
+        foreach ($checked as $item) {
+            $result = $tikilib->remove_user_watch_by_id($item);
+            if ($result && $result->numRows()) {
+                Feedback::success(tr('User watch deleted'));
+            } else {
+                Feedback::error(tr('User watch not deleted'));
+            }
         }
     }
 }



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/7d1d00c43e353c657f5833c603f2762aa4a8f0e7

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/7d1d00c43e353c657f5833c603f2762aa4a8f0e7
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.