2010-04-22 Sergio Martin <sergio.martin@artica.es>

* include/functions_ui.php
       include/functions_agents.php
       include/functions_db.php: Change the way of validate
        the All group. Now the group All has id_group = 0
        and is not on the database

       * extensions/module_groups.php: Remove the All 
        group row from the table. Inprove the table style

       * operation/agentes/status_monitor.php
       operation/agentes/alerts_status.php
       operation/agentes/estado_agente.php
       operation/agentes/exportdata.php
       operation/agentes/networkmap.php 
       godmode/agentes/modificar_agente.php
       godmode/agentes/planned_downtime.php: Changed the
        All group on combos from 1 to 0



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2588 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2010-04-22 16:51:23 +00:00
parent 43926fd022
commit 107599d6c3
12 changed files with 88 additions and 51 deletions

View File

@ -1,3 +1,23 @@
2010-04-22 Sergio Martin <sergio.martin@artica.es>
* include/functions_ui.php
include/functions_agents.php
include/functions_db.php: Change the way of validate
the All group. Now the group All has id_group = 0
and is not on the database
* extensions/module_groups.php: Remove the All
group row from the table. Inprove the table style
* operation/agentes/status_monitor.php
operation/agentes/alerts_status.php
operation/agentes/estado_agente.php
operation/agentes/exportdata.php
operation/agentes/networkmap.php
godmode/agentes/modificar_agente.php
godmode/agentes/planned_downtime.php: Changed the
All group on combos from 1 to 0
2010-04-22 Sergio Martin <sergio.martin@artica.es>
* godmode/groups/group_list.php: Added validation

View File

