new config value `defaultrecords', documentation, javascript config file editor
authorivan <ivan>
Mon, 18 Mar 2002 09:10:12 +0000 (09:10 +0000)
committerivan <ivan>
Mon, 18 Mar 2002 09:10:12 +0000 (09:10 +0000)
FS/FS/Conf.pm
FS/FS/svc_domain.pm
README.1.4.0pre12
httemplate/config/config-process.cgi
httemplate/config/config-view.cgi
httemplate/config/config.cgi
httemplate/docs/upgrade8.html

index 5dba387..18725ce 100644 (file)
@@ -437,28 +437,40 @@ httemplate/docs/config.html
 
   {
     'key'         => 'mxmachines',
 
   {
     'key'         => 'mxmachines',
-    'section'     => 'BIND',
+    'section'     => 'deprecated',
     'description' => 'MX entries for new domains, weight and machine, one per line, with trailing `.\'',
     'type'        => 'textarea',
   },
 
   {
     'key'         => 'nsmachines',
     'description' => 'MX entries for new domains, weight and machine, one per line, with trailing `.\'',
     'type'        => 'textarea',
   },
 
   {
     'key'         => 'nsmachines',
-    'section'     => 'BIND',
+    'section'     => 'deprecated',
     'description' => 'NS nameservers for new domains, one per line, with trailing `.\'',
     'type'        => 'textarea',
   },
 
   {
     'description' => 'NS nameservers for new domains, one per line, with trailing `.\'',
     'type'        => 'textarea',
   },
 
   {
-    'key'         => 'arecords',
+    'key'         => 'defaultrecords',
     'section'     => 'BIND',
     'section'     => 'BIND',
-    'description' => 'A list of tab seperated A records to add automatically when creating a domain',
+    'description' => 'DNS entries add automatically when creating a domain',
+    'type'        => 'editlist',
+    'editlist_parts' => [ { type=>'text' },
+                          { type=>'immutable', value=>'IN' },
+                          { type=>'select',
+                            select_enum=>{ map { $_=>$_ } qw(A CNAME MX NS)} },
+                          { type=> 'text' }, ],
+  },
+
+  {
+    'key'         => 'arecords',
+    'section'     => 'deprecated',
+    'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain',
     'type'        => 'textarea',
   },
 
   {
     'key'         => 'cnamerecords',
     'type'        => 'textarea',
   },
 
   {
     'key'         => 'cnamerecords',
-    'section'     => 'BIND',
+    'section'     => 'deprecated',
     'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain',
     'type'        => 'textarea',
   },
     'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain',
     'type'        => 'textarea',
   },
index 1e16ba8..d01a403 100644 (file)
@@ -2,8 +2,8 @@ package FS::svc_domain;
 
 use strict;
 use vars qw( @ISA $whois_hack $conf $smtpmachine
 
 use strict;
 use vars qw( @ISA $whois_hack $conf $smtpmachine
-  @mxmachines @nsmachines $soadefaultttl $soaemail $soaexpire $soamachine
-  $soarefresh $soaretry $qshellmachine $nossh_hack %arecords %cnamerecords
+  @defaultrecords $soadefaultttl $soaemail $soaexpire $soamachine
+  $soarefresh $soaretry $qshellmachine $nossh_hack 
 );
 use Carp;
 use Mail::Internet;
 );
 use Carp;
 use Mail::Internet;
@@ -29,10 +29,7 @@ $FS::UID::callback{'FS::domain'} = sub {
 
   $smtpmachine = $conf->config('smtpmachine');
 
 
   $smtpmachine = $conf->config('smtpmachine');
 
-  %arecords      = map { split /\t/ } $conf->config('arecords');
-  %cnamerecords  = map { split /\t/ } $conf->config('cnamerecords');
-  @mxmachines    = $conf->config('mxmachines');
-  @nsmachines    = $conf->config('nsmachines');
+  @defaultrecords = $conf->config('defaultrecords');
   $soadefaultttl = $conf->config('soadefaultttl');
   $soaemail      = $conf->config('soaemail');
   $soaexpire     = $conf->config('soaexpire');
   $soadefaultttl = $conf->config('soadefaultttl');
   $soaemail      = $conf->config('soaemail');
   $soaexpire     = $conf->config('soaexpire');
@@ -119,15 +116,9 @@ in the same package, it is automatically used.  Otherwise an error is returned.
 If any I<soamachine> configuration file exists, an SOA record is added to
 the domain_record table (see <FS::domain_record>).
 
 If any I<soamachine> configuration file exists, an SOA record is added to
 the domain_record table (see <FS::domain_record>).
 
-If any machines are defined in the I<nsmachines> configuration file, NS
-records are added to the domain_record table (see L<FS::domain_record>).
-
-If any machines are defined in the I<mxmachines> configuration file, MX
-records are added to the domain_record table (see L<FS::domain_record>).
-
-If the I<arecords> configuration file exits, A records are added to the
-domain_record table.  The I<cnamerecords> file does the same thing for
-CNAME records.
+If any records are defined in the I<defaultrecords> configuration file,
+appropriate records are added to the domain_record table (see
+L<FS::domain_record>).
 
 If a machine is defined in the I<shellmachine> configuration value, the
 I<qmailmachines> configuration file exists, and the I<catchall> field points
 
 If a machine is defined in the I<shellmachine> configuration value, the
 I<qmailmachines> configuration file exists, and the I<catchall> field points
@@ -200,63 +191,19 @@ sub insert {
       return "couldn't insert SOA record for new domain: $error";
     }
 
       return "couldn't insert SOA record for new domain: $error";
     }
 
-    foreach my $nsmachine ( @nsmachines ) {
-      my $ns = new FS::domain_record {
-        'svcnum'  => $self->svcnum,
-        'reczone' => '@',
-        'recaf'   => 'IN',
-        'rectype' => 'NS',
-        'recdata' => $nsmachine,
-      };
-      my $error = $ns->insert;
-      if ( $error ) {
-        $dbh->rollback if $oldAutoCommit;
-        return "couldn't insert NS record for new domain: $error";
-      }
-    }
-
-    foreach my $mxmachine ( @mxmachines ) {
-      my $mx = new FS::domain_record {
-        'svcnum'  => $self->svcnum,
-        'reczone' => '@',
-        'recaf'   => 'IN',
-        'rectype' => 'MX',
-        'recdata' => $mxmachine,
-      };
-      my $error = $mx->insert;
-      if ( $error ) {
-        $dbh->rollback if $oldAutoCommit;
-        return "couldn't insert MX record for new domain: $error";
-      }
-    }
-
-    foreach my $arecord ( keys %arecords ) {
-      my $arec = new FS::domain_record {
-        'svcnum'  => $self->svcnum,
-        'reczone' => $arecord,
-        'recaf'   => 'IN',
-        'rectype' => 'A',
-        'recdata' => $arecords{$arecord},
-      };
-      my $error = $arec->insert;
-      if ( $error ) {
-        $dbh->rollback if $oldAutoCommit;
-        return "WARNING: couldn't insert A record for new domain: $error";
-      }
-    }
-
-    foreach my $cnamerecord ( keys %cnamerecords ) {
-      my $cnamerec = new FS::domain_record {
+    foreach my $record ( @defaultrecords ) {
+      my($zone,$af,$type,$data) = split(/\s+/,$record,4);
+      my $record = new FS::domain_record {
         'svcnum'  => $self->svcnum,
         'svcnum'  => $self->svcnum,
-        'reczone' => $cnamerecord,
-        'recaf'   => 'IN',
-        'rectype' => 'CNAME',
-        'recdata' => $cnamerecords{$cnamerecord},
+        'reczone' => $zone,
+        'recaf'   => $af,
+        'rectype' => $type,
+        'recdata' => $data,
       };
       };
-      my $error = $cnamerec->insert;
+      my $error = $record->insert;
       if ( $error ) {
         $dbh->rollback if $oldAutoCommit;
       if ( $error ) {
         $dbh->rollback if $oldAutoCommit;
-        return "WARNING: couldn't insert CNAME record for new domain: $error";
+        return "couldn't insert record for new domain: $error";
       }
     }
 
       }
     }
 
@@ -460,7 +407,7 @@ sub submit_internic {
 
 =head1 VERSION
 
 
 =head1 VERSION
 
-$Id: svc_domain.pm,v 1.25 2002-03-09 10:19:38 khoff Exp $
+$Id: svc_domain.pm,v 1.26 2002-03-18 09:10:12 ivan Exp $
 
 =head1 BUGS
 
 
 =head1 BUGS
 
index 824b7fd..c801a26 100644 (file)
@@ -25,3 +25,5 @@ Arrange for freeside-expiration-alerter to be run daily, if desired.
 
 Restart Apache and freeside-queued
 
 
 Restart Apache and freeside-queued
 
+the mxmachines, nsmachines, arecords and cnamerecords configuration values have been deprecated.  Use the defaultrecords configuration value instead.
+
index a296abf..38d9af0 100644 (file)
         } else {
           $conf->delete($i->key);
         }
         } else {
           $conf->delete($i->key);
         }
