diff options
author | 2009-11-10 16:31:47 +0000 | |
---|---|---|
committer | 2009-11-10 16:31:47 +0000 | |
commit | 2f804027b44c5790d4547f3161bff28266150bef (patch) | |
tree | a5d9fff8ab4b48d71bea0157bfa3f856fc437b7c /summarize_time.cgi | |
parent | Bug 505038: Use $user->is_insider instead of $user->in_group(Bugzilla->params... (diff) | |
download | bugzilla-2f804027b44c5790d4547f3161bff28266150bef.tar.gz bugzilla-2f804027b44c5790d4547f3161bff28266150bef.tar.bz2 bugzilla-2f804027b44c5790d4547f3161bff28266150bef.zip |
Bug 505039: Use $user->is_timetracker instead of $user->in_group(Bugzilla->params->{'timetrackinggroup'}) - Patch by XqueZme <xquezme@gmail.com> r/a=LpSolit
Diffstat (limited to 'summarize_time.cgi')
-rwxr-xr-x | summarize_time.cgi | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/summarize_time.cgi b/summarize_time.cgi index 0330f9dcf..6f9580ac2 100755 --- a/summarize_time.cgi +++ b/summarize_time.cgi @@ -232,6 +232,20 @@ sub get_inactive_bugs { return $bugs; } +# Return 1st day of the month of the earliest activity date for a given list of bugs. +sub get_earliest_activity_date { + my ($bugids) = @_; + my $dbh = Bugzilla->dbh; + + my ($date) = $dbh->selectrow_array( + 'SELECT ' . $dbh->sql_date_format('MIN(bug_when)', '%Y-%m-01') + . ' FROM longdescs + WHERE ' . $dbh->sql_in('bug_id', $bugids) + . ' AND work_time > 0'); + + return $date; +} + # # Template code starts here # @@ -245,7 +259,7 @@ my $vars = {}; Bugzilla->switch_to_shadow_db(); -$user->in_group(Bugzilla->params->{"timetrackinggroup"}) +$user->is_timetracker || ThrowUserError("auth_failure", {group => "time-tracking", action => "access", object => "timetracking_summaries"}); @@ -301,16 +315,14 @@ if ($do_report) { # Break dates apart into months if necessary; if not, we use the # same @parts list to allow us to use a common codepath. if ($monthly) { - # unfortunately it's not too easy to guess a start date, since - # it depends on what bugs we're looking at. We risk bothering - # the user here. XXX: perhaps run a query to see what the - # earliest activity in longdescs for all bugs and use that as a - # start date. - $start_date || ThrowUserError("illegal_date", {'date' => $start_date}); - # we can, however, provide a default end date. Note that this - # differs in semantics from the open-ended queries we use when - # start/end_date aren't provided -- and clock skews will make - # this evident! + # Calculate the earliest activity date if the user doesn't + # specify a start date. + if (!$start_date) { + $start_date = get_earliest_activity_date(\@bugs); + } + # Provide a default end date. Note that this differs in semantics + # from the open-ended queries we use when start/end_date aren't + # provided -- and clock skews will make this evident! @parts = split_by_month($start_date, $end_date || format_time(scalar localtime(time()), '%Y-%m-%d')); } else { |