[freeside-commits] freeside/FS/FS svc_acct.pm, 1.268.2.31, 1.268.2.32 acct_snarf.pm, 1.3.8.1, 1.3.8.2

Ivan,,, ivan at wavetail.420.am
Sat Aug 7 03:11:46 PDT 2010


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv15609/FS/FS

Modified Files:
      Tag: FREESIDE_1_9_BRANCH
	svc_acct.pm acct_snarf.pm 
Log Message:
communigate phase 3: RPOP/acct_snarf, RT#7515

Index: acct_snarf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/acct_snarf.pm,v
retrieving revision 1.3.8.1
retrieving revision 1.3.8.2
diff -u -w -d -r1.3.8.1 -r1.3.8.2
--- acct_snarf.pm	7 Aug 2010 07:39:06 -0000	1.3.8.1
+++ acct_snarf.pm	7 Aug 2010 10:11:44 -0000	1.3.8.2
@@ -3,7 +3,8 @@
 use strict;
 use vars qw( @ISA );
 use Tie::IxHash;
-use FS::Record;
+use FS::Record qw( qsearchs );
+use FS::cust_svc;
 
 @ISA = qw( FS::Record );
 
@@ -91,6 +92,37 @@
 
 # the replace method can be inherited from FS::Record
 
+=item cust_svc
+
+=cut
+
+sub cust_svc {
+  my $self = shift;
+  qsearchs('cust_svc', { 'svcnum' => $self->svcnum } );
+}
+
+
+=item svc_export
+
+Calls the replace export for any communigate exports attached to this rule's
+service.
+
+=cut
+
+sub svc_export {
+  my $self = shift;
+
+  my $cust_svc = $self->cust_svc;
+  my $svc_x = $cust_svc->svc_x;
+  
+  #_singledomain too
+  my @exports = $cust_svc->part_svc->part_export('communigate_pro');
+  my @errors = map $_->export_replace($svc_x, $svc_x), @exports;
+
+  @errors ? join(' / ', @errors) : '';
+
+}
+
 =item check
 
 Checks all fields to make sure this is a valid external mail account.  If
@@ -149,6 +181,26 @@
   \%hash;
 }
 
+=item cgp_hashref
+
+Returns a hashref representing this external mail account, suitable for
+Communigate Pro API commands:
+
+=cut
+
+sub cgp_hashref {
+  my $self = shift;
+  {
+    'authName' => $self->username,
+    'domain'   => $self->machine,
+    'password' => $self->_password,
+    'period'   => $self->check_freq.'s',
+    'APOP'     => ( $self->apop  eq 'Y' ? 'YES' : 'NO' ),
+    'TLS'      => ( $self->tls   eq 'Y' ? 'YES' : 'NO' ),
+    'Leave'    => ( $self->leave eq 'Y' ? 'YES' : 'NO' ), #XXX leave??
+  };
+}
+
 =back
 
 =head1 BUGS

Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.268.2.31
retrieving revision 1.268.2.32
diff -u -w -d -r1.268.2.31 -r1.268.2.32
--- svc_acct.pm	6 Aug 2010 21:31:07 -0000	1.268.2.31
+++ svc_acct.pm	7 Aug 2010 10:11:44 -0000	1.268.2.32
@@ -47,6 +47,7 @@
 use FS::svc_forward;
 use FS::svc_www;
 use FS::cdr;
+use FS::acct_snarf;
 
 $DEBUG = 0;
 $me = '[FS::svc_acct]';
@@ -1929,17 +1930,27 @@
 =item acct_snarf
 
 Returns an array of FS::acct_snarf records associated with the account.
-If the acct_snarf table does not exist or there are no associated records,
-an empty list is returned
 
 =cut
 
 sub acct_snarf {
   my $self = shift;
-  return () unless dbdef->table('acct_snarf');
-  eval "use FS::acct_snarf;";
-  die $@ if $@;
-  qsearch('acct_snarf', { 'svcnum' => $self->svcnum } );
+  qsearch({
+    'table'    => 'acct_snarf',
+    'hashref'  => { 'svcnum' => $self->svcnum },
+    #'order_by' => 'ORDER BY priority ASC',
+  });
+}
+
+=item cgp_rpop_hashref
+
+Returns an arrayref of RPOP data suitable for Communigate Pro API commands.
+
+=cut
+
+sub cgp_rpop_hashref {
+  my $self = shift;
+  { map { $_->snarfname => $_->cgp_hashref } $self->acct_snarf };
 }
 
 =item decrement_upbytes OCTETS



More information about the freeside-commits mailing list