0) {
foreach (array_keys($settings_graphs) as $setting) {
if (isset($_POST[$setting])) {
db_execute("replace into settings_graphs (user_id,name,value) values (" . (!empty($user_id) ? $user_id : $_POST["user_id"]) . ",'$setting', '" . $_POST[$setting] . "')");
}
}
}
/* reset local settings cache so the user sees the new settings */
kill_session_var("sess_graph_config_array");
}
/* graph permissions */
if ((isset($_POST["save_component_graph_perms"])) && (!is_error_message())) {
$add_button_clicked = false;
if (isset($_POST["add_graph_y"])) {
db_execute("replace into user_auth_perms (user_id,item_id,type) values (" . $_POST["user_id"] . "," . $_POST["perm_graphs"] . ",1)");
$add_button_clicked = true;
}elseif (isset($_POST["add_tree_y"])) {
db_execute("replace into user_auth_perms (user_id,item_id,type) values (" . $_POST["user_id"] . "," . $_POST["perm_trees"] . ",2)");
$add_button_clicked = true;
}elseif (isset($_POST["add_host_y"])) {
db_execute("replace into user_auth_perms (user_id,item_id,type) values (" . $_POST["user_id"] . "," . $_POST["perm_hosts"] . ",3)");
$add_button_clicked = true;
}elseif (isset($_POST["add_graph_template_y"])) {
db_execute("replace into user_auth_perms (user_id,item_id,type) values (" . $_POST["user_id"] . "," . $_POST["perm_graph_templates"] . ",4)");
$add_button_clicked = true;
}
if ($add_button_clicked == true) {
header ("Location: user_admin.php?action=graph_perms_edit&id=" . $_POST["user_id"]);
exit;
}
db_execute("update user_auth set
policy_graphs='" . $_POST["policy_graphs"] . "',
policy_trees='" . $_POST["policy_trees"] . "',
policy_hosts='" . $_POST["policy_hosts"] . "',
policy_graph_templates='" . $_POST["policy_graph_templates"] . "'
where id=" . $_POST["user_id"]);
}
/* redirect to the appropriate page */
if (is_error_message()) {
header ("Location: user_admin.php?action=user_edit&id=" . (empty($user_id) ? $_POST["id"] : $user_id));
}else{
header ("Location: user_admin.php");
}
}
/* --------------------------
Graph Permissions
-------------------------- */
function perm_remove() {
if ($_GET["type"] == "graph") {
db_execute("delete from user_auth_perms where type=1 and user_id=" . $_GET["user_id"] . " and item_id=" . $_GET["id"]);
}elseif ($_GET["type"] == "tree") {
db_execute("delete from user_auth_perms where type=2 and user_id=" . $_GET["user_id"] . " and item_id=" . $_GET["id"]);
}elseif ($_GET["type"] == "host") {
db_execute("delete from user_auth_perms where type=3 and user_id=" . $_GET["user_id"] . " and item_id=" . $_GET["id"]);
}elseif ($_GET["type"] == "graph_template") {
db_execute("delete from user_auth_perms where type=4 and user_id=" . $_GET["user_id"] . " and item_id=" . $_GET["id"]);
}
header ("Location: user_admin.php?action=graph_perms_edit&id=" . $_GET["user_id"]);
}
function graph_perms_edit() {
global $colors;
$graph_policy_array = array(
1 => "Allow",
2 => "Deny");
if (!empty($_GET["id"])) {
$policy = db_fetch_row("select policy_graphs,policy_trees,policy_hosts,policy_graph_templates from user_auth where id=" . $_GET["id"]);
$header_label = "[edit: " . db_fetch_cell("select username from user_auth where id=" . $_GET["id"]) . "]";
}
if (read_config_option("full_view_user_admin") == "") {
draw_user_form_select();
}
start_box("", "98%", "aaaaaa", "3", "center", "");
?>
Graph policies will be evaluated in the order shown until a match is found.
Graph Permissions", "98%", $colors["header"], "3", "center", "");
$graphs = db_fetch_assoc("select
graph_templates_graph.local_graph_id,
graph_templates_graph.title_cache
from graph_templates_graph
left join user_auth_perms on (graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1)
where graph_templates_graph.local_graph_id > 0
and user_auth_perms.user_id=" . (empty($_GET["id"]) ? "0" : $_GET["id"]) . "
order by graph_templates_graph.title_cache");
?>