diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2d73222ec5..7658977470 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2010-11-15 Miguel de Dios + + * include/functions_extensions.php: added functions + "add_extension_godmode_tab_agent" and "add_extension_opemode_tab_agent" to + add the extensions tab in the header in operation and godmode. + + * operation/agentes/ver_agente.php, + godmode/agentes/configurar_agente.php: added hook for to add the extension + tabs. + 2010-11-14 Junichi Satoh * operation/agentes/status_monitor.php: Fixed unnecessary strings diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index c616536425..0c4987f6b8 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -282,7 +282,32 @@ if ($id_agente) { $gistab['active'] = false; } - $onheader = array('view' => $viewtab, 'separator' => "", 'main' => $maintab, 'module' => $moduletab, 'alert' => $alerttab, 'template' => $templatetab, 'inventory' => $inventorytab, 'collection'=> $collectiontab, 'group' => $grouptab, 'gis' => $gistab); + $onheader = array('view' => $viewtab, 'separator' => "", 'main' => $maintab, + 'module' => $moduletab, 'alert' => $alerttab, 'template' => $templatetab, + 'inventory' => $inventorytab, 'collection'=> $collectiontab, 'group' => $grouptab, 'gis' => $gistab); + + foreach($config['extensions'] as $extension) { + if (isset($extension['extension_god_tab'])) { + $image = $extension['extension_god_tab']['icon']; + $name = $extension['extension_god_tab']['name']; + $id = $extension['extension_god_tab']['id']; + + $id_extension = get_parameter('id_extension', ''); + + if ($id_extension == $id) { + $active = true; + } + else { + $active = false; + } + + $url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=extension&id_agente='.$id_agente . '&id_extension=' . $id; + + $extension_tab = array('text' => '' . print_image ($image, true, array ( "title" => $name)) . '', 'active' => $active); + + $onheader = $onheader + array($id => $extension_tab); + } + } print_page_header (__('Agent configuration').' - '.printTruncateText(get_agent_name ($id_agente)), "images/setup.png", false, "", true, $onheader); @@ -651,6 +676,7 @@ if ($update_module) { } // MODULE INSERT +// ================= if ($create_module) { if (isset ($_POST["combo_snmp_oid"])) { $combo_snmp_oid = get_parameter_post ("combo_snmp_oid"); @@ -867,7 +893,8 @@ switch ($tab) { case "module": if ($id_agent_module || $edit_module) { require ("module_manager_editor.php"); - } else { + } + else { require ("module_manager.php"); } break; @@ -881,10 +908,29 @@ switch ($tab) { case "gis": require("agent_conf_gis.php"); break; + case "extension": + $found = false; + foreach($config['extensions'] as $extension) { + if (isset($extension['extension_god_tab'])) { + $id = $extension['extension_god_tab']['id']; + $function = $extension['extension_god_tab']['function']; + + $id_extension = get_parameter('id_extension', ''); + + if ($id_extension == $id) { + call_user_func_array($function, array()); + $found = true; + } + } + } + if (!$found) { + print_error_message ("Invalid tab specified"); + } + break; default: if (enterprise_hook ('switch_agent_tab', array ($tab))) //This will make sure that blank pages will have at least some //debug info in them - do not translate debug - print_error_message ("DEBUG: Invalid tab specified in ".__FILE__.":".__LINE__); + print_error_message ("Invalid tab specified"); } ?> diff --git a/pandora_console/include/functions_extensions.php b/pandora_console/include/functions_extensions.php index 77e559c4b1..56b68ca159 100644 --- a/pandora_console/include/functions_extensions.php +++ b/pandora_console/include/functions_extensions.php @@ -189,6 +189,46 @@ function add_godmode_menu_option ($name, $acl, $fatherId = null, $icon = null) { $extension['godmode_menu'] = $option_menu; } +/** + * Add in the header tabs in godmode agent the extension tab. + * + * @param $tabId + * @param $tabName + * @param $tabIcon + * @param $tabFunction + */ +function add_extension_godmode_tab_agent($tabId, $tabName, $tabIcon, $tabFunction) { + global $config; + global $extension_file; + + $extension = &$config['extensions'][$extension_file]; + $extension['extension_god_tab'] = array(); + $extension['extension_god_tab']['id'] = $tabId; + $extension['extension_god_tab']['name'] = $tabName; + $extension['extension_god_tab']['icon'] = $tabIcon; + $extension['extension_god_tab']['function'] = $tabFunction; +} + +/** + * Add in the header tabs in operation agent the extension tab. + * + * @param unknown_type $tabId + * @param unknown_type $tabName + * @param unknown_type $tabIcon + * @param unknown_type $tabFunction + */ +function add_extension_opemode_tab_agent($tabId, $tabName, $tabIcon, $tabFunction) { + global $config; + global $extension_file; + + $extension = &$config['extensions'][$extension_file]; + $extension['extension_ope_tab'] = array(); + $extension['extension_ope_tab']['id'] = $tabId; + $extension['extension_ope_tab']['name'] = $tabName; + $extension['extension_ope_tab']['icon'] = $tabIcon; + $extension['extension_ope_tab']['function'] = $tabFunction; +} + /** * TODO: Document extensions * diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index ac6612e3cb..8786d85285 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -447,11 +447,35 @@ else { $graphs['active'] = false; } + $onheader = array('manage' => $managetab, 'separator' => "", 'main' => $maintab, 'data' => $datatab, 'alert' => $alerttab, 'sla' => $slatab, 'inventory' => $inventorytab, 'collection' => $collectiontab, 'group' => $grouptab, 'gis' => $gistab, 'custom' => $custom_fields, 'graphs' => $graphs, 'policy' => $policyTab); +foreach($config['extensions'] as $extension) { + if (isset($extension['extension_ope_tab'])) { + $image = $extension['extension_ope_tab']['icon']; + $name = $extension['extension_ope_tab']['name']; + $id = $extension['extension_ope_tab']['id']; + + $id_extension = get_parameter('id_extension', ''); + + if ($id_extension == $id) { + $active = true; + } + else { + $active = false; + } + + $url = 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=extension&id_agente='.$id_agente . '&id_extension=' . $id; + + $extension_tab = array('text' => '' . print_image ($image, true, array ( "title" => $name)) . '', 'active' => $active); + + $onheader = $onheader + array($id => $extension_tab); + } +} + print_page_header (__('Agent').' - '.mb_substr(get_agent_name($id_agente),0,25), $icon, false, "", false, $onheader); @@ -495,6 +519,25 @@ switch ($tab) { case "graphs"; require("operation/agentes/graphs.php"); break; + case "extension": + $found = false; + foreach($config['extensions'] as $extension) { + if (isset($extension['extension_ope_tab'])) { + $id = $extension['extension_ope_tab']['id']; + $function = $extension['extension_ope_tab']['function']; + + $id_extension = get_parameter('id_extension', ''); + + if ($id_extension == $id) { + call_user_func_array($function, array()); + $found = true; + } + } + } + if (!$found) { + print_error_message ("Invalid tab specified in ".__FILE__.":".__LINE__); + } + break; } ?>