improve customer field access in RT queries, #16490
[freeside.git] / rt / lib / RT / URI / freeside.pm
index 57c2a2c..64fb377 100644 (file)
 # END LICENSE BLOCK
 package RT::URI::freeside;
 
-use RT::URI::base;
+use base qw( RT::URI::base );
 use strict;
-use vars qw(@ISA $IntegrationType $URL);
-@ISA = qw/RT::URI::base/;
+use vars qw( $IntegrationType $URL );
+use Carp qw( cluck );
 
 
 =head1 NAME
@@ -83,6 +83,15 @@ A wrapper for the FS::cust_main::smart_search subroutine.
 sub smart_search { return undef; }
 
 
+=item email_search
+
+A wrapper for the FS::cust_main::email_search subroutine.
+
+=cut
+
+sub email_search { return undef; }
+
+
 =item small_custview
 
 A wrapper for the FS::CGI::small_custview subroutine.
@@ -196,10 +205,18 @@ sub ParseURI {
     my ($table, $pkey);
 
     my $uriprefix = $self->_FreesideURIPrefix;
-    if ($uri =~ /^$uriprefix\/(\w+)\/(\d+)$/) {
+    if ($uri =~ /^$uriprefix\/(\w+)\/(\d*)$/) {
+
       $table = $1;
       $pkey = $2;
+
+      unless ( $pkey ) {
+        #way too noisy, using this prefix is normal usage# cluck "bad URL $uri";
+        return(undef);
+      }
+
       $self->{'scheme'} = $self->Scheme;
+
     } else {
       return(undef);
     }
@@ -282,8 +299,19 @@ if ($@ &&
   die $@;
 };
 
-=back
+=item CustomerInfo
+
+Return a hashref of customer information, including all fields from 
+C<cust_main> as well as:
+
+- AgentName: the name of the customer's agent
+- CustomerClass: the name of the customer's class
+- CustomerTags: an arrayref of tags attached to the customer, each
+  as a hashref with keys "name", "desc", and "color".
+- Referral: the name of the customer's advertising source.
 
 =cut
 
+sub CustomerInfo { {} }
+
 1;