Fixed the networkmap editor.
This commit is contained in:
parent
fe863f61df
commit
255f67c545
|
@ -36,7 +36,7 @@ if ($create_networkmap) {
|
|||
$description = "";
|
||||
$source_period = 60 * 5;
|
||||
$source = MAP_SOURCE_GROUP;
|
||||
$source_data = "id_group";
|
||||
$source_data = "";
|
||||
$generation_method = MAP_GENERATION_CIRCULAR;
|
||||
$show_groups_filter = false;
|
||||
$show_module_plugins = false;
|
||||
|
@ -78,10 +78,10 @@ if ($edit_networkmap) {
|
|||
$source_period = $values['source_period'];
|
||||
$source = $values['source'];
|
||||
if ($source == 'group') {
|
||||
$source_data = 'id_group';
|
||||
$source_data = $values['source_data'];
|
||||
}
|
||||
else {
|
||||
$source_data = 'ip_mask';
|
||||
$source_data = $values['source_data'];
|
||||
}
|
||||
$generation_method = $values['generation_method'];
|
||||
$filter = json_decode($values['filter'], true);
|
||||
|
@ -131,36 +131,56 @@ if ($not_found) {
|
|||
else {
|
||||
$table = null;
|
||||
$table->id = 'form_editor';
|
||||
|
||||
|
||||
$table->width = '98%';
|
||||
$table->class = "databox_color";
|
||||
|
||||
|
||||
$table->head = array();
|
||||
|
||||
|
||||
$table->size = array();
|
||||
$table->size[0] = '30%';
|
||||
|
||||
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold; width: 150px;';
|
||||
$table->data = array();
|
||||
|
||||
|
||||
$table->data['name'][0] = __('Name');
|
||||
$table->data['name'][1] = html_print_input_text ('name', $name, '',
|
||||
30, 100, true);
|
||||
|
||||
$table->data['group'][0] = __('Group');
|
||||
$table->data['group'][1] = html_print_select_groups(false, "AR", true,
|
||||
'id_group', $id_group, '', '', 0, true);
|
||||
|
||||
$table->data['description'][0] = __('Description');
|
||||
$table->data['description'][1] = html_print_textarea("description",
|
||||
2, 65, $description, '', true);
|
||||
|
||||
$subtypes = array(
|
||||
MAP_SUBTYPE_TOPOLOGY => 'Topology',
|
||||
MAP_SUBTYPE_POLICIES => 'Policies',
|
||||
MAP_SUBTYPE_GROUPS => 'Groups',
|
||||
MAP_SUBTYPE_RADIAL_DYNAMIC => 'Radial Dynamic'
|
||||
);
|
||||
|
||||
$table->data[0][0] = __('Subtype');
|
||||
$table->data[0][1] = html_print_select($subtypes, 'subtype', $subtype,
|
||||
'', '', 'Topology', true, false, true, '',
|
||||
|
||||
$table->data['subtype'][0] = __('Subtype');
|
||||
$table->data['subtype'][1] = html_print_select($subtypes, 'subtype',
|
||||
$subtype, '', '', 'Topology', true, false, true, '',
|
||||
$disabled_select);
|
||||
|
||||
$table->data['source'][0] = __('Source');
|
||||
|
||||
$table->data['source'][0] = __('Source type');
|
||||
$table->data['source'][1] =
|
||||
html_print_radio_button('source', MAP_SOURCE_GROUP, __('Group'), $source, true) .
|
||||
html_print_radio_button('source', MAP_SOURCE_IP_MASK, __('CIDR IP mask'), $source, true);
|
||||
|
||||
|
||||
$table->data['source_group'][0] = __('Source');
|
||||
$table->data['source_group'][1] = html_print_select_groups(
|
||||
false, "AR", true, 'source_group', $source_data, '', '', 0, true);
|
||||
|
||||
$table->data['source_ip_mask'][0] = __('Source');
|
||||
$table->data['source_ip_mask'][1] = html_print_input_text ('source_ip_mask',
|
||||
$source_data, '', 30, 100,true);
|
||||
|
||||
$generation_methods = array(
|
||||
MAP_GENERATION_RADIAL => 'Radial',
|
||||
MAP_GENERATION_PLANO => 'Flat',
|
||||
|
@ -168,59 +188,52 @@ else {
|
|||
MAP_GENERATION_SPRING1 => 'Spring1',
|
||||
MAP_GENERATION_SPRING2 => 'Spring2'
|
||||
);
|
||||
|
||||
$table->data[2][0] = __('Method generation networkmap');
|
||||
$table->data[2][1] = html_print_select($generation_methods, 'generation_method', $generation_method,
|
||||
|
||||
$table->data['method_generation'][0] = __('Method generation networkmap');
|
||||
$table->data['method_generation'][1] = html_print_select($generation_methods, 'generation_method', $generation_method,
|
||||
'', '', 'twopi', true, false, true, '',
|
||||
$disabled_select);
|
||||
|
||||
$table->data[3][0] = __('Name');
|
||||
$table->data[3][1] = html_print_input_text ('name', $name, '', 30,
|
||||
100,true);
|
||||
|
||||
$table->data[4][0] = __('Group');
|
||||
$table->data[4][1] = html_print_select_groups(false, "AR", true,
|
||||
'id_group', $id_group, '', '', 0, true);
|
||||
|
||||
$table->data[5][0] = __('Description');
|
||||
$table->data[5][1] = html_print_textarea ("description", 2, 65, $description, '', true);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$table->data[6][0] = __('Refresh time');
|
||||
$table->data[6][1] = html_print_input_text ('source_period', $source_period, '', 8,
|
||||
20,true);
|
||||
|
||||
|
||||
$table->data[7][0] = __('Show groups filter');
|
||||
$table->data[7][1] = html_print_checkbox('show_groups_filter', '1', $show_groups_filter, true);
|
||||
|
||||
|
||||
$table->data[8][0] = __('Show module plugins');
|
||||
$table->data[8][1] = html_print_checkbox('show_module_plugins', '1', $show_module_plugins, true);
|
||||
|
||||
|
||||
$table->data[9][0] = __('Show snmp modules');
|
||||
$table->data[9][1] = html_print_checkbox('show_snmp_modules', '1', $show_snmp_modules, true);
|
||||
|
||||
|
||||
$table->data[10][0] = __('Show modules');
|
||||
$table->data[10][1] = html_print_checkbox('show_modules', '1', $show_modules, true);
|
||||
|
||||
|
||||
$table->data[11][0] = __('Show policy modules');
|
||||
$table->data[11][1] = html_print_checkbox('show_policy_modules', '1', $show_policy_modules, true);
|
||||
|
||||
|
||||
$table->data[12][0] = __('Show pandora nodes');
|
||||
$table->data[12][1] = html_print_checkbox('show_pandora_nodes', '1', $show_pandora_nodes, true);
|
||||
|
||||
|
||||
$table->data[13][0] = __('Show module group');
|
||||
$table->data[13][1] = html_print_checkbox('show_module_group', '1', $show_module_group, true);
|
||||
|
||||
|
||||
$table->data[14][0] = __('Filter by tags');
|
||||
$table->data[14][1] = html_print_select (tags_get_user_tags(), "id_tag", $id_tag, '', __('All'), 0, true, false, true, '', false, '');
|
||||
|
||||
|
||||
$table->data[15][0] = __('Filter by text');
|
||||
$table->data[15][1] = html_print_input_text ('text', $text, '', 30,
|
||||
100,true);
|
||||
|
||||
|
||||
echo '<form method="post" action="index.php?sec=maps&sec2=operation/maps/networkmap_list">';
|
||||
|
||||
|
||||
html_print_table($table);
|
||||
|
||||
|
||||
echo "<div style='width: " . $table->width . "; text-align: right;'>";
|
||||
if ($create_networkmap) {
|
||||
html_print_input_hidden ('save_networkmap', 1);
|
||||
|
@ -237,3 +250,35 @@ else {
|
|||
echo "</form>";
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var MAP_SOURCE_GROUP = <?php echo MAP_SOURCE_GROUP; ?>;
|
||||
var MAP_SOURCE_IP_MASK = <?php echo MAP_SOURCE_IP_MASK; ?>;
|
||||
|
||||
$(function() {
|
||||
change_source();
|
||||
|
||||
$("input[name='source']").on("change",
|
||||
function(event) {
|
||||
change_source();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function change_source() {
|
||||
var checked_source_group =
|
||||
$("input[name='source'][value='" + MAP_SOURCE_GROUP + "']")
|
||||
.is(":checked");
|
||||
var checked_source_ip_mask =
|
||||
$("input[name='source'][value='" + MAP_SOURCE_IP_MASK + "']")
|
||||
.is(":checked");
|
||||
|
||||
$("#form_editor-source_group").hide();
|
||||
$("#form_editor-source_ip_mask").hide();
|
||||
if (checked_source_group) {
|
||||
$("#form_editor-source_group").show();
|
||||
}
|
||||
else if (checked_source_ip_mask) {
|
||||
$("#form_editor-source_ip_mask").show();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -77,24 +77,31 @@ $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");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$type = MAP_TYPE_NETWORKMAP;
|
||||
$subtype = (int) get_parameter('subtype', MAP_SUBTYPE_GROUPS);
|
||||
$name = (string) get_parameter('name', "");
|
||||
$description = (string) get_parameter('description', "");
|
||||
$source_period = (int) get_parameter('source_period', 60 * 5);
|
||||
$source = (int) get_parameter('source', MAP_SOURCE_GROUP);
|
||||
$source_data = (string) get_parameter('source_data', 'group');
|
||||
$source_data = (string) get_parameter('source_data', MAP_SOURCE_GROUP);
|
||||
switch ($source_data) {
|
||||
case MAP_SOURCE_GROUP:
|
||||
$source = (string) get_parameter('source_group', 0);
|
||||
break;
|
||||
case MAP_SOURCE_IP_MASK:
|
||||
$source = (string) get_parameter('source_ip_mask', 0);
|
||||
break;
|
||||
}
|
||||
$generation_method = (int) get_parameter('generation_method', MAP_GENERATION_CIRCULAR);
|
||||
$show_groups_filter = (int) get_parameter('show_groups_filter', false);
|
||||
$show_module_plugins = (int) get_parameter('show_module_plugins', false);
|
||||
|
@ -105,7 +112,7 @@ if ($save_networkmap) {
|
|||
$show_module_group = (int) get_parameter('show_module_group', false);
|
||||
$id_tag = (int) get_parameter('id_tag', 0);
|
||||
$text = (string) get_parameter('text', "");
|
||||
|
||||
|
||||
$values = array();
|
||||
$values['name'] = $name;
|
||||
$values['id_user'] = $config['id_user'];
|
||||
|
@ -129,29 +136,32 @@ if ($save_networkmap) {
|
|||
$filter['text'] = $text;
|
||||
$values['filter'] = json_encode($filter);
|
||||
$networkmap_names = db_get_all_rows_sql("SELECT name FROM tmap");
|
||||
|
||||
$same_name = false;
|
||||
foreach ($networkmap_names as $networkmap_name) {
|
||||
if ($networkmap_name == $name) {
|
||||
$same_name = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($name) && !$same_name) {
|
||||
$result_add = maps_save_map($values);
|
||||
}
|
||||
|
||||
|
||||
ui_print_result_message ($result_add,
|
||||
__('Successfully created'),
|
||||
__('Could not be created'));
|
||||
}
|
||||
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",
|
||||
|
@ -159,20 +169,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");
|
||||
|
@ -181,20 +191,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_duplicate,
|
||||
__('Successfully duplicate'),
|
||||
__('Could not be duplicate'));
|
||||
}
|
||||
|
||||
|
||||
else if ($update_networkmap) {
|
||||
$id_group = (int) get_parameter('id_group', 0);
|
||||
$name = (string) get_parameter('name', "");
|
||||
|
@ -211,7 +221,7 @@ else if ($delete_networkmap || $duplicate_networkmap || $update_networkmap) {
|
|||
$show_module_group = (int) get_parameter('show_module_group', false);
|
||||
$id_tag = (int) get_parameter('id_tag', 0);
|
||||
$text = (string) get_parameter('text', "");
|
||||
|
||||
|
||||
$values = array();
|
||||
$values['name'] = $name;
|
||||
$values['id_group'] = $id_group;
|
||||
|
@ -235,7 +245,7 @@ else if ($delete_networkmap || $duplicate_networkmap || $update_networkmap) {
|
|||
if (!empty($name)) {
|
||||
$result_update = maps_update_map($id, $values);
|
||||
}
|
||||
|
||||
|
||||
ui_print_result_message ($result_update,
|
||||
__('Successfully updated'),
|
||||
__('Could not be updated'));
|
||||
|
|
Loading…
Reference in New Issue