diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 859eb1a124..1d65a7f2c8 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2010-10-14 Sergio Martin + + * include/functions_modules.php + godmode/agentes/module_manager.php + godmode/agentes/configurar_agente.php: Added clone module + into an agent to the manage modules view + 2010-10-14 Sergio Martin * operation/agentes/exportdata.php: Safe output the autocomplete diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index dc4921c7f9..f95a0b60a8 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -276,7 +276,7 @@ if ($id_agente) { $onheader = array('view' => $viewtab, 'separator' => "", 'main' => $maintab, 'module' => $moduletab, 'alert' => $alerttab, 'template' => $templatetab, 'inventory' => $inventorytab, 'collection'=> $collectiontab, 'group' => $grouptab, 'gis' => $gistab); - print_page_header (__('Agent configuration').' - '.mb_substr(get_agent_name ($id_agente), 0, 21), "images/setup.png", false, "", true, $onheader); + print_page_header (__('Agent configuration').' - '.printTruncateText(get_agent_name ($id_agente)), "images/setup.png", false, "", true, $onheader); } // Create agent @@ -477,6 +477,7 @@ if ($id_agente) { $update_module = (bool) get_parameter ('update_module'); $create_module = (bool) get_parameter ('create_module'); $delete_module = (bool) get_parameter ('delete_module'); +$duplicate_module = (bool) get_parameter ('duplicate_module'); $edit_module = (bool) get_parameter ('edit_module'); // GET DATA for MODULE UPDATE OR MODULE INSERT @@ -746,6 +747,16 @@ if ($delete_module){ // DELETE agent module ! } } +// MODULE DUPLICATION +// ================= +if ($duplicate_module){ // DUPLICATE agent module ! + $id_duplicate_module = (int) get_parameter_get ("duplicate_module",0); + $result = copy_agent_module_to_agent ($id_duplicate_module, + get_agentmodule_agent($id_duplicate_module), + __('copy of').' '.get_agentmodule_name($id_duplicate_module)); + debugPrint(var_dump($result)); +} + // UPDATE GIS // ========== $updateGIS = get_parameter('update_gis', 0); diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 64f557980d..646cd3c2e2 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -67,7 +67,7 @@ if (! isset ($id_agente)) return; -$multiple_delete = get_parameter('multiple_delete'); +$multiple_delete = (bool) get_parameter('multiple_delete'); if ($multiple_delete) { $id_agent_modules_delete = (array)get_parameter('id_delete'); @@ -240,7 +240,7 @@ $table->style = array (); $table->style[0] = 'font-weight: bold'; $table->size = array (); $table->size[2] = '55px'; -$table->size[7] = '65px'; +$table->size[7] = '90px'; $table->align = array (); $table->align[2] = 'center'; $table->align[7] = 'left'; @@ -366,6 +366,11 @@ foreach ($modules as $module) { $data[7] .= print_image ('images/cross.png', true, array ('title' => __('Delete'))); $data[7] .= ' '; + $data[7] .= ''; + $data[7] .= print_image ('images/copy.png', true, + array ('title' => __('Duplicate'))); + $data[7] .= ' '; // Make a data normalization diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index a01f40237e..6a6b8785d4 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -26,15 +26,19 @@ * * @param int Source agent module id. * @param int Detiny agent id. + * @param string Forced name to the new module. * * @return New agent module id on success. Existing module id if it already exists. * False on error. */ -function copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent) { +function copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent, $forced_name = false) { $module = get_agentmodule ($id_agent_module); if ($module === false) return false; + if($forced_name !== false) + $module['nombre'] = $forced_name; + $modules = get_agent_modules ($id_destiny_agent, false, array ('nombre' => $module['nombre'], 'disabled' => false));