Skip to content

Commit

Permalink
Fixes for filters and custom fields
Browse files Browse the repository at this point in the history
Merging pull request #1183
  • Loading branch information
dregad committed Oct 7, 2017
2 parents ac722d5 + df9a9e4 commit 698ed3e
Show file tree
Hide file tree
Showing 6 changed files with 344 additions and 195 deletions.
7 changes: 5 additions & 2 deletions core/access_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,11 @@ function access_project_array_filter( $p_access_level, array $p_project_ids = nu
$p_project_ids = user_get_all_accessible_projects( $p_user_id );
}

# Determine if parameter is a configuration string to be evaluated for each project
$t_is_config_string = ( is_string( $p_access_level ) && !is_numeric( $p_access_level ) );

# if config will be evaluated for each project, prepare a default value
if( is_string( $p_access_level ) ) {
if( $t_is_config_string ) {
$t_default = config_get( $p_access_level, null, $p_user_id, ALL_PROJECTS );
if( null === $t_default ) {
$t_default = config_get_global( $p_access_level );
Expand All @@ -375,7 +378,7 @@ function access_project_array_filter( $p_access_level, array $p_project_ids = nu
$t_filtered_projects = array();
foreach( $p_project_ids as $t_project_id ) {
# If a config string is provided, evaluate for each project
if( is_string( $p_access_level ) ) {
if( $t_is_config_string ) {
$t_check_level = config_get( $p_access_level, $t_default, $p_user_id, $t_project_id );
}
if( access_has_project_level( $t_check_level, $t_project_id, $p_user_id ) ) {
Expand Down
14 changes: 7 additions & 7 deletions core/columns_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,15 @@ function columns_get_all( $p_project_id = null ) {
} else {
$t_project_id = $p_project_id;
}

$t_related_custom_field_ids = custom_field_get_linked_ids( $t_project_id );
# Get custom fields from this project and sub-projects
$t_projects = user_get_all_accessible_projects( null, $t_project_id );
$t_related_custom_field_ids = custom_field_get_linked_ids( $t_projects );
foreach( $t_related_custom_field_ids as $t_id ) {
if( !custom_field_has_read_access_by_project_id( $t_id, $t_project_id ) ) {
continue;
$t_cfdef = custom_field_get_definition( $t_id );
$t_projects_to_check = array_intersect( $t_projects, custom_field_get_project_ids( $t_id ) );
if( access_has_any_project_level( (int)$t_cfdef['access_level_r'], $t_projects_to_check ) ) {
$t_columns[] = column_get_custom_field_column_name( $t_id );
}

$t_def = custom_field_get_definition( $t_id );
$t_columns[] = 'custom_' . $t_def['name'];
}

return $t_columns;
Expand Down
Loading

0 comments on commit 698ed3e

Please sign in to comment.