2009-07-22 Miguel de Dios <miguel.dedios@artica.es>

* general/header.php, images/lupa_15x15.png, include/functions_html.php
	include/styles/pandora.css, operation/search_results.php: add global
	search bar in the header for searching Agents, Maps, Reports, Graphs,
	Alerts and Users...if you user have access level...

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1814 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2009-07-22 15:26:31 +00:00
parent d642604f59
commit 6ba8073a0b
6 changed files with 471 additions and 93 deletions

View File

@ -1,3 +1,10 @@
2009-07-22 Miguel de Dios <miguel.dedios@artica.es>
* general/header.php, images/lupa_15x15.png, include/functions_html.php
include/styles/pandora.css, operation/search_results.php: add global
search bar in the header for searching Agents, Maps, Reports, Graphs,
Alerts and Users...if you user have access level...
2009-07-20 Miguel de Dios <miguel.dedios@artica.es>
* operation/agentes/tactical.php, operation/agentes/status_monitor.php: add

View File

@ -14,99 +14,150 @@
require_once ("include/functions_messages.php");
//First column (logo)
echo '<table width="100%" cellpadding="0" cellspacing="0" style="margin:0px; padding:0px;" border="0"><tr><td>';
echo '<div id="pandora_logo_header"></div>';
// First column (identifier)
echo '<td width="20%"><img src="images/user_'.((is_user_admin ($config["id_user"]) == 1) ? 'suit' : 'green' ).'.png" class="bot" alt="user" />&nbsp;'.'<a href="index.php?sec=usuarios&amp;sec2=operation/users/user_edit" class="white">'.__('You are').' [<b>'.$config["id_user"].'</b>]</a> ';
$msg_cnt = get_message_count ($config["id_user"]);
if ($msg_cnt > 0) {
echo '<div id="dialog_messages" style="display: none"></div>';
?>
<table width="100%" cellpadding="0" cellspacing="0" style="margin:0px; padding:0px;" border="0">
<tr>
<td><div id="pandora_logo_header"></div></td>
<td width="20%">
<img src="images/user_<?=((is_user_admin ($config["id_user"]) == 1) ? 'suit' : 'green' );?>.png" class="bot" alt="user" />
<a href="index.php?sec=usuarios&sec2=operation/users/user_edit" class="white"><?=__('You are');?> [<b><?=$config["id_user"];?></b>]</a>
<?php
$msg_cnt = get_message_count ($config["id_user"]);
if ($msg_cnt > 0) {
echo '<div id="dialog_messages" style="display: none"></div>';
require_css_file ('dialog');
require_jquery_file ('ui.core');
require_jquery_file ('ui.dialog');
echo '<a href="ajax.php?page=operation/messages/message" id="show_messages_dialog">';
print_image ("images/email.png", false,
array ("title" => __('You have %d unread message(s)', $msg_cnt),
"id" => "yougotmail",
"class" => "bot"));
echo '</a>';
}
//First column, second row (logout button)
echo '<br /><br />';
echo '<a class="white_bold" href="index.php?bye=bye"><img src="images/log-out.png" alt="logout" class="bot" />&nbsp;'. __('Logout').'</a>';
// Second column (link to main page)
echo '</td><td width="20%">';
echo '<a class="white_bold" href="index.php?sec=main"><img src="images/information.png" alt="info" class="bot" />&nbsp;'.__('General information').'</a>';
//Second column, second row (System up/down)
echo '<br /><br />';
echo '<a class="white_bold" href="index.php?sec=estado_server&amp;sec2=operation/servers/view_server&amp;refr=60">';
$servers["all"] = (int) get_db_value ('COUNT(id_server)','tserver');
$servers["up"] = (int) check_server_status ();
$servers["down"] = $servers["all"] - $servers["up"];
if ($servers["up"] == 0) {
//All Servers down or no servers at all
echo '<img src="images/cross.png" alt="cross" class="bot" />&nbsp;'.__('All systems').': '.__('Down');
} elseif ($servers["down"] != 0) {
//Some servers down
echo '<img src="images/error.png" alt="error" class="bot" />&nbsp;'.$servers["down"].' '.__('servers down');
} else {
//All servers up
echo '<img src="images/ok.png" alt="ok" class="bot" />&nbsp;'.__('All systems').': '.__('Ready');
}
unset ($servers); // Since this is the header, we don't like to trickle down variables.
echo "</a>";
// Third column
// Autorefresh
echo '</td><td width="20%">';
$ignored_params = array ('agent_config' => false, 'code' => false);
if ($config["refr"]) {
$ignored_params['refr'] = 0;
echo '<a id="autorefresh" class="white_grey_bold" href="'.get_url_refresh ($ignored_params).'"><img src="images/page_refresh.png" class="bot" alt="lightning" />&nbsp;'. __('Autorefresh');
echo ' (<span id="refrcounter">'.date ("i:s", $config["refr"]).'</span>)';
echo '</a>';
} else {
$ignored_params['refr'] = '';
echo '<a id="autorefresh" class="white_bold" href="'.get_url_refresh ($ignored_params).'"><img src="images/page_refresh.png" class="bot" alt="lightning" />&nbsp;'.__('Autorefresh').'</a>';
$values = array ('5' => '5 '.__('seconds'),
'10' => '10 '.__('seconds'),
'15' => '15 '.__('seconds'),
'30' => '30 '.__('seconds'),
'60' => '1 '.__('minute'),
'120' => '2 '.__('minutes'),
'300' => '5 '.__('minutes'),
'900' => '15 '.__('minutes'),
'1800' => '30 '.__('minutes'),
'3600' => '1 '.__('hour'));
echo '<span id="combo_refr" style="display: none">';
print_select ($values, 'ref', '', '', __('Select'), '0', false, false, false);
unset ($values);
echo '</span>';
}
//Events
echo '<br /><br />';
echo '<a class="white_bold" href="index.php?sec=eventos&amp;sec2=operation/events/events&amp;refr=5"><img src="images/lightning_go.png" alt="lightning_go" class="bot" />&nbsp;'.__('Events').'</a>';
// Styled text
echo '</td><td width="20%"><div id="head_r"><span id="logo_text1">Pandora</span> <span id="logo_text2">FMS</span></div>';
/* Enterprise support */
if (file_exists (ENTERPRISE_DIR."/load_enterprise.php"))
echo '<div id="logo_text3">Enterprise</div>';
else
echo '<div id="logo_text3">OpenSource</div>';
echo '</td></tr></table>';
require_css_file ('dialog');
require_jquery_file ('ui.core');
require_jquery_file ('ui.dialog');
echo '<a href="ajax.php?page=operation/messages/message" id="show_messages_dialog">';
print_image ("images/email.png", false,
array ("title" => __('You have %d unread message(s)', $msg_cnt), "id" => "yougotmail", "class" => "bot"));
echo '</a>';
}
?>
<br />
<br />
<a class="white_bold" href="index.php?bye=bye"><img src="images/log-out.png" alt="<?=__('Logout');?>" class="bot" /> <?=__('Logout');?></a>
</td>
<td width="20%">
<a class="white_bold" href="index.php?sec=main"><img src="images/information.png" alt="info" class="bot" /><?=__('General information');?></a>
<br />
<br />
<a class="white_bold" href="index.php?sec=estado_server&sec2=operation/servers/view_server&refr=60">
<?php
$servers["all"] = (int) get_db_value ('COUNT(id_server)','tserver');
$servers["up"] = (int) check_server_status ();
$servers["down"] = $servers["all"] - $servers["up"];
if ($servers["up"] == 0) {
//All Servers down or no servers at all
echo '<img src="images/cross.png" alt="cross" class="bot" />&nbsp;'.__('All systems').': '.__('Down');
}
elseif ($servers["down"] != 0) {
//Some servers down
echo '<img src="images/error.png" alt="error" class="bot" />&nbsp;'.$servers["down"].' '.__('servers down');
}
else {
//All servers up
echo '<img src="images/ok.png" alt="ok" class="bot" />&nbsp;'.__('All systems').': '.__('Ready');
}
unset ($servers); // Since this is the header, we don't like to trickle down variables.
?>
</a>
</td>
<td width="20%">
<?php
// Autorefresh
$ignored_params = array ('agent_config' => false, 'code' => false);
if ($config["refr"]) {
$ignored_params['refr'] = 0;
echo '<a id="autorefresh" class="white_grey_bold" href="'.get_url_refresh ($ignored_params).'"><img src="images/page_refresh.png" class="bot" alt="lightning" />&nbsp;'. __('Autorefresh');
echo ' (<span id="refrcounter">'.date ("i:s", $config["refr"]).'</span>)';
echo '</a>';
}
else {
$ignored_params['refr'] = '';
echo '<a id="autorefresh" class="white_bold" href="'.get_url_refresh ($ignored_params).'"><img src="images/page_refresh.png" class="bot" alt="lightning" />&nbsp;'.__('Autorefresh').'</a>';
$values = array (
'5' => '5 '.__('seconds'),
'10' => '10 '.__('seconds'),
'15' => '15 '.__('seconds'),
'30' => '30 '.__('seconds'),
'60' => '1 '.__('minute'),
'120' => '2 '.__('minutes'),
'300' => '5 '.__('minutes'),
'900' => '15 '.__('minutes'),
'1800' => '30 '.__('minutes'),
'3600' => '1 '.__('hour'));
echo '<span id="combo_refr" style="display: none">';
print_select ($values, 'ref', '', '', __('Select'), '0', false, false, false);
unset ($values);
echo '</span>';
}
?>
<br />
<br />
<a class="white_bold" href="index.php?sec=eventos&sec2=operation/events/events&refr=5">
<img src="images/lightning_go.png" alt="lightning_go" class="bot" /> <?=__('Events');?>
</a>
</td>
<td width="20%">
<div id="head_r"><span id="logo_text1">Pandora</span> <span id="logo_text2">FMS</span></div>
<?php
if (file_exists (ENTERPRISE_DIR."/load_enterprise.php"))
echo '<div id="logo_text3">Enterprise</div>';
else
echo '<div id="logo_text3">OpenSource</div>';
?>
</td>
</tr>
<tr>
<td colspan="5" style="padding: 0; height: 20px;">
<form method="get" style="" valign="middle">
<script type="text/javascript" language="javascript">
var fieldKeyWordEmpty = true;
</script>
<input type="text" id="keywords" name="keywords"
<?php
if (!isset($config['search_keywords']))
echo "value='" . __("Enter keywords to search") . "'";
else if (strlen($config['search_keywords']) == 0)
echo "value='" . __("Enter keywords to search") . "'";
else echo "value='" . $config['search_keywords'] . "'";
?>
onfocus="javascript: if (fieldKeyWordEmpty) $('#keywords').val('');"
size="119" style="background: white url('images/lupa_15x15.png') no-repeat left; padding: 0; padding-left:15px; margin: 0; width: 70%; margin-left: 2px;" />
<?php
if (isset($config['search_category']))
$selected = $config['search_category'];
else
$selected = 'all';
$values = array (
//'adsf' => ((strlen(__("Search")) > 12) ? (substr(__("0123456789AB"), 0, 12) . "&hellip;") : __("0123456789AB")),
'all' => ((strlen(__("All")) > 12) ? (substr(__("All"), 0, 12) . "&hellip;") : __("All")),
'users' => ((strlen(__("Users")) > 12) ? (substr(__("Users"), 0, 12) . "&hellip;") : __("Users")),
'alerts' => ((strlen(__("Alerts")) > 12) ? (substr(__("Alerts"), 0, 12) . "&hellip;") : __("Alerts")),
'reports' => ((strlen(__("Reports")) > 12) ? (substr(__("Reports"), 0, 12) . "&hellip;") : __("Reports"))
);
//INI SECURITY ACL
if (check_acl ($config['id_user'], 0, "AW") || check_acl ($config['id_user'], 0, "AR")) {
$values['agents'] = ((strlen(__("Agents")) > 12) ? (substr(__("Agents"), 0, 12) . "&hellip;") : __("Agents"));
$values['graphs'] = ((strlen(__("Graphs")) > 12) ? (substr(__("Graphs"), 0, 12) . "&hellip;") : __("Graphs"));
}
if (give_acl ($config["id_user"], 0, "AR"))
$values['maps'] = ((strlen(__("Maps")) > 12) ? (substr(__("Maps"), 0, 12) . "&hellip;") : __("Maps"));;
//END SECURITY ACL
print_select_style ($values, 'search_category', $selected, "min-width: 12em;");
?>
<input id="submit-srcbutton" name="head_search_keywords"
value="<?=((strlen(__("Search")) > 12) ? (substr(__("0123456789ABCD"), 0, 12) . "&hellip;") : __("Search")); ?>"
class="sub" type="submit" style="min-width: 12em; height: 23px;" />
</form>
</td>
</tr>
</table>
<?php
require_jquery_file ('countdown');
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

