2010-10-14 Sergio Martin <sergio.martin@artica.es>

* 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



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3404 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2010-10-14 17:07:50 +00:00
parent c802715dc3
commit 12a12d5959
4 changed files with 31 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2010-10-14 Sergio Martin <sergio.martin@artica.es>
* 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 <sergio.martin@artica.es> 2010-10-14 Sergio Martin <sergio.martin@artica.es>
* operation/agentes/exportdata.php: Safe output the autocomplete * operation/agentes/exportdata.php: Safe output the autocomplete

View File

@ -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); $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').' -&nbsp;'.mb_substr(get_agent_name ($id_agente), 0, 21), "images/setup.png", false, "", true, $onheader); print_page_header (__('Agent configuration').' -&nbsp;'.printTruncateText(get_agent_name ($id_agente)), "images/setup.png", false, "", true, $onheader);
} }
// Create agent // Create agent
@ -477,6 +477,7 @@ if ($id_agente) {
$update_module = (bool) get_parameter ('update_module'); $update_module = (bool) get_parameter ('update_module');
$create_module = (bool) get_parameter ('create_module'); $create_module = (bool) get_parameter ('create_module');
$delete_module = (bool) get_parameter ('delete_module'); $delete_module = (bool) get_parameter ('delete_module');
$duplicate_module = (bool) get_parameter ('duplicate_module');
$edit_module = (bool) get_parameter ('edit_module'); $edit_module = (bool) get_parameter ('edit_module');
// GET DATA for MODULE UPDATE OR MODULE INSERT // 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 // UPDATE GIS
// ========== // ==========
$updateGIS = get_parameter('update_gis', 0); $updateGIS = get_parameter('update_gis', 0);

View File

@ -67,7 +67,7 @@ if (! isset ($id_agente))
return; return;
$multiple_delete = get_parameter('multiple_delete'); $multiple_delete = (bool) get_parameter('multiple_delete');
if ($multiple_delete) { if ($multiple_delete) {
$id_agent_modules_delete = (array)get_parameter('id_delete'); $id_agent_modules_delete = (array)get_parameter('id_delete');
@ -240,7 +240,7 @@ $table->style = array ();
$table->style[0] = 'font-weight: bold'; $table->style[0] = 'font-weight: bold';
$table->size = array (); $table->size = array ();
$table->size[2] = '55px'; $table->size[2] = '55px';
$table->size[7] = '65px'; $table->size[7] = '90px';
$table->align = array (); $table->align = array ();
$table->align[2] = 'center'; $table->align[2] = 'center';
$table->align[7] = 'left'; $table->align[7] = 'left';
@ -366,6 +366,11 @@ foreach ($modules as $module) {
$data[7] .= print_image ('images/cross.png', true, $data[7] .= print_image ('images/cross.png', true,
array ('title' => __('Delete'))); array ('title' => __('Delete')));
$data[7] .= '</a> '; $data[7] .= '</a> ';
$data[7] .= '<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&duplicate_module='.$module['id_agente_modulo'].'"
onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
$data[7] .= print_image ('images/copy.png', true,
array ('title' => __('Duplicate')));
$data[7] .= '</a> ';
// Make a data normalization // Make a data normalization

View File

@ -26,15 +26,19 @@
* *
* @param int Source agent module id. * @param int Source agent module id.
* @param int Detiny agent 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. * @return New agent module id on success. Existing module id if it already exists.
* False on error. * 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); $module = get_agentmodule ($id_agent_module);
if ($module === false) if ($module === false)
return false; return false;
if($forced_name !== false)
$module['nombre'] = $forced_name;
$modules = get_agent_modules ($id_destiny_agent, false, $modules = get_agent_modules ($id_destiny_agent, false,
array ('nombre' => $module['nombre'], 'disabled' => false)); array ('nombre' => $module['nombre'], 'disabled' => false));