diff options
author | ivan <ivan> | 2010-06-07 02:39:35 +0000 |
---|---|---|
committer | ivan <ivan> | 2010-06-07 02:39:35 +0000 |
commit | 31a9c95e5b7125ef666248699fff31f1f8211364 (patch) | |
tree | 3673d519ac208bbf6b4ecc174511d3cef99a1501 /FS | |
parent | da99804133e55d5ce02402645b593a6de06d1947 (diff) |
domain rules based on templates (rules from other domains), RT#7514
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Conf.pm | 7 | ||||
-rw-r--r-- | FS/FS/cgp_rule.pm | 63 |
2 files changed, 60 insertions, 10 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 472320d..89a36af 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2440,6 +2440,13 @@ worry that config_items is freeside-specific and icky. }, { + 'key' => 'cgp_rule-domain_templates', + 'section' => '', + 'description' => 'Communigate Pro rule templates for domains, one per line, "svcnum Name"', + 'type' => 'textarea', + }, + + { 'key' => 'svc_forward-no_srcsvc', 'section' => '', 'description' => "Don't allow forwards from existing accounts, only arbitrary addresses. Useful when exporting to systems such as Communigate Pro which treat forwards in this fashion.", diff --git a/FS/FS/cgp_rule.pm b/FS/FS/cgp_rule.pm index ad5ab1e..e9c5090 100644 --- a/FS/FS/cgp_rule.pm +++ b/FS/FS/cgp_rule.pm @@ -100,11 +100,12 @@ sub insert { return $error; } - $error = $self->svc_export; - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return $error; - } + #conditions and actions not in yet + #$error = $self->svc_export; + #if ( $error ) { + # $dbh->rollback if $oldAutoCommit; + # return $error; + #} $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; @@ -188,11 +189,12 @@ sub replace { return $error; } - $error = $new->svc_export; - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return $error; - } + #conditions and actions not in yet + #$error = $new->svc_export; + #if ( $error ) { + # $dbh->rollback if $oldAutoCommit; + # return $error; + #} $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; @@ -246,6 +248,47 @@ sub check { $self->SUPER::check; } +=item clone NEW_SVCNUM + +Clones this rule into an identical rule for the specified new service. + +If there is an error, returns the error, otherwise returns false. + +=cut + +#should return the newly inserted rule instead? used in misc/clone-cgp_rule.html + +#i should probably be transactionalized so i'm all-or-nothing +sub clone { + my( $self, $svcnum ) = @_; + + my $new = $self->new( { $self->hash } ); + $new->rulenum(''); + $new->svcnum( $svcnum ); + my $error = $new->insert; + return $error if $error; + + my @dup = $self->cgp_rule_condition; + push @dup, $self->cgp_rule_action; + + foreach my $dup (@dup) { + my $new_dup = $dup->new( { $dup->hash } ); + my $pk = $new_dup->primary_key; + $new_dup->$pk(''); + $new_dup->rulenum( $new->rulenum ); + + $error = $new_dup->insert; + return $error if $error; + + } + + $error = $new->svc_export; + return $error if $error; + + ''; + +} + =item cust_svc =cut |