rt 4.0.23
[freeside.git] / rt / lib / RT / Report / Tickets.pm
index c34d1cb..f977673 100644 (file)
@@ -1,40 +1,40 @@
 # BEGIN BPS TAGGED BLOCK {{{
-# 
+#
 # COPYRIGHT:
-# 
-# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
-#                                          <jesse@bestpractical.com>
-# 
+#
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
+#                                          <sales@bestpractical.com>
+#
 # (Except where explicitly superseded by other copyright notices)
-# 
-# 
+#
+#
 # LICENSE:
-# 
+#
 # This work is made available to you under the terms of Version 2 of
 # the GNU General Public License. A copy of that license should have
 # been provided with this software, but in any event can be snarfed
 # from www.gnu.org.
-# 
+#
 # This work is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301 or visit their web page on the internet at
 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-# 
-# 
+#
+#
 # CONTRIBUTION SUBMISSION POLICY:
-# 
+#
 # (The following paragraph is not intended to limit the rights granted
 # to you to modify and distribute this software under the terms of
 # the GNU General Public License and is only of importance to you if
 # you choose to contribute your changes and enhancements to the
 # community by submitting them to Best Practical Solutions, LLC.)
-# 
+#
 # By intentionally submitting any modifications, corrections or
 # derivatives to this work, or any other work intended for use with
 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
@@ -43,7 +43,7 @@
 # royalty-free, perpetual, license to use, copy, create derivative
 # works based on those contributions, and sublicense and distribute
 # those contributions and any derivatives thereof.
-# 
+#
 # END BPS TAGGED BLOCK }}}
 
 package RT::Report::Tickets;
@@ -57,22 +57,27 @@ use warnings;
 sub Groupings {
     my $self = shift;
     my %args = (@_);
-    my @fields = map {$_, $_} qw(
-        Status
-        Queue
-    );
-
-    foreach my $type ( qw(Owner Creator LastUpdatedBy Requestor Cc AdminCc Watcher) ) {
-        push @fields, $type.' '.$_, $type.'.'.$_ foreach qw(
-            Name EmailAddress RealName NickName Organization Lang City Country Timezone
-        );
+    my @fields =
+      map { $self->CurrentUser->loc($_), $_ } qw( Status Queue );    # loc_qw
+
+    foreach my $type ( qw(Owner Creator LastUpdatedBy Requestor Cc AdminCc Watcher) ) { # loc_qw
+        for my $field (
+            qw( Name EmailAddress RealName NickName Organization Lang City Country Timezone ) # loc_qw
+          )
+        {
+            push @fields,
+              $self->CurrentUser->loc($type) . ' '
+              . $self->CurrentUser->loc($field), $type . '.' . $field;
+        }
     }
 
 
-    for my $field (qw(Due Resolved Created LastUpdated Started Starts)) {
-        for my $frequency (qw(Hourly Daily Monthly Annually)) {
-            my $item = $field.$frequency;
-            push @fields,  $item,  $item;
+    for my $field (qw(Due Resolved Created LastUpdated Started Starts Told)) { # loc_qw
+        for my $frequency (qw(Hourly Daily Monthly Annually)) { # loc_qw
+            push @fields,
+              $self->CurrentUser->loc($field)
+              . $self->CurrentUser->loc($frequency),
+              $field . $frequency;
         }
     }
 
@@ -89,17 +94,15 @@ sub Groupings {
         foreach my $id (keys %$queues) {
             my $queue = RT::Queue->new( $self->CurrentUser );
             $queue->Load($id);
-            unless ($queue->id) {
-                # XXX TODO: This ancient code dates from a former developer
-                # we have no idea what it means or why cfqueues are so encoded.
-                $id =~ s/^.'*(.*).'*$/$1/;
-                $queue->Load($id);
-            }
-            $CustomFields->LimitToQueue($queue->Id);
+            $CustomFields->LimitToQueue($queue->Id) if $queue->Id;
         }
         $CustomFields->LimitToGlobal;
         while ( my $CustomField = $CustomFields->Next ) {
-            push @fields, "Custom field '". $CustomField->Name ."'", "CF.{". $CustomField->id ."}";
+            push @fields, $self->CurrentUser->loc(
+                "Custom field '[_1]'",
+                $CustomField->Name
+              ),
+              "CF.{" . $CustomField->id . "}";
         }
     }
     return @fields;
@@ -108,7 +111,7 @@ sub Groupings {
 sub Label {
     my $self = shift;
     my $field = shift;
-    if ( $field =~ /^(?:CF|CustomField)\.{(.*)}$/ ) {
+    if ( $field =~ /^(?:CF|CustomField)\.\{(.*)\}$/ ) {
         my $cf = $1;
         return $self->CurrentUser->loc( "Custom field '[_1]'", $cf ) if $cf =~ /\D/;
         my $obj = RT::CustomField->new( $self->CurrentUser );
@@ -166,7 +169,14 @@ columns if it makes sense
 sub _DoSearch {
     my $self = shift;
     $self->SUPER::_DoSearch( @_ );
-    $self->AddEmptyRows;
+    if ( $self->{'must_redo_search'} ) {
+        $RT::Logger->crit(
+"_DoSearch is not so successful as it still needs redo search, won't call AddEmptyRows"
+        );
+    }
+    else {
+        $self->AddEmptyRows;
+    }
 }
 
 =head2 _FieldToFunction FIELD
@@ -229,7 +239,7 @@ sub _FieldToFunction {
             $func = "SUBSTR($func,1,4)";
         }
         $args{'FUNCTION'} = $func;
-    } elsif ( $field =~ /^(?:CF|CustomField)\.{(.*)}$/ ) { #XXX: use CFDecipher method
+    } elsif ( $field =~ /^(?:CF|CustomField)\.\{(.*)\}$/ ) { #XXX: use CFDecipher method
         my $cf_name = $1;
         my $cf = RT::CustomField->new( $self->CurrentUser );
         $cf->Load($cf_name);
@@ -265,16 +275,6 @@ sub _FieldToFunction {
     return %args;
 }
 
-
-# Override the AddRecord from DBI::SearchBuilder::Unique. id isn't id here
-# wedon't want to disambiguate all the items with a count of 1.
-sub AddRecord {
-    my $self = shift;
-    my $record = shift;
-    push @{$self->{'items'}}, $record;
-    $self->{'rows'}++;
-}
-
 1;
 
 
@@ -289,7 +289,7 @@ sub Next {
 
 sub NewItem {
     my $self = shift;
-    return RT::Report::Tickets::Entry->new($RT::SystemUser); # $self->CurrentUser);
+    return RT::Report::Tickets::Entry->new(RT->SystemUser); # $self->CurrentUser);
 }
 
 
@@ -317,14 +317,6 @@ sub AddEmptyRows {
     }
 }
 
-eval "require RT::Report::Tickets_Vendor";
-if ($@ && $@ !~ qr{^Can't locate RT/Report/Tickets_Vendor.pm}) {
-    die $@;
-};
-
-eval "require RT::Report::Tickets_Local";
-if ($@ && $@ !~ qr{^Can't locate RT/Report/Tickets_Local.pm}) {
-    die $@;
-};
+RT::Base->_ImportOverlays();
 
 1;