diff --git a/pandora_console/include/functions_maps.php b/pandora_console/include/functions_maps.php index 654930265d..fe42839e2c 100644 --- a/pandora_console/include/functions_maps.php +++ b/pandora_console/include/functions_maps.php @@ -22,7 +22,8 @@ */ function maps_save_map($values) { - return db_process_sql_insert('tmap', $values); + $result_add = db_process_sql_insert('tmap', $values); + return $result_add; } function maps_get_maps($filter) { @@ -51,18 +52,19 @@ function maps_get_subtype_string($subtype) { function maps_duplicate_map($id) { global $config; - $map = db_get_sql("SELECT * FROM tmap WHERE id = " . $id); - $result = 0; + $map = db_get_all_rows_sql("SELECT * FROM tmap WHERE id = " . $id); + $result = false; + $map = $map[0]; if (!empty($map)) { - $map_names = db_get_all_rows_sql("SELECT name FROM tmap WHERE name LIKE '" . $map['name'] . "%'"); + $map_names = db_get_row_sql("SELECT name FROM tmap WHERE name LIKE '" . $map['name'] . "%'"); $index = 0; foreach ($map_names as $map_name) { $index++; } - $map['name'] = $map['name'] . '_' . $index; + $new_name = $map['name'] . '_' . $index; $result = db_process_sql_insert('tmap', array('id_group' => $map['id_group'], 'id_user' => $config['id_user'], 'type' => $map['type'], 'subtype' => $map['subtype'], - 'name' => $map['name'], 'description' => $map['description'], 'width' => $map['width'], + 'name' => $new_name, 'description' => $map['description'], 'width' => $map['width'], 'height' => $map['height'], 'center_x' => $map['center_x'], 'center_y' => $map['center_y'], 'background' => $map['background'], 'background_options' => $map['background_options'], 'source_period' => $map['source_period'], 'source' => $map['source'], @@ -74,7 +76,8 @@ function maps_duplicate_map($id) { function maps_delete_map($id) { $where = 'id=' . $id; - db_process_sql_delete('tmap', $where); + $result = db_process_sql_delete('tmap', $where); + return (int)$result; } function maps_get_count_nodes($id) { diff --git a/pandora_console/operation/maps/networkmap_editor.php b/pandora_console/operation/maps/networkmap_editor.php index d7ebbb46df..1d60febd5d 100644 --- a/pandora_console/operation/maps/networkmap_editor.php +++ b/pandora_console/operation/maps/networkmap_editor.php @@ -195,9 +195,10 @@ else { $table->data[14][1] = html_print_input_text ('text', $text, '', 20, 10,true); - html_print_table($table); - echo '
'; + + html_print_table($table); + echo "
"; if ($create_networkmap) { html_print_input_hidden ('save_networkmap', 1); diff --git a/pandora_console/operation/maps/networkmap_list.php b/pandora_console/operation/maps/networkmap_list.php index f7e5f00513..3992888c19 100644 --- a/pandora_console/operation/maps/networkmap_list.php +++ b/pandora_console/operation/maps/networkmap_list.php @@ -77,10 +77,10 @@ $save_networkmap = (bool)get_parameter('save_networkmap', 0); if ($save_networkmap) { $id_group = (int) get_parameter('id_group', 0); - + $networkmap_write = check_acl ($config['id_user'], $id_group, "MW"); $networkmap_manage = check_acl ($config['id_user'], $id_group, "MM"); - + if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit("ACL Violation", "Trying to access networkmap enterprise"); @@ -105,9 +105,10 @@ if ($save_networkmap) { $show_module_group = get_parameter('show_module_group', false); $id_tag = get_parameter('id_tag', 0); $text = get_parameter('text', ""); - + $values = array(); $values['name'] = $name; + $values['id_user'] = $config['id_user']; $values['id_group'] = $id_group; $values['subtype'] = $subtype; $values['type'] = $$type; @@ -115,7 +116,7 @@ if ($save_networkmap) { $values['source_period'] = $source_period; $values['source_data'] = $source_data; $values['generation_method'] = $generation_method; - + $filter = array(); $filter['show_groups_filter'] = 60; $filter['show_module_plugins'] = $show_module_plugins; @@ -127,9 +128,14 @@ if ($save_networkmap) { $filter['id_tag'] = $id_tag; $filter['text'] = $text; $values['filter'] = json_encode($filter); - - $result_add = false; - if (!empty($name)) { + $networkmap_names = db_get_all_rows_sql("SELECT name FROM tmap"); + foreach ($networkmap_names as $networkmap_name) { + if ($networkmap_name == $name) { + $same_name = true; + } + } + html_debug($values); + if (!empty($name) && !$same_name) { $result_add = maps_save_map($values); } @@ -139,14 +145,14 @@ if ($save_networkmap) { } else if ($delete_networkmap || $duplicate_networkmap || $update_networkmap) { $id = (int)get_parameter('id_networkmap', 0); - + if (empty($id)) { db_pandora_audit("ACL Violation", "Trying to access networkmap enterprise"); require ("general/noaccess.php"); return; } - + $id_group_old = db_get_value('id_group', 'tmap', 'id', $id); if ($id_group_old === false) { db_pandora_audit("ACL Violation", @@ -154,20 +160,20 @@ else if ($delete_networkmap || $duplicate_networkmap || $update_networkmap) { require ("general/noaccess.php"); return; } - + $networkmap_write_old_group = check_acl ($config['id_user'], $id_group_old, "MW"); $networkmap_manage_old_group = check_acl ($config['id_user'], $id_group_old, "MM"); - + if (!$networkmap_write_old_group && !$networkmap_manage_old_group) { db_pandora_audit("ACL Violation", "Trying to access networkmap"); require ("general/noaccess.php"); return; } - + if ($delete_networkmap) { $result_delete = maps_delete_map($id); - + if (!$result_delete) { db_pandora_audit( "Networkmap management", "Fail try to delete networkmap #$id"); @@ -176,20 +182,20 @@ else if ($delete_networkmap || $duplicate_networkmap || $update_networkmap) { db_pandora_audit( "Networkmap management", "Delete networkmap #$id"); } - + ui_print_result_message ($result_delete, __('Successfully deleted'), __('Could not be deleted')); } - + else if ($duplicate_networkmap) { $result_duplicate = maps_duplicate_map($id); - - ui_print_result_message ($result, + + ui_print_result_message ($result_duplicate, __('Successfully duplicate'), __('Could not be duplicate')); } - + else if ($update_networkmap) { $name = (string) get_parameter('name', ""); $description = (string) get_parameter('description', ""); @@ -205,14 +211,14 @@ else if ($delete_networkmap || $duplicate_networkmap || $update_networkmap) { $show_module_group = get_parameter('show_module_group', false); $id_tag = get_parameter('id_tag', 0); $text = get_parameter('text', ""); - + $values = array(); $values['name'] = $name; $values['id_group'] = $id_group; $values['description'] = $description; $values['source_period'] = $source_period; $values['source_data'] = $source_data; - + $filter = array(); $filter['show_groups_filter'] = 60; $filter['show_module_plugins'] = $show_module_plugins; @@ -224,12 +230,12 @@ else if ($delete_networkmap || $duplicate_networkmap || $update_networkmap) { $filter['id_tag'] = $id_tag; $filter['text'] = $text; $values['filter'] = json_encode($filter); - + $result_add = false; if (!empty($name)) { $result_add = maps_update_map($id, $values); } - + ui_print_result_message ($result_add, __('Successfully updated'), __('Could not be updated')); @@ -240,37 +246,22 @@ else if ($delete_networkmap || $duplicate_networkmap || $update_networkmap) { $table = new stdClass(); $table->width = "100%"; $table->class = "databox data"; -$table->headstyle['name'] = 'text-align: center;'; -$table->headstyle['type'] = 'text-align: center;'; -if (enterprise_installed()) { - $table->headstyle['nodes'] = 'text-align: center;'; -} -$table->headstyle['group'] = 'text-align: center;'; -$table->headstyle['copy'] = 'text-align: center;'; -$table->headstyle['edit'] = 'text-align: center;'; -$table->headstyle['delete'] = 'text-align: center;'; $table->style = array(); $table->style['name'] = 'text-align: left;'; -$table->style['type'] = 'text-align: center;'; +$table->style['type'] = 'text-align: left;'; if (enterprise_installed()) { - $table->style['nodes'] = 'text-align: center;'; + $table->style['nodes'] = 'text-align: left;'; } $table->style['group'] = 'text-align: center;'; -$table->style['copy'] = 'text-align: center;'; -$table->style['edit'] = 'text-align: center;'; -$table->style['delete'] = 'text-align: center;'; +$table->style['copy'] = 'text-align: left;'; +$table->style['edit'] = 'text-align: left;'; +$table->style['delete'] = 'text-align: left;'; $table->size = array(); -$table->size['name'] = '60%'; -$table->size['type'] = '30px'; -if (enterprise_installed()) { - $table->size['nodes'] = '30px'; -} -$table->size['group'] = '30px'; -$table->size['copy'] = '30px'; -$table->size['edit'] = '30px'; -$table->size['delete'] = '30px'; +$table->size[0] = '60%'; +$table->size[1] = '60px'; +$table->size[2] = '70px'; $table->head = array(); $table->head['name'] = __('Name'); @@ -293,18 +284,18 @@ if (empty($networkmaps)) { else { foreach ($networkmaps as $networkmap) { $data = array(); - + $data['name'] = $networkmap['name']; - + $data['name'] = '' . $networkmap['name'] . ''; - + $data['type'] = maps_get_subtype_string($networkmap['subtype']); - - + + if (enterprise_installed()) { if ($networkmap['generated']) { $data['nodes'] = maps_get_count_nodes($networkmap['id']); @@ -313,7 +304,7 @@ else { $data['nodes'] = __('Pending to generate'); } } - + if (!empty($networkmap['id_user'])) { $data['group'] = __('Private for (%s)', $networkmap['id_user']); } @@ -321,26 +312,26 @@ else { $data['groups'] = ui_print_group_icon($networkmap['id_group'], true); } - + $data['copy'] = '' . html_print_image("images/copy.png", true) . ''; - + $data['edit'] = '' . html_print_image("images/edit.png", true) . ''; - + $data['delete'] = '' . html_print_image('images/cross.png', true) . ''; - + $table->data[] = $data; } html_print_table($table);