Merge branch 'ent-11993-user-notifications-esta-roto' into 'develop'
Ent 11993 user notifications esta roto See merge request artica/pandorafms!6412
This commit is contained in:
commit
0c6aaa6723
|
@ -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;
|
||||||
|
}
|
|
@ -635,6 +635,12 @@ function notifications_get_user_label_status($source, $user, $label)
|
||||||
array_keys(users_get_groups($user)),
|
array_keys(users_get_groups($user)),
|
||||||
array_keys(notifications_get_group_sources_for_select($source['id']))
|
array_keys(notifications_get_group_sources_for_select($source['id']))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Clean default common groups error for mesagges.
|
||||||
|
if ($common_groups[0] === 0) {
|
||||||
|
unset($common_groups[0]);
|
||||||
|
}
|
||||||
|
|
||||||
// No group found, return no permissions.
|
// No group found, return no permissions.
|
||||||
$value = empty($common_groups) ? false : $source[$label];
|
$value = empty($common_groups) ? false : $source[$label];
|
||||||
return notifications_build_user_enable_return($value, false);
|
return notifications_build_user_enable_return($value, false);
|
||||||
|
@ -760,9 +766,10 @@ function notifications_print_global_source_configuration($source)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the title.
|
// Generate the title.
|
||||||
$html_title = "<div class='global-config-notification-title'>";
|
$html_title = '<h2 style="margin-bottom: auto;">'.$source['description'].'</h2>';
|
||||||
|
$html_title .= "<div class='global-config-notification-title'>";
|
||||||
$html_title .= html_print_switch($switch_values);
|
$html_title .= html_print_switch($switch_values);
|
||||||
$html_title .= '<h2>'.$source['description'].'</h2>';
|
$html_title .= '<h2>'.__('Enable user configuration').'</h2>';
|
||||||
$html_title .= '</div>';
|
$html_title .= '</div>';
|
||||||
|
|
||||||
// Generate the html for title.
|
// Generate the html for title.
|
||||||
|
|
|
@ -36,33 +36,11 @@ 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>
|
||||||
<div class="table_th">'.__('Enable').'</div>
|
<div class="table_th">'.__('Console notifications').'</div>
|
||||||
<div class="table_th">'.__('Also receive an email').'</div>
|
<div class="table_th">'.__('E-mail notifications').'</div>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
$sources = notifications_get_all_sources();
|
$sources = notifications_get_all_sources();
|
||||||
|
@ -109,13 +87,12 @@ 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;
|
||||||
|
|
||||||
var match = /notifications-user-([0-9]+)-label-(.*)/
|
var match = /notifications-user-([0-9]+)-label-(.*)/
|
||||||
.exec(event.target.id);
|
.exec(event.target.id);
|
||||||
|
|
||||||
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],
|
||||||
|
@ -148,4 +125,5 @@ html_print_input_hidden('id_user', $id);
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue