add option for exports to avoid suspending services, #20739
authorMark Wells <mark@freeside.biz>
Thu, 31 Dec 2015 02:51:09 +0000 (18:51 -0800)
committerMark Wells <mark@freeside.biz>
Thu, 31 Dec 2015 02:51:09 +0000 (18:51 -0800)
FS/FS/Schema.pm
FS/FS/part_export.pm
FS/FS/svc_Common.pm
httemplate/browse/part_export.cgi
httemplate/edit/part_export.cgi

index a10b5c0..56bdfc3 100644 (file)
@@ -4487,6 +4487,8 @@ sub tables_hashref {
         'exporttype', 'varchar',     '', $char_d, '', '', 
         'nodomain',      'char', 'NULL',       1, '', '', 
         'default_machine','int', 'NULL',      '', '', '',
         'exporttype', 'varchar',     '', $char_d, '', '', 
         'nodomain',      'char', 'NULL',       1, '', '', 
         'default_machine','int', 'NULL',      '', '', '',
+        'no_suspend',    'char', 'NULL',       1, '', '',
+        # could also have 'no_insert', 'no_replace', etc.
       ],
       'primary_key'  => 'exportnum',
       'unique'       => [],
       ],
       'primary_key'  => 'exportnum',
       'unique'       => [],
index f3d9774..d6357fd 100644 (file)
@@ -58,6 +58,12 @@ fields are currently supported:
 
 =item nodomain - blank or "Y" : usernames are exported to this service with no domain
 
 
 =item nodomain - blank or "Y" : usernames are exported to this service with no domain
 
+=item default_machine - For exports that require a machine to be selected for
+each service (see L<FS::svc_export_machine>), the one to use as the default.
+
+=item no_suspend - Don't export service suspensions. In the future there may
+be "no_*" options for the other service actions.
+
 =back
 
 =head1 METHODS
 =back
 
 =head1 METHODS
@@ -337,6 +343,7 @@ sub check {
     || $self->ut_textn('exportname')
     || $self->ut_domainn('machine')
     || $self->ut_alpha('exporttype')
     || $self->ut_textn('exportname')
     || $self->ut_domainn('machine')
     || $self->ut_alpha('exporttype')
+    || $self->ut_flag('no_suspend')
   ;
 
   if ( $self->machine eq '_SVC_MACHINE' ) {
   ;
 
   if ( $self->machine eq '_SVC_MACHINE' ) {
index 35415a2..73658f6 100644 (file)
@@ -1154,7 +1154,9 @@ Runs the provided export hook (i.e. "suspend", "unsuspend") for this service.
 sub export {
   my( $self, $method ) = ( shift, shift );
 
 sub export {
   my( $self, $method ) = ( shift, shift );
 
+  # $method must start with export_, $action must be the part after that
   $method = "export_$method" unless $method =~ /^export_/;
   $method = "export_$method" unless $method =~ /^export_/;
+  my ($action) = $method =~ /^export_(\w+)/;
 
   local $SIG{HUP} = 'IGNORE';
   local $SIG{INT} = 'IGNORE';
 
   local $SIG{HUP} = 'IGNORE';
   local $SIG{INT} = 'IGNORE';
@@ -1171,6 +1173,7 @@ sub export {
   unless ( $noexport_hack ) {
     foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
       next unless $part_export->can($method);
   unless ( $noexport_hack ) {
     foreach my $part_export ( $self->cust_svc->part_svc->part_export ) {
       next unless $part_export->can($method);
+      next if $part_export->get("no_$action"); # currently only 'no_suspend'
       my $error = $part_export->$method($self, @_);
       if ( $error ) {
         $dbh->rollback if $oldAutoCommit;
       my $error = $part_export->$method($self, @_);
       if ( $error ) {
         $dbh->rollback if $oldAutoCommit;
index af988d3..bbb723d 100755 (executable)
@@ -38,6 +38,11 @@ function part_export_areyousure(href) {
       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
         <% $part_export->label_html %>
         (<A HREF="<% $p %>edit/part_export.cgi?<% $part_export->exportnum %>">edit</A>&nbsp;|&nbsp;<A HREF="javascript:part_export_areyousure('<% $p %>misc/delete-part_export.cgi?<% $part_export->exportnum %>')">delete</A>)
       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
         <% $part_export->label_html %>
         (<A HREF="<% $p %>edit/part_export.cgi?<% $part_export->exportnum %>">edit</A>&nbsp;|&nbsp;<A HREF="javascript:part_export_areyousure('<% $p %>misc/delete-part_export.cgi?<% $part_export->exportnum %>')">delete</A>)
+%       if ( $part_export->no_suspend ) {
+        <P STYLE="position: absolute">
+        This export will not suspend services.
+        </P>
+%       }
 %       if ( my @actions = $part_export->actions ) {
         <P STYLE="position: absolute">
         Management:
 %       if ( my @actions = $part_export->actions ) {
         <P STYLE="position: absolute">
         Management:
index 3820931..5411feb 100644 (file)
@@ -285,6 +285,11 @@ my $widget = new HTML::Widgets::SelectLayers(
       $html .= '</TD></TR>';
     }
 
       $html .= '</TD></TR>';
     }
 
+    $html .= '<TR><TD ALIGN="right">Do not suspend services</TD>' .
+                '<TD><INPUT TYPE="checkbox" NAME="no_suspend" VALUE="Y"';
+    $html .= ' CHECKED' if $part_export->no_suspend eq 'Y';
+    $html .= '></TD></TR>';
+
     $html .= '</TABLE>';
 
     # false laziness with config_element above
     $html .= '</TABLE>';
 
     # false laziness with config_element above