Permalink
Browse files

Code cleanup

- remove unneeded variables
- replace ternary operator with array_splice call
  • Loading branch information...
1 parent 84dd80e commit 927706b3311407712ee16b9be71f56a974683d73 @dregad dregad committed Feb 17, 2014
Showing with 6 additions and 4 deletions.
  1. +6 −4 core/user_api.php
View
@@ -1033,9 +1033,6 @@ function user_get_accessible_subprojects( $p_user_id, $p_project_id, $p_show_dis
$t_project_user_list_table = db_get_table( 'project_user_list' );
$t_project_hierarchy_table = db_get_table( 'project_hierarchy' );
- $t_public = VS_PUBLIC;
- $t_private = VS_PRIVATE;
-
if( access_has_global_level( config_get( 'private_project_threshold' ), $p_user_id ) ) {
$t_enabled_clause = $p_show_disabled ? '' : 'p.enabled = ' . db_param() . ' AND';
$query = "SELECT DISTINCT p.id, p.name, ph.parent_id
@@ -1061,7 +1058,12 @@ function user_get_accessible_subprojects( $p_user_id, $p_project_id, $p_show_dis
u.user_id=' . db_param() . ' )
)
ORDER BY p.name';
- $result = db_query_bound( $query, ( $p_show_disabled ? array( $p_user_id, $t_public, $t_private, $p_user_id ) : array( $p_user_id, 1, $t_public, $t_private, $p_user_id ) ) );
+ $t_param = array( $p_user_id, VS_PUBLIC, VS_PRIVATE, $p_user_id );
+ if( $p_show_disabled ) {
+ # Insert enabled flag value in 2nd position of parameter array
+ array_splice( $t_param, 1, 0, true );
+ }
+ $result = db_query_bound( $query, $t_param );
}
$t_projects = array();

0 comments on commit 927706b

Please sign in to comment.