Esempio n. 1
0
function grow_edit_graph_tree($tree_id, $user_id, $options) {
	global $config, $colors;

	include_once($config["library_path"] . "/tree.php");

	$tree_sorting_type = db_fetch_cell("select sort_type from graph_tree where id='$tree_id'");

	$tree = db_fetch_assoc("select
		graph_tree_items.id,
		graph_tree_items.title,
		graph_tree_items.graph_tree_id,
		graph_tree_items.local_graph_id,
		graph_tree_items.host_id,
		graph_tree_items.order_key,
		graph_tree_items.sort_children_type,
		graph_templates_graph.title_cache as graph_title,
		CONCAT_WS('',description,' (',hostname,')') as hostname
		from graph_tree_items
		left join graph_templates_graph on (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id and graph_tree_items.local_graph_id>0)
		left join host on (host.id=graph_tree_items.host_id)
		where graph_tree_items.graph_tree_id=$tree_id
		order by graph_tree_id, graph_tree_items.order_key");

	print "<!-- <P>Building Hierarchy w/ " . sizeof($tree) . " leaves</P>  -->\n";

	##  Here we go.  Starting the main tree drawing loop.

	/* change the visibility session variable if applicable */
	set_tree_visibility_status();

	$i = 0;
	if (sizeof($tree) > 0) {
	foreach ($tree as $leaf) {
		$tier = tree_tier($leaf["order_key"]);
		$transparent_indent = "<img width='" . (($tier-1) * 20) . "' height='1' align='middle' alt=''>&nbsp;";
		$sort_cache[$tier] = $leaf["sort_children_type"];

		if ($i % 2 == 0) { $row_color = $colors["form_alternate1"]; }else{ $row_color = $colors["form_alternate2"]; } $i++;

		$visible = get_visibility($leaf);

		if ($leaf["local_graph_id"] > 0) {
			if ($visible) {
				print "<td bgcolor='#$row_color' bgcolor='#" . $colors["panel"] . "'>$transparent_indent<a href='tree.php?action=item_edit&tree_id=" . $_GET["id"] . "&id=" . $leaf["id"] . "'>" . $leaf["graph_title"] . "</a></td>\n";
				print "<td bgcolor='#$row_color' bgcolor='#" . $colors["panel"] . "'>Graph</td>";
			}
		}elseif ($leaf["title"] != "") {
			$icon = get_icon($leaf["graph_tree_id"], $leaf["order_key"]);
			if ($visible) {
				print "<td bgcolor='#$row_color' bgcolor='#" . $colors["panel"] . "'>$transparent_indent<a href='tree.php?action=edit&id=" . $_GET["id"] . "&leaf_id=" . $leaf["id"] . "&subaction=change'><img src='" . $icon . "' border='0'></a><a href='tree.php?action=item_edit&tree_id=" . $_GET["id"] . "&id=" . $leaf["id"] . "'>&nbsp;<strong>" . $leaf["title"] . "</strong></a> (<a href='tree.php?action=item_edit&tree_id=" . $_GET["id"] . "&parent_id=" . $leaf["id"] . "'>Add</a>)</td>\n";
				print "<td bgcolor='#$row_color' bgcolor='#" . $colors["panel"] . "'>Heading</td>";
			}
		}elseif ($leaf["host_id"] > 0) {
			if ($visible) {
				print "<td bgcolor='#$row_color' bgcolor='#" . $colors["panel"] . "'>$transparent_indent<a href='tree.php?action=item_edit&tree_id=" . $_GET["id"] . "&id=" . $leaf["id"] . "'><strong>Host:</strong> " . $leaf["hostname"] . "</a>&nbsp;<a href='host.php?action=edit&id=" . $leaf["host_id"] . "'>(Edit host)</a></td>\n";
				print "<td bgcolor='#$row_color' bgcolor='#" . $colors["panel"] . "'>Host</td>";
			}
		}

		if ($visible) {
			if ( ((isset($sort_cache{$tier-1})) && ($sort_cache{$tier-1} != TREE_ORDERING_NONE)) || ($tree_sorting_type != TREE_ORDERING_NONE) )  {
				print "<td bgcolor='#$row_color' width='80'></td>\n";
			}else{
				print "<td bgcolor='#$row_color' width='80' align='center'>\n
					<a href='tree.php?action=item_movedown&id=" . $leaf["id"] . "&tree_id=" . $_GET["id"] . "'><img src='images/move_down.gif' border='0' alt='Move Down'></a>\n
					<a href='tree.php?action=item_moveup&id=" . $leaf["id"] . "&tree_id=" . $_GET["id"] . "'><img src='images/move_up.gif' border='0' alt='Move Up'></a>\n
					</td>\n";
			}

			print 	"<td bgcolor='#$row_color' align='right'>\n
				<a href='tree.php?action=item_remove&id=" . $leaf["id"] . "&tree_id=$tree_id'><img src='images/delete_icon.gif' width='10' height='10' border='0' alt='Delete'></a>\n
				</td></tr>\n";
		}
	}
	}else{
		print "<tr><td><em>No Graph Tree Items</em></td></tr>";
	}
}
Esempio n. 2
0
function grow_edit_graph_tree($tree_id, $user_id, $options)
{
    global $config, $colors;
    include_once $config["library_path"] . "/tree.php";
    $tree_sorting_type = db_fetch_cell("select sort_type from graph_tree where id='{$tree_id}'");
    $tree = db_fetch_assoc("select\r\n\t\tgraph_tree_items.id,\r\n\t\tgraph_tree_items.title,\r\n\t\tgraph_tree_items.graph_tree_id,\r\n\t\tgraph_tree_items.local_graph_id,\r\n\t\tgraph_tree_items.host_id,\r\n\t\tgraph_tree_items.order_key,\r\n\t\tgraph_tree_items.sort_children_type,\r\n\t\tgraph_templates_graph.title_cache as graph_title,\r\n\t\tCONCAT_WS('',description,' (',hostname,')') as hostname\r\n\t\tfrom graph_tree_items\r\n\t\tleft join graph_templates_graph on (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id and graph_tree_items.local_graph_id>0)\r\n\t\tleft join host on (host.id=graph_tree_items.host_id)\r\n\t\twhere graph_tree_items.graph_tree_id={$tree_id}\r\n\t\torder by graph_tree_id, graph_tree_items.order_key");
    print "<!-- <P>Building Hierarchy w/ " . sizeof($tree) . " leaves</P>  -->\n";
    ##  Here we go.  Starting the main tree drawing loop.
    /* change the visibility session variable if applicable */
    set_tree_visibility_status();
    $i = 0;
    if (sizeof($tree) > 0) {
        foreach ($tree as $leaf) {
            /* modify for multi user start */
            $permission = check_tree_item($leaf["id"]);
            if ($permission == FALSE) {
                if ($_SESSION["permission"] == ACCESS_ADMINISTRATOR && ($leaf["graph_tree_id"] != $_SESSION["public_tree_id"] && $leaf["graph_tree_id"] != $_SESSION["private_tree_id"])) {
                    // administrator can view other private tree
                } else {
                    continue;
                }
            }
            /* modify for multi user end */
            $tier = tree_tier($leaf["order_key"]);
            $transparent_indent = "<img src='images/transparent_line.gif' style='padding-right:" . ($tier - 1) * 20 . "px;' style='height:1px;' align='middle' alt=''>&nbsp;";
            $sort_cache[$tier] = $leaf["sort_children_type"];
            if ($i % 2 == 0) {
                $row_color = $colors["form_alternate1"];
            } else {
                $row_color = $colors["form_alternate2"];
            }
            $i++;
            $visible = get_visibility($leaf);
            if ($leaf["local_graph_id"] > 0) {
                if ($visible) {
                    /* modify for multi user start */
                    if ($_SESSION["permission"] == ACCESS_ADMINISTRATOR || $permission == TREE_ITEM_PRIVATE) {
                        print "<td bgcolor='#{$row_color}'>{$transparent_indent}<a href='" . htmlspecialchars("tree.php?action=item_edit&tree_id=" . $_GET["id"] . "&id=" . $leaf["id"]) . "'>" . $leaf["graph_title"] . "</a></td>\n";
                    } elseif ($permission == TREE_ITEM_PUBLIC) {
                        $local_graph_id = db_fetch_cell("SELECT local_graph_id FROM graph_tree_items WHERE id = '" . $leaf["id"] . "'");
                        print "<td bgcolor='#{$row_color}'><a href='graph.php?action=properties&local_graph_id=" . $local_graph_id . "&rra_id=0&view_type=tree'>{$transparent_indent}" . $leaf["graph_title"] . "</a></td>\n";
                    } else {
                        print "<td bgcolor='#{$row_color}'>{$transparent_indent}" . $leaf["graph_title"] . "</td>\n";
                    }
                    /* modify for multi user end */
                    print "<td bgcolor='#{$row_color}'>Graph</td>";
                }
            } elseif ($leaf["title"] != "") {
                $icon = get_icon($leaf["graph_tree_id"], $leaf["order_key"]);
                if ($visible) {
                    /* modify for multi user start */
                    if ($_SESSION["permission"] == ACCESS_ADMINISTRATOR || $permission == TREE_ITEM_PRIVATE) {
                        print "<td bgcolor='#{$row_color}'>{$transparent_indent}<a href='" . htmlspecialchars("tree.php?action=edit&id=" . $_GET["id"] . "&leaf_id=" . $leaf["id"] . "&subaction=change") . "'><img src='" . $icon . "' border='0'></a><a href='" . htmlspecialchars("tree.php?action=item_edit&tree_id=" . $_GET["id"] . "&id=" . $leaf["id"]) . "'>&nbsp;<strong>" . htmlspecialchars($leaf["title"]) . "</strong></a> (<a href='" . htmlspecialchars("tree.php?action=item_edit&tree_id=" . $_GET["id"] . "&parent_id=" . $leaf["id"]) . "'>Add</a>)</td>\n";
                    } else {
                        print "<td bgcolor='#{$row_color}'>{$transparent_indent}<a href='" . htmlspecialchars("tree.php?action=edit&id=" . $_GET["id"] . "&leaf_id=" . $leaf["id"] . "&subaction=change") . "'><img src='" . $icon . "' border='0'></a>&nbsp;<strong>" . htmlspecialchars($leaf["title"]) . "</strong></td>\n";
                    }
                    /* modify for multi user end */
                    print "<td bgcolor='#{$row_color}'>Heading</td>";
                }
            } elseif ($leaf["host_id"] > 0) {
                if ($visible) {
                    /* modify for multi user start */
                    if ($_SESSION["permission"] == ACCESS_ADMINISTRATOR || $permission == TREE_ITEM_PRIVATE) {
                        print "<td bgcolor='#{$row_color}'>{$transparent_indent}<a href='" . htmlspecialchars("tree.php?action=item_edit&tree_id=" . $_GET["id"] . "&id=" . $leaf["id"]) . "'><strong>Host:</strong> " . htmlspecialchars($leaf["hostname"]) . "</a>&nbsp;<a href='" . htmlspecialchars("host.php?action=edit&id=" . $leaf["host_id"]) . "'>(Edit host)</a></td>\n";
                    } else {
                        print "<td bgcolor='#{$row_color}'>{$transparent_indent}<strong>Host:</strong> " . htmlspecialchars($leaf["hostname"]) . "</td>\n";
                    }
                    /* modify for multi user end */
                    print "<td bgcolor='#{$row_color}'>Host</td>";
                }
            }
            if ($visible) {
                /* modify for multi user start */
                if ($_SESSION["permission"] == ACCESS_ADMINISTRATOR || ($permission == TREE_ITEM_PRIVATE || $permission == TREE_ITEM_OTHER)) {
                    if (isset($sort_cache[$tier - 1]) && $sort_cache[$tier - 1] != TREE_ORDERING_NONE || $tree_sorting_type != TREE_ORDERING_NONE) {
                        print "<td bgcolor='#{$row_color}' width='80'></td>\n";
                    } else {
                        print "<td bgcolor='#{$row_color}' width='80' align='center'>\n\r\n\t\t\t\t\t<a href='" . htmlspecialchars("tree.php?action=item_movedown&id=" . $leaf["id"] . "&tree_id=" . $_GET["id"]) . "'><img src='images/move_down.gif' border='0' alt='Move Down'></a>\n\r\n\t\t\t\t\t<a href='" . htmlspecialchars("tree.php?action=item_moveup&id=" . $leaf["id"] . "&tree_id=" . $_GET["id"]) . "'><img src='images/move_up.gif' border='0' alt='Move Up'></a>\n\r\n\t\t\t\t\t</td>\n";
                    }
                } else {
                    print "<td bgcolor='#{$row_color}' width='80'></td>\n";
                }
                if ($_SESSION["permission"] == ACCESS_ADMINISTRATOR || $leaf["local_graph_id"] != 0 && $permission == TREE_ITEM_PUBLIC || $leaf["local_graph_id"] != 0 && $permission == TREE_ITEM_OTHER && $tier > 1 || $leaf["host_id"] != 0 && $permission == TREE_ITEM_PRIVATE && $tier > 1 || $leaf["host_id"] == 0 && $permission == TREE_ITEM_PRIVATE) {
                    // private header or graph
                    print "<td bgcolor='#{$row_color}' align='right'>\n\r\n\t\t\t\t<a href='" . htmlspecialchars("tree.php?action=item_remove&id=" . $leaf["id"] . "&tree_id={$tree_id}") . "'><img src='images/delete_icon.gif' style='height:10px;width:10px;' border='0' alt='Delete'></a>\n\r\n\t\t\t\t</td></tr>\n";
                } else {
                    print "<td bgcolor='#{$row_color}' align='right'></td></tr>\n";
                }
                /* modify for multi user end */
            }
        }
    } else {
        print "<tr><td><em>No Graph Tree Items</em></td></tr>";
    }
}
Esempio n. 3
0
function grow_edit_graph_tree($tree_id, $user_id, $options)
{
    global $config;
    include_once $config['library_path'] . '/tree.php';
    $tree_sorting_type = db_fetch_cell("select sort_type from graph_tree where id='{$tree_id}'");
    $tree = db_fetch_assoc("select\n\t\tgraph_tree_items.id,\n\t\tgraph_tree_items.title,\n\t\tgraph_tree_items.graph_tree_id,\n\t\tgraph_tree_items.local_graph_id,\n\t\tgraph_tree_items.host_id,\n\t\tgraph_tree_items.order_key,\n\t\tgraph_tree_items.sort_children_type,\n\t\tgraph_templates_graph.title_cache as graph_title,\n\t\tCONCAT_WS('',description,' (',hostname,')') as hostname\n\t\tfrom graph_tree_items\n\t\tleft join graph_templates_graph on (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id and graph_tree_items.local_graph_id>0)\n\t\tleft join host on (host.id=graph_tree_items.host_id)\n\t\twhere graph_tree_items.graph_tree_id={$tree_id}\n\t\torder by graph_tree_id, graph_tree_items.order_key");
    print "<!-- <P>Building Hierarchy w/ " . sizeof($tree) . " leaves</P>  -->\n";
    ##  Here we go.  Starting the main tree drawing loop.
    /* change the visibility session variable if applicable */
    set_tree_visibility_status();
    $i = 0;
    if (sizeof($tree) > 0) {
        foreach ($tree as $leaf) {
            $tier = tree_tier($leaf['order_key']);
            $transparent_indent = "<img src='images/transparent_line.gif' style='padding-right:" . ($tier - 1) * 20 . "px;' style='height:1px;' align='absmiddle' alt=''>&nbsp;";
            $sort_cache[$tier] = $leaf['sort_children_type'];
            if ($i % 2 == 0) {
                $class = 'odd';
            } else {
                $class = 'even';
            }
            $i++;
            form_alternate_row();
            $visible = get_visibility($leaf);
            if ($leaf['local_graph_id'] > 0) {
                if ($visible) {
                    print "<td>{$transparent_indent}<a href='" . htmlspecialchars('tree.php?action=item_edit&tree_id=' . $_GET['id'] . '&id=' . $leaf['id']) . "'>" . $leaf['graph_title'] . "</a></td>\n";
                    print "<td>Graph</td>";
                }
            } elseif ($leaf['title'] != '') {
                $icon = get_icon($leaf['graph_tree_id'], $leaf['order_key']);
                if ($visible) {
                    print "<td>{$transparent_indent}<a href='" . htmlspecialchars('tree.php?action=edit&id=' . $_GET['id'] . '&leaf_id=' . $leaf['id'] . '&subaction=change') . "'><img src='" . $icon . "' border='0'></a><a href='" . htmlspecialchars('tree.php?action=item_edit&tree_id=' . $_GET['id'] . '&id=' . $leaf['id']) . "'>&nbsp;<strong>" . htmlspecialchars($leaf['title']) . "</strong></a> (<a href='" . htmlspecialchars('tree.php?action=item_edit&tree_id=' . $_GET['id'] . '&parent_id=' . $leaf['id']) . "'>Add</a>)</td>\n";
                    print "<td>Heading</td>";
                }
            } elseif ($leaf['host_id'] > 0) {
                if ($visible) {
                    print "<td>{$transparent_indent}<a href='" . htmlspecialchars('tree.php?action=item_edit&tree_id=' . $_GET['id'] . '&id=' . $leaf['id']) . "'><strong>Host:</strong> " . htmlspecialchars($leaf['hostname']) . "</a>&nbsp;<a href='" . htmlspecialchars('host.php?action=edit&id=' . $leaf['host_id']) . "'>(Edit host)</a></td>\n";
                    print "<td>Host</td>";
                }
            }
            if ($visible) {
                if (isset($sort_cache[$tier - 1]) && $sort_cache[$tier - 1] != TREE_ORDERING_NONE || $tree_sorting_type != TREE_ORDERING_NONE) {
                    print "<td width='80'></td>\n";
                } else {
                    print "<td width='80' align='center'>\n\n\t\t\t\t\t<a href='" . htmlspecialchars('tree.php?action=item_movedown&id=' . $leaf['id'] . '&tree_id=' . $_GET['id']) . "'><img src='images/move_down.gif' border='0' alt='Move Down'></a>\n\n\t\t\t\t\t<a href='" . htmlspecialchars('tree.php?action=item_moveup&id=' . $leaf['id'] . '&tree_id=' . $_GET['id']) . "'><img src='images/move_up.gif' border='0' alt='Move Up'></a>\n\n\t\t\t\t\t</td>\n";
                }
                print "<td align='right'>\n\n\t\t\t\t<a href='" . htmlspecialchars('tree.php?action=item_remove&id=' . $leaf['id'] . '&tree_id=' . $tree_id) . "'><img src='images/delete_icon.gif' style='height:10px;width:10px;' border='0' alt='Delete'></a>\n\n\t\t\t\t</td></tr>\n";
            }
            form_end_row();
        }
    } else {
        print '<tr><td><em>No Graph Tree Items</em></td></tr>';
    }
}