diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e00dfa7110..e46a64e8b2 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2011-07-21 Sergio Martin + + * include/functions_users.php + extensions/module_groups.php + godmode/groups/modu_group_list.php + godmode/groups/group_list.php + godmode/alerts/alert_commands.php + godmode/setup/os.list.php + godmode/setup/news.php + godmode/users/profile_list.php + godmode/modules/manage_network_components.php + godmode/modules/manage_nc_groups.php: Fixed several lonely + headers when no data and other no data little bugs for 3371455 + 2011-07-21 Ramon Novoa * include/functions_config.php: Set dbtype to mysql by default diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 0818e7052d..c4aad54de9 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -125,140 +125,146 @@ function mainModuleGroups() { $agentGroups = users_get_groups ($config['id_user'], "AR", false); $modelGroups = users_get_all_model_groups(); - array_walk($modelGroups, 'translate'); //Translate all head titles to language is set - foreach ($modelGroups as $i => $n) { - $modelGroups[$i] = ui_print_truncate_text($n, 20); - } + if(!empty($agentGroups) && !empty($modelGroups)) { + array_walk($modelGroups, 'translate'); //Translate all head titles to language is set - $head = $modelGroups; - array_unshift($head, ' '); - - //Metaobject use in html_print_table - $table = null; - $table->align[0] = 'right'; //Align to right the first column. - $table->style[0] = 'color: #ffffff; background-color: #778866; font-weight: bolder;'; - $table->head = $head; - $table->width = '95%'; - - //The content of table - $tableData = array(); - - $fired = false; - - //Create rows and cells - foreach ($agentGroups as $idAgentGroup => $name) { + foreach ($modelGroups as $i => $n) { + $modelGroups[$i] = ui_print_truncate_text($n, 20); + } + + $head = $modelGroups; + array_unshift($head, ' '); - $row = array(); + //Metaobject use in html_print_table + $table = null; + $table->align[0] = 'right'; //Align to right the first column. + $table->style[0] = 'color: #ffffff; background-color: #778866; font-weight: bolder;'; + $table->head = $head; + $table->width = '95%'; - array_push($row, ui_print_truncate_text($name, 20)); - - foreach ($modelGroups as $idModelGroup => $modelGroup) { - $query = sprintf($sql,$idAgentGroup, $idModelGroup); + //The content of table + $tableData = array(); + + $fired = false; + + //Create rows and cells + foreach ($agentGroups as $idAgentGroup => $name) { - $rowsDB = db_get_all_rows_sql ($query); + $row = array(); - - $agents = agents_get_group_agents($idAgentGroup); - - if (!empty($agents)) { - $alerts = agents_get_alerts_simple($agents); + array_push($row, ui_print_truncate_text($name, 20)); + + foreach ($modelGroups as $idModelGroup => $modelGroup) { + $query = sprintf($sql,$idAgentGroup, $idModelGroup); - foreach ($alerts as $alert) { - $module = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $alert['id_agent_module'])); + $rowsDB = db_get_all_rows_sql ($query); + + + $agents = agents_get_group_agents($idAgentGroup); + + if (!empty($agents)) { + $alerts = agents_get_alerts_simple($agents); - if ($idModelGroup == $module['id_module_group']) { - if ($alert["times_fired"] > 0) { - $fired = true; + foreach ($alerts as $alert) { + $module = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $alert['id_agent_module'])); + + if ($idModelGroup == $module['id_module_group']) { + if ($alert["times_fired"] > 0) { + $fired = true; + } } } - } - } - - $states = array(); - if ($rowsDB !== false) { - foreach ($rowsDB as $rowDB) { - $states[$rowDB['estado']] = $rowDB['count']; - } - } - - $count = 0; - foreach ($states as $idState => $state) { - $count += $state; - } - - $color = 'transparent'; //Defaut color for cell - $font_color = '#000000'; //Default font color for cell - if ($count == 0) { - $color = '#eeeeee'; //Soft grey when the cell for this model group and agent group hasn't modules. - $alinkStart = ''; - $alinkEnd = ''; - } - else { + } - if ($fired) { - $color = '#ffa300'; //Orange when the cell for this model group and agent has at least one alert fired. - } - 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'; - } - elseif (array_key_exists(2,$states)) { - $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. - } - elseif (array_key_exists(3,$states)) { - $color = '#babdb6'; //Grey when the cell for this model group and agent has at least one module in unknown state and the rest in any state. - } - elseif (array_key_exists(0,$states)) { - $color = '#8ae234'; //Green when the cell for this model group and agent has OK state all modules. + $states = array(); + if ($rowsDB !== false) { + foreach ($rowsDB as $rowDB) { + $states[$rowDB['estado']] = $rowDB['count']; + } } + $count = 0; + foreach ($states as $idState => $state) { + $count += $state; + } - $alinkStart = ''; - $alinkEnd = ''; + $color = 'transparent'; //Defaut color for cell + $font_color = '#000000'; //Default font color for cell + if ($count == 0) { + $color = '#eeeeee'; //Soft grey when the cell for this model group and agent group hasn't modules. + $alinkStart = ''; + $alinkEnd = ''; + } + else { + + if ($fired) { + $color = '#ffa300'; //Orange when the cell for this model group and agent has at least one alert fired. + } + 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'; + } + elseif (array_key_exists(2,$states)) { + $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. + } + elseif (array_key_exists(3,$states)) { + $color = '#babdb6'; //Grey when the cell for this model group and agent has at least one module in unknown state and the rest in any state. + } + elseif (array_key_exists(0,$states)) { + $color = '#8ae234'; //Green when the cell for this model group and agent has OK state all modules. + } + + + $alinkStart = ''; + $alinkEnd = ''; + } + + array_push($row, + '
+ ' . $alinkStart . $count . $alinkEnd . '
'); } - - array_push($row, - '
- ' . $alinkStart . $count . $alinkEnd . '
'); + array_push($tableData,$row); } - array_push($tableData,$row); + $table->data = $tableData; + echo "
"; + html_print_table($table); + echo "
"; + + echo "

" . __("The colours meaning:") . + "

" . + "

"; + } + else { + echo "
".__('There are no defined groups or module groups')."
"; } - $table->data = $tableData; - echo "
"; - html_print_table($table); - echo "
"; - - echo "

" . __("The colours meaning:") . - "

" . - "

"; ui_require_css_file('cluetip'); ui_require_jquery_file('cluetip'); diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index ae5961fdcb..34f5d0a119 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -162,7 +162,12 @@ foreach ($commands as $command) { array_push ($table->data, $data); } -html_print_table ($table); +if(isset($data)) { + html_print_table ($table); +} +else { + echo "
".__('No alert commands configured')."
"; +} echo '
'; echo '
'; diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index ac6d64acb2..d287cd40f5 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -205,111 +205,125 @@ if ($delete_group) { } - -$table->width = '98%'; -$table->head = array (); -$table->head[0] = __('Name'); -$table->head[1] = __('ID'); -$table->head[2] = __('Icon'); -$table->head[3] = __('Alerts'); -$table->head[4] = __('Actions'); -$table->align = array (); -$table->align[2] = 'center'; -$table->align[4] = 'center'; -$table->data = array (); - $groups = users_get_groups_tree ($config['id_user'], "AR", true); -$iterator = 0; +$table->width = '98%'; -foreach ($groups as $id_group => $group) { - if ($group['deep'] == 0) { - $table->rowstyle[$iterator] = ''; - } - else { - if ($group['parent'] != 0) { - $table->rowstyle[$iterator] = 'display: none;'; +if(!empty($groups)) { + $table->head = array (); + $table->head[0] = __('Name'); + $table->head[1] = __('ID'); + $table->head[2] = __('Icon'); + $table->head[3] = __('Alerts'); + $table->head[4] = __('Actions'); + $table->align = array (); + $table->align[2] = 'center'; + $table->align[4] = 'center'; + $table->data = array (); + + $iterator = 0; + + foreach ($groups as $id_group => $group) { + if ($group['deep'] == 0) { + $table->rowstyle[$iterator] = ''; } - } - - $symbolBranchs = ''; - if ($group['id_grupo'] != 0) { - - //Make a list of parents this group - $end = false; - $unloop = true; - $parents = null; - $parents[] = $group['parent']; - while (!$end) { - $lastParent = end($parents); - if ($lastParent == 0) { - $end = true; + else { + if ($group['parent'] != 0) { + $table->rowstyle[$iterator] = 'display: none;'; } - else { - $unloop = true; - foreach ($groups as $id => $node) { - if ($node['id_grupo'] == 0) { - continue; + } + + $symbolBranchs = ''; + if ($group['id_grupo'] != 0) { + + //Make a list of parents this group + $end = false; + $unloop = true; + $parents = null; + $parents[] = $group['parent']; + while (!$end) { + $lastParent = end($parents); + if ($lastParent == 0) { + $end = true; + } + else { + $unloop = true; + foreach ($groups as $id => $node) { + if ($node['id_grupo'] == 0) { + continue; + } + if ($node['id_grupo'] == $lastParent) { + array_push($parents, $node['parent']); + $unloop = false; + } } - if ($node['id_grupo'] == $lastParent) { - array_push($parents, $node['parent']); - $unloop = false; + + //For exit of infinite loop + if ($unloop) { + break; } } - - //For exit of infinite loop - if ($unloop) { - break; + } + + $table->rowclass[$iterator] = 'parent_' . $group['parent']; + + //Print the branch classes (for close a branch with child branch in the + //javascript) of this parent as example: + // + // the tree (0(1,2(4,5),3)) + // for the group 4 have the style "parent_4 branch_0 branch_2" + if (!empty($parents)) { + foreach ($parents as $idParent) { + $table->rowclass[$iterator] .= ' branch_' . $idParent; + $symbolBranchs .= ' symbol_branch_' . $idParent; } } } - $table->rowclass[$iterator] = 'parent_' . $group['parent']; + $tabulation = str_repeat('    ', $group['deep']); - //Print the branch classes (for close a branch with child branch in the - //javascript) of this parent as example: - // - // the tree (0(1,2(4,5),3)) - // for the group 4 have the style "parent_4 branch_0 branch_2" - if (!empty($parents)) { - foreach ($parents as $idParent) { - $table->rowclass[$iterator] .= ' branch_' . $idParent; - $symbolBranchs .= ' symbol_branch_' . $idParent; - } + if ($group['id_grupo'] == 0) { + $symbol = '-'; } + else { + $symbol = '+'; + } + + if ($group['hash_branch']) { + $data[0] = ''.$tabulation . ' ' . + '' . $symbol . ' '. ui_print_truncate_text($group['nombre']).''; + } + else { + $data[0] = ''.$tabulation . ' '. ui_print_truncate_text($group['nombre'], 60).''; + } + $data[1] = $group['id_grupo']; + $data[2] = ui_print_group_icon($group['id_grupo'], true); + $data[3] = $group['disabled'] ? __('Disabled') : __('Enabled'); + if ($group['id_grupo'] == 0) { + $data[4] = ''; + } + else { + $data[4] = '' . html_print_image("images/config.png", true, array("alt" => __('Edit'), "title" => __('Edit'), "border" => '0')); + $data[4] .= '  ' . html_print_image("images/cross.png", true, array("alt" => __('Delete'), "border" => '0')); + } + + array_push ($table->data, $data); + $iterator++; } - - $tabulation = str_repeat('    ', $group['deep']); - - if ($group['id_grupo'] == 0) { - $symbol = '-'; - } - else { - $symbol = '+'; - } - - if ($group['hash_branch']) { - $data[0] = ''.$tabulation . ' ' . - '' . $symbol . ' '. ui_print_truncate_text($group['nombre']).''; - } - else { - $data[0] = ''.$tabulation . ' '. ui_print_truncate_text($group['nombre'], 60).''; - } - $data[1] = $group['id_grupo']; - $data[2] = ui_print_group_icon($group['id_grupo'], true); - $data[3] = $group['disabled'] ? __('Disabled') : __('Enabled'); - if ($group['id_grupo'] == 0) { - $data[4] = ''; - } - else { - $data[4] = '' . html_print_image("images/config.png", true, array("alt" => __('Edit'), "title" => __('Edit'), "border" => '0')); - $data[4] .= '  ' . html_print_image("images/cross.png", true, array("alt" => __('Delete'), "border" => '0')); - } - - array_push ($table->data, $data); - $iterator++; + + html_print_table ($table); +} +else { + echo "
".__('There are no defined groups')."
"; } +echo ''; +echo '
'; +html_print_submit_button (__('Create group'), 'crt', false, 'class="sub next"'); +echo '
'; +echo ''; + ?> + -'; -echo '
'; -html_print_submit_button (__('Create group'), 'crt', false, 'class="sub next"'); -echo '
'; -echo ''; - -?> diff --git a/pandora_console/godmode/groups/modu_group_list.php b/pandora_console/godmode/groups/modu_group_list.php index 227422056d..8ece070642 100644 --- a/pandora_console/godmode/groups/modu_group_list.php +++ b/pandora_console/godmode/groups/modu_group_list.php @@ -129,31 +129,36 @@ if ($delete_group) { echo "

".__('Group successfully deleted')."

"; } -$table->width = '98%'; -$table->head = array (); -$table->head[0] = __('ID'); -$table->head[1] = __('Name'); -$table->head[2] = __('Delete'); -$table->align = array (); -$table->align[1] = 'left'; -$table->align[2] = 'center'; -$table->data = array (); - $sql = "SELECT * FROM tmodule_group "; $groups = db_get_all_rows_sql ($sql, true); +$table->width = '98%'; -foreach ($groups as $id_group ) { - $data = array (); - $data[0] = $id_group["id_mg"]; - $data[1] = '
' . ui_print_truncate_text($id_group["name"], 50).''; - $data[2] = '' . html_print_image("images/cross.png", true, array("border" => '0')) . ''; - - array_push ($table->data, $data); +if(!empty($groups)) { + $table->head = array (); + $table->head[0] = __('ID'); + $table->head[1] = __('Name'); + $table->head[2] = __('Delete'); + $table->align = array (); + $table->align[1] = 'left'; + $table->align[2] = 'center'; + $table->data = array (); + + foreach ($groups as $id_group ) { + $data = array (); + $data[0] = $id_group["id_mg"]; + $data[1] = '' . ui_print_truncate_text($id_group["name"], 50).''; + $data[2] = '' . html_print_image("images/cross.png", true, array("border" => '0')) . ''; + + array_push ($table->data, $data); + } + + html_print_table ($table); +} +else{ + echo "
".__('There are no defined module groups')."
"; } - -html_print_table ($table); echo '
'; echo '
'; diff --git a/pandora_console/godmode/modules/manage_nc_groups.php b/pandora_console/godmode/modules/manage_nc_groups.php index 8120bebbc9..683a0b1381 100644 --- a/pandora_console/godmode/modules/manage_nc_groups.php +++ b/pandora_console/godmode/modules/manage_nc_groups.php @@ -85,6 +85,14 @@ $url = ui_get_url_refresh (array ('offset' => false, 'upd' => false, 'id_sg' => false)); +$filter = array (); +$filter['offset'] = (int) get_parameter ('offset'); +$filter['limit'] = (int) $config['block_size']; + +$groups = db_get_all_rows_filter ('tnetwork_component_group', $filter); +if ($groups === false) + $groups = array (); + $table->width = '98%'; $table->head = array (); $table->head[0] = __('Name'); @@ -103,14 +111,6 @@ $table->data = array (); $total_groups = db_get_all_rows_filter ('tnetwork_component_group', false, 'COUNT(*) AS total'); $total_groups = $total_groups[0]['total']; -$filter = array (); -$filter['offset'] = (int) get_parameter ('offset'); -$filter['limit'] = (int) $config['block_size']; - -$groups = db_get_all_rows_filter ('tnetwork_component_group', $filter); -if ($groups === false) - $groups = array (); - ui_pagination ($total_groups, $url); foreach ($groups as $group) { @@ -130,7 +130,13 @@ foreach ($groups as $group) { array_push ($table->data, $data); } -html_print_table ($table); +if(isset($data)) { + html_print_table ($table); +} +else { + echo "
".__('There are no defined component groups')."
"; +} + echo ''; echo '
'; diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index 381901b75e..aba1eefcef 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -299,6 +299,7 @@ if ($components === false) $components = array (); unset ($table); + $table->width = '98%'; $table->head = array (); $table->head[0] = __('Module name'); @@ -340,7 +341,13 @@ foreach ($components as $component) { array_push ($table->data, $data); } -html_print_table ($table); +if(isset($data)) { + html_print_table ($table); +} +else { + echo "
".__('There are no defined network components')."
"; +} + echo ''; echo '
'; @@ -349,7 +356,7 @@ html_print_select (array (2 => __('Create a new network component'), 4 => __('Create a new plugin component'), 6 => __('Create a new WMI component')), 'id_component_type', '', '', '', '', ''); -html_print_submit_button (__('Create'), 'crt', false, 'class="sub next"'); +html_print_submit_button (__('Create'), 'crt', false, 'class="sub next" style="margin-left: 5px;"'); echo '
'; echo '' ?> diff --git a/pandora_console/godmode/setup/news.php b/pandora_console/godmode/setup/news.php index 103cfc62ae..7645d8df02 100644 --- a/pandora_console/godmode/setup/news.php +++ b/pandora_console/godmode/setup/news.php @@ -126,37 +126,41 @@ if ((isset ($_GET["form_add"])) || (isset ($_GET["form_edit"]))) { echo ''; } else { - - // Main list view for Links editor - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - $rows = db_get_all_rows_in_table("tnews", "timestamp"); if ($rows === false) { $rows = array(); + echo "
".__('There are no defined news')."
"; } - - $color = 1; - foreach ($rows as $row) { - if ($color == 1) { - $tdcolor = "datos"; - $color = 0; - } - else { - $tdcolor = "datos2"; - $color = 1; - } - echo ""; - - echo ""; - echo ""; + else { + // Main list view for Links editor + echo "
".__('Subject')."".__('Author')."".__('Timestamp')."".__('Delete')."
".$row["subject"]."".$row["author"]."".$row["timestamp"]."
"; + echo ""; + echo ""; + echo ""; + echo ""; - echo ''; + + + $color = 1; + foreach ($rows as $row) { + if ($color == 1) { + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + echo ""; + + echo ""; + echo ""; + + echo ''; + } + echo "
".__('Subject')."".__('Author')."".__('Timestamp')."".__('Delete')."' . html_print_image("images/cross.png", true, array("border" => '0')) . '
".$row["subject"]."".$row["author"]."".$row["timestamp"]."' . html_print_image("images/cross.png", true, array("border" => '0')) . '
"; } - echo ""; + echo ""; echo "
"; echo "
"; diff --git a/pandora_console/godmode/setup/os.list.php b/pandora_console/godmode/setup/os.list.php index 1eef5dfffd..f7a2a4186b 100644 --- a/pandora_console/godmode/setup/os.list.php +++ b/pandora_console/godmode/setup/os.list.php @@ -60,5 +60,10 @@ foreach ($osList as $os) { $table->data[] = $data; } -html_print_table($table); +if(isset($data)) { + html_print_table($table); +} +else { + echo "
".__('There are no defined operating systems')."
"; +} ?> diff --git a/pandora_console/godmode/users/profile_list.php b/pandora_console/godmode/users/profile_list.php index a07ce953da..ba2788bae4 100644 --- a/pandora_console/godmode/users/profile_list.php +++ b/pandora_console/godmode/users/profile_list.php @@ -99,7 +99,12 @@ foreach ($profiles as $profile) { } echo ''; - html_print_table ($table); + if(isset($data)) { + html_print_table ($table); + } + else { + echo "
".__('There are no defined profiles')."
"; + } echo '
'; html_print_input_hidden ('new_profile', 1); html_print_submit_button (__('Create'), "crt", false, 'class="sub next"'); diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index cf82d1548d..66b0ec999b 100644 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -48,7 +48,9 @@ function users_get_info ($order = "fullname", $info = "fullname") { */ function users_get_all_model_groups () { $groups = db_get_all_rows_in_table ('tmodule_group'); - + if($groups === false) { + $groups = array(); + } $returnGroups = array(); foreach ($groups as $group) $returnGroups[$group['id_mg']] = $group['name'];