[freeside-commits] freeside/FS/FS Conf.pm, 1.324.2.35, 1.324.2.36 cgp_rule.pm, 1.1.2.4, 1.1.2.5

Ivan,,, ivan at wavetail.420.am
Sun Jun 6 19:40:15 PDT 2010


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

Modified Files:
      Tag: FREESIDE_1_9_BRANCH
	Conf.pm cgp_rule.pm 
Log Message:
domain rules based on templates (rules from other domains), RT#7514

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.324.2.35
retrieving revision 1.324.2.36
diff -u -w -d -r1.324.2.35 -r1.324.2.36
--- Conf.pm	22 May 2010 19:49:19 -0000	1.324.2.35
+++ Conf.pm	7 Jun 2010 02:39:56 -0000	1.324.2.36
@@ -2432,6 +2432,13 @@
   },
 
   {
+    '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.",

Index: cgp_rule.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cgp_rule.pm,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -w -d -r1.1.2.4 -r1.1.2.5
--- cgp_rule.pm	23 May 2010 01:59:21 -0000	1.1.2.4
+++ cgp_rule.pm	7 Jun 2010 02:40:00 -0000	1.1.2.5
@@ -100,11 +100,12 @@
     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 @@
     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 @@
   $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



More information about the freeside-commits mailing list