';
echo "
";
$layout_datas = db_get_all_rows_field_filter('tlayout_data',
'id_layout', $id_layout);
if (empty($layout_datas))
$layout_datas = array();
$lines = array ();
foreach ($layout_datas as $layout_data) {
//Check the items are from disabled or pending delete modules
if ($layout_data['id_agente_modulo'] != 0 &&
(($layout_data['type'] != LABEL)
|| ($layout_data['type'] != ICON)
|| ($layout_data['type'] != SERVICE))) {
$delete_pending_module = db_get_value ("delete_pending",
"tagente_modulo", "id_agente_modulo",
$layout_data["id_agente_modulo"]);
$disabled_module = db_get_value ("disabled", "tagente_modulo",
"id_agente_modulo", $layout_data["id_agente_modulo"]);
if ($delete_pending_module == 1 || $disabled_module == 1)
continue;
}
if (($dif_height === 0) && ($dif_width === 0)) {
$proportion = null;
}
else {
$proportion = array(
'dif_height' => $dif_height,
'dif_width' => $dif_width,
'proportion_height' => $proportion_height,
'proportion_width' => $proportion_width);
}
switch ($layout_data['type']) {
case LINE_ITEM:
visual_map_print_user_lines($layout_data, $proportion);
break;
default:
visual_map_print_item("read", $layout_data,
$proportion, $show_links, $isExternalLink, $graph_javascript);
break;
}
}
// End main div
echo "
";
if (defined('METACONSOLE')) {
echo "";
}
}
//End function
//Start function
/**
* Get a list with the layouts for a user.
*
* @param int User id.
* @param bool Wheter to return all the fields or only the name (to use in
* html_print_select() directly)
* @param array Additional filters to filter the layouts.
* @param bool Whether to return All group or not.
*
* @return array A list of layouts the user can see.
*/
function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter = false, $returnAllGroup = true) {
if (! is_array ($filter))
$filter = array ();
if ($returnAllGroup)
$groups = users_get_groups ($id_user, 'RR');
else
$groups = users_get_groups ($id_user, 'RR', false);
if (!empty($groups)) {
if (empty($where))
$where = "";
if ($where != '') {
$where .= ' AND ';
}
$where .= sprintf ('id_group IN (%s)', implode (",", array_keys ($groups)));
}
$where .= db_format_array_where_clause_sql ($filter);
if ($where == '') {
$where = array();
}
$layouts = db_get_all_rows_filter ('tlayout', $where);
if ($layouts == false)
return array ();
$retval = array ();
foreach ($layouts as $layout) {
if ($only_names)
$retval[$layout['id']] = $layout['name'];
else
$retval[$layout['id']] = $layout;
}
return $retval;
}
/**
* Get the status of a layout.
*
* It gets all the data of the contained elements (including nested
* layouts), and makes an AND operation to be sure that all the items
* are OK. If any of them is down, then result is down (0)
*
* @param int Id of the layout
* @param int Depth (for recursion control)
*
* @return bool The status of the given layout. True if it's OK, false if not.
*/
function visual_map_get_layout_status ($id_layout = 0, $depth = 0) {
$temp_status = VISUAL_MAP_STATUS_NORMAL;
$temp_total = VISUAL_MAP_STATUS_NORMAL;
$depth++; // For recursion depth checking
// TODO: Implement this limit as a configurable item in setup
if ($depth > 10) {
return VISUAL_MAP_STATUS_UNKNOWN; // No status data if we need to exit by a excesive recursion
}
$id_layout = (int) $id_layout;
$result = db_get_all_rows_filter ('tlayout_data',
array ('id_layout' => $id_layout),
array (
'id_agente_modulo',
'id_group',
'parent_item',
'id_layout_linked',
'id_agent',
'type'));
if ($result === false)
return VISUAL_MAP_STATUS_NORMAL;
foreach ($result as $data) {
switch ($data['type']) {
case GROUP_ITEM:
if ($data["id_layout_linked"] == 0) {
$group_status = groups_get_status($data['id_group']);
switch ($group_status) {
case AGENT_STATUS_ALERT_FIRED:
$status = VISUAL_MAP_STATUS_CRITICAL_ALERT;
break;
case AGENT_STATUS_CRITICAL:
$status = VISUAL_MAP_STATUS_CRITICAL_BAD;
break;
case AGENT_STATUS_WARNING:
$status = VISUAL_MAP_STATUS_WARNING;
break;
case AGENT_STATUS_UNKNOWN:
$status = VISUAL_MAP_STATUS_UNKNOWN;
break;
case AGENT_STATUS_NORMAL:
default:
$status = VISUAL_MAP_STATUS_NORMAL;
break;
}
}
else {
$status = visual_map_get_layout_status(
$data["id_layout_linked"], $depth);
}
break;
default:
if (($data["id_layout_linked"] == 0 &&
$data["id_agente_modulo"] == 0 &&
$data["id_agent"] == 0) ||
$data['type'] != 0)
continue;
// Other Layout (Recursive!)
if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) {
$status = visual_map_get_layout_status($data["id_layout_linked"], $depth);
}
// Module
elseif ($data["id_agente_modulo"] != 0) {
$status = modules_get_agentmodule_status($data["id_agente_modulo"]);
}
// Agent
else {
//--------------------------------------------------
// ADDED NO CHECK ACL FOR AVOID CHECK TAGS THAT
// MAKE VERY SLOW THE VISUALMAPS WITH ACL TAGS
//--------------------------------------------------
$status = agents_get_status($data["id_agent"], true);
}
break;
}
if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD)
return VISUAL_MAP_STATUS_CRITICAL_BAD;
if ($status > $temp_total)
$temp_total = $status;
}
return $temp_total;
}
/**
* Make a text for the parent select, when the label is not empty put this for
* the return text. Instead for the empty labels make the text with next form
* (