diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2b3902d608..39fc17626e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2009-01-22 Evi Vanoost + + * include/auth/mysql.php, include/auth/ldap.php, + operation/users/user_edit.php, godmode/users/configure_user.php, + godmode/users/user_list.php: Fixed some minor problems and annoyances + 2009-01-22 Evi Vanoost * pandoradb_migrate_20_to_21.sql, pandoradb.sql: Added user table updates diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index b37716b863..39f068da70 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -47,43 +47,52 @@ if (isset ($_GET["create"]) && $config["admin_can_add_user"]) { $user_info["email"] = ''; $user_info["phone"] = ''; $user_info["comments"] = ''; + $user_info["is_admin"] = 0; } elseif (isset ($_GET["create"])) { print_error_message (false, '', __('The current authentication scheme doesn\'t support creating users from Pandora FMS')); } elseif (isset ($_GET["user_mod"])) { $mod = get_parameter_get ("user_mod", 0); //0 is no user info modify (can modify passwords and admin status), 1 is modify, 2 is create $upd_info = array (); - $upd_info["fullname"] = get_parameter_post ("fullname", $user_info["fullname"]); - $upd_info["firstname"] = get_parameter_post ("firstname", $user_info["firstname"]); - $upd_info["lastname"] = get_parameter_post ("lastname", $user_info["lastname"]); + $upd_info["fullname"] = get_parameter_post ("fullname"); + $upd_info["firstname"] = get_parameter_post ("firstname"); + $upd_info["lastname"] = get_parameter_post ("lastname"); $password_old = get_parameter_post ("password_old", "-"); $password_new = get_parameter_post ("password_new", "-"); $password_confirm = get_parameter_post ("password_confirm", "-"); - $upd_info["email"] = get_parameter_post ("email", $user_info["email"]); - $upd_info["phone"] = get_parameter_post ("phone", $user_info["phone"]); - $upd_info["comments"] = get_parameter_post ("comments", $user_info["comments"]); - $is_admin = get_parameter_post ("is_admin", $user_info["is_admin"]); + $upd_info["email"] = get_parameter_post ("email"); + $upd_info["phone"] = get_parameter_post ("phone"); + $upd_info["comments"] = get_parameter_post ("comments"); + $is_admin = get_parameter_post ("is_admin", 0); $group = get_parameter_post ("assign_group", 0); $profile = get_parameter_post ("assign_profile", 0); if ($config["admin_can_add_user"] && $mod == 2) { - if ($password_new !== $password_confirm) { + if ($password_new != $password_confirm) { print_error_message (false, '', __('Passwords didn\t match')); + $id = ''; $user_info = $upd_info; //Fill in the blanks again + $user_info["is_admin"] = $is_admin; + $_GET["create"] = 1; //Set create mode back on + $password_old = "-"; + $password_new = "-"; + $password_confirm = "-"; } else { $id = get_parameter_post ("id_user"); $return = create_user ($id, $password_new, $upd_info); print_error_message ($return, __('User successfully created'), __('Error creating user')); $user_info = get_user_info ($id); $id = $user_info["id_user"]; - $_GET["create"] = 1; //Set create mode back on + $password_old = "-"; + $password_new = "-"; + $password_confirm = "-"; } - } elseif ($config["user_can_update_info"] && mod == 1) { + } elseif ($config["user_can_update_info"] && $mod == 1) { $return = process_user_info ($id, $upd_info); - print_error_message ($return, __('User info successfully updated'), __('Error updating user info')); - $user_info = get_user_info ($id); - $id = $user_info["id_user"]; + print_error_message ($return, __('User info successfully updated'), __('Error updating user info (no change?)')); + $user_info = $upd_info; + $user_info["is_admin"] = $is_admin; } //If User can update password and the new password is not the same as the old one, it's not the default and it's not empty and the new password is the same as the confirmed one @@ -112,9 +121,9 @@ if (isset ($_GET["create"]) && $config["admin_can_add_user"]) { echo "

".__('Pandora users')." > ".__('User detail editor')."

"; if (!empty ($id)) { - echo '
'; + echo ''; } else { - echo ''; + echo ''; } echo ''; @@ -135,12 +144,12 @@ print_input_text_extended ("lastname", $user_info["lastname"], '', '', '', '', $ echo '
'.__('Password').''; if ($config["user_can_update_password"]) { if (!isset ($_GET["create"])) { - print_input_text_extended ("password_old", "", '', '', '', '', $view_mode, '', 'class="input"', false, true); + print_input_text_extended ("password_old", "-", '', '', '', '', $view_mode, '', 'class="input"', false, true); } echo '
'.__('New Password').''; - print_input_text_extended ("password_new", "", '', '', '', '', $view_mode, '', 'class="input"', false, true); + print_input_text_extended ("password_new", "-", '', '', '', '', $view_mode, '', 'class="input"', false, true); echo '
'.__('Password confirmation').''; - print_input_text_extended ("password_conf", "", '', '', '', '', $view_mode, '', 'class="input"', false, true); + print_input_text_extended ("password_confirm", "-", '', '', '', '', $view_mode, '', 'class="input"', false, true); } else { echo ''.__('You can not change passwords from Pandora FMS under the current authentication scheme').''; } @@ -201,7 +210,7 @@ $table->align[1] = 'center'; $table->align[2] = 'center'; -$result = get_db_all_rows_field_filter ("tusuario_perfil", "id_usuario", $user_info["id_user"]); +$result = get_db_all_rows_field_filter ("tusuario_perfil", "id_usuario", $id); if ($result === false) { $result = array (); } diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 32ba755f3c..ae6f69ba53 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -65,7 +65,7 @@ $info = array (); $info = get_users (); foreach ($info as $user_id => $user_info) { - $data[0] = ''.$user_id.''; + $data[0] = ''.$user_id.''; $data[1] = $user_info["fullname"].''; $data[1] .= __('First name').': '.$user_info["firstname"].'
'; $data[1] .= __('Last name').': '.$user_info["lastname"].'
'; diff --git a/pandora_console/include/auth/ldap.php b/pandora_console/include/auth/ldap.php index 503162d37a..4c933f434d 100644 --- a/pandora_console/include/auth/ldap.php +++ b/pandora_console/include/auth/ldap.php @@ -189,6 +189,15 @@ function process_user_contact ($id_user) { //Empty function } +/** + * Sets the user admin status (LDAP doesn't do this) + * + * @param string User id + */ +function process_user_isadmin ($id_user, $is_admin) { + return false; +} + /** * LDAP user functions based on webcalendar's implementation * diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index b061dbe5fb..ce1db2296b 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -185,9 +185,7 @@ function create_user ($id_user, $password, $user_info) { } } - process_sql_insert ("tusuario", $values); - - return (bool) process_sql ($sql); + return process_sql_insert ("tusuario", $values); } /** @@ -242,6 +240,20 @@ function process_user_info ($id_user, $user_info) { return process_sql_update ("tusuario", $values, array ("id_user" => $id_user)); } +/** + * Sets the user admin status (LDAP doesn't do this) + * + * @param string User id + */ +function process_user_isadmin ($id_user, $is_admin) { + if ($is_admin == true) { + $is_admin = 1; + } else { + $is_admin = 0; + } + return process_sql_update ("tusuario", array ("is_admin" => $is_admin), array ("id_user" => $id_user)); +} + //Reference the global use authorization error to last auth error. $config["auth_error"] = &$mysql_cache["auth_error"]; ?> \ No newline at end of file diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 876500615e..41c8fa942a 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -53,7 +53,7 @@ if (isset ($_GET["modified"]) && !$view_mode) { $return = process_user_info ($id, $upd_info); print_error_message ($return, __('User info successfully updated'), __('Error updating user info')); - $user_info = get_user_info ($id); //Reread it + $user_info = $upd_info; } echo "

".__('Pandora users')." > ".__('User detail editor')."

";