diff --git a/account_prefs_update.php b/account_prefs_update.php index 9e08c2f0aa..5dfae33002 100644 --- a/account_prefs_update.php +++ b/account_prefs_update.php @@ -86,7 +86,7 @@ # prevent users from changing other user's accounts if ( $f_user_id != auth_get_current_user_id() ) { - access_ensure_project_level( ADMINISTRATOR ); + access_ensure_global_level( config_get_global( 'admin_site_threshold' ) ); } # make sure the delay isn't too low diff --git a/admin/check.php b/admin/check.php index 58afea5961..e6e95ce4fe 100644 --- a/admin/check.php +++ b/admin/check.php @@ -317,7 +317,7 @@ function test_database_utf8() { print_test_row( 'check configuration: anonymous_account is a valid username if set', ( (strlen( config_get_global( 'anonymous_account') ) > 0 ) ? ( ($t_anon_user = user_get_id_by_name( config_get_global( 'anonymous_account') ) ) !== false ) : TRUE ) ); print_test_row( 'check configuration: anonymous_account should not be an administrator', - ( $t_anon_user ? ( !access_compare_level( user_get_field( $t_anon_user, 'access_level' ), ADMINISTRATOR) ) : TRUE ) ); + ( $t_anon_user ? ( !user_is_administrator( $t_anon_user ) ) : TRUE ) ); print_test_row( '$g_bug_link_tag is not empty ("' . config_get_global( 'bug_link_tag' ) . '")', '' <> config_get_global( 'bug_link_tag' ) ); print_test_row( '$g_bugnote_link_tag is not empty ("' . config_get_global( 'bugnote_link_tag' ) . '")', diff --git a/admin/copy_field.php b/admin/copy_field.php index 019a9fcbe6..1498b78b81 100644 --- a/admin/copy_field.php +++ b/admin/copy_field.php @@ -26,7 +26,7 @@ */ require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' ); -access_ensure_global_level( ADMINISTRATOR ); +access_ensure_global_level( config_get_global( 'admin_site_threshold' ) ); $f_source_field_id = gpc_get_int( 'source_id' ); $f_dest_field = gpc_get( 'dest_id' ); diff --git a/admin/db_stats.php b/admin/db_stats.php index 36da1272b5..e26fdda852 100644 --- a/admin/db_stats.php +++ b/admin/db_stats.php @@ -25,7 +25,7 @@ */ require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' ); -access_ensure_global_level( ADMINISTRATOR ); +access_ensure_global_level( config_get_global( 'admin_site_threshold' ) ); # -------------------- function helper_table_row_count( $p_table ) { diff --git a/admin/email_queue.php b/admin/email_queue.php index ccbc4e9b43..0af9ebf350 100644 --- a/admin/email_queue.php +++ b/admin/email_queue.php @@ -25,7 +25,7 @@ */ require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' ); -access_ensure_global_level( ADMINISTRATOR ); +access_ensure_global_level( config_get_global( 'admin_site_threshold' ) ); $f_to = gpc_get( 'send', null ); @@ -72,4 +72,4 @@ } html_button( 'email_queue.php', 'Send All', array( 'send' => 'all') ); -html_button( 'email_queue.php', 'Send Or Delete All', array( 'send' => 'sendordelall') ); \ No newline at end of file +html_button( 'email_queue.php', 'Send Or Delete All', array( 'send' => 'sendordelall') ); diff --git a/admin/index.php b/admin/index.php index 746f926969..c21ab20195 100644 --- a/admin/index.php +++ b/admin/index.php @@ -26,7 +26,7 @@ require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' ); require_once( 'schema.php' ); -access_ensure_global_level( ADMINISTRATOR ); +access_ensure_global_level( config_get_global( 'admin_site_threshold' ) ); html_page_top( 'MantisBT Administration' ); diff --git a/admin/move_db2disk.php b/admin/move_db2disk.php index 5673c94bd9..82081dc093 100644 --- a/admin/move_db2disk.php +++ b/admin/move_db2disk.php @@ -26,7 +26,7 @@ */ require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' ); -access_ensure_global_level( ADMINISTRATOR ); +access_ensure_global_level( config_get_global( 'admin_site_threshold' ) ); // Move type should be attachment or project. $f_move_type = gpc_get( 'doc' ); diff --git a/admin/system_utils.php b/admin/system_utils.php index 867c714100..a2d3d2d285 100644 --- a/admin/system_utils.php +++ b/admin/system_utils.php @@ -26,7 +26,7 @@ */ require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' ); -access_ensure_global_level( ADMINISTRATOR ); +access_ensure_global_level( config_get_global( 'admin_site_threshold' ) ); html_page_top( 'MantisBT Administration - System Utilities' ); @@ -95,4 +95,4 @@ ' ) . lang_get( 'edit_news_link' ) . ''; } else { $t_menu_options[] = '' ) . lang_get( 'edit_news_link' ) . ''; diff --git a/core/plugin_api.php b/core/plugin_api.php index 2f3c035909..9521fc3af2 100644 --- a/core/plugin_api.php +++ b/core/plugin_api.php @@ -177,7 +177,11 @@ function plugin_config_get( $p_option, $p_default = null, $p_global = false ) { * @param int Project ID * @param int Access threshold */ -function plugin_config_set( $p_option, $p_value, $p_user = NO_USER, $p_project = ALL_PROJECTS, $p_access = ADMINISTRATOR ) { +function plugin_config_set( $p_option, $p_value, $p_user = NO_USER, $p_project = ALL_PROJECTS, $p_access = DEFAULT_ACCESS_LEVEL ) { + if( $p_access == DEFAULT_ACCESS_LEVEL ) { + $p_access = config_get_global( 'admin_site_threshold' ); + } + $t_basename = plugin_get_current(); $t_full_option = 'plugin_' . $t_basename . '_' . $p_option; diff --git a/core/print_api.php b/core/print_api.php index 673a5b5dad..83bc0f3729 100644 --- a/core/print_api.php +++ b/core/print_api.php @@ -326,7 +326,7 @@ function print_news_item_option_list() { $t_project_id = helper_get_current_project(); - $t_global = access_has_global_level( ADMINISTRATOR ); + $t_global = access_has_global_level( config_get_global( 'admin_site_threshold' ) ); if( $t_global ) { $query = "SELECT id, headline, announcement, view_state FROM $t_mantis_news_table @@ -1035,7 +1035,7 @@ function print_project_user_list_option_list( $p_project_id = null ) { } $c_project_id = (int) $p_project_id; - $t_adm = ADMINISTRATOR; + $t_adm = config_get_global( 'admin_site_threshold' ); $query = "SELECT DISTINCT u.id, u.username, u.realname FROM $t_mantis_user_table u LEFT JOIN $t_mantis_project_user_list_table p diff --git a/core/user_api.php b/core/user_api.php index 1b35e6ebde..9287c5bdef 100644 --- a/core/user_api.php +++ b/core/user_api.php @@ -338,7 +338,7 @@ function user_is_monitoring_bug( $p_user_id, $p_bug_id ) { function user_is_administrator( $p_user_id ) { $t_access_level = user_get_field( $p_user_id, 'access_level' ); - if( $t_access_level >= ADMINISTRATOR ) { + if( $t_access_level >= config_get_global( 'admin_site_threshold' ) ) { return true; } else { return false; @@ -801,7 +801,7 @@ function user_get_avatar( $p_user_id, $p_size = 80 ) { function user_get_access_level( $p_user_id, $p_project_id = ALL_PROJECTS ) { $t_access_level = user_get_field( $p_user_id, 'access_level' ); - if( $t_access_level >= ADMINISTRATOR ) { + if( user_is_administrator( $p_user_id ) ) { return $t_access_level; } diff --git a/manage_overview_page.php b/manage_overview_page.php index 669cfea3d1..6251e83c82 100644 --- a/manage_overview_page.php +++ b/manage_overview_page.php @@ -26,7 +26,6 @@ auth_reauthenticate(); access_ensure_global_level( config_get( 'manage_site_threshold' ) ); - $t_is_admin = access_has_global_level( config_get( 'admin_site_threshold' ) ); $t_version_suffix = config_get_global( 'version_suffix' ); @@ -56,7 +55,7 @@ - + > diff --git a/manage_user_edit_page.php b/manage_user_edit_page.php index 0105aeb718..1bda085583 100644 --- a/manage_user_edit_page.php +++ b/manage_user_edit_page.php @@ -149,7 +149,7 @@ -= user_count_level( ADMINISTRATOR ) ) ) ) { ?> +
@@ -172,7 +172,7 @@
diff --git a/manage_user_update.php b/manage_user_update.php index b68c07cb07..773fd60a10 100644 --- a/manage_user_update.php +++ b/manage_user_update.php @@ -77,15 +77,17 @@ $t_old_protected = user_get_field( $f_user_id, 'protected' ); # check that we are not downgrading the last administrator - $t_old_access = user_get_field( $f_user_id, 'access_level' ); - if ( ( ADMINISTRATOR == $t_old_access ) && ( $t_old_access <> $f_access_level ) && ( 1 >= user_count_level( ADMINISTRATOR ) ) ) { + $t_admin_threshold = config_get_global( 'admin_site_threshold' ); + if ( user_is_administrator( $f_user_id ) && + $f_access_level < $t_admin_threshold && + user_count_level( $t_admin_threshold ) <= 1 ) { trigger_error( ERROR_USER_CHANGE_LAST_ADMIN, ERROR ); } # 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 ( ( $f_access_level >= $t_admin_threshold ) && ( !user_is_administrator( $f_user_id ) ) ) { + user_delete_project_specific_access_levels( $f_user_id ); } # if the user is already protected and the admin is not removing the diff --git a/news_edit_page.php b/news_edit_page.php index bf2a504004..7fd282c616 100644 --- a/news_edit_page.php +++ b/news_edit_page.php @@ -106,7 +106,7 @@