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 @@ - html_page_bottom( __FILE__ ); \ No newline at end of file + html_page_bottom( __FILE__ ); diff --git a/admin/test_email.php b/admin/test_email.php index 4c6de4bd0f..ee4aff8df2 100644 --- a/admin/test_email.php +++ b/admin/test_email.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_mail_test = gpc_get_bool( 'mail_test' ); diff --git a/admin/test_icons.php b/admin/test_icons.php index 49fe4a7d4c..d002eabc10 100644 --- a/admin/test_icons.php +++ b/admin/test_icons.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' ) ); html_page_top(); diff --git a/admin/test_langs.php b/admin/test_langs.php index fd6d6b2180..77e0c1054b 100644 --- a/admin/test_langs.php +++ b/admin/test_langs.php @@ -48,7 +48,7 @@ unset( $g_skip_lang_load ) ; lang_push( 'english' ); -access_ensure_global_level( ADMINISTRATOR ); +access_ensure_global_level( config_get_global( 'admin_site_threshold' ) ); set_time_limit( 0 ); diff --git a/admin/upgrade_warning.php b/admin/upgrade_warning.php index 3d4fe8029e..d0e60bedc1 100644 --- a/admin/upgrade_warning.php +++ b/admin/upgrade_warning.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' ) ); $g_error_send_page_header = false; # suppress page headers in the error handler diff --git a/api/soap/mc_project_api.php b/api/soap/mc_project_api.php index 06d63a9cbf..dda0b784c9 100644 --- a/api/soap/mc_project_api.php +++ b/api/soap/mc_project_api.php @@ -526,7 +526,7 @@ function mc_project_get_attachments( $p_username, $p_password, $p_project_id ) { $t_user_table = db_get_table( 'mantis_user_table' ); $t_pub = VS_PUBLIC; $t_priv = VS_PRIVATE; - $t_admin = ADMINISTRATOR; + $t_admin = config_get_global( 'admin_site_threshold' ); if( $p_project_id == ALL_PROJECTS ) { # Select all the projects that the user has access to diff --git a/core/access_api.php b/core/access_api.php index ef860e7605..f626d5fb7a 100644 --- a/core/access_api.php +++ b/core/access_api.php @@ -293,7 +293,8 @@ function access_get_project_level( $p_project_id = null, $p_user_id = null ) { } $t_global_access_level = access_get_global_level( $p_user_id ); - if(( ALL_PROJECTS == $p_project_id ) || ( ADMINISTRATOR == $t_global_access_level ) ) { + + if( ALL_PROJECTS == $p_project_id || user_is_administrator( $p_user_id ) ) { return $t_global_access_level; } else { $t_project_access_level = access_get_local_level( $p_user_id, $p_project_id ); diff --git a/core/config_api.php b/core/config_api.php index 9f09d57a92..071a52e70c 100644 --- a/core/config_api.php +++ b/core/config_api.php @@ -242,7 +242,7 @@ function config_get_access( $p_option, $p_user = null, $p_project = null ) { } } - return $t_found ? $t_access : ADMINISTRATOR; + return $t_found ? $t_access : config_get_global( 'admin_site_threshold' ); } # ------------------ @@ -302,7 +302,10 @@ function config_is_set( $p_option, $p_user = null, $p_project = null ) { # ------------------ # Sets the value of the given config option to the given value # If the config option does not exist, an ERROR is triggered -function config_set( $p_option, $p_value, $p_user = NO_USER, $p_project = ALL_PROJECTS, $p_access = ADMINISTRATOR ) { +function 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' ); + } if( is_array( $p_value ) || is_object( $p_value ) ) { $t_type = CONFIG_TYPE_COMPLEX; $c_value = serialize( $p_value ); @@ -383,8 +386,13 @@ function config_set_global( $p_option, $p_value, $p_override = true ) { # ------------------ # Sets the value of the given config option to the given value # If the config option does not exist, an ERROR is triggered -function config_set_cache( $p_option, $p_value, $p_type, $p_user = NO_USER, $p_project = ALL_PROJECTS, $p_access = ADMINISTRATOR ) { +function config_set_cache( $p_option, $p_value, $p_type, $p_user = NO_USER, $p_project = ALL_PROJECTS, $p_access = DEFAULT_ACCESS_LEVEL ) { global $g_cache_config, $g_cache_config_access; + + if( $p_access == DEFAULT_ACCESS_LEVEL ) { + $p_access = config_get_global( 'admin_site_threshold' ); + } + $g_cache_config[$p_option][$p_user][$p_project] = $p_type . ';' . $p_value; $g_cache_config_access[$p_option][$p_user][$p_project] = $p_access; diff --git a/core/filter_api.php b/core/filter_api.php index 9455af961c..7fee1cc5df 100644 --- a/core/filter_api.php +++ b/core/filter_api.php @@ -4493,7 +4493,7 @@ function filter_db_can_delete_filter( $p_filter_id ) { $t_user_id = auth_get_current_user_id(); # Administrators can delete any filter - if( access_has_global_level( ADMINISTRATOR ) ) { + if( user_is_administrator( $t_user_id ) ) { return true; } diff --git a/core/html_api.php b/core/html_api.php index d73a034ac0..0aed3f3f66 100644 --- a/core/html_api.php +++ b/core/html_api.php @@ -804,7 +804,7 @@ function print_menu() { if ( news_is_enabled() && access_has_project_level( config_get( 'manage_news_threshold' ) ) ) { # Admin can edit news for All Projects (site-wide) - if(( ALL_PROJECTS != helper_get_current_project() ) || ( access_has_project_level( ADMINISTRATOR ) ) ) { + if( ALL_PROJECTS != helper_get_current_project() || current_user_is_administrator() ) { $t_menu_options[] = '' ) . 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 @@