[freeside-commits] freeside/FS/FS svc_CGPRule_Mixin.pm, NONE, 1.1.2.2 svc_domain.pm, 1.56.2.12, 1.56.2.13 svc_acct.pm, 1.268.2.23, 1.268.2.24 cgp_rule_action.pm, 1.1.2.3, 1.1.2.4 cgp_rule_condition.pm, 1.1.2.3, 1.1.2.4 cgp_rule.pm, 1.1.2.3, 1.1.2.4 Schema.pm, 1.168.2.38, 1.168.2.39
Ivan,,,
ivan at wavetail.420.am
Sat May 22 18:59:23 PDT 2010
- Previous message: [freeside-commits] freeside/FS/FS svc_CGPRule_Mixin.pm, NONE, 1.1 svc_domain.pm, 1.68, 1.69 svc_acct.pm, 1.292, 1.293 cgp_rule_action.pm, 1.4, 1.5 cgp_rule_condition.pm, 1.4, 1.5 cgp_rule.pm, 1.4, 1.5 Schema.pm, 1.217, 1.218
- Next message: [freeside-commits] freeside/FS/t svc_CGPRule_Mixin.t,NONE,1.1.2.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv13396/FS/FS
Modified Files:
Tag: FREESIDE_1_9_BRANCH
svc_domain.pm svc_acct.pm cgp_rule_action.pm
cgp_rule_condition.pm cgp_rule.pm Schema.pm
Added Files:
Tag: FREESIDE_1_9_BRANCH
svc_CGPRule_Mixin.pm
Log Message:
communigate pro rules, RT#7515
Index: svc_domain.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_domain.pm,v
retrieving revision 1.56.2.12
retrieving revision 1.56.2.13
diff -u -w -d -r1.56.2.12 -r1.56.2.13
--- svc_domain.pm 20 Apr 2010 04:29:16 -0000 1.56.2.12
+++ svc_domain.pm 23 May 2010 01:59:20 -0000 1.56.2.13
@@ -1,7 +1,8 @@
package FS::svc_domain;
use strict;
-use vars qw( @ISA $whois_hack $conf
+use base qw( FS::svc_Parent_Mixin FS::svc_CGPRule_Mixin FS::svc_Common );
+use vars qw( $whois_hack $conf
@defaultrecords $soadefaultttl $soaemail $soaexpire $soamachine
$soarefresh $soaretry
);
@@ -12,8 +13,6 @@
use Net::Domain::TLD qw(tld_exists);
use FS::Record qw(fields qsearch qsearchs dbh);
use FS::Conf;
-use FS::svc_Common;
-use FS::svc_Parent_Mixin;
use FS::cust_svc;
use FS::svc_acct;
use FS::cust_pkg;
@@ -21,8 +20,6 @@
use FS::domain_record;
use FS::queue;
- at ISA = qw( FS::svc_Parent_Mixin FS::svc_Common );
-
#ask FS::UID to run this stuff for us later
$FS::UID::callback{'FS::domain'} = sub {
$conf = new FS::Conf;
Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.268.2.23
retrieving revision 1.268.2.24
diff -u -w -d -r1.268.2.23 -r1.268.2.24
--- svc_acct.pm 20 Apr 2010 04:14:04 -0000 1.268.2.23
+++ svc_acct.pm 23 May 2010 01:59:20 -0000 1.268.2.24
@@ -1,7 +1,7 @@
package FS::svc_acct;
use strict;
-use base qw( FS::svc_Domain_Mixin FS::svc_Common );
+use base qw( FS::svc_Domain_Mixin FS::svc_CGPRule_Mixin FS::svc_Common );
use vars qw( $DEBUG $me $conf $skip_fuzzyfiles
$dir_prefix @shells $usernamemin
$usernamemax $passwordmin $passwordmax
Index: cgp_rule_action.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cgp_rule_action.pm,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -w -d -r1.1.2.3 -r1.1.2.4
--- cgp_rule_action.pm 30 Apr 2010 02:17:32 -0000 1.1.2.3
+++ cgp_rule_action.pm 23 May 2010 01:59:21 -0000 1.1.2.4
@@ -48,7 +48,6 @@
rulenum
-
=back
=head1 METHODS
@@ -119,6 +118,15 @@
$self->SUPER::check;
}
+=item arrayref
+
+=cut
+
+sub arrayref {
+ my $self = shift;
+ [ $self->action, $self->params ];
+}
+
=back
=head1 BUGS
Index: cgp_rule.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cgp_rule.pm,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -w -d -r1.1.2.3 -r1.1.2.4
--- cgp_rule.pm 29 Apr 2010 07:40:47 -0000 1.1.2.3
+++ cgp_rule.pm 23 May 2010 01:59:21 -0000 1.1.2.4
@@ -80,7 +80,35 @@
=cut
-# the insert method can be inherited from FS::Record
+sub insert {
+ my $self = shift;
+
+ 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;
+
+ my $error = $self->SUPER::insert(@_);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $error = $self->svc_export;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ '';
+}
=item delete
@@ -119,8 +147,14 @@
return $error;
}
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ $error = $self->svc_export;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ '';
}
=item replace OLD_RECORD
@@ -130,7 +164,61 @@
=cut
-# the replace method can be inherited from FS::Record
+sub replace {
+ my $new = shift;
+
+ my $old = ( ref($_[0]) eq ref($new) )
+ ? shift
+ : $new->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;
+
+ my $error = $new->SUPER::replace($old, @_);
+ if ( $error ) {
+ $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
+ return $error;
+ }
+
+ $error = $new->svc_export;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ '';
+
+}
+
+=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
@@ -191,6 +279,33 @@
qsearch('cgp_rule_action', { 'rulenum' => $self->rulenum } );
}
+=item arrayref
+
+Returns an arraref representing this rule, suitable for Communigate Pro API
+commands:
+
+The first element specifies the rule priority.
+
+The second element specifies the rule name.
+
+The third element specifies the rule conditions.
+
+The fourth element specifies the rule actions.
+
+The fifth element specifies the rule comment.
+
+=cut
+
+sub arrayref {
+ my $self = shift;
+ [ $self->priority,
+ $self->name,
+ [ map $_->arrayref, $self->cgp_rule_condition ],
+ [ map $_->arrayref, $self->cgp_rule_action ],
+ $self->comment,
+ ],
+}
+
=back
=head1 BUGS
--- NEW FILE: svc_CGPRule_Mixin.pm ---
package FS::svc_CGPRule_Mixin;
use strict;
use FS::Record qw(qsearch);
use FS::cgp_rule;
=head1 NAME
FS::svc_CGPRule_Mixin - Mixin class for svc_classes which can be related to cgp_rule
=head1 SYNOPSIS
package FS::svc_table;
use base qw( FS::svc_CGPRule_Mixin FS::svc_Common );
=head1 DESCRIPTION
This is a mixin class for svc_ classes that can have Communigate Pro rules
(currently, domains and accounts).
=head1 METHODS
=over 4
=item
Returns the rules associated with this service, as FS::cgp_rule objects.
=cut
sub cgp_rule {
my $self = shift;
qsearch({
'table' => 'cgp_rule',
'hashref' => { 'svcnum' => $self->svcnum },
'order_by' => 'ORDER BY priority ASC',
});
}
=item cgp_rule_arrayref
Returns an arrayref of rules suitable for Communigate Pro API commands.
=cut
sub cgp_rule_arrayref {
my $self = shift;
[ map $_->arrayref, $self->cgp_rule ];
}
=back
=head1 BUGS
=head1 SEE ALSO
L<FS::cgp_rule>
=cut
1;
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.168.2.38
retrieving revision 1.168.2.39
diff -u -w -d -r1.168.2.38 -r1.168.2.39
--- Schema.pm 22 May 2010 19:49:20 -0000 1.168.2.38
+++ Schema.pm 23 May 2010 01:59:21 -0000 1.168.2.39
@@ -1631,7 +1631,7 @@
'priority', 'int', '', '', '', '',
],
'primary_key' => 'rulenum',
- 'unique' => [],
+ 'unique' => [ [ 'svcnum', 'name' ] ],
'index' => [ [ 'svcnum' ] ],
},
Index: cgp_rule_condition.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cgp_rule_condition.pm,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -w -d -r1.1.2.3 -r1.1.2.4
--- cgp_rule_condition.pm 30 Apr 2010 02:17:32 -0000 1.1.2.3
+++ cgp_rule_condition.pm 23 May 2010 01:59:21 -0000 1.1.2.4
@@ -52,7 +52,6 @@
rulenum
-
=back
=head1 METHODS
@@ -124,6 +123,17 @@
$self->SUPER::check;
}
+=item arrayref
+
+Returns an array reference of the condition, op and params fields.
+
+=cut
+
+sub arrayref {
+ my $self = shift;
+ [ map $self->$_, qw( condition op params ) ];
+}
+
=back
=head1 BUGS
- Previous message: [freeside-commits] freeside/FS/FS svc_CGPRule_Mixin.pm, NONE, 1.1 svc_domain.pm, 1.68, 1.69 svc_acct.pm, 1.292, 1.293 cgp_rule_action.pm, 1.4, 1.5 cgp_rule_condition.pm, 1.4, 1.5 cgp_rule.pm, 1.4, 1.5 Schema.pm, 1.217, 1.218
- Next message: [freeside-commits] freeside/FS/t svc_CGPRule_Mixin.t,NONE,1.1.2.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list