Skip to content

Commit

Permalink
Allow helper_get_columns_to_view to specify project id for which we w…
Browse files Browse the repository at this point in the history
…ant a column list.
  • Loading branch information
mantis committed Apr 7, 2013
1 parent cc89f12 commit eae2a50
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
9 changes: 7 additions & 2 deletions core/custom_function_api.php
Expand Up @@ -269,10 +269,15 @@ function custom_function_default_auth_can_change_password() {
*
* @param int $p_columns_target see COLUMNS_TARGET_* in constant_inc.php
* @param int $p_user_id The user id or null for current logged in user.
* @param int $p_project_id The project id or null for current project.
* @return array
*/
function custom_function_default_get_columns_to_view( $p_columns_target = COLUMNS_TARGET_VIEW_PAGE, $p_user_id = null ) {
$t_project_id = helper_get_current_project();
function custom_function_default_get_columns_to_view( $p_columns_target = COLUMNS_TARGET_VIEW_PAGE, $p_user_id = null, $p_project_id = null ) {
if( $p_project_id === null ) {
$t_project_id = helper_get_current_project();
} else {
$t_project_id = $p_project_id;
}

if( $p_columns_target == COLUMNS_TARGET_EXPORT_PAGE ) {
$t_columns = config_get( 'export_columns', columns_get_default( 'export' ), $p_user_id, $t_project_id );
Expand Down
18 changes: 11 additions & 7 deletions core/helper_api.php
Expand Up @@ -430,10 +430,11 @@ function helper_project_specific_where( $p_project_id, $p_user_id = null ) {
* @param int $p_columns_target
* @param bool $p_viewable_only
* @param int $p_user_id
* @param int $p_project_id
* @return array
*/
function helper_get_columns_to_view( $p_columns_target = COLUMNS_TARGET_VIEW_PAGE, $p_viewable_only = true, $p_user_id = null ) {
$t_columns = helper_call_custom_function( 'get_columns_to_view', array( $p_columns_target, $p_user_id ) );
function helper_get_columns_to_view( $p_columns_target = COLUMNS_TARGET_VIEW_PAGE, $p_viewable_only = true, $p_user_id = null, $p_project_id = null ) {
$t_columns = helper_call_custom_function( 'get_columns_to_view', array( $p_columns_target, $p_user_id, $p_project_id ) );

if( !$p_viewable_only ) {
return $t_columns;
Expand All @@ -449,17 +450,20 @@ function helper_get_columns_to_view( $p_columns_target = COLUMNS_TARGET_VIEW_PAG
$t_keys_to_remove[] = 'overdue';
}

if( $p_columns_target == COLUMNS_TARGET_EXPORT_PAGE || OFF == config_get( 'show_attachment_indicator' ) ) {
if( $p_project_id === null ) {
$t_current_project_id = helper_get_current_project();
} else {
$t_current_project_id = $p_project_id;
}
if( $p_columns_target == COLUMNS_TARGET_EXPORT_PAGE || OFF == config_get( 'show_attachment_indicator', null, $p_user_id, $t_current_project_id ) ) {
$t_keys_to_remove[] = 'attachment';
}

$t_current_project_id = helper_get_current_project();

if( $t_current_project_id != ALL_PROJECTS && !access_has_project_level( config_get( 'view_handler_threshold' ), $t_current_project_id ) ) {
if( $t_current_project_id != ALL_PROJECTS && !access_has_project_level( config_get( 'view_handler_threshold', null, $p_user_id, $t_current_project_id ), $t_current_project_id ) ) {
$t_keys_to_remove[] = 'handler_id';
}

if( $t_current_project_id != ALL_PROJECTS && !access_has_project_level( config_get( 'roadmap_view_threshold' ), $t_current_project_id ) ) {
if( $t_current_project_id != ALL_PROJECTS && !access_has_project_level( config_get( 'roadmap_view_threshold', null, $p_user_id, $t_current_project_id ), $t_current_project_id ) ) {
$t_keys_to_remove[] = 'target_version';
}

Expand Down

0 comments on commit eae2a50

Please sign in to comment.