Ejemplo n.º 1
0
function settings()
{
    global $tabs_graphs, $settings_graphs, $current_user, $graph_views, $current_user;
    /* you cannot have per-user graph settings if cacti's user management is not turned on */
    if (read_config_option('auth_method') == 0) {
        raise_message(6);
        display_output_messages();
        return;
    }
    if ($_REQUEST['action'] == 'edit') {
        if (isset($_SERVER['HTTP_REFERER'])) {
            $timespan_sel_pos = strpos($_SERVER['HTTP_REFERER'], '&predefined_timespan');
            if ($timespan_sel_pos) {
                $_SERVER['HTTP_REFERER'] = substr($_SERVER['HTTP_REFERER'], 0, $timespan_sel_pos);
            }
        }
        $_SESSION['profile_referer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'graph_view.php';
    }
    print "<form method='post' action='auth_profile.php'>\n";
    html_start_box('<strong>User Settings</strong>', '100%', '', '3', 'center', '');
    $current_user = db_fetch_row_prepared('SELECT * FROM user_auth WHERE id = ?', array($_SESSION['sess_user_id']));
    if (!sizeof($current_user)) {
        return;
    }
    /* file: user_admin.php, action: user_edit (host) */
    $fields_user = array('username' => array('method' => 'value', 'friendly_name' => 'User Name', 'description' => 'The login name for this user.', 'value' => '|arg1:username|', 'max_length' => '40', 'size' => '40'), 'full_name' => array('method' => 'textbox', 'friendly_name' => 'Full Name', 'description' => 'A more descriptive name for this user, that can include spaces or special characters.', 'value' => '|arg1:full_name|', 'max_length' => '120', 'size' => '60'), 'email_address' => array('method' => 'textbox', 'friendly_name' => 'E-Mail Address', 'description' => 'An E-Mail Address you be reached at.', 'value' => '|arg1:email_address|', 'max_length' => '60', 'size' => '60'));
    draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($fields_user, isset($current_user) ? $current_user : array())));
    html_end_box();
    if (is_view_allowed('graph_settings') == true) {
        if (read_config_option('auth_method') != 0) {
            $settings_graphs['tree']['default_tree_id']['sql'] = get_graph_tree_array(true);
        }
        html_start_box('<strong>Graph Settings</strong>', '100%', '', '3', 'center', '');
        while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
            $collapsible = true;
            print "<tr class='spacer tableHeader" . ($collapsible ? ' collapsible' : '') . "' id='row_{$tab_short_name}'><td colspan='2' style='cursor:pointer;' class='tableSubHeaderColumn'>" . $tabs_graphs[$tab_short_name] . ($collapsible ? "<div style='float:right;padding-right:4px;'><i class='fa fa-angle-double-up'></i></div>" : "") . "</td></tr>\n";
            $form_array = array();
            while (list($field_name, $field_array) = each($tab_fields)) {
                $form_array += array($field_name => $tab_fields[$field_name]);
                if (isset($field_array['items']) && is_array($field_array['items'])) {
                    while (list($sub_field_name, $sub_field_array) = each($field_array['items'])) {
                        if (graph_config_value_exists($sub_field_name, $_SESSION['sess_user_id'])) {
                            $form_array[$field_name]['items'][$sub_field_name]['form_id'] = 1;
                        }
                        $form_array[$field_name]['items'][$sub_field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($sub_field_name, $_SESSION['sess_user_id']));
                    }
                } else {
                    if (graph_config_value_exists($field_name, $_SESSION['sess_user_id'])) {
                        $form_array[$field_name]['form_id'] = 1;
                    }
                    $form_array[$field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($field_name, $_SESSION['sess_user_id']));
                }
            }
            draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
        }
        html_end_box();
    }
    ?>
	<script type="text/javascript">
	<!--
	var themeFonts=<?php 
    print read_config_option('font_method');
    ?>
