[freeside-commits] freeside/FS/FS cust_pkg.pm, 1.60,
1.61 svc_acct.pm, 1.187, 1.188
Ivan,,,
ivan at wavetail.420.am
Fri Nov 11 06:06:36 PST 2005
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv11439
Modified Files:
cust_pkg.pm svc_acct.pm
Log Message:
for prepaid packages, trigger export update of RADIUS Expiration attribute when cust_pkg.bill changes
Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -d -r1.187 -r1.188
--- svc_acct.pm 13 Oct 2005 21:16:42 -0000 1.187
+++ svc_acct.pm 11 Nov 2005 14:06:34 -0000 1.188
@@ -1021,6 +1021,9 @@
sub radius_reply {
my $self = shift;
+ return %{ $self->{'radius_reply'} }
+ if exists $self->{'radius_reply'};
+
my %reply =
map {
/^(radius_(.*))$/;
@@ -1054,6 +1057,9 @@
sub radius_check {
my $self = shift;
+ return %{ $self->{'radius_check'} }
+ if exists $self->{'radius_check'};
+
my %check =
map {
/^(rc_(.*))$/;
@@ -1074,6 +1080,41 @@
}
+=item snapshot
+
+This method instructs the object to "snapshot" or freeze RADIUS check and
+reply attributes to the current values.
+
+=cut
+
+#bah, my english is too broken this morning
+#Of note is the "Expiration" attribute, which, for accounts in prepaid packages, is typically defined on-the-fly as the associated packages cust_pkg.bill. (This is used by
+#the FS::cust_pkg's replace method to trigger the correct export updates when
+#package dates change)
+
+sub snapshot {
+ my $self = shift;
+
+ $self->{$_} = { $self->$_() }
+ foreach qw( radius_reply radius_check );
+
+}
+
+=item forget_snapshot
+
+This methos instructs the object to forget any previously snapshotted
+RADIUS check and reply attributes.
+
+=cut
+
+sub forget_snapshot {
+ my $self = shift;
+
+ delete $self->{$_}
+ foreach qw( radius_reply radius_check );
+
+}
+
=item domain
Returns the domain associated with this account.
Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- cust_pkg.pm 20 Oct 2005 12:30:12 -0000 1.60
+++ cust_pkg.pm 11 Nov 2005 14:06:34 -0000 1.61
@@ -264,6 +264,8 @@
cancel is normally updated by the cancel method (and also the order subroutine
in some cases).
+Calls
+
=cut
sub replace {
@@ -281,7 +283,51 @@
local($disable_agentcheck) = 1 if $old->pkgpart == $new->pkgpart;
- $new->SUPER::replace($old);
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+
+ #save off and freeze RADIUS attributes for any associated svc_acct records
+ my @svc_acct = ();
+ if ( $old->part_pkg->is_prepaid || $new->part_pkg->is_prepaid ) {
+
+ #also check for specific exports?
+ # to avoid spurious modify export events
+ @svc_acct = map { $_->svc_x }
+ grep { $_->part_svc->svcdb eq 'svc_acct' }
+ $old->cust_svc;
+
+ $_->snapshot foreach @svc_acct;
+
+ }
+
+ my $error = $new->SUPER::replace($old);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ #for prepaid packages,
+ #trigger export of new RADIUS Expiration attribute when cust_pkg.bill changes
+ foreach my $old_svc_acct ( @svc_acct ) {
+ my $new_svc_acct = new FS::svc_acct { $old_svc_acct->hash };
+ my $s_error = $new_svc_acct->replace($old_svc_acct);
+ if ( $s_error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $s_error;
+ }
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ '';
+
}
=item check
More information about the freeside-commits
mailing list