From 29a2b2f37aa9ee2adc920f08d4ca8a01ce583607 Mon Sep 17 00:00:00 2001 From: raulmateos Date: Thu, 23 Sep 2010 12:34:06 +0000 Subject: [PATCH] 2010-09-23 Raul Mateos * godmode/users/user_list.php: Able to edit profiles. * godmode/users/configure_profile.php: New page, based on the old profile one (that should be deleted if all it's OK) * godmode/menu.php: Removed profiles menu entry. * godmode/alerts/alert_list.list.php: Centered several icons. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3285 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- .../godmode/alerts/alert_list.list.php | 7 + pandora_console/godmode/menu.php | 8 - .../godmode/users/configure_profile.php | 208 ++++++++++++++++++ pandora_console/godmode/users/user_list.php | 22 +- 4 files changed, 227 insertions(+), 18 deletions(-) create mode 100644 pandora_console/godmode/users/configure_profile.php diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 1778e4c892..29632df826 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -317,9 +317,16 @@ $table->head[6] = __('Actions'); $table->head[7] = __('Status'); $table->head[8] = __('Delete'); +$table->valign[2] = 'middle'; +$table->valign[4] = 'middle'; $table->valign[6] = 'middle'; +$table->valign[7] = 'middle'; +$table->valign[8] = 'middle'; +$table->align[2] = 'center'; +$table->align[4] = 'center'; $table->align[6] = 'center'; $table->align[7] = 'center'; +$table->align[8] = 'center'; $table->data = array (); diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index e5905e02cd..1e6113caaa 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -109,14 +109,6 @@ if (give_acl ($config['id_user'], 0, "UM")) { $menu["gusuarios"]["sec2"] = "godmode/users/user_list"; $menu["gusuarios"]["id"] = "god-users"; - - if (give_acl ($config['id_user'], 0, "PM")) { - $sub = array (); - // Manage profiles - $sub["godmode/profiles/profile_list"]["text"] = __('Manage profiles'); - $menu["gusuarios"]["sub"] = $sub; - } - } // SNMP console diff --git a/pandora_console/godmode/users/configure_profile.php b/pandora_console/godmode/users/configure_profile.php new file mode 100644 index 0000000000..f293a0f451 --- /dev/null +++ b/pandora_console/godmode/users/configure_profile.php @@ -0,0 +1,208 @@ +'.__('There was a problem deleting the profile').''; + } else { + echo '

'.__('Successfully deleted').'

'; + echo '« Back'; + } + + //Delete profile from user data + $sql = sprintf ('DELETE FROM tusuario_perfil WHERE id_perfil = %d', $id_profile); + process_sql ($sql); + + $id_profile = 0; +} + +// Update profile +if ($update_profile) { + $name = get_parameter ("name"); + $incident_view = (bool) get_parameter ("incident_view"); + $incident_edit = (bool) get_parameter ("incident_edit"); + $incident_management = (bool) get_parameter ("incident_management"); + $agent_view = (bool) get_parameter ("agent_view"); + $agent_edit = (bool) get_parameter ("agent_edit"); + $alert_edit = (bool) get_parameter ("alert_edit"); + $user_management = (bool) get_parameter ("user_management"); + $db_management = (bool) get_parameter ("db_management"); + $alert_management = (bool) get_parameter ("alert_management"); + $pandora_management = (bool) get_parameter ("pandora_management"); + + $sql = sprintf ('UPDATE tperfil SET + name = "%s", incident_view = %d, incident_edit = %d, + incident_management = %d, agent_view = %d, agent_edit = %d, + alert_edit = %d, user_management = %d, db_management = %d, + alert_management = %d, pandora_management = %d WHERE id_perfil = %d', + $name, $incident_view, $incident_edit, $incident_management, + $agent_view, $agent_edit, $alert_edit, $user_management, + $db_management, $alert_management, $pandora_management, + $id_profile); + $ret = process_sql ($sql); + if ($ret !== false) { + echo '

'.__('Successfully updated').'

'; + echo '« Back'; + } else { + echo '

'; + } + $id_profile = 0; +} + +// Create profile +if ($create_profile) { + $name = get_parameter ("name"); + $incident_view = (bool) get_parameter ("incident_view"); + $incident_edit = (bool) get_parameter ("incident_edit"); + $incident_management = (bool) get_parameter ("incident_management"); + $agent_view = (bool) get_parameter ("agent_view"); + $agent_edit = (bool) get_parameter ("agent_edit"); + $alert_edit = (bool) get_parameter ("alert_edit"); + $user_management = (bool) get_parameter ("user_management"); + $db_management = (bool) get_parameter ("db_management"); + $alert_management = (bool) get_parameter ("alert_management"); + $pandora_management = (bool) get_parameter ("pandora_management"); + + $sql = sprintf ('INSERT INTO tperfil + (name, incident_view, incident_edit, incident_management, agent_view, + agent_edit, alert_edit, user_management, db_management, + alert_management, pandora_management) + VALUES ("%s", %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)', + $name, $incident_view, $incident_edit, $incident_management, + $agent_view, $agent_edit, $alert_edit, $user_management, + $db_management, $alert_management, $pandora_management); + + $ret = process_sql ($sql, 'insert_id'); + if ($ret !== false) { + echo '

'.__('Successfully created').'

'; + echo '« Back'; + } else { + echo '

'.__('There was a problem creating this profile').'

'; + } + $id_profile = 0; +} + +// Edit profile +if ($id_profile || $new_profile) { + + if ($new_profile) { + $name = ''; + $incident_view = 0; + $incident_edit = 0; + $incident_management = 0; + $agent_view = 0; + $agent_edit = 0; + $alert_edit = 0; + $user_management = 0; + $db_management = 0; + $alert_management = 0; + $pandora_management = 0; + + $page_title = __('Create profile'); + } else { + $profile = get_db_row ('tperfil', 'id_perfil', $id_profile); + + if ($profile === false) { + echo '

'.__('There was a problem loading profile').'

'; + include ("general/footer.php"); + exit; + } + $name = $profile["name"]; + $incident_view = (bool) $profile["incident_view"]; + $incident_edit = (bool) $profile["incident_edit"]; + $incident_management = (bool) $profile["incident_management"]; + $agent_view = (bool) $profile["agent_view"]; + $agent_edit = (bool) $profile["agent_edit"]; + $alert_edit = (bool) $profile["alert_edit"]; + $user_management = (bool) $profile["user_management"]; + $db_management = (bool) $profile["db_management"]; + $alert_management = (bool) $profile["alert_management"]; + $pandora_management = (bool) $profile["pandora_management"]; + + $page_title = __('Update profile'); + } + + $table->width = '400px'; + $table->class = 'databox'; + $table->size = array (); + $table->style = array (); + $table->style[0] = 'font-weight: bold'; + $table->data = array (); + + $table->data[0][0] = __('Profile name'); + $table->data[0][1] = print_input_text ('name', $name, '', 30, 60, true); + $table->data[1][0] = __('View incidents'); + $table->data[1][1] = print_checkbox ('incident_view', 1, $incident_view, true); + $table->data[2][0] = __('Edit incidents'); + $table->data[2][1] = print_checkbox ('incident_edit', 1, $incident_edit, true); + $table->data[3][0] = __('Manage incidents'); + $table->data[3][1] = print_checkbox ('incident_management', 1, $incident_management, true); + $table->data[4][0] = __('View agents'); + $table->data[4][1] = print_checkbox ('agent_view', 1, $agent_view, true); + $table->data[5][0] = __('Edit agents'); + $table->data[5][1] = print_checkbox ('agent_edit', 1, $agent_edit, true); + $table->data[6][0] = __('Edit alerts'); + $table->data[6][1] = print_checkbox ('alert_edit', 1, $alert_edit, true); + $table->data[7][0] = __('Manage alerts'); + $table->data[7][1] = print_checkbox ('alert_management', 1, $alert_management, true); + $table->data[8][0] = __('Manage users'); + $table->data[8][1] = print_checkbox ('user_management', 1, $user_management, true); + $table->data[9][0] = __('Manage Database'); + $table->data[9][1] = print_checkbox ('db_management', 1, $db_management, true); + $table->data[10][0] = __('Pandora management'); + $table->data[10][1] = print_checkbox ('pandora_management', 1, $pandora_management, true); + + echo '
'; + + print_table ($table); + + echo '
'; + if ($new_profile) { + print_submit_button (__('Add'), "crt", false, 'class="sub wand"'); + print_input_hidden ('create_profile', 1); + } else { + print_input_hidden ('id', $id_profile); + print_input_hidden ('update_profile', 1); + print_submit_button (__('Update'), "upd", false, 'class="sub upd"'); + } + echo "
"; + +} +?> diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 8d09decb62..806b0e7774 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -13,7 +13,7 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// Load globar vars +// Load global vars global $config; check_login (); @@ -248,8 +248,7 @@ $profiles = get_db_all_rows_in_table ("tperfil"); $img = print_image ("images/ok.png", true, array ("border" => 0)); foreach ($profiles as $profile) { - $data[0] = $profile["name"]; - + $data[0] = ''.$profile["name"].''; $data[1] = ($profile["incident_view"] ? $img : ''); $data[2] = ($profile["incident_edit"] ? $img : ''); $data[3] = ($profile["incident_management"] ? $img : ''); @@ -260,14 +259,17 @@ foreach ($profiles as $profile) { $data[8] = ($profile["db_management"] ? $img : ''); $data[9] = ($profile["alert_management"] ? $img : ''); $data[10] = ($profile["pandora_management"] ? $img : ''); - $data[11] = print_input_image ("delete_profile", "images/cross.png", $profile["id_perfil"], 'border:0px;', true); //Delete profile button - + $data[11] = ''; array_push ($table->data, $data); } - -echo '
'; -print_table ($table); -echo '
'; -unset ($table); + + echo '
'; + print_table ($table); + echo '
'; + print_input_hidden ('new_profile', 1); + print_submit_button (__('Create'), "crt", false, 'class="sub next"'); + echo "
"; + echo '
'; + unset ($table); ?>