View File

@ -15,6 +15,96 @@
// GNU General Public License for more details.
/**
* Prints an array of fields in a popup menu of a form.
*
* Based on choose_from_menu() from Moodle
*
* @param array Array with dropdown values. Example: $fields["value"] = "label"
* @param string Select form name
* @param variant Current selected value. Can be a single value or an
* array of selected values (in combination with multiple)
* @param string Javascript onChange code.
* @param string Label when nothing is selected.
* @param variant Value when nothing is selected
* @param bool Whether to return an output string or echo now (optional, echo by default).
* @param bool Set the input to allow multiple selections (optional, single selection by default).
* @param bool Whether to sort the options or not (optional, unsorted by default).
*
* @return string HTML code if return parameter is true.
*/
function print_select_style ($fields, $name, $selected = '', $style='', $script = '', $nothing = '', $nothing_value = 0, $return = false, $multiple = false, $sort = true, $class = '', $disabled = false) {
$output = "\n";
static $idcounter = array ();
//If duplicate names exist, it will start numbering. Otherwise it won't
if (isset ($idcounter[$name])) {
$idcounter[$name]++;
} else {
$idcounter[$name] = 0;
}
$id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : ''));
$attributes = "";
if (!empty ($script)) {
$attributes .= ' onchange="'.$script.'"';
}
if (!empty ($multiple)) {
$attributes .= ' multiple="multiple" size="10"';
}
if (!empty ($class)) {
$attributes .= ' class="'.$class.'"';
}
if (!empty ($disabled)) {
$attributes .= ' disabled="disabled"';
}
$output .= '<select style="'.$style.'" id="'.$id.'" name="'.$name.'"'.$attributes.'>';
if ($nothing != '' || empty ($fields)) {
if ($nothing == '') {
$nothing = __('None');
}
$output .= '<option value="'.$nothing_value.'"';
if ($nothing_value == $selected) {
$output .= ' selected="selected"';
}
$output .= '>'.$nothing.'</option>';
}
if (!empty ($fields)) {
if ($sort !== false) {
asort ($fields);
}
foreach ($fields as $value => $label) {
$output .= '<option value="'.$value.'"';
if (is_array ($selected) && in_array ($value, $selected)) {
$output .= ' selected="selected"';
} elseif (is_numeric ($value) && is_numeric ($selected) && $value == $selected) {
//This fixes string ($value) to int ($selected) comparisons
$output .= ' selected="selected"';
} elseif ($value === $selected) {
//Needs type comparison otherwise if $selected = 0 and $value = "string" this would evaluate to true
$output .= ' selected="selected"';
}
if ($label === '') {
$output .= '>'.$value."</option>";
} else {
$output .= '>'.$label."</option>";
}
}
}
$output .= "</select>";
if ($return)
return $output;
echo $output;
}
/**
* Prints an array of fields in a popup menu of a form.

View File

@ -209,7 +209,7 @@ div#menu {
div#head {
font-size: 8pt;
width: 960px;
height: 60px;
height: 87px;/*84px;*/ /*height: 60px;*/
background: url(../../images/header.jpg);
border-bottom: solid 2px #555;
}

