Skip to content

Commit

Permalink
Fixes for "My View" boxes display
Browse files Browse the repository at this point in the history
Addresses the following issues:

- #22104 My View Page layout misses some boxes
- #23418 Plugin tab in Summary section not highlighted when selected
- #25679 Uneven distribution of boxes on My View page when Timeline is OFF

Plus some minor code cleanup.

Fixes #22104, #23418, #25679
PR #1497
  • Loading branch information
dregad committed Apr 11, 2019
2 parents 745e4f7 + 04e5223 commit 5ad064d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 60 deletions.
8 changes: 0 additions & 8 deletions config_defaults_inc.php
Expand Up @@ -3748,13 +3748,6 @@
'my_comments' => '0'
);

/**
* Toggle whether 'My View' boxes are shown in a fixed position (i.e. adjacent
* boxes start at the same vertical position)
* @global integer $g_my_view_boxes_fixed_position
*/
$g_my_view_boxes_fixed_position = ON;


#############
# RSS Feeds #
Expand Down Expand Up @@ -4570,7 +4563,6 @@
'monitor_delete_others_bug_threshold',
'move_bug_threshold',
'my_view_boxes',
'my_view_boxes_fixed_position',
'my_view_bug_count',
'news_enabled',
'news_limit_method',
Expand Down
5 changes: 4 additions & 1 deletion core/obsolete.php
Expand Up @@ -222,4 +222,7 @@
config_obsolete( 'session_handler' );

# changes in 2.17.0
config_obsolete( 'default_manage_user_prefix' );
config_obsolete( 'default_manage_user_prefix' );

# changes in 2.21.0
config_obsolete( 'my_view_boxes_fixed_position' );
96 changes: 45 additions & 51 deletions my_view_page.php
Expand Up @@ -85,10 +85,6 @@
$t_bug_count = null;
$t_page_count = null;

$t_boxes = config_get( 'my_view_boxes' );
asort( $t_boxes );
reset( $t_boxes );

# The projects that need to be evaluated are those that will be included in the filters
# used for each box. At this point, those filter are created for "current" project, and
# may include subprojects, or not, based on the default "_view_type" property
Expand All @@ -103,67 +99,65 @@
$t_project_ids_to_check = filter_get_included_projects( $t_test_filter );
}

# Retrieve the boxes to display
# - exclude hidden boxes per configuration (order == 0)
# - remove boxes that do not make sense in the user's context (access level)
$t_boxes = array_filter( config_get( 'my_view_boxes' ) );
$t_anonymous_user = current_user_is_anonymous();
foreach( $t_boxes as $t_box_title => $t_box_display ) {
if( # Remove "Assigned to Me" box for users that can't handle issues
( $t_box_title == 'assigned'
&& ( $t_anonymous_user
|| !access_has_any_project_level('handle_bug_threshold', $t_project_ids_to_check, $t_current_user_id )
)
) ||
# Remove "Monitored by Me" box for users that can't monitor issues
( $t_box_title == 'monitored'
&& ( $t_anonymous_user
|| !access_has_any_project_level( 'monitor_bug_threshold', $t_project_ids_to_check, $t_current_user_id )
)
) ||
# Remove display of "Reported by Me", "Awaiting Feedback" and
# "Awating confirmation of resolution" boxes for users that can't report bugs
( in_array( $t_box_title, array( 'reported', 'feedback', 'verify' ) )
&& ( $t_anonymous_user
|| !access_has_any_project_level( 'report_bug_threshold', $t_project_ids_to_check, $t_current_user_id )
)
)
) {
unset( $t_boxes[$t_box_title] );
}
}
asort( $t_boxes );

$t_timeline_view_threshold_access = access_has_any_project_level( config_get( 'timeline_view_threshold' ), $t_project_ids_to_check, $t_current_user_id );
$t_timeline_view_class = ( $t_timeline_view_threshold_access ) ? "col-md-7" : "col-md-6";
?>
<div class="col-xs-12 <?php echo $t_timeline_view_class ?>">

<?php
$t_number_of_boxes = count ( $t_boxes );
$t_boxes_position = config_get( 'my_view_boxes_fixed_position' );
$t_counter = 0;
$t_two_columns_applied = false;

define( 'MY_VIEW_INC_ALLOW', true );

# Determine the box number where column 2 should start
# Use shift-right bitwise operator to divide by 2 as integer
$t_column2_start = ( count( $t_boxes ) + 1 ) >> 1;

$t_counter = 0;
foreach( $t_boxes as $t_box_title => $t_box_display ) {
# don't display boxes that are set as 0
if ( $t_box_display == 0 ) {
$t_number_of_boxes = $t_number_of_boxes - 1;
}
# don't display "Assigned to Me" bugs to users that bugs can't be assigned to
else if( $t_box_title == 'assigned'
&& ( current_user_is_anonymous()
|| !access_has_any_project_level( 'handle_bug_threshold', $t_project_ids_to_check, $t_current_user_id ) ) ) {
$t_number_of_boxes = $t_number_of_boxes - 1;
}
# don't display "Monitored by Me" bugs to users that can't monitor bugs
else if( $t_box_title == 'monitored'
&& ( current_user_is_anonymous()
|| !access_has_any_project_level( 'monitor_bug_threshold', $t_project_ids_to_check, $t_current_user_id ) ) ) {
$t_number_of_boxes = $t_number_of_boxes - 1;
}
# don't display "Reported by Me" bugs to users that can't report bugs
else if( in_array( $t_box_title, array( 'reported', 'feedback', 'verify' ) )
&& ( current_user_is_anonymous()
|| !access_has_any_project_level( 'report_bug_threshold', $t_project_ids_to_check, $t_current_user_id ) ) ) {
$t_number_of_boxes = $t_number_of_boxes - 1;
}
# display the box
else {
if( !$t_timeline_view_threshold_access ) {
if ($t_counter >= $t_number_of_boxes / 2 && !$t_two_columns_applied) {
echo '</div>';
echo '<div class="col-xs-12 col-md-6">';
$t_two_columns_applied = true;
} elseif ($t_counter >= $t_number_of_boxes && $t_two_columns_applied) {
echo '</div>';
} else {
include( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'my_view_inc.php' );
echo '<div class="space-10"></div>';
}
$t_counter++;
} else {
include( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'my_view_inc.php' );
echo '<div class="space-10"></div>';
}
}
# If timeline is OFF, display boxes on 2 columns
if( !$t_timeline_view_threshold_access && $t_counter++ == $t_column2_start ) {
# End of 1st column
echo '</div>';
echo '<div class="col-xs-12 col-md-6">';
}
include( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'my_view_inc.php' );
echo '<div class="space-10"></div>';
}
?>
</div>

<?php if( $t_timeline_view_threshold_access ) { ?>
<div class="col-md-5 col-xs-12">
<div class="col-xs-12 col-md-5">
<?php
# Build a simple filter that gets all bugs for current project
$g_timeline_filter = array();
Expand Down

0 comments on commit 5ad064d

Please sign in to comment.