From 8798d946e3f6ce435d871a7799f5703f9e2fa1e7 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Thu, 15 Jan 2015 15:43:08 +0100 Subject: [PATCH] Changed ACL's permission in Networkmaps visualization: RR (Report Read) Edition: RW (Report Write) Deletion: RW (only yours networkmaps), RM(any of its group, although he did not create it.) (cherry picked from commit d34ce5aa9e15dceaf2b5e4fb0f610b8c86179fbf) Conflicts: pandora_console/operation/agentes/networkmap_list.php --- .../include/functions_networkmap.php | 21 +++++++++++++++++++ .../operation/agentes/networkmap.php | 2 +- .../operation/agentes/networkmap_list.php | 8 +++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 9f0383c59f..f4e084fba2 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -1557,6 +1557,27 @@ function networkmap_delete_networkmap ($id_networkmap) { return @db_process_sql_delete ('tnetwork_map', array ('id_networkmap' => $id_networkmap)); } +/** + * Deletes a network map if the property is that user. + * + * @param string User id that call this funtion. + * @param int Map id to be deleted. + * + * @return bool True if the map was deleted, false the map is not yours. + */ +function networkmap_delete_user_networkmap ($id_user = '', $id_networkmap) { + if ($id_user == '') { + $id_user = $config['id_user']; + } + $id_networkmap = safe_int ($id_networkmap); + if (empty ($id_networkmap)) + return false; + $networkmap = networkmap_get_networkmap ($id_networkmap); + if ($networkmap === false) + return false; + return @db_process_sql_delete ('tnetwork_map', array ('id_networkmap' => $id_networkmap, 'id_user' => $id_user)); +} + /** * Updates a network map. * diff --git a/pandora_console/operation/agentes/networkmap.php b/pandora_console/operation/agentes/networkmap.php index 19ac0d15a1..0c05bd98b0 100644 --- a/pandora_console/operation/agentes/networkmap.php +++ b/pandora_console/operation/agentes/networkmap.php @@ -229,7 +229,7 @@ $combolist .= ''; $buttons['combolist'] = $combolist; -if (check_acl ($config['id_user'], 0, "AW")) { +if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) { $buttons['addmap'] = array('active' => $activeTab == false, 'text' => '' . html_print_image("images/add_mc.png", true, array ("title" => __('Add map'))) .''); diff --git a/pandora_console/operation/agentes/networkmap_list.php b/pandora_console/operation/agentes/networkmap_list.php index 6e9bb8965c..7eae7d9f7c 100644 --- a/pandora_console/operation/agentes/networkmap_list.php +++ b/pandora_console/operation/agentes/networkmap_list.php @@ -100,7 +100,7 @@ $table->size[] = '80%'; $table->size[] = '60px'; $table->size[] = '30px'; -if (check_acl ($config["id_user"], 0, "AW")) { +if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) { $table->size[] = '30px'; $table->size[] = '30px'; } @@ -109,7 +109,7 @@ $table->head = array(); $table->head[] = __('Name'); $table->head[] = __('Type'); $table->head[] = __('Group'); -if (check_acl ($config["id_user"], 0, "AW")) { +if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) { $table->head[] = __('Edit'); $table->head[] = __('Delete'); } @@ -154,7 +154,7 @@ else { $data[] = $network_map['type']; $data[] = ui_print_group_icon ($network_map['id_group'], true); - if (check_acl ($config["id_user"], 0, "AW")) { + if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) { $data[] = '' . html_print_image("images/config.png", true) . ''; $data[] = '' . html_print_image('images/cross.png', true) . ''; } @@ -166,7 +166,7 @@ else { } // Create networkmap form -if (check_acl ($config['id_user'], 0, "AW")) { +if (check_acl ($config['id_user'], 0, "RW") || check_acl ($config['id_user'], 0, "RM")) { $networkmap_types = networkmap_get_types(); echo '
'; echo "";