View File

@ -0,0 +1,230 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 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.
require ("include/config.php");
$searchGraphs = $searchAgents = (check_acl ($config['id_user'], 0, "AW") || check_acl ($config['id_user'], 0, "AR"));
$linkEditUser = check_acl ($config['id_user'], 0, "UM");
$searchMaps = give_acl ($config["id_user"], 0, "AR");
$arrayKeywords = explode(' ', $config['search_keywords']);
$temp = array();
foreach($arrayKeywords as $keyword)
array_push($temp, "%" . $keyword . "%");
$stringSearchSQL = implode(" ",$temp);
if ($config['search_category'] == "all") $searchTab = "agents";
else $searchTab = $config['search_category'];
//INI SECURITY ACL
if ((!$searchAgents) && ($searchTab == 'agents')) $searchTab = "users";
if ((!$searchGraphs) && ($searchTab == 'graphs')) $searchTab = "users";
if ((!$searchMaps) && ($searchTab == 'maps')) $searchTab = "users";
//END SECURITY ACL
$agents = false;
if ($searchTab == 'agents') {
if ($searchAgents) {
$sql = "SELECT id_agente, tagente.nombre
FROM tagente
INNER JOIN tgrupo
ON tgrupo.id_grupo = tagente.id_grupo
WHERE tagente.nombre LIKE '%" . $stringSearchSQL . "%' OR
tgrupo.nombre LIKE '%" . $stringSearchSQL . "%'";
$agents = process_sql($sql);
}
}
$users = false;
if ($searchTab == 'users') {
$sql = "SELECT id_user, fullname, firstname, lastname, middlename, email FROM tusuario
WHERE fullname LIKE '%" . $stringSearchSQL . "%' OR
firstname LIKE '%" . $stringSearchSQL . "%' OR
lastname LIKE '%" . $stringSearchSQL . "%' OR
middlename LIKE '%" . $stringSearchSQL . "%' OR
email LIKE '%" . $stringSearchSQL . "%'";
$users = process_sql($sql);
}
$alerts = false;
if ($searchTab == 'alerts') {
//TODO: NOT IS CORRECT QUERY...TUNE AND CLEAN
$sql = "SELECT *
FROM
(SELECT id,
(SELECT t.nombre
FROM tagente_modulo AS t WHERE t.id_agente_modulo = id_agent_module AND t.nombre LIKE '%" . $stringSearchSQL . "%') AS agent_name ,
(SELECT t.name FROM talert_templates AS t WHERE t.id = id_alert_template AND t.name LIKE '%" . $stringSearchSQL . "%') AS template_name,
(SELECT (SELECT t1.name FROM talert_actions AS t1 WHERE t1.id = t2.id_alert_action AND t1.name LIKE '%" . $stringSearchSQL . "%')
FROM talert_template_module_actions AS t2
WHERE t2.id_alert_template_module = id) AS action_name
FROM talert_template_modules
) AS t
WHERE t.agent_name IS NOT NULL
OR t.template_name IS NOT NULL
OR t.action_name IS NOT NULL";
$alerts = process_sql($sql);
}
$graphs = false;
if ($searchTab == 'graphs') {
if ($searchGraphs) {
$sql = "SELECT id_graph, name FROM tgraph WHERE name LIKE '%" . $stringSearchSQL . "%'";
$graphs = process_sql($sql);
}
}
$reports = false;
if (($config['search_category'] == 'all') || ($config['search_category'] == 'reports')) {
$sql = "SELECT id_report, name FROM treport WHERE name LIKE '%" . $stringSearchSQL . "%'";
$reports = process_sql($sql);
}
$maps = false;
if (($config['search_category'] == 'all') || ($config['search_category'] == 'maps')) {
if ($searchMaps) {
$sql = "SELECT id, name FROM tlayout WHERE name LIKE '%" . $stringSearchSQL . "%'";
$maps = process_sql($sql);
}
}
echo "
<div id='menu_tab_frame_view'>
<div id='menu_tab_left'>
<ul class='mn'>
<li class='view'>" . __('Search') . ": \"" . $config['search_keywords'] . "\"</li>
</ul>
</div>
<div id='menu_tab'>
<ul class='mn'>";
if ($searchAgents)
{
if ($searchTab == "agents")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=agents&keywords=".$config['search_keywords']."&head_search_keywords=Search'>".__('Agents')." </a>";
echo "</li>";
}
if ($searchTab == "users")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=users&keywords=".$config['search_keywords']."&head_search_keywords=Search'>".__('Users')." </a>";
echo "</li>";
if ($searchTab == "alerts")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=alerts&keywords=".$config['search_keywords']."&head_search_keywords=Search'>".__('Alerts')." </a>";
echo "</li>";
if ($searchGraphs)
{
if ($searchTab == "graphs")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=graphs&keywords=".$config['search_keywords']."&head_search_keywords=Search'>".__('Graphs')." </a>";
echo "</li>";
}
if ($searchTab == "reports")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=reports&keywords=".$config['search_keywords']."&head_search_keywords=Search'>".__('Reports')." </a>";
echo "</li>";
if ($searchMaps)
{
if ($searchTab == "maps")
echo "<li class='nomn_high'>";
else
echo "<li class='nomn'>";
echo "<a href='?search_category=maps&keywords=".$config['search_keywords']."&head_search_keywords=Search'>".__('Maps')." </a>";
echo "</li>";
}
echo "</ul>
</div>
</div>";
echo "<div style='height: 25px'> </div>";
if (($agents === false) && ($users === false) && ($alerts === false) && ($graphs === false)
&& ($reports === false) && ($maps === false)) {
echo "<h2>" . __("None results") . "</h2>\n";
}
else {
if ($agents !== false) {
echo "<ul>\n";
foreach ($agents as $agent) {
echo "<li><a href='?sec=estado&sec2=operation/agentes/ver_agente&id_agente=" . $agent['id_agente'] . "'>" . $agent['nombre'] . "</a></li>\n";
}
echo "</ul>\n";
}
if ($users !== false) {
echo "<ul>\n";
foreach ($users as $user) {
if ($linkEditUser)
echo "<li><a href='?sec=gusuarios&sec2=godmode/users/configure_user&id=" .
$user['id_user'] . "'>" . $user['fullname'] . "</a> (<a href='mailto:" . $user['email'] . "'>" . $user['email'] . "</a>)</li>\n";
else
echo "<li>" . $user['fullname'] . " (<a href='mailto:" . $user['email'] . "'>" . $user['email'] . "</a>)</li>\n";
}
echo "</ul>\n";
}
if ($alerts !== false) {
echo "<ul>\n";
foreach ($alerts as $alert) {
echo "<li>" . $alert['agent_name'] . " - " . $alert['template_name'] . " - " . $alert['action_name'] . "</li>\n";
}
echo "</ul>\n";
}
if ($graphs !== false) {
echo "<ul>\n";
foreach ($graphs as $graph) {
echo "<li><a href='?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=" .
$graph['id_graph'] . "'>" . $graph['name'] . "</a></li>\n";
}
echo "</ul>\n";
}
if ($reports !== false) {
echo "<ul>\n";
foreach ($reports as $report) {
echo "<li>" . $report['name'] . "</li>\n";
}
echo "</ul>\n";
}
if ($maps !== false) {
//echo "<h3 style='border-bottom: 1px #778866 solid;'>" . __("Maps") . "</h3>\n";
echo "<ul>\n";
foreach ($maps as $map) {
echo "<li><a href='?sec=visualc&sec2=operation/visual_console/render_view&id=" .
$map['id'] . "'>" . $map['name'] . "</a></li>\n";
}
echo "</ul>\n";
}
}
?>