[freeside-commits] freeside/rt/lib/RT Tickets_Overlay.pm,1.3,1.4

Ivan,,, ivan at wavetail.420.am
Fri Jul 23 15:51:01 PDT 2010


Update of /home/cvs/cvsroot/freeside/rt/lib/RT
In directory wavetail.420.am:/tmp/cvs-serv29125

Modified Files:
	Tickets_Overlay.pm 
Log Message:
cleaner customer number searching, RT#8784

Index: Tickets_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Tickets_Overlay.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- Tickets_Overlay.pm	22 Jul 2010 21:01:40 -0000	1.3
+++ Tickets_Overlay.pm	23 Jul 2010 22:50:59 -0000	1.4
@@ -1724,7 +1724,6 @@
             next;
         }
         if ( $row->{FIELD} !~ /\./ ) {
-
             my $meta = $self->FIELDS->{ $row->{FIELD} };
             unless ( $meta ) {
                 push @res, $row;
@@ -1855,21 +1854,21 @@
                VALUE    => 'freeside://freeside/cust_main/',
            );
 
+           #if there was a Links.RemoteTarget int, this bs wouldn't be necessary
+           my $custnum_sql = "CAST(SUBSTR($linkalias.Target,31) AS INTEGER)";
+
            if ( $subkey eq 'Number' ) {
 
                push @res, { %$row,
-                            ALIAS => $linkalias,
-                            FIELD => "CAST(SUBSTR(Target,31) AS INTEGER)",
-                            #ORDER => ($row->{ORDER} || 'ASC')
+                            ALIAS => '',
+                            FIELD => $custnum_sql,
                           };
 
            } elsif ( $subkey eq 'Name' ) {
 
               my $custalias = $self->Join(
                   TYPE   => 'LEFT',
-                  #ALIAS1 => $linkalias,
-                  #FIELD1 => 'CAST(SUBSTR(Target,31) AS INTEGER)',
-                  EXPRESSION => "CAST(SUBSTR($linkalias.Target,31) AS INTEGER)",
+                  EXPRESSION => $custnum_sql,
                   TABLE2 => 'cust_main',
                   FIELD2 => 'custnum',
                   
@@ -1894,53 +1893,6 @@
 
 # }}}
 
-#this duplicates/ovverrides the DBIx::SearchBuilder version..
-# we need to fix the "handle FUNCTION(FIELD)" stuff and this is much easier
-# than patching SB
-# but does this have other terrible ramifications?  maybe a flag to trigger
-# this specific case?
-sub _OrderClause {
-    my $self = shift;
-
-    return '' unless $self->{'order_by'};
-
-    my $clause = '';
-    foreach my $row ( @{$self->{'order_by'}} ) {
-
-        my %rowhash = ( ALIAS => 'main',
-                        FIELD => undef,
-                        ORDER => 'ASC',
-                        %$row
-                      );
-        if ($rowhash{'ORDER'} && $rowhash{'ORDER'} =~ /^des/i) {
-            $rowhash{'ORDER'} = "DESC";
-        }
-        else {
-            $rowhash{'ORDER'} = "ASC";
-        }
-        $rowhash{'ALIAS'} = 'main' unless defined $rowhash{'ALIAS'};
-
-        if ( defined $rowhash{'ALIAS'} and
-             $rowhash{'FIELD'} and
-             $rowhash{'ORDER'} ) {
-
-            if ( length $rowhash{'ALIAS'} && $rowhash{'FIELD'} =~ /^((\w+\()+)(.*\)+)$/ ) {
-                # handle 'FUNCTION(FIELD)' formatted fields
-                $rowhash{'FIELD'} = $1. $rowhash{'ALIAS'}. '.'. $3;
-                $rowhash{'ALIAS'} = '';
-            }
-
-            $clause .= ($clause ? ", " : " ");
-            $clause .= $rowhash{'ALIAS'} . "." if length $rowhash{'ALIAS'};
-            $clause .= $rowhash{'FIELD'} . " ";
-            $clause .= $rowhash{'ORDER'};
-        }
-    }
-    $clause = " ORDER BY$clause " if $clause;
-
-    return $clause;
-}
-
 # {{{ Limit the result set based on content
 
 # {{{ sub Limit



More information about the freeside-commits mailing list