@ -43,7 +43,7 @@ function mainModuleGroups() {
echo "<p>" . __("This table shows in columns the modules group and in rows agents group. The cell shows all modules") . "</p>";
$agentGroups = get_user_groups ($config['id_user']);
$agentGroups = get_user_groups ($config['id_user'], "AR", false);
$modelGroups = get_all_model_groups();
array_walk($modelGroups, 'translate'); //Translate all head titles to language is set
@ -83,36 +83,37 @@ function mainModuleGroups() {
}
$color = 'transparent'; //Defaut color for cell
$font_color = '#ffffff'; //Default font color for cell
$font_color = '#000000'; //Default font color for cell
if ($count == 0) {
$color = '#babdb6'; //Grey when the cell for this model group and agent group hasn't modules.
$alinkStart = '';
$alinkEnd = '';
}
else {
$alinkStart = '<a href="index.php?sec=estado&sec2=operation/agentes/status_monitor&status=-1&ag_group=' . $idAgentGroup .
'&modulegroup=' . $idModelGroup . '".
style="color: ' . $font_color . '";>';
$alinkEnd = '</a>';
else {
if (array_key_exists(0,$states) && (count($states) == 1))
$color = '#8ae234'; //Green when the cell for this model group and agent has OK state all modules.
else {
if (array_key_exists(1,$states)) {
$color = '#cc0000'; //Red when the cell for this model group and agent has at least one module in critical state and the rest in any state.
$font_color = '#ffffff';
}
else
$color = '#fce94f'; //Yellow when the cell for this model group and agent has at least one in warning state and the rest in green state.
}
$alinkStart = '<a href="index.php?sec=estado&sec2=operation/agentes/status_monitor&status=-1&ag_group=' . $idAgentGroup .
'&modulegroup=' . $idModelGroup . '".
style="color: ' . $font_color . '; font-size: 18px;";>';
$alinkEnd = '</a>';
}
array_push($row,
'<div
style="background: ' . $color . ';
height: 15px;
height: 25px;
margin-left: auto; margin-right: auto;
text-align: center; padding-top: 5px;">
' . $alinkStart . $count . ' modules' . $alinkEnd . '</div>');
text-align: center; padding-top: 0px; font-size: 18px;">
' . $alinkStart . $count . $alinkEnd . '</div>');
}
array_push($tableData,$row);
}

View File

@ -67,16 +67,9 @@ if (isset($_POST["ag_group"])){
echo "<table cellpadding='4' cellspacing='4' class='databox' width=770><tr>";
echo "<td valign='top'>".__('Group')."</td>";
echo "<td valign='top'>";
echo "<select name='ag_group' onChange='javascript:this.form.submit();'
class='w130'>";
if ($ag_group > 1) {
echo "<option value='".$ag_group."'>".get_group_name ($ag_group).
"</option>";
}
//echo "<option value=1>".get_group_name (1)."</option>"; // Group all is always active
$mis_grupos = list_group ($config["id_user"]); //Print combo for groups and set an array with all groups
echo "</select>";
print_select (get_user_groups(), "ag_group", $ag_group, 'this.form.submit();', '', 0);
echo "<td valign='top'>
<noscript>
<input name='uptbutton' type='submit' class='sub upd' value='".__('Show')."'>
@ -115,7 +108,7 @@ if ($search != ""){
}
// Show only selected groups
if ($ag_group > 1) {
if ($ag_group > 0) {
$sql = sprintf ('SELECT COUNT(*)
FROM tagente
WHERE id_grupo = %d

View File

@ -27,7 +27,7 @@ if (! give_acl ($config['id_user'], 0, "AW")) {
//Initialize data
$id_agent = get_parameter ("id_agent");
$id_group = (int) get_parameter ("id_group", 1);
$id_group = (int) get_parameter ("id_group", 0);
$name = '';
$description = '';
$date_from = (string) get_parameter ('date_from', date ('Y-m-j'));
@ -187,8 +187,11 @@ if ($create_downtime || $update_downtime) {
// Show available agents to include into downtime
echo '<h3>'.__('Available agents').':</h3>';
$filter_group = get_parameter("filter_group", $result['id_group']);
$filter_cond = " AND id_grupo = $filter_group ";
$filter_group = get_parameter("filter_group", 0);
$filter_cond = '';
if($filter_group > 0)
$filter_cond = " AND id_grupo = $filter_group ";
$sql = sprintf ("SELECT tagente.id_agente, tagente.nombre, tagente.id_grupo FROM tagente WHERE tagente.id_agente NOT IN (SELECT tagente.id_agente FROM tagente, tplanned_downtime_agents WHERE tplanned_downtime_agents.id_agent = tagente.id_agente AND tplanned_downtime_agents.id_downtime = %d) AND disabled = 0 $filter_cond ORDER by tagente.nombre", $id_downtime);
$downtimes = get_db_all_rows_sql ($sql);
$data = array ();

View File

@ -133,7 +133,7 @@ function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = fa
}
if (($id_agent === false) && ($idGroup !== false)) {
if ($idGroup != 1) { //All group
if ($idGroup != 0) { //All group
$subQuery = 'SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 0 AND id_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = ' . $idGroup . ')';
}
else {
@ -217,7 +217,7 @@ function get_agent_alerts_compound ($id_agent = false, $filter = '', $options =
}
if (($id_agent === false) && ($idGroup !== false)) {
if ($idGroup != 1) { //All group
if ($idGroup != 0) { //All group
$subQuery = 'SELECT id_agente FROM tagente WHERE id_grupo = ' . $idGroup;
}
else {
@ -298,7 +298,7 @@ function get_agents ($filter = false, $fields = false, $access = 'AR') {
}
}
if (in_array (1, $filter['id_grupo'])) {
if (in_array (0, $filter['id_grupo'])) {
unset ($filter['id_grupo']);
}

View File

@ -171,7 +171,7 @@ function give_acl ($id_user, $id_group, $access) {
function safe_acl_group ($id_user, $id_groups, $access) {
if (!is_array ($id_groups) && check_acl ($id_user, $id_groups, $access)) {
/* Return all the user groups if it's the group All */
if ($id_groups == 1 || $id_groups == 0)
if ($id_groups == 0)
return array_keys (get_user_groups ($id_user, $access));
return array ($id_groups);
} elseif (!is_array ($id_groups)) {
@ -288,9 +288,7 @@ function get_profiles () {
function create_user_profile ($id_user, $id_profile = 1, $id_group = 1, $assignUser = false) {
global $config;
if (empty ($id_profile))
return false;
if (empty ($id_group))
if (empty ($id_profile) || $id_group < 0)
return false;
if (isset ($config["id_user"])) {
@ -400,7 +398,7 @@ function get_group_agents ($id_group = 0, $search = false, $case = "lower", $noA
if (is_array($id_group)) {
$search_sql = sprintf ('WHERE id_grupo IN (%s)', implode (",", $id_group));
}
else if (($id_group == 1) || ($id_group == 0)) { //All group
else if ($id_group == 0) { //All group
$search_sql = 'WHERE 1 = 1';
}
else {
@ -1371,13 +1369,13 @@ function get_user_groups ($id_user = false, $privilege = "AR", $returnAllGroup =
if (!$groups)
return $user_groups;
if ($returnAllGroup) //All group
$user_groups[0] = "All";
foreach ($groups as $group) {
if (! give_acl ($id_user, $group["id_grupo"], $privilege))
continue;
if ((!$returnAllGroup) && ($group["id_grupo"] == 1)) //All group
continue;
$user_groups[$group['id_grupo']] = $group['nombre'];
if (give_acl ($id_user, $group["id_grupo"], $privilege))
$user_groups[$group['id_grupo']] = $group['nombre'];
}
return $user_groups;
@ -2873,11 +2871,15 @@ function get_agent_group ($id_agent) {
* This function gets the group name for a given group id
*
* @param int The group id
* @param boolean $returnAllGroup Flag the return group, by default false.
*
* @return string The group name
*/
function get_group_name ($id_group) {
return (string) get_db_value ('nombre', 'tgrupo', 'id_grupo', (int) $id_group);
function get_group_name ($id_group, $returnAllGroup = false) {
if($id_group > 0)
return (string) get_db_value ('nombre', 'tgrupo', 'id_grupo', (int) $id_group);
elseif($returnAllGroup)
return "All";
}
/**
@ -3091,8 +3093,23 @@ function get_group_users ($id_group, $filter = false) {
if (! is_array ($filter))
$filter = array ();
$filter['id_grupo'] = (int) $id_group;
$result = get_db_all_rows_filter ("tusuario_perfil", $filter);
$resulta = array();
$resulta = get_db_all_rows_filter ("tusuario_perfil", $filter);
// The users of the group All (0) will be also returned
$filter['id_grupo'] = 0;
$resultb = array();
$resultb = get_db_all_rows_filter ("tusuario_perfil", $filter);
if($resulta == false && $resultb == false)
$result = false;
elseif($resulta == false)
$result = $resultb;
elseif($resultb == false)
$result = $resulta;
else
$result = array_merge($resulta,$resultb);
if ($result === false)
return array ();
//This removes stale users from the list. This can happen if switched to another auth scheme

View File

@ -200,7 +200,10 @@ function print_username ($username, $return = false) {
* @return string HTML code if return parameter is true.
*/
function print_group_icon ($id_group, $return = false, $path = "groups_small", $style='', $link = true) {
$icon = (string) get_db_value ('icon', 'tgrupo', 'id_grupo', (int) $id_group);
if($id_group > 0)
$icon = (string) get_db_value ('icon', 'tgrupo', 'id_grupo', (int) $id_group);
else
$icon = "world";
if (empty ($icon)) {
return "-";
@ -208,7 +211,7 @@ function print_group_icon ($id_group, $return = false, $path = "groups_small", $
$output = '';
if ($link) $output = '<a href="index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60&amp;group_id='.$id_group.'">';
$output .= '<img style="' . $style . '" class="bot" src="images/'.$path.'/'.$icon.'.png" alt="'.get_group_name ($id_group).'" title="'.get_group_name ($id_group).'" />';
$output .= '<img style="' . $style . '" class="bot" src="images/'.$path.'/'.$icon.'.png" alt="'.get_group_name ($id_group, true).'" title="'.get_group_name ($id_group, true).'" />';
if ($link) $output .= '</a>';
if (!$return)

View File

@ -26,7 +26,7 @@ $isFunctionPolicies = enterprise_include_once ('include/functions_policies.php')
$filter = get_parameter ("filter", "all_enabled");
$offset_simple = (int) get_parameter_get ("offset_simple", 0);
$offset_combined = (int) get_parameter_get("offset_combined", 0);
$id_group = (int) get_parameter ("ag_group", 1); //1 is the All group (selects all groups)
$id_group = (int) get_parameter ("ag_group", 0); //0 is the All group (selects all groups)
$free_search = get_parameter("free_search", '');
$sec2 = get_parameter_get ('sec2');

View File

@ -102,7 +102,7 @@ if ($search != ""){
}
// Show only selected groups
if ($group_id > 1) {
if ($group_id > 0) {
$groups = $group_id;
$agent_names = get_group_agents ($group_id, $filter, "upper");
// Not selected any specific group

View File

@ -71,7 +71,7 @@ print_page_header (__("Export data"), "images/bricks.png");
echo "<h2>".__('Pandora agents')." &raquo; ".__('Export data')."</h2>";
$group = get_parameter_post ('group', 1);
$group = get_parameter_post ('group', 0);
//$agent = get_parameter_post ('agent', 0);
$agentName = get_parameter_post ('agent', 0);
$agents = get_agents (array('nombre LIKE "' . $agentName . '"'), array ('id_agente'));
@ -302,7 +302,7 @@ if (!in_array ($agent, array_keys ($agents))) {
$table->data[1][1] = print_input_text_extended ('agent', get_agent_name ($agent), 'text-agent', '', 30, 100, false, '',
array('style' => 'background: url(images/lightning.png) no-repeat right;'), true)
. '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two characters to search") . '</span></a>';
//Module selector
$table->data[2][0] = '<b>'.__('Modules').'</b>';

View File

@ -67,7 +67,7 @@ echo '<form action="index.php?sec=estado&amp;sec2=operation/agentes/networkmap&a
echo '<table cellpadding="4" cellspacing="4" class="databox" width="100%">';
echo '<tr>';
echo '<td valign="top">' . __('Group') . '<br />';
print_select_from_sql ('SELECT id_grupo, nombre FROM tgrupo WHERE id_grupo > 1 ORDER BY nombre', 'group', $group, '', 'All', 0, false);
print_select_from_sql ('SELECT id_grupo, nombre FROM tgrupo WHERE id_grupo > 0 ORDER BY nombre', 'group', $group, '', 'All', 0, false);
echo '</td>';
echo '<td valign="top">' . __('Layout') . '<br />';
print_select ($layout_array, 'layout', $layout, '', '', '');

View File

@ -33,7 +33,7 @@ print_page_header ("Monitor detail", "images/bricks.png", false);
$ag_freestring = get_parameter ('ag_freestring');
$ag_modulename = (string) get_parameter ('ag_modulename');
$ag_group = (int) get_parameter ('ag_group', 1);
$ag_group = (int) get_parameter ('ag_group', 0);
$offset = (int) get_parameter ('offset');
$status = (int) get_parameter ('status', 4);
$modulegroup = (int) get_parameter ('modulegroup');
@ -51,11 +51,11 @@ echo "</td>";
echo "<td>".__('Monitor status')."</td><td>";
$fields = array ();
$fields[0] = __('Normal'); //default
$fields[0] = __('Normal');
$fields[1] = __('Warning');
$fields[2] = __('Critical');
$fields[3] = __('Unknown');
$fields[4] = __('Not normal');
$fields[4] = __('Not normal'); //default
$fields[5] = __('Not init');
print_select ($fields, "status", $status, 'this.form.submit();', __('All'), -1);
@ -92,7 +92,7 @@ $sql = " FROM tagente, tagente_modulo, tagente_estado
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo";
// Agent group selector
if ($ag_group > 1 && give_acl ($config["id_user"], $ag_group, "AR")) {
if ($ag_group > 0 && give_acl ($config["id_user"], $ag_group, "AR")) {
$sql .= sprintf (" AND tagente.id_grupo = %d", $ag_group);
} else {
// User has explicit permission on group 1 ?