From 25671d9c28bcce4a877a01d1004d350c6a3f5bff Mon Sep 17 00:00:00 2001 From: zarzuelo <zarzuelo@gmail.com> Date: Mon, 6 Aug 2012 08:40:31 +0000 Subject: [PATCH] 2012-08-06 Sergio Martin <sergio.martin@artica.es> * include/functions_users.php include/functions_html.php include/constants.php godmode/modules/manage_network_components_form_plugin.php: order functions to use from enterprise side, fix little interface bug in components form git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6848 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 ++++ .../manage_network_components_form_plugin.php | 6 ++- pandora_console/include/constants.php | 1 + pandora_console/include/functions_html.php | 30 +----------- pandora_console/include/functions_users.php | 47 +++++++++++++++++++ 5 files changed, 64 insertions(+), 29 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f38dd5d509..7487d5c980 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2012-08-06 Sergio Martin <sergio.martin@artica.es> + + * include/functions_users.php + include/functions_html.php + include/constants.php + godmode/modules/manage_network_components_form_plugin.php: order + functions to use from enterprise side, fix little interface bug in + components form + 2012-08-02 Miguel de Dios <miguel.dedios@artica.es> * pandoradb_data.sql, pandoradb.data.postgreSQL.sql, diff --git a/pandora_console/godmode/modules/manage_network_components_form_plugin.php b/pandora_console/godmode/modules/manage_network_components_form_plugin.php index 292444d175..c0deba6b04 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_plugin.php +++ b/pandora_console/godmode/modules/manage_network_components_form_plugin.php @@ -117,7 +117,11 @@ while(1) { $data[1] = __('Add macro').' <a href="javascript:new_macro(\'network_component-plugin_\')">'.html_print_image('images/add.png',true).'</a>'; $data[1] .= '<div id="next_macro" style="display:none">'.$i.'</div>'; $data[1] .= '<div id="next_row" style="display:none">'.$next_name_number.'</div>'; - $data[2] = '<div id="delete_macro_button" style="display:none;">'.__('Delete macro').' <a href="javascript:delete_macro(\'network_component-plugin_\')">'.html_print_image('images/cancel.png',true).'</a></div>'; + $delete_macro_style = ''; + if($i <= 2) { + $delete_macro_style = 'display:none;'; + } + $data[2] = '<div id="delete_macro_button" style="'.$delete_macro_style.'">'.__('Delete macro').' <a href="javascript:delete_macro(\'network_component-plugin_\')">'.html_print_image('images/cancel.png',true).'</a></div>'; push_table_row ($data, 'plugin_n'); } diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 42c47843e5..8f93349a8c 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -48,6 +48,7 @@ define ('ERR_FILE', -50000); define ('ERR_NOCHANGES', -60000); define ('ERR_NODATA', -70000); define ('ERR_CONNECTION', -80000); +define ('ERR_DISABLED', -90000); diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index ba53f47db0..204763f005 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -211,34 +211,8 @@ function html_print_select_groups($id_user = false, $privilege = "AR", $returnAl $multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $id_group = false) { global $config; - $user_groups = users_get_groups ($id_user, $privilege, $returnAllGroup, true); - - if ($id_group !== false) { - $childrens = groups_get_childrens($id_group); - foreach ($childrens as $child) { - unset($user_groups[$child['id_grupo']]); - } - unset($user_groups[$id_group]); - } - - if (empty($user_groups)) { - $user_groups_tree = array(); - } - else { - // First group it's needed to retrieve its parent group - $first_group = array_slice($user_groups, 0, 1); - $parent_group = $first_group[0]['parent']; - - $user_groups_tree = groups_get_groups_tree_recursive($user_groups, $parent_group); - } - - $fields = array(); - foreach ($user_groups_tree as $group) { - $groupName = ui_print_truncate_text($group['nombre'], GENERIC_SIZE_TEXT, false, true, false); - - $fields[$group['id_grupo']] = str_repeat(" ", $group['deep']) . $groupName; - } - + $fields = users_get_groups_for_select($id_user, $privilege, $returnAllGroup, true, $id_group); + $output = html_print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, $return, $multiple, false, $class, $disabled, $style, $option_style); diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index 8a87c242fa..828e44d4d6 100644 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -73,6 +73,53 @@ function users_get_all_model_groups () { return $returnGroups; } +/** + * Get all the groups a user has reading privileges with the special format to use it on select. + * + * @param string User id + * @param string The privilege to evaluate, and it is false then no check ACL. + * @param boolean $returnAllGroup Flag the return group, by default true. + * @param boolean $returnAllColumns Flag to return all columns of groups. + * @param array $id_groups The list of group to scan to bottom child. By default null. + * + * @return array A list of the groups the user has certain privileges. + */ +function users_get_groups_for_select($id_user, $privilege = "AR", $returnAllGroup = true, $returnAllColumns = false, $id_groups = null) { + if($id_groups === false) { + $id_groups = null; + } + + $user_groups = users_get_groups ($id_user, $privilege, $returnAllGroup, $returnAllColumns, $id_groups); + + if ($id_groups !== null) { + $childrens = groups_get_childrens($id_groups); + foreach ($childrens as $child) { + unset($user_groups[$child['id_grupo']]); + } + unset($user_groups[$id_groups]); + } + + if (empty($user_groups)) { + $user_groups_tree = array(); + } + else { + // First group it's needed to retrieve its parent group + $first_group = array_slice($user_groups, 0, 1); + $parent_group = $first_group[0]['parent']; + + $user_groups_tree = groups_get_groups_tree_recursive($user_groups, $parent_group); + } + $fields = array(); + + foreach ($user_groups_tree as $group) { + $groupName = ui_print_truncate_text($group['nombre'], GENERIC_SIZE_TEXT, false, true, false); + + $fields[$group['id_grupo']] = str_repeat(" ", $group['deep']) . $groupName; + } + + return $fields; +} + /** * Get all the groups a user has reading privileges. *