Skip to content

Commit f0248c8

Browse files
Dentxinhodregad
authored andcommittedDec 13, 2011
Removed unneeded auth check in the access API.
Some functions on the Access API (access_get_global_level, access_get_project_level and access_has_bug_level) require an authenticated user in order to return correct values, FALSE otherwise. However, these functions can be used by plugins while not authenticated, so the code was changed to allow the execution to proceed if existing parameter $p_user_id is provided. Fixes #13538 Signed-off-by: Damien Regad <damien.regad@merckgroup.com> Original patch was modified to follow MantisBT coding guidelines and improve the commit message
1 parent 100dc97 commit f0248c8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed
 

‎core/access_api.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ function access_get_global_level( $p_user_id = null ) {
219219
# Deal with not logged in silently in this case
220220
# @@@ we may be able to remove this and just error
221221
# and once we default to anon login, we can remove it for sure
222-
if( !auth_is_user_authenticated() ) {
222+
if( empty( $p_user_id ) && !auth_is_user_authenticated() ) {
223223
return false;
224224
}
225225

@@ -273,16 +273,16 @@ function access_ensure_global_level( $p_access_level, $p_user_id = null ) {
273273
* @access public
274274
*/
275275
function access_get_project_level( $p_project_id = null, $p_user_id = null ) {
276+
if( null === $p_user_id ) {
277+
$p_user_id = auth_get_current_user_id();
278+
}
279+
276280
# Deal with not logged in silently in this case
277281
/** @todo we may be able to remove this and just error and once we default to anon login, we can remove it for sure */
278-
if( !auth_is_user_authenticated() ) {
282+
if( empty( $p_user_id ) && !auth_is_user_authenticated() ) {
279283
return ANYBODY;
280284
}
281285

282-
if( null === $p_user_id ) {
283-
$p_user_id = auth_get_current_user_id();
284-
}
285-
286286
if( null === $p_project_id ) {
287287
$p_project_id = helper_get_current_project();
288288
}
@@ -400,17 +400,17 @@ function access_has_any_project( $p_access_level, $p_user_id = null ) {
400400
* @access public
401401
*/
402402
function access_has_bug_level( $p_access_level, $p_bug_id, $p_user_id = null ) {
403+
if( $p_user_id === null ) {
404+
$p_user_id = auth_get_current_user_id();
405+
}
406+
403407
# Deal with not logged in silently in this case
404408
# @@@ we may be able to remove this and just error
405409
# and once we default to anon login, we can remove it for sure
406-
if( !auth_is_user_authenticated() ) {
410+
if( empty( $p_user_id ) && !auth_is_user_authenticated() ) {
407411
return false;
408412
}
409413

410-
if( $p_user_id === null ) {
411-
$p_user_id = auth_get_current_user_id();
412-
}
413-
414414
$t_project_id = bug_get_field( $p_bug_id, 'project_id' );
415415

416416
# check limit_Reporter (Issue #4769)

0 commit comments

Comments
 (0)
Please sign in to comment.