part two of #1160: linking a ticket to its first customer will auto-link any customer...
[freeside.git] / rt / lib / RT / Record.pm
index a7598bf..f7100c5 100755 (executable)
@@ -1231,8 +1231,37 @@ sub DependsOn {
 
 # }}}
 
+# {{{ Customers
 
+=head2 Customers
 
+  This returns an RT::Links object which references all the customers that this object is a member of.
+
+=cut
+
+sub Customers {
+    my( $self, %opt ) = @_;
+    my $Debug = $opt{'Debug'};
+
+    unless ( $self->{'Customers'} ) {
+
+      $self->{'Customers'} = $self->MemberOf->Clone;
+
+      $self->{'Customers'}->Limit(
+                                   FIELD    => 'Target',
+                                   OPERATOR => 'STARTSWITH',
+                                   VALUE    => 'freeside://freeside/cust_main/',
+                                 );
+    }
+
+    warn "->Customers method called on $self; returning ".
+         ref($self->{'Customers'}). ' object'
+      if $Debug;
+
+    return $self->{'Customers'};
+}
+
+# }}}
 
 # {{{ sub _Links