Beispiel #1
0
function user_edit() {
	global $colors, $fields_user_user_edit_host;

	if (!empty($_GET["id"])) {
		$user = db_fetch_row("select * from user_auth where id=" . $_GET["id"]);
		$header_label = "[edit: " . $user["username"] . "]";
	}else{
		$header_label = "[new]";
	}

	html_start_box("<strong>User Management</strong> $header_label", "98%", $colors["header"], "3", "center", "");

	draw_edit_form(array(
		"config" => array("form_name" => "chk"),
		"fields" => inject_form_variables($fields_user_user_edit_host, (isset($user) ? $user : array()))
		));

	html_end_box();

	if (!empty($_GET["id"])) {
		/* draw user admin nav tabs */
		?>
		<table class='tabs' width='98%' cellspacing='0' cellpadding='3' align='center'>
			<tr>
				<td width='1'></td>
				<td <?php print ((($_GET["action"] == "user_realms_edit") || ($_GET["action"] == "user_edit")) ? "bgcolor='silver'" : "bgcolor='#DFDFDF'");?> nowrap='nowrap' width='150' align='center' class='tab'>
					<span class='textHeader'><a href='user_admin.php?action=user_realms_edit&id=<?php print $_GET["id"];?>'>Realm Permissions</a></span>
				</td>
				<td width='1'></td>
				<td <?php print (($_GET["action"] == "graph_perms_edit") ? "bgcolor='silver'" : "bgcolor='#DFDFDF'");?> nowrap='nowrap' width='150' align='center' class='tab'>
					<span class='textHeader'><a href='user_admin.php?action=graph_perms_edit&id=<?php print $_GET["id"];?>'>Graph Permissions</a></span>
				</td>
				<td width='1'></td>
				<td <?php print (($_GET["action"] == "graph_settings_edit") ? "bgcolor='silver'" : "bgcolor='#DFDFDF'");?> nowrap='nowrap' width='130' align='center' class='tab'>
					<span class='textHeader'><a href='user_admin.php?action=graph_settings_edit&id=<?php print $_GET["id"];?>'>Graph Settings</a></span>
				</td>
				<td></td>
			</tr>
		</table>
		<?php
	}

	if ($_GET["action"] == "graph_settings_edit") {
		graph_settings_edit();
	}elseif ($_GET["action"] == "user_realms_edit") {
		user_realms_edit();
	}elseif ($_GET["action"] == "graph_perms_edit") {
		graph_perms_edit();
	}else{
		user_realms_edit();
	}

	form_save_button("user_admin.php");
}
Beispiel #2
0
function user_edit() {
	global $colors, $fields_user_user_edit_device;

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

	if (!empty($_GET["id"])) {
		$user = db_fetch_row("SELECT * FROM user_auth WHERE id = " . get_request_var("id"));
		$header_label = __("[edit: ") . $user["username"] . "]";
	}else{
		$header_label = __("[new]");
	}

	api_plugin_hook_function('user_admin_edit', (isset($user) ? get_request_var("id") : 0));

	$user_tabs = array(
		"user_edit" => array("name" => __("General Settings"), "title" => __("General Settings are common settings for all users.")),
		"user_realms_edit" => array("name" => __("Realm Permissions"), "title" => __("Realm permissions control which sections of Cacti this user will have access to.")),
		"graph_perms_edit" => array("name" => __("Graph Permissions"), "title" => __("Graph policies will be evaluated in the order shown until a match is found.")),
		"graph_settings_edit" => array("name" => __("Graph Settings"), "title" => __("Graph settings control how graphs are displayed for this user.")));

	/* draw the categories tabs on the top of the page */
	/* set the default settings category */
	if (!isset($_GET["action"])) {
		/* there is no selected tab; select the first one */
		$current_tab = array_keys($user_tabs);
		$current_tab = $current_tab[0];
	}else{
		$current_tab = $_GET["action"];
	}

	print "<table width='100%' cellspacing='0' cellpadding='0' align='center'><tr>";
	print "<td><div class='tabs'>";

	if (sizeof($user_tabs)) {
	foreach (array_keys($user_tabs) as $tab_short_name) {
		print "<div title='" . $user_tabs[$tab_short_name]["title"] . "' class='tabDefault'><a " . (($tab_short_name == $current_tab) ? "class='tabSelected'" : "class='tabDefault'") . " href='" . htmlspecialchars("user_admin.php?action=shift&action=" . $tab_short_name . "&id=" . get_request_var("id")) . "'>" . $user_tabs[$tab_short_name]["name"] . "</a></div>";

		if (empty($_GET["id"])) break;
	}
	}

	print "</div></td></tr></table>\n";

	print "<form method='post' action='" .  basename($_SERVER["PHP_SELF"]) . "' name='user_edit'>\n";
	if (get_request_var("action") == "user_edit") {
		html_start_box("<strong>" . __("General Settings") . "</strong>", "100", $colors["header"], 0, "center");
		$header_items = array(__("Field"), __("Value"));
		print "<tr><td>";
		html_header($header_items, 2, true, 'settings_general');

		draw_edit_form(array(
			"config" => array("form_name" => "chk"),
			"fields" => inject_form_variables($fields_user_user_edit_device, (isset($user) ? $user : array()))
		));
		print "</table></td></tr>";		/* end of html_header */
		html_end_box();
	}else{
#		print "<span style='display:none;'>";
#
#		html_start_box("", "100%", $colors["header"], "3", "center");
#		draw_edit_form(array(
#			"config" => array("form_name" => "chk"),
#			"fields" => inject_form_variables($fields_user_user_edit_device, (isset($user) ? $user : array()))
#		));
#		html_end_box();
#
#		print "</span>";

		if (get_request_var("action") == "graph_settings_edit") {
			graph_settings_edit();
		}elseif (get_request_var("action") == "user_realms_edit") {
			user_realms_edit();
		}elseif (get_request_var("action") == "graph_perms_edit") {
			graph_perms_edit();
		}else{
			if (!api_plugin_hook_function('user_admin_run_action', get_request_var_request("action"))) {
				user_realms_edit();
			}
		}
	}
	form_save_button_alt("return!user_admin.php");
}
Beispiel #3
0
function user_edit()
{
    global $colors, $fields_user_user_edit_host;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    /* ==================================================== */
    if (!empty($_GET["id"])) {
        $user = db_fetch_row("SELECT * FROM user_auth WHERE id = " . get_request_var("id"));
        $header_label = "[edit: " . $user["username"] . "]";
    } else {
        $header_label = "[new]";
    }
    html_start_box("<strong>User Management</strong> {$header_label}", "100%", $colors["header"], "3", "center", "");
    draw_edit_form(array("config" => array("form_name" => "chk"), "fields" => inject_form_variables($fields_user_user_edit_host, isset($user) ? $user : array())));
    html_end_box();
    if (!empty($_GET["id"])) {
        /* draw user admin nav tabs */
        ?>
		<table class='tabs' width='100%' cellspacing='0' cellpadding='3' align='center'>
			<tr>
				<td width='1'></td>
				<td <?php 
        print get_request_var("action") == "user_realms_edit" || get_request_var("action") == "user_edit" ? "bgcolor='silver'" : "bgcolor='#DFDFDF'";
        ?>
 nowrap='nowrap' width='150' align='center' class='tab'>
					<span class='textHeader'><a href='user_admin.php?action=user_realms_edit&id=<?php 
        print $_GET["id"];
        ?>
'>Realm Permissions</a></span>
				</td>
				<td width='1'></td>
				<td <?php 
        print get_request_var("action") == "graph_perms_edit" ? "bgcolor='silver'" : "bgcolor='#DFDFDF'";
        ?>
 nowrap='nowrap' width='150' align='center' class='tab'>
					<span class='textHeader'><a href='user_admin.php?action=graph_perms_edit&id=<?php 
        print $_GET["id"];
        ?>
'>Graph Permissions</a></span>
				</td>
				<td width='1'></td>
				<td <?php 
        print get_request_var("action") == "graph_settings_edit" ? "bgcolor='silver'" : "bgcolor='#DFDFDF'";
        ?>
 nowrap='nowrap' width='130' align='center' class='tab'>
					<span class='textHeader'><a href='user_admin.php?action=graph_settings_edit&id=<?php 
        print $_GET["id"];
        ?>
'>Graph Settings</a></span>
				</td>
				<td></td>
			</tr>
		</table>
		<?php 
    }
    if (get_request_var("action") == "graph_settings_edit") {
        graph_settings_edit();
    } elseif (get_request_var("action") == "user_realms_edit") {
        user_realms_edit();
    } elseif (get_request_var("action") == "graph_perms_edit") {
        graph_perms_edit();
    } else {
        user_realms_edit();
    }
    form_save_button("user_admin.php");
}
Beispiel #4
0
function user_edit() {
	global $colors, $fields_user_user_edit_host;

	if (!empty($_GET["id"])) {
		$user = api_user_info(array( "id" => $_GET["id"]));
		$header_label = _("[edit: ") . $user["username"] . "]";
	}else{
		$header_label = _("[new]");
	}

	html_start_box("<strong>" . _("User Management") . "</strong> $header_label", "98%", $colors["header_background"], "3", "center", "");
	draw_edit_form(array(
		"config" => array("form_name" => "chk"),
		"fields" => inject_form_variables($fields_user_user_edit_host, (isset($user) ? $user : array()))
		));

	html_end_box();

	if (!empty($_GET["id"])) {
		/* draw user admin nav tabs */
		html_tab_start();
		html_tab_draw(_("Realm Permissions"), "user_admin.php?action=user_realms_edit&id=" . $_GET["id"], ((($_REQUEST["action"] == "user_realms_edit") || ($_REQUEST["action"] == "user_edit")) ? true : false));
		html_tab_draw(_("Graph Permissions"), "user_admin.php?action=graph_perms_edit&id=" . $_GET["id"], (($_REQUEST["action"] == "graph_perms_edit") ? true : false));
		html_tab_draw(_("Graph Settings"), "user_admin.php?action=graph_settings_edit&id=" . $_GET["id"], (($_REQUEST["action"] == "graph_settings_edit") ? true : false));
		html_tab_end();
	}

	if ($_GET["action"] == "graph_settings_edit") {
		graph_settings_edit();
	}elseif ($_GET["action"] == "user_realms_edit") {
		user_realms_edit();
	}elseif ($_GET["action"] == "graph_perms_edit") {
		graph_perms_edit();
	}else{
		user_realms_edit();
	}

	form_hidden_box("last_action", $_GET["action"], "");
	form_save_button("user_admin.php");
}
Beispiel #5
0
function user_edit()
{
    global $config, $fields_user_user_edit_host;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    /* ==================================================== */
    /* present a tabbed interface */
    $tabs = array('general' => 'General', 'realms' => 'Realm Perms', 'permsgr' => 'Group Membership', 'permsg' => 'Graph Perms', 'permsd' => 'Device Perms', 'permste' => 'Template Perms', 'permstr' => 'Tree Perms', 'settings' => 'Graph Settings');
    /* set the default tab */
    load_current_session_value('tab', 'sess_user_admin_tab', 'general');
    $current_tab = $_REQUEST['tab'];
    if (!empty($_REQUEST['id'])) {
        $user = db_fetch_row_prepared('SELECT * FROM user_auth WHERE id = ?', array(get_request_var_request('id')));
        $header_label = '[edit: ' . $user['username'] . ']';
    } else {
        $header_label = '[new]';
    }
    if (sizeof($tabs) && isset($_REQUEST['id'])) {
        /* draw the tabs */
        print "<div class='tabs'><nav><ul>\n";
        foreach (array_keys($tabs) as $tab_short_name) {
            print "<li class='subTab'><a " . ($tab_short_name == $current_tab ? "class='selected'" : '') . " href='" . htmlspecialchars($config['url_path'] . 'user_admin.php?action=user_edit&id=' . get_request_var_request('id') . '&tab=' . $tab_short_name) . "'>{$tabs[$tab_short_name]}</a></li>\n";
        }
        api_plugin_hook('user_admin_tab');
        print "</ul></nav></div>\n";
        if (read_config_option('legacy_menu_nav') != 'on') {
            ?>
		<script type='text/javascript'>

		$('.subTab').find('a').click(function(event) {
			event.preventDefault();
			href = $(this).attr('href');
			href = href+ (href.indexOf('?') > 0 ? '&':'?') + 'header=false';
			$.get(href, function(data) {
				$('#main').html(data);
				applySkin();
			});
		});
		</script>
		<?php 
        }
    }
    switch ($current_tab) {
        case 'general':
            api_plugin_hook_function('user_admin_edit', isset($user) ? get_request_var_request('id') : 0);
            html_start_box("<strong>User Management</strong> {$header_label}", '100%', '', '3', 'center', '');
            draw_edit_form(array('config' => array('form_name' => 'chk'), 'fields' => inject_form_variables($fields_user_user_edit_host, isset($user) ? $user : array())));
            html_end_box();
            form_save_button('user_admin.php', 'return');
            break;
        case 'settings':
            graph_settings_edit($header_label);
            break;
        case 'realms':
            user_realms_edit($header_label);
            break;
        case 'permsg':
        case 'permsd':
        case 'permsgr':
        case 'permste':
        case 'permstr':
            graph_perms_edit($current_tab, $header_label);
            break;
        default:
            if (api_plugin_hook_function('user_admin_run_action', get_request_var_request('tab'))) {
                user_realms_edit();
            }
            break;
    }
}