2009-01-30 Esteban Sanchez <estebans@artica.es>

* godmode/agentes/alert_manager.php: Fixed the page title. Show the
	right latest value in non-numeric modules. jQuery selectors fixed to
	work with many alerts.

	* extensions/update_manager/load_updatemanager.php: Fixed setup error
	messages.

	* include/functions_db.php: Added get_agent_module(). Added filter
	paremeter to get_agent_modules(). return_value_agent_module() renamed
	to get_agent_module_last_value() and do not transform to integer.
	Removed useless get_agent_modules_count().



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1414 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2009-01-30 12:48:08 +00:00
parent 5336f5a808
commit cb185df47f
4 changed files with 88 additions and 47 deletions

View File

@ -1,3 +1,17 @@
2009-01-30 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Fixed the page title. Show the
right latest value in non-numeric modules. jQuery selectors fixed to
work with many alerts.
* extensions/update_manager/load_updatemanager.php: Fixed setup error
messages.
* include/functions_db.php: Added get_agent_module(). Added filter
paremeter to get_agent_modules(). return_value_agent_module() renamed
to get_agent_module_last_value() and do not transform to integer.
Removed useless get_agent_modules_count().
2009-01-30 Jorge Gonzalez <jorgegonz@svn.gnome.org>
* include/help/en/help_alert-matches.php,
@ -44,7 +58,6 @@
include/languages/pt_BR.mo, include/languages/es.mo: Updated
translations.
>>>>>>> .r1409
2009-01-28 Esteban Sanchez <estebans@artica.es>
* godmode/alerts/configure_alert_template.php: Removed a javascript

View File

