#11993 Fix configration users notification
This commit is contained in:
parent
f2b99cf38e
commit
4911d84c76
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Extension to manage a list of gateways and the node address where they should
|
||||||
|
* point to.
|
||||||
|
*
|
||||||
|
* @category Users
|
||||||
|
* @package Pandora FMS
|
||||||
|
* @subpackage Community
|
||||||
|
* @version 1.0.0
|
||||||
|
* @license See below
|
||||||
|
*
|
||||||
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2023 Pandora FMS
|
||||||
|
* Please see https://pandorafms.com/community/ for full contribution list
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation for version 2.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
// Includes.
|
||||||
|
require_once $config['homedir'].'/include/functions_notifications.php';
|
||||||
|
|
||||||
|
$change_label = get_parameter('change_label', 0);
|
||||||
|
if ($change_label === '1') {
|
||||||
|
$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();
|
||||||
|
$json = json_encode(
|
||||||
|
[
|
||||||
|
'result' => notifications_set_user_label_status(
|
||||||
|
$source,
|
||||||
|
$user,
|
||||||
|
$label,
|
||||||
|
$value
|
||||||
|
),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
echo $json;
|
||||||
|
return;
|
||||||
|
}
|
|
@ -36,28 +36,6 @@ require_once $config['homedir'].'/include/functions_notifications.php';
|
||||||
$headerTitle = __('User notifications');
|
$headerTitle = __('User notifications');
|
||||||
require $config['homedir'].'/operation/users/user_edit_header.php';
|
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 '<div id="user-notifications-wrapper" class="white_box table_div table_three_columns padding-2">
|
echo '<div id="user-notifications-wrapper" class="white_box table_div table_three_columns padding-2">
|
||||||
<div class="table_thead">
|
<div class="table_thead">
|
||||||
<div class="table_th"></div>
|
<div class="table_th"></div>
|
||||||
|
@ -109,13 +87,15 @@ html_print_input_hidden('id_user', $id);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var check = document.getElementById(event.target.id);
|
var check = document.getElementById(event.target.id);
|
||||||
if (check === null) return;
|
if (check === null) return;
|
||||||
|
console.log(check.checked);
|
||||||
|
console.log(document.getElementById('hidden-id_user').value)
|
||||||
var match = /notifications-user-([0-9]+)-label-(.*)/
|
var match = /notifications-user-([0-9]+)-label-(.*)/
|
||||||
.exec(event.target.id);
|
.exec(event.target.id);
|
||||||
|
console.log(match);
|
||||||
jQuery.post ("ajax.php",
|
jQuery.post ("ajax.php",
|
||||||
{
|
{
|
||||||
"page" : "operation/users/user_edit_notifications",
|
//"page" : "operation/users/user_edit_notifications",
|
||||||
|
"page" : 'include/ajax/notifications.ajax',
|
||||||
"change_label" : 1,
|
"change_label" : 1,
|
||||||
"label" : match[2],
|
"label" : match[2],
|
||||||
"source" : match[1],
|
"source" : match[1],
|
||||||
|
@ -123,6 +103,7 @@ html_print_input_hidden('id_user', $id);
|
||||||
"value": check.checked ? 1 : 0
|
"value": check.checked ? 1 : 0
|
||||||
},
|
},
|
||||||
function (data, status) {
|
function (data, status) {
|
||||||
|
console.log(data, status);
|
||||||
if (!data.result) {
|
if (!data.result) {
|
||||||
console.error("Error changing configuration in database.");
|
console.error("Error changing configuration in database.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -132,6 +113,8 @@ html_print_input_hidden('id_user', $id);
|
||||||
"json"
|
"json"
|
||||||
).done(function(m){})
|
).done(function(m){})
|
||||||
.fail(function(xhr, textStatus, errorThrown){
|
.fail(function(xhr, textStatus, errorThrown){
|
||||||
|
console.log(textStatus)
|
||||||
|
console.log(errorThrown)
|
||||||
console.error(
|
console.error(
|
||||||
"Cannot change configuration in database. Server error.",
|
"Cannot change configuration in database. Server error.",
|
||||||
xhr.responseText
|
xhr.responseText
|
||||||
|
@ -148,4 +131,5 @@ html_print_input_hidden('id_user', $id);
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue