Update of /cvsroot/mantisbt/mantisbt/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18588/core
Modified Files:
access_api.php bugnote_api.php custom_field_api.php
email_api.php file_api.php
Log Message:
refactored access routines to access comparison
fixed comparisons that didn't use apis in other routines
Index: file_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/file_api.php,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- file_api.php 12 Feb 2005 20:01:10 -0000 1.64
+++ file_api.php 21 Mar 2005 02:03:12 -0000 1.65
@@ -664,15 +664,8 @@
return true;
}
- # Get the user's access level
- $t_access = user_get_access_level( $p_user_id, $t_project_id );
-
# Check the access level against the config setting
- if ( $t_access >= config_get( 'upload_bug_file_threshold' ) ) {
- return true;
- } else {
- return false;
- }
+ return access_has_project_level( config_get(
'upload_bug_file_threshold' ), $t_project_id, $p_user_id );
}
# --------------------
Index: bugnote_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/bugnote_api.php,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- bugnote_api.php 4 Mar 2005 13:41:03 -0000 1.33
+++ bugnote_api.php 21 Mar 2005 02:03:12 -0000 1.34
@@ -252,11 +252,7 @@
$t_all_bugnotes = bugnote_get_all_bugnotes(
$p_bug_id, $p_user_bugnote_order, $p_user_bugnote_limit );
$t_private_bugnote_threshold = config_get(
'private_bugnote_threshold' );
- if ( $p_user_access_level >= $t_private_bugnote_threshold ) {
- $t_private_bugnote_visible = true;
- } else {
- $t_private_bugnote_visible = false ;
- }
+ $t_private_bugnote_visible = access_compare_level(
$p_user_access_level, config_get( 'private_bugnote_threshold' ) );
$t_bugnotes = array();
foreach ( $t_all_bugnotes as $t_note_index => $t_bugnote ) {
Index: access_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/access_api.php,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- access_api.php 19 Mar 2005 22:59:31 -0000 1.38
+++ access_api.php 21 Mar 2005 02:03:12 -0000 1.39
@@ -131,6 +131,20 @@
#===================================
# --------------------
+ # Check the a user's access against the given "threshold" and return
true
+ # if the user can access, false otherwise.
+ # $p_access_level may be a single value, or an array. If it is a single
+ # value, treat it as a threshold so return true if user is >= threshold.
+ # If it is an array, look for exact matches to one of the values
+ function access_compare_level( $p_user_access_level,
$p_threshold=NOBODY ) {
+ if ( is_array( $p_threshold ) ) {
+ return ( in_array( $p_user_access_level, $p_threshold ) );
+ } else {
+ return ( $p_user_access_level >= $p_threshold );
+ }
+ }
+
+ # --------------------
# Get the current user's access
#
# This function only checks the user's global access level, ignoring any
@@ -166,14 +180,7 @@
$t_access_level = access_get_global_level( $p_user_id );
- # $p_access_level may be a single value, or an array. If it is
a single
- # value, treat it as a threshold so return true if user is >=
threshold.
- # If it is an array, look for exact matches to one of the values
- if ( is_array( $p_access_level ) ) {
- return ( in_array( $t_access_level, $p_access_level ) );
- } else {
- return ( $t_access_level >= $p_access_level );
- }
+ return access_compare_level( $t_access_level, $p_access_level )
;
}
# --------------------
@@ -251,14 +258,7 @@
$t_access_level = access_get_project_level( $p_project_id,
$p_user_id );
- # $p_access_level may be a single value, or an array. If it is
a single
- # value, treat it as a threshold so return true if user is >=
threshold.
- # If it is an array, look for exact matches to one of the values
- if ( is_array( $p_access_level ) ) {
- return ( in_array( $t_access_level, $p_access_level ) );
- } else {
- return ( $t_access_level >= $p_access_level );
- }
+ return access_compare_level( $t_access_level, $p_access_level )
;
}
# --------------------
Index: email_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/email_api.php,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- email_api.php 4 Mar 2005 13:34:56 -0000 1.109
+++ email_api.php 21 Mar 2005 02:03:12 -0000 1.110
@@ -230,7 +230,7 @@
$t_threshold_users = project_get_all_user_rows( $t_project_id,
$t_threshold_min );
foreach( $t_threshold_users as $t_user ) {
if ( $t_user['access_level'] <= $t_threshold_max ) {
- if ( !$t_bug_is_private ||
$t_user['access_level'] >= config_get( 'private_bug_threshold' ) ) {
+ if ( !$t_bug_is_private ||
access_compare_level( $t_user['access_level'], config_get(
'private_bug_threshold' ) ) ) {
$t_recipients[$t_user['id']] = true;
}
}
@@ -1019,7 +1019,7 @@
$t_bug_data['email_bug_view_url'] =
string_get_bug_view_url_with_fqdn( $p_bug_id );
}
- if ( $t_user_access_level >= config_get(
'view_handler_threshold' ) ) {
+ if ( access_compare_level( $t_user_access_level, config_get(
'view_handler_threshold' ) ) ) {
if ( 0 != $row['handler_id'] ) {
$t_bug_data['email_handler'] = user_get_name(
$row['handler_id'] );
} else {
@@ -1056,7 +1056,7 @@
$t_bug_data['bugnotes'] = bugnote_get_all_visible_bugnotes(
$p_bug_id, $t_user_access_level, $t_user_bugnote_order, $t_user_bugnote_limit );
# put history data
- if ( ON == config_get( 'history_default_visible' ) &&
$t_user_access_level >= config_get( 'view_history_threshold' ) ) {
+ if ( ( ON == config_get( 'history_default_visible' ) ) &&
access_compare_level( $t_user_access_level, config_get(
'view_history_threshold' ) ) ) {
$t_bug_data['history'] = history_get_raw_events_array(
$p_bug_id );
}
Index: custom_field_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/custom_field_api.php,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- custom_field_api.php 27 Feb 2005 15:33:01 -0000 1.49
+++ custom_field_api.php 21 Mar 2005 02:03:12 -0000 1.50
@@ -202,11 +202,7 @@
$t_project_id = bug_get_field( $p_bug_id, 'project_id' );
- if ( user_get_access_level( $p_user_id, $t_project_id ) >=
$t_access_level_r ) {
- return true;
- } else {
- return false;
- }
+ return access_has_project_level( $t_access_level_r, $t_project_id,
$p_user_id );
}
# --------------------
@@ -221,11 +217,7 @@
$t_access_level_rw = custom_field_get_field( $p_field_id,
'access_level_rw' );
- if ( user_get_access_level( $p_user_id, $p_project_id ) >=
$t_access_level_rw ) {
- return true;
- } else {
- return false;
- }
+ return access_has_project_level( $t_access_level_rw, $p_project_id,
$p_user_id );
}
# --------------------
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
|