@ -33,14 +33,14 @@ require_once ('lib/libupdate_manager.php');
function get_user_key ($settings) {
if ($settings->customer_key != FREE_USER) {
if (! file_exists ($settings->keygen_path)) {
echo '<h3 class="err">';
echo '<h3 class="error">';
echo __('Keygen file does not exists');
echo '</h3>';
return '';
}
if (! is_executable ($settings->keygen_path)) {
echo '<h3 class="err">';
echo '<h3 class="error">';
echo __('Keygen file is not executable');
echo '</h3>';

View File

@ -106,7 +106,7 @@ if ($disable_alert) {
$modules = get_agent_modules ($id_agente,
array ('id_tipo_modulo', 'nombre', 'id_agente'));
echo "<h3>".__('Modules defined')."</h3>";
echo "<h3>".__('Alerts defined')."</h3>";
$table->class = 'databox_color modules';
$table->cellspacing = '0';
@ -125,17 +125,22 @@ $table_alerts->style = array ();
$table_alerts->style[0] = 'vertical-align: top';
$table_alerts->style[1] = 'vertical-align: top';
foreach ($modules as $id_agent_module => $module) {
$last_data = return_value_agent_module ($id_agent_module);
$last_data = get_agent_module_last_value ($id_agent_module);
if ($last_data === false)
$last_data = '<em>'.__('N/A').'</em>';
$table->data[0][0] = '<span>'.$module['nombre'].'</span>';
$table->data[0][0] = '<span><strong>Module</strong>: '.$module['nombre'].'</span>';
$table->data[0][0] .= '<div class="actions left" style="visibility: hidden;">';
$table->data[0][0] .= '<span class="module_values" style="float: right;">';
$table->data[0][0] .= '<em>'.__('Latest value').'</em>: ';
$table->data[0][0] .= $last_data;
if ($last_data == '')
$table->data[0][0] .= '<em>'.__('Empty').'</emp>';
elseif (is_numeric ($last_data))
$table->data[0][0] .= format_numeric ($last_data);
else
$table->data[0][0] .= $last_data;
$table->data[0][0] .= '</span>';
$table->data[0][0] .= '</div>';
$table->data[0][0] .= '<div class="actions right" style="visibility: hidden;">';
@ -158,7 +163,7 @@ foreach ($modules as $id_agent_module => $module) {
$table->rowstyle[1] = 'display: none';
} else {
$table->data[1][0] = '<h4 class="left" style="clear: left">';
$table->data[1][0] .= __('Alerts');
$table->data[1][0] .= __('Alerts assigned');
$table->data[1][0] .= '</h4>';
$table->rowstyle[1] = '';
}
@ -394,7 +399,7 @@ $(document).ready (function () {
return true;
});
$("input#image-disable").attr ("title", "<?php echo __('Disable')?>")
$("input[name=disable]").attr ("title", "<?php echo __('Disable')?>")
.hover (function () {
$(this).attr ("src", "images/lightbulb_off.png");
},
@ -402,7 +407,7 @@ $(document).ready (function () {
$(this).attr ("src", "images/lightbulb.png");
}
);
$("input#image-enable").attr ("title", "<?php echo __('Enable')?>")
$("input[name=enable]").attr ("title", "<?php echo __('Enable')?>")
.hover (function () {
$(this).attr ("src", "images/lightbulb.png");
},

View File

@ -314,23 +314,67 @@ function get_group_agents ($id_group = 0, $disabled = false, $case = "lower") {
return ($agents);
}
/**
* Get a singlemodule in an agent.
*
* @param mixed Agent id to get modules. It can also be an array of agent id's.
*
* @return array An array with all modules in the agent.
* If multiple rows are selected, they will be in an array
*/
function get_agent_module ($id_agent_module) {
return get_db_row ('tagente_modulo', 'id_agente_modulo', (int) $id_agent_module);
}
/**
* Get all the modules in an agent. If an empty list is passed it will select all
*
* @param mixed Agent id to get modules. It can also be an array of agent id's.
* @param mixed Array, comma delimited list or singular value of rows to
* select. If nothing is specified, nombre will be selected.
* @param mixed Aditional filters to the modules. It can be an indexed array
* (keys would be the field name and value the expected value, and would be
* joined with an AND operator) or a string, including any SQL clause (without
* the WHERE keyword). Example:
<code>
Both are similars:
$modules = get_agent_modules ($id_agent, false, array ('disabled', 0));
$modules = get_agent_modules ($id_agent, false, 'disabled = 0');
Both are similars:
$modules = get_agent_modules ($id_agent, '*', array ('disabled' => 0, 'history_data' => 0));
$modules = get_agent_modules ($id_agent, '*', 'disabled = 0 AND history_data = 0');
</code>
*
* @return array An array with all modules in the agent.
* If multiple rows are selected, they will be in an array
*/
function get_agent_modules ($id_agent, $details = false) {
function get_agent_modules ($id_agent, $details = false, $filter = false) {
$id_agent = safe_int ($id_agent, 1);
if (empty ($id_agent)) {
$filter = '';
$where = '';
if (! empty ($id_agent)) {
} else {
$filter = sprintf (' WHERE id_agente IN (%s)', implode (",", (array) $id_agent));
$where = sprintf (' WHERE id_agente IN (%s)', implode (",", (array) $id_agent));
}
if (! empty ($filter)) {
if ($where != '') {
$where .= ' AND ';
} else {
$where .= ' WHERE ';
}
if (is_array ($filter)) {
$fields = array ();
foreach ($filter as $field => $value) {
array_push ($fields, $field.'='.$value);
}
$where .= implode (' AND ', $fields);
} else {
$where .= $filter;
}
}
if (empty ($details)) {
@ -344,7 +388,7 @@ function get_agent_modules ($id_agent, $details = false) {
%s
ORDER BY nombre',
implode (",", (array) $details),
$filter);
$where);
$result = get_db_all_rows_sql ($sql);
if (empty ($result)) {
@ -362,6 +406,7 @@ function get_agent_modules ($id_agent, $details = false) {
}
return $modules;
}
/**
* Get a list of the reports the user can view.
*
@ -1561,12 +1606,12 @@ function get_db_all_fields_in_table ($table, $field = '', $condition = '', $orde
* values. Example code:
*
* <code>
* $values = array ();
* $values['name'] = "Name";
* $values['description'] = "Long description";
* $sql = 'UPDATE table SET '.format_array_to_update_sql ($values).' WHERE id=1';
* echo $sql;
* </code>
$values = array ();
$values['name'] = "Name";
$values['description'] = "Long description";
$sql = 'UPDATE table SET '.format_array_to_update_sql ($values).' WHERE id=1';
echo $sql;
</code>
* Will return:
* <code>
* UPDATE table SET `name` = "Name", `description` = "Long description" WHERE id=1
@ -1687,9 +1732,9 @@ function return_status_layout ($id_layout = 0) {
*
* @return int a numerically formatted value
*/
function return_value_agent_module ($id_agentmodule) {
return format_numeric (get_db_value ('datos', 'tagente_estado',
'id_agente_modulo', $id_agentmodule));
function get_agent_module_last_value ($id_agentmodule) {
return get_db_value ('datos', 'tagente_estado',
'id_agente_modulo', $id_agentmodule);
}
/**
@ -2270,28 +2315,6 @@ function get_server_info ($id_server = -1) {
return $return;
}
/**
* Get the number of all agent modules in the database
*
* @param mixed Array of integers with agent(s) id or a single agent id. Default
* value will select all.
*
* @return int The number of agent modules
*/
function get_agent_modules_count ($id_agent = 0) {
//Make sure we're all int's and filter out bad stuff
$id_agent = safe_int ($id_agent, 1);
if (empty ($id_agent)) {
//If the array proved empty or the agent is less than 1 (eg. -1)
$filter = '';
} else {
$filter = sprintf (" WHERE id_agente IN (%s)", implode (",", (array) $id_agent));
}
return (int) get_db_sql ("SELECT COUNT(*) FROM tagente_modulo".$filter);
}
/**
* This function gets the agent group for a given agent module
*