;

	function graphSettings() {
		if (themeFonts == 1) {
				$('#row_fonts').hide();
				$('#row_custom_fonts').hide();
				$('#row_title_size').hide();
				$('#row_title_font').hide();
				$('#row_legend_size').hide();
				$('#row_legend_font').hide();
				$('#row_axis_size').hide();
				$('#row_axis_font').hide();
				$('#row_unit_size').hide();
				$('#row_unit_font').hide();
		}else{
			var custom_fonts = $('#custom_fonts').is(':checked');

			switch(custom_fonts) {
			case true:
				$('#row_fonts').show();
				$('#row_title_size').show();
				$('#row_title_font').show();
				$('#row_legend_size').show();
				$('#row_legend_font').show();
				$('#row_axis_size').show();
				$('#row_axis_font').show();
				$('#row_unit_size').show();
				$('#row_unit_font').show();
				break;
			case false:
				$('#row_fonts').show();
				$('#row_title_size').hide();
				$('#row_title_font').hide();
				$('#row_legend_size').hide();
				$('#row_legend_font').hide();
				$('#row_axis_size').hide();
				$('#row_axis_font').hide();
				$('#row_unit_size').hide();
				$('#row_unit_font').hide();
				break;
			}
		}

		if ($('#timespan_sel').is(':checked')) {
			$('#row_default_rra_id').hide();
			$('#row_default_timespan').show();
			$('#row_default_timeshift').show();
			$('#row_allow_graph_dates_in_future').show();
			$('#row_first_weekdayid').show();
			$('#row_day_shift_start').show();
			$('#row_day_shift_end').show();
		} else {
			$('#row_default_rra_id').show();
			$('#row_default_timespan').hide();
			$('#row_default_timeshift').hide();
			$('#row_allow_graph_dates_in_future').hide();
			$('#row_first_weekdayid').hide();
			$('#row_day_shift_start').hide();
			$('#row_day_shift_end').hide();
		}
	}

	$(function() {
		graphSettings();

		$('#navigation').show();
		$('#navigation_right').show();

		$('input[value="Save"]').unbind().click(function(event) {
			event.preventDefault();
			href='<?php 
    print $_SERVER['HTTP_REFERER'];
    ?>
';
			href=href+(href.indexOf('?') > 0 ? '&':'?')+'header=false';
			$.post('auth_profile.php?header=false', $('input, select, textarea').serialize()).done(function(data) {
				$.get('auth_profile.php?action=noreturn&header=false', function(data) {
					$('#main').html(data);
					applySkin();
				});
			});
		});

		$('input[value="Return"]').unbind().click(function(event) {
			console.log('The refer is:<?php 
    print $_SESSION['profile_referer'];
    ?>
');
			document.location = '<?php 
    print $_SESSION['profile_referer'];
    ?>
';
		});

		$('#timespan_sel').change(function() {
			graphSettings();
		});
	});

	-->
	</script>
	<?php 
    form_hidden_box('save_component_graph_config', '1', '');
    form_save_buttons(array(array('id' => 'return', 'value' => 'Return'), array('id' => 'save', 'value' => 'Save')));
}
Ejemplo n.º 2
0
function graph_settings_edit() {
	global $settings_graphs, $tabs_graphs, $colors, $graph_views, $graph_tree_views;

	?>
	<table width='98%' align='center' cellpadding="5">
		<tr>
			<td>
				<span style='font-size: 12px; font-weight: bold;'>Graph settings control how graphs are displayed for this user.</span>
			</td>
		</tr>
	</table>
	<?php

	html_start_box("<strong>Graph Settings</strong>", "98%", $colors["header"], "3", "center", "");

	while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
		?>
		<tr bgcolor='<?php print $colors["header_panel"];?>'>
			<td colspan='2' class='textSubHeaderDark' style='padding: 3px;'>
				<?php print $tabs_graphs[$tab_short_name];?>
			</td>
		</tr>
		<?php

		$form_array = array();

		while (list($field_name, $field_array) = each($tab_fields)) {
			$form_array += array($field_name => $tab_fields[$field_name]);

			if ((isset($field_array["items"])) && (is_array($field_array["items"]))) {
				while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) {
					if (graph_config_value_exists($sub_field_name, $_GET["id"])) {
						$form_array[$field_name]["items"][$sub_field_name]["form_id"] = 1;
					}

					$form_array[$field_name]["items"][$sub_field_name]["value"] =  db_fetch_cell("select value from settings_graphs where name='$sub_field_name' and user_id=" . $_GET["id"]);
				}
			}else{
				if (graph_config_value_exists($field_name, $_GET["id"])) {
					$form_array[$field_name]["form_id"] = 1;
				}

				$form_array[$field_name]["value"] = db_fetch_cell("select value from settings_graphs where name='$field_name' and user_id=" . $_GET["id"]);
			}
		}

		draw_edit_form(
			array(
				"config" => array(
					"no_form_tag" => true
					),
				"fields" => $form_array
				)
			);
	}

	html_end_box();

	form_hidden_box("save_component_graph_settings","1","");
}
Ejemplo n.º 3
0
function graph_settings_edit() {
	global $settings_graphs, $tabs_graphs, $colors;

	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	/* ==================================================== */

	html_start_box("<strong>" . __("Graph Settings") . "</strong>", "100", $colors["header"], 0, "center", "");

	while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
		$header_items = array($tabs_graphs[$tab_short_name], "&nbsp;");
		print "<tr><td>";
		html_header($header_items, 1, true, $tab_short_name);

		$form_array = array();

		while (list($field_name, $field_array) = each($tab_fields)) {
			$form_array += array($field_name => $tab_fields[$field_name]);

			if ((isset($field_array["items"])) && (is_array($field_array["items"]))) {
				while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) {
					if (graph_config_value_exists($sub_field_name, get_request_var("id"))) {
						$form_array[$field_name]["items"][$sub_field_name]["form_id"] = 1;
					}

					$form_array[$field_name]["items"][$sub_field_name]["value"] =  db_fetch_cell("SELECT value FROM settings_graphs WHERE name = '" . $sub_field_name . "' AND user_id = " . get_request_var("id"));
				}
			}else{
				if (graph_config_value_exists($field_name, get_request_var("id"))) {
					$form_array[$field_name]["form_id"] = 1;
				}

				$form_array[$field_name]["value"] = db_fetch_cell("select value from settings_graphs where name='$field_name' and user_id=" . $_GET["id"]);
			}
		}

		draw_edit_form(
			array(
				"config" => array(
					"no_form_tag" => true
					),
				"fields" => $form_array
				)
			);
		print "</table></td></tr>";		/* end of html_header */
	}

	html_end_box();

	# the id tag is required for our js code!
	form_hidden_box("hidden_rrdtool_version", read_config_option("rrdtool_version"), "");

	include_once(CACTI_BASE_PATH . "/access/js/colorpicker.js");
	include_once(CACTI_BASE_PATH . "/access/js/graph_template_options.js");

	?>
	<script type="text/javascript">
	<!--
	$(document).ready(function(){

		Show_if_Checked('#custom_colortags', ".colortags");
		Show_if_Checked('#custom_fonts', ".custom_fonts");

		$('#custom_colortags').click( function() {
			Show_if_Checked('#custom_colortags', ".colortags");
		});
		$('#custom_fonts').click( function() {
			Show_if_Checked('#custom_fonts', ".custom_fonts");
		});

		function Show_if_Checked(findstring, match) {
			if ($(findstring).is(':checked')) {
				$(match).each(function() { $(this).show(); });
			} else {
				$(match).each(function() { $(this).hide(); });
			}
		}

	});

	//-->
	</script>
	<?php

	form_hidden_box("id", get_request_var_request("id"), "");
	form_hidden_box("save_component_graph_settings","1","");
}
Ejemplo n.º 4
0
function settings() {
	global $colors, $tabs_graphs, $settings_graphs, $current_user, $graph_views, $current_user, $graph_tree_views;

	/* you cannot have per-user graph settings if cacti's user management is not turned on */
	if (read_config_option("auth_method") == 0) {
		raise_message(6);
		display_output_messages();
		return;
	}

	/* Find out whether this user has right here */
	if($current_user["graph_settings"] == "") {
		print "<strong><font size='+1' color='#FF0000'>YOU DO NOT HAVE RIGHTS TO CHANGE GRAPH SETTINGS</font></strong>";
		include_once("./include/bottom_footer.php");
		exit;
	}

	if (read_config_option("auth_method") != 0) {
		if ($current_user["policy_graphs"] == "1") {
			$sql_where = "where user_auth_tree.user_id is null";
		}elseif ($current_user["policy_graphs"] == "2") {
			$sql_where = "where user_auth_tree.user_id is not null";
		}

		$settings_graphs["tree"]["default_tree_id"]["sql"] = get_graph_tree_array(true);
	}

	print "<form method='post' action='graph_settings.php'>\n";

	html_graph_start_box(1, true);

	print "<tr bgcolor='#" . $colors["header"] . "'><td colspan='3'><table cellspacing='0' cellpadding='3' width='100%'><tr><td class='textHeaderDark'><strong>Graph Settings</strong></td></tr></table></td></tr>";

	while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
		?>
		<tr bgcolor='<?php print $colors["header_panel"];?>'>
			<td colspan='2' class='textSubHeaderDark' style='padding: 3px;'>
				<?php print $tabs_graphs[$tab_short_name];?>
			</td>
		</tr>
		<?php

		$form_array = array();

		while (list($field_name, $field_array) = each($tab_fields)) {
			$form_array += array($field_name => $tab_fields[$field_name]);

			if ((isset($field_array["items"])) && (is_array($field_array["items"]))) {
				while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) {
					if (graph_config_value_exists($sub_field_name, $_SESSION["sess_user_id"])) {
						$form_array[$field_name]["items"][$sub_field_name]["form_id"] = 1;
					}

					$form_array[$field_name]["items"][$sub_field_name]["value"] =  db_fetch_cell("select value from settings_graphs where name='$sub_field_name' and user_id=" . $_SESSION["sess_user_id"]);
				}
			}else{
				if (graph_config_value_exists($field_name, $_SESSION["sess_user_id"])) {
					$form_array[$field_name]["form_id"] = 1;
				}

				$form_array[$field_name]["value"] = db_fetch_cell("select value from settings_graphs where name='$field_name' and user_id=" . $_SESSION["sess_user_id"]);
			}
		}

		draw_edit_form(
			array(
				"config" => array(
					"no_form_tag" => true
					),
				"fields" => $form_array
				)
			);
	}

	html_graph_end_box();

	print "<br>";

	if (isset($_SERVER["HTTP_REFERER"])) {
		$timespan_sel_pos = strpos($_SERVER["HTTP_REFERER"],"&predefined_timespan");
		if ($timespan_sel_pos) {
		   $_SERVER["HTTP_REFERER"] = substr($_SERVER["HTTP_REFERER"],0,$timespan_sel_pos);
		}
	}

	form_hidden_box("referer",(isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : ""),"");
	form_hidden_box("save_component_graph_config","1","");
	form_save_button("graph_settings.php", "save");
}
Ejemplo n.º 5
0
function settings()
{
    global $tabs_graphs, $settings_graphs, $current_user, $graph_views, $current_user, $graph_tree_views;
    /* you cannot have per-user graph settings if cacti's user management is not turned on */
    if (read_config_option("auth_method") == 0) {
        raise_message(6);
        display_output_messages();
        return;
    }
    /* Find out whether this user has right here */
    if ($current_user["graph_settings"] == "") {
        print "<strong><font size='+1' color='#FF0000'>YOU DO NOT HAVE RIGHTS TO CHANGE GRAPH SETTINGS</font></strong>";
        include_once "./include/bottom_footer.php";
        exit;
    }
    if (read_config_option("auth_method") != 0) {
        if ($current_user["policy_graphs"] == "1") {
            $sql_where = "where user_auth_tree.user_id is null";
        } elseif ($current_user["policy_graphs"] == "2") {
            $sql_where = "where user_auth_tree.user_id is not null";
        }
        $settings_graphs["tree"]["default_tree_id"]["sql"] = get_graph_tree_array(true);
    }
    print "<form method='post' action='graph_settings.php'>\n";
    html_start_box("<strong>Graph Settings</strong>", "100%", "", "3", "center", "");
    while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
        ?>
		<tr>
			<td colspan='2' class='textSubHeaderDark' style='padding: 3px;'>
				<?php 
        print $tabs_graphs[$tab_short_name];
        ?>
			</td>
		</tr>
		<?php 
        $form_array = array();
        while (list($field_name, $field_array) = each($tab_fields)) {
            $form_array += array($field_name => $tab_fields[$field_name]);
            if (isset($field_array["items"]) && is_array($field_array["items"])) {
                while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) {
                    if (graph_config_value_exists($sub_field_name, $_SESSION["sess_user_id"])) {
                        $form_array[$field_name]["items"][$sub_field_name]["form_id"] = 1;
                    }
                    $form_array[$field_name]["items"][$sub_field_name]["value"] = db_fetch_cell("select value from settings_graphs where name='{$sub_field_name}' and user_id=" . $_SESSION["sess_user_id"]);
                }
            } else {
                if (graph_config_value_exists($field_name, $_SESSION["sess_user_id"])) {
                    $form_array[$field_name]["form_id"] = 1;
                }
                $form_array[$field_name]["value"] = db_fetch_cell("select value from settings_graphs where name='{$field_name}' and user_id=" . $_SESSION["sess_user_id"]);
            }
        }
        draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => $form_array));
    }
    html_end_box();
    ?>
	<script type="text/javascript">
	<!--

	function graphSettings() {
		var custom_fonts = document.getElementById('custom_fonts').checked;

		switch(custom_fonts) {
		case true:
			document.getElementById('row_title_size').style.display  = "";
			document.getElementById('row_title_font').style.display  = "";
			document.getElementById('row_legend_size').style.display = "";
			document.getElementById('row_legend_font').style.display = "";
			document.getElementById('row_axis_size').style.display   = "";
			document.getElementById('row_axis_font').style.display   = "";
			document.getElementById('row_unit_size').style.display   = "";
			document.getElementById('row_unit_font').style.display   = "";

			break;
		case false:
			document.getElementById('row_title_size').style.display  = "none";
			document.getElementById('row_title_font').style.display  = "none";
			document.getElementById('row_legend_size').style.display = "none";
			document.getElementById('row_legend_font').style.display = "none";
			document.getElementById('row_axis_size').style.display   = "none";
			document.getElementById('row_axis_font').style.display   = "none";
			document.getElementById('row_unit_size').style.display   = "none";
			document.getElementById('row_unit_font').style.display   = "none";

			break;
		}
	}

	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}

	addLoadEvent(graphSettings);

	-->
	</script>
	<?php 
    print "<br>";
    if (isset($_SERVER["HTTP_REFERER"])) {
        $timespan_sel_pos = strpos($_SERVER["HTTP_REFERER"], "&predefined_timespan");
        if ($timespan_sel_pos) {
            $_SERVER["HTTP_REFERER"] = substr($_SERVER["HTTP_REFERER"], 0, $timespan_sel_pos);
        }
    }
    $_SESSION["graph_settings_referer"] = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "graph_view.php";
    form_hidden_box("save_component_graph_config", "1", "");
    form_save_button("graph_settings.php", "save");
}
Ejemplo n.º 6
0
function settings() {
	global $colors, $tabs_graphs, $settings_graphs, $current_user, $current_user;

	/* you cannot have per-user graph settings if cacti's user management is not turned on */
	if (read_config_option("auth_method") == 0) {
		raise_message(6);
		display_output_messages();
		return;
	}

	/* Find out whether this user has right here */
	if($current_user["graph_settings"] == "") {
		print "<strong><font size='+1' color='#FF0000'>" . __("YOU DO NOT HAVE RIGHTS TO CHANGE GRAPH SETTINGS") . "</font></strong>";
		include_once(CACTI_BASE_PATH . "/include/bottom_footer.php");
		exit;
	}

	if (read_config_option("auth_method") != 0) {
		if ($current_user["policy_graphs"] == "1") {
			$sql_where = "where user_auth_tree.user_id is null";
		}elseif ($current_user["policy_graphs"] == "2") {
			$sql_where = "where user_auth_tree.user_id is not null";
		}

		$settings_graphs["tree"]["default_tree_id"]["sql"] = get_graph_tree_array(true);
	}

	/* draw the categories tabs on the top of the page */
	print "<form method='post' action='graph_settings.php'>\n";

	# the tabs
	print "<table width='100%' cellspacing='0' cellpadding='0' align='center'><tr><td><div class='tabs'>\n";
	if (sizeof($settings_graphs) > 0) {
		foreach (array_keys($settings_graphs) as $tab_short_name) {
			print "<div><a id='tab_" . clean_up_name($tabs_graphs[$tab_short_name]) . "' " . (($tab_short_name == "General") ? "class='tab tabSelected'" : "class='tab tabDefault'") . " onClick='selectTab(\"" . clean_up_name($tabs_graphs[$tab_short_name]) . "\")' href='#'>$tabs_graphs[$tab_short_name]</a></div>\n";
		}
	}
	print "</div></td></tr></table>\n";

	# the tab contents
	while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
		print "<table cellpadding='0' cellspacing='0' width='100%'><tr><td><div class='tab_settings' id='settings_" . clean_up_name($tabs_graphs[$tab_short_name]) . "'>\n";
		html_start_box("<strong>" . __("Graph Settings") . " (" . $tabs_graphs[$tab_short_name] . ")</strong>", "100", $colors["header"], 0, "center", "", false, "Tab_Settings_" . clean_up_name($tabs_graphs[$tab_short_name]));
		$header_items = array(__("Field"), __("Value"));
		print "<tr><td>";
		html_header($header_items, 2, true, "Header_Settings_" . clean_up_name($tabs_graphs[$tab_short_name]),'left wp100');

		$form_array = array();

		while (list($field_name, $field_array) = each($tab_fields)) {
			$form_array += array($field_name => $tab_fields[$field_name]);

			if ((isset($field_array["items"])) && (is_array($field_array["items"]))) {
				while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) {
					if (graph_config_value_exists($sub_field_name, $_SESSION["sess_user_id"])) {
						$form_array[$field_name]["items"][$sub_field_name]["form_id"] = 1;
					}

					$form_array[$field_name]["items"][$sub_field_name]["value"] =  db_fetch_cell("select value from settings_graphs where name='$sub_field_name' and user_id=" . $_SESSION["sess_user_id"]);
				}
			}else{
				if (graph_config_value_exists($field_name, $_SESSION["sess_user_id"])) {
					$form_array[$field_name]["form_id"] = 1;
				}

				$form_array[$field_name]["value"] = db_fetch_cell("select value from settings_graphs where name='$field_name' and user_id=" . $_SESSION["sess_user_id"]);
			}
		}

		draw_edit_form(
			array(
				"config" => array("no_form_tag" => true),
				"fields" => $form_array
				)
		);

		print "</table></td></tr>";		/* end of html_header */
		html_end_box();
		print "</div></td></tr></table>\n";
	}

	if (isset($_SERVER["HTTP_REFERER"])) {
		$timespan_sel_pos = strpos($_SERVER["HTTP_REFERER"],"&predefined_timespan");
		if ($timespan_sel_pos) {
			$_SERVER["HTTP_REFERER"] = substr($_SERVER["HTTP_REFERER"],0,$timespan_sel_pos);
		}
	}

	form_hidden_box("referer", "graph_view.php","");
	form_hidden_box("save_component_graph_config","1","");

	form_save_button_alt("", "save", "save");

	?>
	<script type="text/javascript">
	<!--

	function selectTab(tab) {
		$('.tab_settings').hide();
		$('.tab').removeClass("tabSelected");
		$('.tab').addClass("tabDefault");
		$('#settings_'+tab).show();
		$('#tab_'+tab).removeClass("tabDefault");
		$('#tab_'+tab).addClass("tabSelected");
	}

	$().ready(function() {
		selectTab('General');
	});

	//-->
	</script>
	<?php

	include(CACTI_BASE_PATH . "/include/bottom_footer.php");
}
Ejemplo n.º 7
0
function settings()
{
    global $tabs_graphs, $settings_graphs, $current_user, $graph_views, $current_user;
    $current_user = db_fetch_row_prepared('SELECT * FROM user_auth WHERE id = ?', array($_SESSION['sess_user_id']));
    /* you cannot have per-user graph settings if cacti's user management is not turned on */
    if (read_config_option('auth_method') == 0) {
        raise_message(6);
        display_output_messages();
        return;
    }
    /* Find out whether this user has right here */
    if (!is_view_allowed('graph_settings')) {
        print "<strong><font class='txtErrorTextBox'>YOU DO NOT HAVE RIGHTS TO CHANGE GRAPH SETTINGS</font></strong>";
        bottom_footer();
        exit;
    }
    if (read_config_option('auth_method') != 0) {
        $settings_graphs['tree']['default_tree_id']['sql'] = get_graph_tree_array(true);
    }
    print "<form method='post' action='graph_settings.php'>\n";
    html_start_box('<strong>Graph Settings</strong>', '100%', '', '3', 'center', '');
    while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
        $collapsible = true;
        print "<tr class='spacer tableHeader" . ($collapsible ? ' collapsible' : '') . "' id='row_{$tab_short_name}'><td colspan='2' style='cursor:pointer;' class='tableSubHeaderColumn'>" . $tabs_graphs[$tab_short_name] . ($collapsible ? "<div style='float:right;padding-right:4px;'><i class='fa fa-angle-double-up'></i></div>" : "") . "</td></tr>\n";
        $form_array = array();
        while (list($field_name, $field_array) = each($tab_fields)) {
            $form_array += array($field_name => $tab_fields[$field_name]);
            if (isset($field_array['items']) && is_array($field_array['items'])) {
                while (list($sub_field_name, $sub_field_array) = each($field_array['items'])) {
                    if (graph_config_value_exists($sub_field_name, $_SESSION['sess_user_id'])) {
                        $form_array[$field_name]['items'][$sub_field_name]['form_id'] = 1;
                    }
                    $form_array[$field_name]['items'][$sub_field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($sub_field_name, $_SESSION['sess_user_id']));
                }
            } else {
                if (graph_config_value_exists($field_name, $_SESSION['sess_user_id'])) {
                    $form_array[$field_name]['form_id'] = 1;
                }
                $form_array[$field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($field_name, $_SESSION['sess_user_id']));
            }
        }
        draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
    }
    html_end_box();
    ?>
	<script type="text/javascript">
	<!--
	var themeFonts=<?php 
    print read_config_option('font_method');
    ?>
