2011-07-21 Tomas Palacios <tomas.palacios@artica.es>
* operation/agentes/networkmap.php: fixed bug 3374043 regarding having different network maps with the same name. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4618 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ff6846ef67
commit
a483e7d56d
|
@ -63,11 +63,23 @@ if($add_networkmap) {
|
|||
$module_group = 0;
|
||||
$center = 0;
|
||||
$name = $activeTab;
|
||||
$check = db_get_value('name', 'tnetwork_map', 'name', $name);
|
||||
$sql = db_get_value_filter('COUNT(name)', 'tnetwork_map', array('name' => "%$name"));
|
||||
$subcheck = db_get_value('name', 'tnetwork_map', 'name', "($sql)".$name);
|
||||
|
||||
if ($check) {
|
||||
|
||||
$id_networkmap = networkmap_create_networkmap("($sql) ".$name, $activeTab, $layout, $nooverlap, $simple, $regen, $font_size, $group, $module_group, $depth, $modwithalerts, $hidepolicymodules, $zoom, $ranksep, $center);
|
||||
$message = ui_print_result_message ($id_networkmap,
|
||||
__('Network map created successfully'),
|
||||
__('Could not create network map'), '', true);
|
||||
}
|
||||
else {
|
||||
$id_networkmap = networkmap_create_networkmap($name, $activeTab, $layout, $nooverlap, $simple, $regen, $font_size, $group, $module_group, $depth, $modwithalerts, $hidepolicymodules, $zoom, $ranksep, $center);
|
||||
$message = ui_print_result_message ($id_networkmap,
|
||||
__('Network map created successfully'),
|
||||
__('Could not create network map'), '', true);
|
||||
}
|
||||
}
|
||||
|
||||
if($save_networkmap || $update_networkmap) {
|
||||
|
@ -87,8 +99,13 @@ if($save_networkmap || $update_networkmap) {
|
|||
$module_group = (int) get_parameter ('module_group', 0);
|
||||
$center = (int) get_parameter ('center', 0);
|
||||
$name = (string) get_parameter ('name', $activeTab);
|
||||
$check = db_get_value('name', 'tnetwork_map', 'name', $name);
|
||||
$subcheck = db_get_value('name', 'tnetwork_map', 'id_networkmap', $id_networkmap);
|
||||
# $regexp = "/^(\([0-9]+\))/";
|
||||
# $regexpresult = eregi($regexp, $name);
|
||||
|
||||
if($save_networkmap){
|
||||
if (!$check && !preg_match("/$activeTab/", $name) || $subcheck == $name) {
|
||||
$result = networkmap_update_networkmap($id_networkmap, array('name' => $name, 'type' => $activeTab, 'layout' => $layout,
|
||||
'nooverlap' => $nooverlap, 'simple' => $simple, 'regenerate' => $regen, 'font_size' => $font_size,
|
||||
'id_group' => $group, 'id_module_group' => $module_group, 'depth' => $depth, 'only_modules_with_alerts' => $modwithalerts,
|
||||
|
@ -98,6 +115,15 @@ if($save_networkmap || $update_networkmap) {
|
|||
__('Network map saved successfully'),
|
||||
__('Could not save network map'), '', true);
|
||||
}
|
||||
else {
|
||||
if (preg_match("/$activeTab/", $name)) {
|
||||
$message = "<h3 class='error'>".__("Network map name cannot be manually defined as $activeTab")."</h3>";
|
||||
}
|
||||
else {
|
||||
$message = "<h3 class='error'>".__('Each network map must have a different name')."</h3>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$networkmaps = networkmap_get_networkmaps();
|
||||
|
|
Loading…
Reference in New Issue