pandorafms/pandora_console/operation/search_graphs.php

85 lines
2.4 KiB
PHP
Raw Normal View History

<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
include_once('include/functions_custom_graphs.php');
$searchGraphs = check_acl($config["id_user"], 0, "IR");
$graphs = false;
if ($searchGraphs) {
//Check ACL
$usergraphs = get_user_custom_graphs($config['id_user'], true);
$usergraphs_id = array_keys($usergraphs);
if(!$usergraphs_id){
$graphs_condition = " AND 1<>1";
}else {
$graphs_condition = " AND id_graph IN (".implode(',',$usergraphs_id).")";
}
$sql = "SELECT id_graph, name, description FROM tgraph WHERE (name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%')".$graphs_condition.
" LIMIT " . $config['block_size'] . " OFFSET " . get_parameter ('offset',0);
$graphs = process_sql($sql);
if($graphs !== false) {
$sql = "SELECT COUNT(id_graph) AS count FROM tgraph WHERE name LIKE '%" . $stringSearchSQL . "%' OR description LIKE '%" . $stringSearchSQL . "%'";
$totalGraphs = get_db_row_sql($sql);
$totalGraphs = $totalGraphs['count'];
}
}
if ($graphs === false) {
echo "<br><div class='nf'>" . __("Zero results found") . "</div>\n";
}
else {
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = "98%";
$table->class = "databox";
$table->head = array ();
$table->head[0] = __('Graph name');
$table->head[1] = __('Description');
$table->data = array ();
foreach ($graphs as $graph) {
array_push($table->data, array(
"<a href='?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=" .
$graph['id_graph'] . "'>" . $graph['name'] . "</a>",
$graph['description']
));
}
echo "<br />";pagination ($totalGraphs);
print_table ($table); unset($table);
pagination ($totalGraphs);
}
switch ($searchTab) {
case 'agents':
require_once('search_agents.php');
break;
case 'users':
require_once('search_users.php');
break;
case 'alerts':
require_once('search_alerts.php');
break;
}
?>