+      } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' )  {
+        if ( scalar(@{[ $cgi->param($i->key. $n) ]}) ) {
+          $conf->set($i->key, join("\n", $cgi->param($i->key. $n) ));
+        } else {
+          $conf->delete($i->key);
+        }
       } else {
       }
       $n++;
       } else {
       }
       $n++;
index 917cc73..d40c4dc 100644 (file)
@@ -8,6 +8,7 @@
                             shell mail radius apache BIND
                            ),
                          '', 'deprecated') { %>
                             shell mail radius apache BIND
                            ),
                          '', 'deprecated') { %>
+  <A NAME="<%= $section || 'unclassified' %>"></A>
   <FONT SIZE="-2">
   <% foreach my $nav_section ( qw(required billing username password UI session
                                   shell mail radius apache BIND
   <FONT SIZE="-2">
   <% foreach my $nav_section ( qw(required billing username password UI session
                                   shell mail radius apache BIND
     <% if ( $section eq $nav_section ) { %>
       [<A NAME="not<%= $nav_section || 'unclassified' %>" style="background-color: #cccccc"><%= ucfirst($nav_section || 'unclassified') %></A>]
     <% } else { %>
     <% if ( $section eq $nav_section ) { %>
       [<A NAME="not<%= $nav_section || 'unclassified' %>" style="background-color: #cccccc"><%= ucfirst($nav_section || 'unclassified') %></A>]
     <% } else { %>
-      [<A HREF="#<%= $nav_section %>"><%= ucfirst($nav_section || 'unclassified') %></A>]
+      [<A HREF="#<%= $nav_section || 'unclassified' %>"><%= ucfirst($nav_section || 'unclassified') %></A>]
     <% } %>
   <% } %>
   </FONT><BR>
     <% } %>
   <% } %>
   </FONT><BR>
-  <A NAME="<%= $section || 'unclassified' %>"></A>
   <%= table("#cccccc", 2) %>
   <tr>
     <th colspan="2" bgcolor="#dcdcdc">
   <%= table("#cccccc", 2) %>
   <tr>
     <th colspan="2" bgcolor="#dcdcdc">
index 155dcfd..5013de0 100644 (file)
@@ -2,25 +2,33 @@
 <%= header('Edit Configuration', menubar( 'Main Menu' => $p ) ) %>
 <SCRIPT>
 var gSafeOnload = new Array();
 <%= header('Edit Configuration', menubar( 'Main Menu' => $p ) ) %>
 <SCRIPT>
 var gSafeOnload = new Array();
+var gSafeOnsubmit = new Array();
 window.onload = SafeOnload;
 function SafeAddOnLoad(f) {
   gSafeOnload[gSafeOnload.length] = f;
 }
 window.onload = SafeOnload;
 function SafeAddOnLoad(f) {
   gSafeOnload[gSafeOnload.length] = f;
 }
-function SafeOnload()
-{
+function SafeOnload() {
   for (var i=0;i<gSafeOnload.length;i++)
     gSafeOnload[i]();
 }
   for (var i=0;i<gSafeOnload.length;i++)
     gSafeOnload[i]();
 }
+function SafeAddOnSubmit(f) {
+  gSafeOnsubmit[gSafeOnsubmit.length] = f;
+}
+function SafeOnsubmit() {
+  for (var i=0;i<gSafeOnsubmit.length;i++)
+    gSafeOnsubmit[i]();
+}
 </SCRIPT>
 
 <% my $conf = new FS::Conf; my @config_items = $conf->config_items; %>
 
 </SCRIPT>
 
 <% my $conf = new FS::Conf; my @config_items = $conf->config_items; %>
 
-<form name="OneTrueForm" action="config-process.cgi" METHOD="POST">
+<form name="OneTrueForm" action="config-process.cgi" METHOD="POST" onSubmit="SafeOnsubmit()">
 
 <% foreach my $section ( qw(required billing username password UI session
                             shell mail radius apache BIND
                            ),
                          '', 'deprecated') { %>
 
 <% foreach my $section ( qw(required billing username password UI session
                             shell mail radius apache BIND
                            ),
                          '', 'deprecated') { %>
+  <A NAME="<%= $section || 'unclassified' %>"></A>
   <FONT SIZE="-2">
   <% foreach my $nav_section ( qw(required billing username password UI session
                                   shell mail radius apache BIND
   <FONT SIZE="-2">
   <% foreach my $nav_section ( qw(required billing username password UI session
                                   shell mail radius apache BIND
@@ -29,11 +37,10 @@ function SafeOnload()
     <% if ( $section eq $nav_section ) { %>
       [<A NAME="not<%= $nav_section || 'unclassified' %>" style="background-color: #cccccc"><%= ucfirst($nav_section || 'unclassified') %></A>]
     <% } else { %>
     <% if ( $section eq $nav_section ) { %>
       [<A NAME="not<%= $nav_section || 'unclassified' %>" style="background-color: #cccccc"><%= ucfirst($nav_section || 'unclassified') %></A>]
     <% } else { %>
-      [<A HREF="#<%= $nav_section %>"><%= ucfirst($nav_section || 'unclassified') %></A>]
+      [<A HREF="#<%= $nav_section || 'unclassified' %>"><%= ucfirst($nav_section || 'unclassified') %></A>]
     <% } %>
   <% } %>
   </FONT><BR>
     <% } %>
   <% } %>
   </FONT><BR>
-  <A NAME="<%= $section || 'unclassified' %>"></A>
   <%= table("#cccccc", 2) %>
   <tr>
     <th colspan="2" bgcolor="#dcdcdc">
   <%= table("#cccccc", 2) %>
   <tr>
     <th colspan="2" bgcolor="#dcdcdc">
@@ -65,6 +72,7 @@ function SafeOnload()
               <% if ( $conf->exists($i->key) && $conf->config($i->key) && ! grep { $conf->config($i->key) eq $_ } @{$i->select_enum}) { %>
                 <option value=<%= $conf->config($i->key) %> SELECTED><%= conf->config($i->key) %>
               <% } %>
               <% if ( $conf->exists($i->key) && $conf->config($i->key) && ! grep { $conf->config($i->key) eq $_ } @{$i->select_enum}) { %>
                 <option value=<%= $conf->config($i->key) %> SELECTED><%= conf->config($i->key) %>
               <% } %>
+            </select>
           <% } elsif ( $type eq 'editlist' )  { %>
             <script>
               function doremove<%= $i->key. $n %>() {
           <% } elsif ( $type eq 'editlist' )  { %>
             <script>
               function doremove<%= $i->key. $n %>() {
@@ -77,6 +85,12 @@ function SafeOnload()
               function deleteOption<%= $i->key. $n %>(object,index) {
                 object.options[index] = null;
               }
               function deleteOption<%= $i->key. $n %>(object,index) {
                 object.options[index] = null;
               }
+              function selectall<%= $i->key. $n %>() {
+                fromObject = document.OneTrueForm.<%= $i->key. $n %>;
+                for (var i=fromObject.options.length-1;i>-1;i--) {
+                  fromObject.options[i].selected = true;
+                }
+              }
               function doadd<%= $i->key. $n %>(object) {
                 var myvalue = "";
                 <% if ( defined($i->editlist_parts) ) { %>
               function doadd<%= $i->key. $n %>(object) {
                 var myvalue = "";
                 <% if ( defined($i->editlist_parts) ) { %>
@@ -105,16 +119,19 @@ function SafeOnload()
               }
             </script>
             <select multiple size=5 name="<%= $i->key. $n %>">
               }
             </script>
             <select multiple size=5 name="<%= $i->key. $n %>">
-            <option selected>--------------------------------</option>
+            <option selected>----------------------------------------------------------------</option>
             <% foreach my $line ( $conf->config($i->key) ) { %>
             <% foreach my $line ( $conf->config($i->key) ) { %>
-              <option value="$line">$line</option>
+              <option value="<%= $line %>"><%= $line %></option>
             <% } %>
             </select><br>
             <input type="button" value="remove selected" onClick="doremove<%= $i->key. $n %>()">
             <% } %>
             </select><br>
             <input type="button" value="remove selected" onClick="doremove<%= $i->key. $n %>()">
-            <script>SafeAddOnLoad(doremove<%= $i->key. $n %>)</script>
+            <script>SafeAddOnLoad(doremove<%= $i->key. $n %>);
+                    SafeAddOnSubmit(selectall<%= $i->key. $n %>);</script>
             <br>
             <br>
+            <%= itable() %><tr>
             <% if ( defined $i->editlist_parts ) { %>
               <% my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) { %>
             <% if ( defined $i->editlist_parts ) { %>
               <% my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) { %>
+                <td>
                 <% if ( $part->{type} eq 'text' ) { %>
                   <input type="text" name="add<%= $i->key. $n."_$pnum" %>">
                 <% } elsif ( $part->{type} eq 'immutable' ) { %>
                 <% if ( $part->{type} eq 'text' ) { %>
                   <input type="text" name="add<%= $i->key. $n."_$pnum" %>">
                 <% } elsif ( $part->{type} eq 'immutable' ) { %>
@@ -128,11 +145,13 @@ function SafeOnload()
                 <% } else { %>
                   <font color="#ff0000">unknown type <%= $part->type %></font>
                 <% } %>
                 <% } else { %>
                   <font color="#ff0000">unknown type <%= $part->type %></font>
                 <% } %>
+                </td>
               <% $pnum++; } %>
             <% } else { %>
               <% $pnum++; } %>
             <% } else { %>
-              <input type="text" name="add<%= $i->key. $n %>_0">
+              <td><input type="text" name="add<%= $i->key. $n %>_0"></td>
             <% } %>
             <% } %>
-            <input type="button" value="add" onClick="doadd<%= $i->key. $n %>(this.form)">
+            <td><input type="button" value="add" onClick="doadd<%= $i->key. $n %>(this.form)"></td>
+            </tr></table>
           <% } else { %>
             <font color="#ff0000">unknown type <%= $type %></font>
           <% } %>
           <% } else { %>
             <font color="#ff0000">unknown type <%= $type %></font>
           <% } %>
@@ -143,13 +162,15 @@ function SafeOnload()
       </a></td>
     </tr>
   <% } %>
       </a></td>
     </tr>
   <% } %>
-  </table><br><br>
-<% } %>
+  </table><br>
 
 
-You may need to restart Apache and/or freeside-queued for configuration
-changes to take effect.<BR>
+  You may need to restart Apache and/or freeside-queued for configuration
+  changes to take effect.<br>
+
+  <input type="submit" value="Apply changes"><br><br>
+
+<% } %>
 
 
-<input type="submit" value="Apply changes">
 </form>
 
 </body></html>
 </form>
 
 </body></html>
index 2640be4..25e766b 100644 (file)
@@ -308,8 +308,9 @@ ALTER TABLE cust_refund DROP COLUMN crednum;
   <li><b>IMPORTANT</b>: run bin/create-history-tables
   <li><b>IMPORTANT: After running bin/create-history-tables</b>, run bin/dbdef-create again.
   <li>set the <a href="../config/config.cgi#username_policy">user_policy configuration value</a> as appropriate for your site.
   <li><b>IMPORTANT</b>: run bin/create-history-tables
   <li><b>IMPORTANT: After running bin/create-history-tables</b>, run bin/dbdef-create again.
   <li>set the <a href="../config/config.cgi#username_policy">user_policy configuration value</a> as appropriate for your site.
+  <li>the mxmachines, nsmachines, arecords and cnamerecords configuration values have been deprecated.  Set the <a href="../config/config.cgi#defaultrecords">defaultrecords configuration value</a> instead.
   <li>Create the `/usr/local/etc/freeside/cache.<i>datasrc</i>' directory
   <li>Create the `/usr/local/etc/freeside/cache.<i>datasrc</i>' directory
-      (ownded by the freeside user).
+      (owned by the freeside user).
   <li>freeside-queued was installed with the Perl modules.  Start it now and ensure that is run upon system startup.
   <li>Set appropriate <a href="../browse/part_bill_event.cgi">invoice events</a> for your site.  At the very least, you'll want to set some invoice events "<i>After 0 days</i>": a <i>BILL</i> invoice event to print invoices, a <i>CARD</i> invoice event to batch or run cards real-time, and a <i>COMP</i> invoice event to "pay" complimentary customers.  If you were using the <i>-i</i> option to <a href="man/bin/freeside-bill.html">freeside-bill</a> it should be removed.
   <li>Use <a href="man/bin/freeside-daily.html">freeside-daily</a> instead of <a href="man/bin/freeside-bill.html">freeside-bill</a>.
   <li>freeside-queued was installed with the Perl modules.  Start it now and ensure that is run upon system startup.
   <li>Set appropriate <a href="../browse/part_bill_event.cgi">invoice events</a> for your site.  At the very least, you'll want to set some invoice events "<i>After 0 days</i>": a <i>BILL</i> invoice event to print invoices, a <i>CARD</i> invoice event to batch or run cards real-time, and a <i>COMP</i> invoice event to "pay" complimentary customers.  If you were using the <i>-i</i> option to <a href="man/bin/freeside-bill.html">freeside-bill</a> it should be removed.
   <li>Use <a href="man/bin/freeside-daily.html">freeside-daily</a> instead of <a href="man/bin/freeside-bill.html">freeside-bill</a>.