View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003389 | mantisbt | bugtracker | public | 2003-10-27 11:06 | 2003-12-13 04:34 |
Reporter | smhanson | Assigned To | vboctor | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Summary | 0003389: Problems upgrading exister user to administrator | ||||
Description | A user entered as, say, reporter or developer in a private project is later promoted to administrator. He still has only his old rights for that project until he is removed from the project, which he cannot do himself. | ||||
Tags | No tags attached. | ||||
Attached Files | upgrade_access_level_to_admin.diff (4,104 bytes)
Index: manage_user_update.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/manage_user_update.php,v retrieving revision 1.29 diff -u -r1.29 manage_user_update.php --- manage_user_update.php 18 Feb 2003 02:18:01 -0000 1.29 +++ manage_user_update.php 28 Oct 2003 10:16:00 -0000 @@ -47,6 +47,12 @@ $t_old_protected = user_get_field( $f_user_id, 'protected' ); + # Project specific access rights override global levels, hence, for users who are changed + # to be administrators, we have to remove project specific rights. + if ( ( $c_access_level >= ADMINISTRATOR ) && ( !user_is_administrator( $c_user_id ) ) ) { + user_delete_project_specific_access_levels( $c_user_id ); + } + # if the user is already protected and the admin is not removing the # protected flag then don't update the access level and enabled flag. # If the user was unprotected or the protected flag is being turned off @@ -64,8 +70,8 @@ WHERE id='$c_user_id'"; } - $result = db_query( $query ); - $t_redirect_url = 'manage_user_page.php'; + $result = db_query( $query ); + $t_redirect_url = 'manage_user_page.php'; ?> <?php html_page_top1() ?> <?php Index: core/user_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/user_api.php,v retrieving revision 1.60 diff -u -r1.60 user_api.php --- core/user_api.php 25 Aug 2003 22:24:44 -0000 1.60 +++ core/user_api.php 28 Oct 2003 10:16:04 -0000 @@ -318,17 +318,55 @@ } # -------------------- - # delete an account + # delete project-specific user access levels. + # returns true when successfully deleted + function user_delete_project_specific_access_levels( $p_user_id ) { + $c_user_id = db_prepare_int($p_user_id); + + user_ensure_unprotected( $p_user_id ); + + $t_project_user_list_table = config_get('mantis_project_user_list_table'); + + $query = "DELETE + FROM $t_project_user_list_table + WHERE user_id='$c_user_id'"; + db_query( $query ); + + user_clear_cache( $p_user_id ); + + return true; + } + + # -------------------- + # delete profiles for the specified user + # returns true when successfully deleted + function user_delete_profiles( $p_user_id ) { + $c_user_id = db_prepare_int($p_user_id); + + user_ensure_unprotected( $p_user_id ); + + $t_user_profile_table = config_get('mantis_user_profile_table'); + + # Remove associated profiles + $query = "DELETE + FROM $t_user_profile_table + WHERE user_id='$c_user_id'"; + db_query( $query ); + + user_clear_cache( $p_user_id ); + + return true; + } + + # -------------------- + # delete a user account (account, profiles, preferences, project-specific access levels) # returns true when the account was successfully deleted function user_delete( $p_user_id ) { $c_user_id = db_prepare_int($p_user_id); - user_ensure_unprotected( $p_user_id ); + user_ensure_unprotected( $p_user_id ); $t_user_table = config_get('mantis_user_table'); - $t_user_profile_table = config_get('mantis_user_profile_table'); - $t_user_pref_table = config_get('mantis_user_pref_table'); - $t_project_user_list_table = config_get('mantis_project_user_list_table'); # Remove account $query = "DELETE @@ -337,23 +375,18 @@ db_query( $query ); # Remove associated profiles - $query = "DELETE - FROM $t_user_profile_table - WHERE user_id='$c_user_id'"; - db_query( $query ); + user_delete_profiles( $p_user_id ); # Remove associated preferences user_pref_delete_all( $p_user_id ); - $query = "DELETE - FROM $t_project_user_list_table - WHERE user_id='$c_user_id'"; - db_query( $query ); + # Remove project specific access levels + user_delete_project_specific_access_levels( $p_user_id ); user_clear_cache( $p_user_id ); return true; - } + } #=================================== # Data Access | ||||
The way the access level of a user is determined is as follows:
The easiest way to fix this and not introduce extra queries when acquiring the current user's access level, is to delete the user's project-specific access levels when the user's access level is set to administrator. |
|
Then something like this could be added at line 50 of manage_user_update.php if updating user to admin, remove from all projectsif (!user_is_administrator($c_user_id) && $c_access_level == ADMINISTRATOR) { |
|
I attached a patch which fixes the problem. The idea is similar to what you mentioned with some differences:
Let me know if applying the patches solves your problem. |
|
We should also consider adding a DB upgrade step that deletes all project specific access rights for any user with access level equal to administrator. |
|
The patch works for me. Thanks! |
|
Fixed in CVS. Will be available in next release. |
|
MantisBT: master d5674886 2003-10-28 05:37 Details Diff |
Fix 0003389: Problems upgrading existing users to administrator. M manage_user_update.php - Deleting project specific access levels for users who are upgraded to ADMINISTRATORS. M core/user_api.php - (user_delete_project_specific_access_levels) Added to delete project specific access levels for a user - (user_delete_profiles) Added to delete profiles associated with a user. git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2270 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9 |
Affected Issues 0003389 |
|
mod - core/user_api.php | Diff File | ||
mod - doc/ChangeLog | Diff File | ||
mod - manage_user_update.php | Diff File |