Beispiel #1
0
function item_moveup() {
	global $graph_item_types;

	$arr = get_graph_group($_GET["id"]);
	$previous_id = get_graph_parent($_GET["id"], "previous");

	if ((!empty($previous_id)) && (isset($arr{$_GET["id"]}))) {
		move_graph_group($_GET["id"], $arr, $previous_id, "previous");
	}elseif (ereg("(GPRINT|VRULE|HRULE|COMMENT)", $graph_item_types{db_fetch_cell("select graph_type_id from graph_templates_item where id=" . $_GET["id"])})) {
		move_item_up("graph_templates_item", $_GET["id"], "local_graph_id=" . $_GET["local_graph_id"]);
	}
}
Beispiel #2
0
function move_graph_group($graph_template_item_id, $graph_group_array, $target_id, $direction) {
	$graph_item = db_fetch_row("select local_graph_id,graph_template_id from graph_templates_item where id=$graph_template_item_id");

	if (empty($graph_item["local_graph_id"])) {
		$sql_where = "graph_template_id = " . $graph_item["graph_template_id"] . " and local_graph_id=0";
	}else{
		$sql_where = "local_graph_id = " . $graph_item["local_graph_id"];
	}

	$graph_items = db_fetch_assoc("select id,sequence from graph_templates_item where $sql_where order by sequence");

	/* get a list of parent+children of our target group */
	$target_graph_group_array = get_graph_group($target_id);

	/* if this "parent" item has no children, then treat it like a regular gprint */
	if (sizeof($target_graph_group_array) == 0) {
		if ($direction == "next") {
			move_item_down("graph_templates_item", $graph_template_item_id, $sql_where);
		}elseif ($direction == "previous") {
			move_item_up("graph_templates_item", $graph_template_item_id, $sql_where);
		}

		return;
	}

	/* start the sequence at '1' */
	$sequence_counter = 1;

	if (sizeof($graph_items) > 0) {
	foreach ($graph_items as $item) {
		/* check to see if we are at the "target" spot in the loop; if we are, update the sequences and move on */
		if ($target_id == $item["id"]) {
			if ($direction == "next") {
				$group_array1 = $target_graph_group_array;
				$group_array2 = $graph_group_array;
			}elseif ($direction == "previous") {
				$group_array1 = $graph_group_array;
				$group_array2 = $target_graph_group_array;
			}

			while (list($sequence,$graph_template_item_id) = each($group_array1)) {
				db_execute("update graph_templates_item set sequence=$sequence_counter where id=$graph_template_item_id");

				/* propagate to ALL graphs using this template */
				if (empty($graph_item["local_graph_id"])) {
					db_execute("update graph_templates_item set sequence=$sequence_counter where local_graph_template_item_id=$graph_template_item_id");
				}

				$sequence_counter++;
			}

			while (list($sequence,$graph_template_item_id) = each($group_array2)) {
				db_execute("update graph_templates_item set sequence=$sequence_counter where id=$graph_template_item_id");

				/* propagate to ALL graphs using this template */
				if (empty($graph_item["local_graph_id"])) {
					db_execute("update graph_templates_item set sequence=$sequence_counter where local_graph_template_item_id=$graph_template_item_id");
				}

				$sequence_counter++;
			}
		}

		/* make sure to "ignore" the items that we handled above */
		if ((!isset($graph_group_array{$item["id"]})) && (!isset($target_graph_group_array{$item["id"]}))) {
			db_execute("update graph_templates_item set sequence=$sequence_counter where id=" . $item["id"]);
			$sequence_counter++;
		}
	}
	}
}
Beispiel #3
0
function item_moveup()
{
    global $graph_item_types;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    input_validate_input_number(get_request_var_request('local_graph_id'));
    /* ==================================================== */
    $arr = get_graph_group($_REQUEST['id']);
    $previous_id = get_graph_parent($_REQUEST['id'], 'previous');
    if (!empty($previous_id) && isset($arr[$_REQUEST['id']])) {
        move_graph_group($_REQUEST['id'], $arr, $previous_id, 'previous');
    } elseif (preg_match('/(GPRINT|VRULE|HRULE|COMMENT)/', $graph_item_types[db_fetch_cell_prepared('SELECT graph_type_id FROM graph_templates_item WHERE id = ?', array(get_request_var_request('id')))])) {
        move_item_up('graph_templates_item', $_REQUEST['id'], 'local_graph_id=' . $_REQUEST['local_graph_id']);
    }
}
function item_moveup() {
	/* ================= input validation ================= */
	input_validate_input_number(get_request_var("id"));
	input_validate_input_number(get_request_var("graph_template_id"));
	/* ==================================================== */

	global $graph_item_types;

	$arr = get_graph_group($_GET["id"]);
	$next_id = get_graph_parent($_GET["id"], "previous");

	if ((!empty($next_id)) && (isset($arr{$_GET["id"]}))) {
		move_graph_group($_GET["id"], $arr, $next_id, "previous");
	}elseif (ereg("(GPRINT|VRULE|HRULE|COMMENT)", $graph_item_types{db_fetch_cell("select graph_type_id from graph_templates_item where id=" . $_GET["id"])})) {
		/* this is so we know the "other" graph item to propagate the changes to */
		$last_item = get_item("graph_templates_item", "sequence", $_GET["id"], "graph_template_id=" . $_GET["graph_template_id"] . " and local_graph_id=0", "previous");

		move_item_up("graph_templates_item", $_GET["id"], "graph_template_id=" . $_GET["graph_template_id"] . " and local_graph_id=0");

		db_execute("update graph_templates_item set sequence=" . db_fetch_cell("select sequence from graph_templates_item where id=" . $_GET["id"]) . " where local_graph_template_item_id=" . $_GET["id"]);
		db_execute("update graph_templates_item set sequence=" . db_fetch_cell("select sequence from graph_templates_item where id=" . $last_item). " where local_graph_template_item_id=" . $last_item);
	}
}
Beispiel #5
0
function item_moveup()
{
    global $graph_item_types;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("local_graph_id"));
    /* ==================================================== */
    $arr = get_graph_group($_GET["id"]);
    $previous_id = get_graph_parent($_GET["id"], "previous");
    if (!empty($previous_id) && isset($arr[$_GET["id"]])) {
        move_graph_group($_GET["id"], $arr, $previous_id, "previous");
    } elseif (preg_match("/(GPRINT|VRULE|HRULE|COMMENT)/", $graph_item_types[db_fetch_cell("select graph_type_id from graph_templates_item where id=" . $_GET["id"])])) {
        move_item_up("graph_templates_item", $_GET["id"], "local_graph_id=" . $_GET["local_graph_id"]);
    }
}
Beispiel #6
0
function move_graph_group($graph_template_item_id, $graph_group_array, $target_id, $direction)
{
    $graph_item = db_fetch_row_prepared('SELECT local_graph_id, graph_template_id FROM graph_templates_item WHERE id = ?', array($graph_template_item_id));
    if (empty($graph_item['local_graph_id'])) {
        $sql_where = 'graph_template_id = ' . $graph_item['graph_template_id'] . ' AND local_graph_id = 0';
    } else {
        $sql_where = 'local_graph_id = ' . $graph_item['local_graph_id'];
    }
    $graph_items = db_fetch_assoc_prepared("SELECT id, sequence FROM graph_templates_item WHERE {$sql_where} ORDER BY sequence");
    /* get a list of parent+children of our target group */
    $target_graph_group_array = get_graph_group($target_id);
    /* if this "parent" item has no children, then treat it like a regular gprint */
    if (sizeof($target_graph_group_array) == 0) {
        if ($direction == 'next') {
            move_item_down('graph_templates_item', $graph_template_item_id, $sql_where);
        } elseif ($direction == 'previous') {
            move_item_up('graph_templates_item', $graph_template_item_id, $sql_where);
        }
        return;
    }
    /* start the sequence at '1' */
    $sequence_counter = 1;
    if (sizeof($graph_items) > 0) {
        foreach ($graph_items as $item) {
            /* check to see if we are at the "target" spot in the loop; if we are, update the sequences and move on */
            if ($target_id == $item['id']) {
                if ($direction == 'next') {
                    $group_array1 = $target_graph_group_array;
                    $group_array2 = $graph_group_array;
                } elseif ($direction == 'previous') {
                    $group_array1 = $graph_group_array;
                    $group_array2 = $target_graph_group_array;
                }
                while (list($sequence, $graph_template_item_id) = each($group_array1)) {
                    db_execute_prepared('UPDATE graph_templates_item SET sequence = ? WHERE id = ?', array($sequence_counter, $graph_template_item_id));
                    /* propagate to ALL graphs using this template */
                    if (empty($graph_item['local_graph_id'])) {
                        db_execute_prepared('UPDATE graph_templates_item SET sequence = ? WHERE local_graph_template_item_id = ?', array($sequence_counter, $graph_template_item_id));
                    }
                    $sequence_counter++;
                }
                while (list($sequence, $graph_template_item_id) = each($group_array2)) {
                    db_execute_prepared('UPDATE graph_templates_item SET sequence = ? WHERE id = ?', array($sequence_counter, $graph_template_item_id));
                    /* propagate to ALL graphs using this template */
                    if (empty($graph_item['local_graph_id'])) {
                        db_execute_prepared('UPDATE graph_templates_item SET sequence = ? WHERE local_graph_template_item_id = ?', array($sequence_counter, $graph_template_item_id));
                    }
                    $sequence_counter++;
                }
            }
            /* make sure to "ignore" the items that we handled above */
            if (!isset($graph_group_array[$item['id']]) && !isset($target_graph_group_array[$item['id']])) {
                db_execute_prepared('UPDATE graph_templates_item SET sequence = ? WHERE id = ?', array($sequence_counter, $item['id']));
                $sequence_counter++;
            }
        }
    }
}
Beispiel #7
0
function item_moveup() {
	require(CACTI_BASE_PATH . "/include/graph/graph_arrays.php");

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

	$arr = get_graph_group($_GET["id"]);
	$previous_id = get_graph_parent($_GET["id"], "previous");

	$graph_type_id = db_fetch_cell("select graph_type_id from graph_templates_item where id=" . $_GET["id"]);
	if ((!empty($previous_id)) && (isset($arr{$_GET["id"]}))) {
		move_graph_group(get_request_var("id"), $arr, $previous_id, "previous");
	}elseif ($graph_type_id == GRAPH_ITEM_TYPE_GPRINT_AVERAGE ||
			$graph_type_id == GRAPH_ITEM_TYPE_GPRINT_LAST ||
			$graph_type_id == GRAPH_ITEM_TYPE_GPRINT_MAX ||
			$graph_type_id == GRAPH_ITEM_TYPE_GPRINT_MIN ||
			$graph_type_id == GRAPH_ITEM_TYPE_HRULE ||
			$graph_type_id == GRAPH_ITEM_TYPE_VRULE ||
			$graph_type_id == GRAPH_ITEM_TYPE_COMMENT) {
		move_item_up("graph_templates_item", $_GET["id"], "local_graph_id=" . $_GET["local_graph_id"]);
	}
}
function item_moveup() {
	require(CACTI_BASE_PATH . "/include/graph/graph_arrays.php");

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

	$arr = get_graph_group(get_request_var("id"));
	$next_id = get_graph_parent(get_request_var("id"), "previous");

	$graph_type_id = db_fetch_cell("select graph_type_id from graph_templates_item where id=" . get_request_var("id"));
	if ((!empty($next_id)) && (isset($arr{$_GET["id"]}))) {
		move_graph_group(get_request_var("id"), $arr, $next_id, "previous");
	}elseif ($graph_type_id == GRAPH_ITEM_TYPE_GPRINT_AVERAGE ||
			$graph_type_id == GRAPH_ITEM_TYPE_GPRINT_LAST ||
			$graph_type_id == GRAPH_ITEM_TYPE_GPRINT_MAX ||
			$graph_type_id == GRAPH_ITEM_TYPE_GPRINT_MIN ||
			$graph_type_id == GRAPH_ITEM_TYPE_HRULE ||
			$graph_type_id == GRAPH_ITEM_TYPE_VRULE ||
			$graph_type_id == GRAPH_ITEM_TYPE_COMMENT) {
		/* this is so we know the "other" graph item to propagate the changes to */
		$last_item = get_item("graph_templates_item", "sequence", get_request_var("id"), "graph_template_id=" . get_request_var("graph_template_id") . " and local_graph_id=0", "previous");

		move_item_up("graph_templates_item", get_request_var("id"), "graph_template_id=" . get_request_var("graph_template_id") . " and local_graph_id=0");

		db_execute("update graph_templates_item set sequence=" . db_fetch_cell("select sequence from graph_templates_item where id=" . get_request_var("id")) . " where local_graph_template_item_id=" . get_request_var("id"));
		db_execute("update graph_templates_item set sequence=" . db_fetch_cell("select sequence from graph_templates_item where id=" . $last_item). " where local_graph_template_item_id=" . $last_item);
	}
}
Beispiel #9
0
function item_moveup()
{
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    input_validate_input_number(get_request_var_request('graph_template_id'));
    /* ==================================================== */
    global $graph_item_types;
    $arr = get_graph_group($_REQUEST['id']);
    $next_id = get_graph_parent($_REQUEST['id'], 'previous');
    if (!empty($next_id) && isset($arr[$_REQUEST['id']])) {
        move_graph_group($_REQUEST['id'], $arr, $next_id, 'previous');
    } elseif (preg_match('/(GPRINT|VRULE|HRULE|COMMENT)/', $graph_item_types[db_fetch_cell_prepared('SELECT graph_type_id FROM graph_templates_item WHERE id = ?', array($_REQUEST['id']))])) {
        /* this is so we know the "other" graph item to propagate the changes to */
        $last_item = get_item('graph_templates_item', 'sequence', $_REQUEST['id'], 'graph_template_id=' . $_REQUEST['graph_template_id'] . ' and local_graph_id=0', 'previous');
        move_item_up('graph_templates_item', $_REQUEST['id'], 'graph_template_id=' . $_REQUEST['graph_template_id'] . ' and local_graph_id=0');
        db_execute_prepared('UPDATE graph_templates_item SET sequence = ' . db_fetch_cell_prepared('SELECT sequence FROM graph_templates_item WHERE id = ?', array($_REQUEST['id'])) . ' WHERE local_graph_template_item_id = ?', array($_REQUEST['id']));
        db_execute_prepared('UPDATE graph_templates_item SET sequence = ' . db_fetch_cell_prepared('SELECT sequence FROM graph_templates_item WHERE id = ?', array($last_item)) . ' WHERE local_graph_template_item_id = ?', array($last_item));
    }
}