From 4911d84c7660b736145a5b25b5966ea307f6bf13 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 5 Sep 2023 11:52:16 +0200 Subject: [PATCH] #11993 Fix configration users notification --- .../include/ajax/notifications.ajax.php | 57 +++++++++++++++++++ .../users/user_edit_notifications.php | 34 +++-------- 2 files changed, 66 insertions(+), 25 deletions(-) create mode 100644 pandora_console/include/ajax/notifications.ajax.php diff --git a/pandora_console/include/ajax/notifications.ajax.php b/pandora_console/include/ajax/notifications.ajax.php new file mode 100644 index 0000000000..36ea95900d --- /dev/null +++ b/pandora_console/include/ajax/notifications.ajax.php @@ -0,0 +1,57 @@ + notifications_set_user_label_status( + $source, + $user, + $label, + $value + ), + ] + ); + + echo $json; + return; +} diff --git a/pandora_console/operation/users/user_edit_notifications.php b/pandora_console/operation/users/user_edit_notifications.php index 309439dfe7..a6dfdb1821 100644 --- a/pandora_console/operation/users/user_edit_notifications.php +++ b/pandora_console/operation/users/user_edit_notifications.php @@ -36,28 +36,6 @@ require_once $config['homedir'].'/include/functions_notifications.php'; $headerTitle = __('User notifications'); require $config['homedir'].'/operation/users/user_edit_header.php'; -if (get_parameter('change_label', 0)) { - $label = get_parameter('label', ''); - $source = get_parameter('source', 0); - $user = get_parameter('user', ''); - $value = get_parameter('value', 0) ? 1 : 0; - - // Update the label value. - ob_clean(); - echo json_encode( - [ - 'result' => notifications_set_user_label_status( - $source, - $user, - $label, - $value - ), - ] - ); - return; -} - - echo '
@@ -109,13 +87,15 @@ html_print_input_hidden('id_user', $id); event.preventDefault(); var check = document.getElementById(event.target.id); if (check === null) return; - + console.log(check.checked); + console.log(document.getElementById('hidden-id_user').value) var match = /notifications-user-([0-9]+)-label-(.*)/ .exec(event.target.id); - + console.log(match); jQuery.post ("ajax.php", { - "page" : "operation/users/user_edit_notifications", + //"page" : "operation/users/user_edit_notifications", + "page" : 'include/ajax/notifications.ajax', "change_label" : 1, "label" : match[2], "source" : match[1], @@ -123,6 +103,7 @@ html_print_input_hidden('id_user', $id); "value": check.checked ? 1 : 0 }, function (data, status) { + console.log(data, status); if (!data.result) { console.error("Error changing configuration in database."); } else { @@ -132,6 +113,8 @@ html_print_input_hidden('id_user', $id); "json" ).done(function(m){}) .fail(function(xhr, textStatus, errorThrown){ + console.log(textStatus) + console.log(errorThrown) console.error( "Cannot change configuration in database. Server error.", xhr.responseText @@ -148,4 +131,5 @@ html_print_input_hidden('id_user', $id); ); } }()); +