[freeside-commits] freeside/FS/FS cgp_rule_action.pm, 1.1.2.1, 1.1.2.2 cgp_rule_condition.pm, 1.1.2.1, 1.1.2.2 cgp_rule.pm, 1.1.2.1, 1.1.2.2 Mason.pm, 1.19.2.5, 1.19.2.6
Ivan,,,
ivan at wavetail.420.am
Thu Apr 22 23:43:42 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv14733/FS/FS
Modified Files:
Tag: FREESIDE_1_9_BRANCH
cgp_rule_action.pm cgp_rule_condition.pm cgp_rule.pm Mason.pm
Log Message:
communigate (phase 2): rules. RT#7514
Index: cgp_rule_action.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cgp_rule_action.pm,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -w -d -r1.1.2.1 -r1.1.2.2
--- cgp_rule_action.pm 22 Apr 2010 02:00:51 -0000 1.1.2.1
+++ cgp_rule_action.pm 23 Apr 2010 06:43:40 -0000 1.1.2.2
@@ -3,6 +3,7 @@
use strict;
use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs );
+use FS::cgp_rule;
=head1 NAME
@@ -25,8 +26,9 @@
=head1 DESCRIPTION
-An FS::cgp_rule_action object represents an example. FS::cgp_rule_action inherits from
-FS::Record. The following fields are currently supported:
+An FS::cgp_rule_action object represents a mail filtering action.
+FS::cgp_rule_action inherits from FS::Record. The following fields are
+currently supported:
=over 4
@@ -55,7 +57,7 @@
=item new HASHREF
-Creates a new example. To add the example to the database, see L<"insert">.
+Creates a new action. To add the action to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
@@ -94,7 +96,7 @@
=item check
-Checks all fields to make sure this is a valid example. If there is
+Checks all fields to make sure this is a valid action. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
@@ -110,7 +112,7 @@
$self->ut_numbern('ruleactionnum')
|| $self->ut_text('action')
|| $self->ut_text('params')
- || $self->ut_number('rulenum')
+ || $self->ut_foreign_key('rulenum', 'cgp_rule', 'rulenum')
;
return $error if $error;
@@ -121,8 +123,6 @@
=head1 BUGS
-The author forgot to customize this manpage.
-
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
Index: Mason.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Mason.pm,v
retrieving revision 1.19.2.5
retrieving revision 1.19.2.6
diff -u -w -d -r1.19.2.5 -r1.19.2.6
--- Mason.pm 9 Apr 2010 08:18:36 -0000 1.19.2.5
+++ Mason.pm 23 Apr 2010 06:43:40 -0000 1.19.2.6
@@ -223,6 +223,7 @@
use FS::cust_statement;
use FS::svc_pbx;
use FS::svc_mailinglist;
+ use FS::cgp_rule;
# Sammath Naur
if ( $FS::Mason::addl_handler_use ) {
Index: cgp_rule_condition.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cgp_rule_condition.pm,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -w -d -r1.1.2.1 -r1.1.2.2
--- cgp_rule_condition.pm 22 Apr 2010 02:00:51 -0000 1.1.2.1
+++ cgp_rule_condition.pm 23 Apr 2010 06:43:40 -0000 1.1.2.2
@@ -3,6 +3,7 @@
use strict;
use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs );
+use FS::cgp_rule;
=head1 NAME
@@ -25,8 +26,9 @@
=head1 DESCRIPTION
-An FS::cgp_rule_condition object represents an example. FS::cgp_rule_condition inherits from
-FS::Record. The following fields are currently supported:
+An FS::cgp_rule_condition object represents a mail filtering condition.
+FS::cgp_rule_condition inherits from FS::Record. The following fields are
+currently supported:
=over 4
@@ -59,7 +61,7 @@
=item new HASHREF
-Creates a new example. To add the example to the database, see L<"insert">.
+Creates a new condition. To add the condition to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
@@ -98,7 +100,7 @@
=item check
-Checks all fields to make sure this is a valid example. If there is
+Checks all fields to make sure this is a valid condition. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
@@ -115,7 +117,7 @@
|| $self->ut_text('condition')
|| $self->ut_text('op')
|| $self->ut_text('params')
- || $self->ut_number('rulenum')
+ || $self->ut_foreign_key('rulenum', 'cgp_rule', 'rulenum')
;
return $error if $error;
@@ -126,8 +128,6 @@
=head1 BUGS
-The author forgot to customize this manpage.
-
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
Index: cgp_rule.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cgp_rule.pm,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -w -d -r1.1.2.1 -r1.1.2.2
--- cgp_rule.pm 22 Apr 2010 02:00:51 -0000 1.1.2.1
+++ cgp_rule.pm 23 Apr 2010 06:43:40 -0000 1.1.2.2
@@ -2,7 +2,10 @@
use strict;
use base qw( FS::Record );
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearch qsearchs dbh );
+use FS::cust_svc;
+use FS::cgp_rule_condition;
+use FS::cgp_rule_action;
=head1 NAME
@@ -25,8 +28,8 @@
=head1 DESCRIPTION
-An FS::cgp_rule object represents an example. FS::cgp_rule inherits from
-FS::Record. The following fields are currently supported:
+An FS::cgp_rule object represents a mail filtering rule. FS::cgp_rule
+inherits from FS::Record. The following fields are currently supported:
=over 4
@@ -59,7 +62,7 @@
=item new HASHREF
-Creates a new example. To add the example to the database, see L<"insert">.
+Creates a new rule. To add the rule to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
@@ -85,7 +88,40 @@
=cut
-# the delete method can be inherited from FS::Record
+sub delete {
+ 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 @del = $self->cgp_rule_condition;
+ push @del, $self->cgp_rule_action;
+
+ foreach my $del (@del) {
+ my $error = $del->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ my $error = $self->SUPER::delete(@_);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+}
=item replace OLD_RECORD
@@ -98,7 +134,7 @@
=item check
-Checks all fields to make sure this is a valid example. If there is
+Checks all fields to make sure this is a valid rule. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
@@ -113,8 +149,8 @@
my $error =
$self->ut_numbern('rulenum')
|| $self->ut_text('name')
- || $self->ut_text('comment')
- || $self->ut_number('svcnum')
+ || $self->ut_textn('comment')
+ || $self->ut_foreign_key('svcnum', 'cust_svc', 'svcnum')
|| $self->ut_number('priority')
;
return $error if $error;
@@ -122,12 +158,43 @@
$self->SUPER::check;
}
+=item cust_svc
+
+=cut
+
+sub cust_svc {
+ my $self = shift;
+ qsearchs('cust_svc', { 'svcnum' => $self->svcnum } );
+}
+
+=item cgp_rule_condition
+
+Returns the conditions associated with this rule, as FS::cgp_rule_condition
+objects.
+
+=cut
+
+sub cgp_rule_condition {
+ my $self = shift;
+ qsearch('cgp_rule_condition', { 'rulenum' => $self->rulenum } );
+}
+
+=item cgp_rule_action
+
+Returns the actions associated with this rule, as FS::cgp_rule_action
+objects.
+
+=cut
+
+sub cgp_rule_action {
+ my $self = shift;
+ qsearch('cgp_rule_action', { 'rulenum' => $self->rulenum } );
+}
+
=back
=head1 BUGS
-The author forgot to customize this manpage.
-
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
More information about the freeside-commits
mailing list