;

	function graphSettings() {
		if (themeFonts == 1) {
				$('#row_fonts').hide();
				$('#row_custom_fonts').hide();
				$('#row_title_size').hide();
				$('#row_title_font').hide();
				$('#row_legend_size').hide();
				$('#row_legend_font').hide();
				$('#row_axis_size').hide();
				$('#row_axis_font').hide();
				$('#row_unit_size').hide();
				$('#row_unit_font').hide();
		}else{
			var custom_fonts = $('#custom_fonts').is(':checked');

			switch(custom_fonts) {
			case true:
				$('#row_fonts').show();
				$('#row_title_size').show();
				$('#row_title_font').show();
				$('#row_legend_size').show();
				$('#row_legend_font').show();
				$('#row_axis_size').show();
				$('#row_axis_font').show();
				$('#row_unit_size').show();
				$('#row_unit_font').show();
				break;
			case false:
				$('#row_fonts').show();
				$('#row_title_size').hide();
				$('#row_title_font').hide();
				$('#row_legend_size').hide();
				$('#row_legend_font').hide();
				$('#row_axis_size').hide();
				$('#row_axis_font').hide();
				$('#row_unit_size').hide();
				$('#row_unit_font').hide();
				break;
			}
		}

		if ($('#timespan_sel').is(':checked')) {
			$('#row_default_rra_id').hide();
			$('#row_default_timespan').show();
			$('#row_default_timeshift').show();
			$('#row_allow_graph_dates_in_future').show();
			$('#row_first_weekdayid').show();
			$('#row_day_shift_start').show();
			$('#row_day_shift_end').show();
		} else {
			$('#row_default_rra_id').show();
			$('#row_default_timespan').hide();
			$('#row_default_timeshift').hide();
			$('#row_allow_graph_dates_in_future').hide();
			$('#row_first_weekdayid').hide();
			$('#row_day_shift_start').hide();
			$('#row_day_shift_end').hide();
		}
	}

	$(function() {
		graphSettings();

		$('#navigation').show();
		$('#navigation_right').show();

		$('input[value="Save"]').click(function(event) {
			event.preventDefault();
			href='<?php 
    print $_SERVER['HTTP_REFERER'];
    ?>
';
			href=href+(href.indexOf('?') > 0 ? '&':'?')+'header=false';
			$.post('graph_settings.php?header=false', $('input, select, textarea').serialize()).done(function(data) {
				document.location='<?php 
    print $_SERVER['HTTP_REFERER'];
    ?>
';
			});
		});

		$('#timespan_sel').change(function() {
			graphSettings();
		});
	});

	-->
	</script>
	<?php 
    if (isset($_SERVER['HTTP_REFERER'])) {
        $timespan_sel_pos = strpos($_SERVER['HTTP_REFERER'], '&predefined_timespan');
        if ($timespan_sel_pos) {
            $_SERVER['HTTP_REFERER'] = substr($_SERVER['HTTP_REFERER'], 0, $timespan_sel_pos);
        }
    }
    $_SESSION['graph_settings_referer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'graph_view.php';
    form_hidden_box('save_component_graph_config', '1', '');
    form_save_button('graph_settings.php', 'save');
}
Ejemplo n.º 8
0
function graph_settings_edit()
{
    global $settings_graphs, $tabs_graphs, $graph_views, $graph_tree_views;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    /* ==================================================== */
    ?>
	<table width='100%' align='center' cellpadding="5">
		<tr>
			<td>
				<span style='font-size: 12px; font-weight: bold;'>Graph settings control how graphs are displayed for this user.</span>
			</td>
		</tr>
	</table>
	<?php 
    html_start_box("<strong>Graph Settings</strong>", "100%", "", "3", "center", "");
    while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
        ?>
		<tr>
			<td colspan='2' class='textSubHeaderDark' style='padding: 3px;'>
				<?php 
        print $tabs_graphs[$tab_short_name];
        ?>
			</td>
		</tr>
		<?php 
        $form_array = array();
        while (list($field_name, $field_array) = each($tab_fields)) {
            $form_array += array($field_name => $tab_fields[$field_name]);
            if (isset($field_array["items"]) && is_array($field_array["items"])) {
                while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) {
                    if (graph_config_value_exists($sub_field_name, $_GET["id"])) {
                        $form_array[$field_name]["items"][$sub_field_name]["form_id"] = 1;
                    }
                    $form_array[$field_name]["items"][$sub_field_name]["value"] = db_fetch_cell("SELECT value FROM settings_graphs WHERE name = '" . $sub_field_name . "' AND user_id = " . get_request_var("id"));
                }
            } else {
                if (graph_config_value_exists($field_name, $_GET["id"])) {
                    $form_array[$field_name]["form_id"] = 1;
                }
                $form_array[$field_name]["value"] = db_fetch_cell("select value from settings_graphs where name='{$field_name}' and user_id=" . $_GET["id"]);
            }
        }
        draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => $form_array));
    }
    html_end_box();
    form_hidden_box("save_component_graph_settings", "1", "");
}
Ejemplo n.º 9
0
function graph_settings_edit($header_label)
{
    global $settings_graphs, $tabs_graphs, $graph_views;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    /* ==================================================== */
    print "<form name='chk' action='user_admin.php' method='post'>\n";
    html_start_box("<strong>Graph Settings</strong> {$header_label}", '100%', '', '3', 'center', '');
    while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
        ?>
		<tr id='row_<?php 
        print $tab_short_name;
        ?>
' class='tableHeader'>
			<th colspan='2' style='padding: 3px;'>
				<?php 
        print $tabs_graphs[$tab_short_name];
        ?>
			</th>
		</tr>
		<?php 
        $form_array = array();
        while (list($field_name, $field_array) = each($tab_fields)) {
            $form_array += array($field_name => $tab_fields[$field_name]);
            if (isset($field_array['items']) && is_array($field_array['items'])) {
                while (list($sub_field_name, $sub_field_array) = each($field_array['items'])) {
                    if (graph_config_value_exists($sub_field_name, $_REQUEST['id'])) {
                        $form_array[$field_name]['items'][$sub_field_name]['form_id'] = 1;
                    }
                    $form_array[$field_name]['items'][$sub_field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($sub_field_name, get_request_var_request('id')));
                }
            } else {
                if (graph_config_value_exists($field_name, $_REQUEST['id'])) {
                    $form_array[$field_name]['form_id'] = 1;
                }
                $form_array[$field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? and user_id = ?', array($field_name, $_REQUEST['id']));
            }
        }
        draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
    }
    html_end_box();
    form_hidden_box('action', 'user_edit', '');
    form_hidden_box('id', get_request_var_request('id'), '');
    form_hidden_box('tab', 'settings', '');
    form_hidden_box('save_component_graph_settings', '1', '');
    form_save_button('user_admin.php', 'return');
    ?>
	<script type="text/javascript">
	<!--
	var themeFonts=<?php 
    print read_config_option('font_method');
    ?>
;

	function graphSettings() {
		if (themeFonts == 1) {
				$('#row_fonts').hide();
				$('#row_custom_fonts').hide();
				$('#row_title_size').hide();
				$('#row_title_font').hide();
				$('#row_legend_size').hide();
				$('#row_legend_font').hide();
				$('#row_axis_size').hide();
				$('#row_axis_font').hide();
				$('#row_unit_size').hide();
				$('#row_unit_font').hide();
		}else{
			var custom_fonts = $('#custom_fonts').is(':checked');

			switch(custom_fonts) {
			case true:
				$('#row_fonts').show();
				$('#row_title_size').show();
				$('#row_title_font').show();
				$('#row_legend_size').show();
				$('#row_legend_font').show();
				$('#row_axis_size').show();
				$('#row_axis_font').show();
				$('#row_unit_size').show();
				$('#row_unit_font').show();
				break;
			case false:
				$('#row_fonts').show();
				$('#row_title_size').hide();
				$('#row_title_font').hide();
				$('#row_legend_size').hide();
				$('#row_legend_font').hide();
				$('#row_axis_size').hide();
				$('#row_axis_font').hide();
				$('#row_unit_size').hide();
				$('#row_unit_font').hide();
				break;
			}
		}
	}

	$(function() {
		graphSettings();
	});

	-->
	</script>
	<?php 
}