- documentation updates
authorivan <ivan>
Sat, 13 Apr 2002 13:36:26 +0000 (13:36 +0000)
committerivan <ivan>
Sat, 13 Apr 2002 13:36:26 +0000 (13:36 +0000)
- move Critical Path export to new-style export
- bin/sqlradius_reset gets a manpage and becomes FS/bin/freeside-sqlradius-reset

FS/FS.pm
FS/FS/Conf.pm
FS/FS/part_export.pm
FS/FS/part_export/cp.pm [new file with mode: 0644]
FS/FS/svc_acct.pm
FS/bin/freeside-overdue
FS/bin/freeside-sqlradius-reset [new file with mode: 0755]
bin/sqlradius_reset [deleted file]
httemplate/edit/part_export.cgi

index 36fabcb..287e50c 100644 (file)
--- a/FS/FS.pm
+++ b/FS/FS.pm
@@ -5,6 +5,9 @@ use vars qw($VERSION);
 
 $VERSION = '0.01';
 
+#find missing entries in this file with:
+# for a in `ls *pm | cut -d. -f1`; do grep 'L<FS::'$a'>' ../FS.pm >/dev/null || echo "missing $a" ; done
+
 1;
 __END__
 
@@ -26,6 +29,12 @@ L<FS::UID> - User class (not yet OO)
 
 L<FS::CGI> - Non OO-subroutines for the web interface.
 
+L<FS::Msgcat> - Message catalog
+
+L<FS::SearchCache> - Message catalog
+
+L<FS::raddb> - RADIUS dictionary
+
 =head2 Database record classes
 
 L<FS::Record> - Database record base class
@@ -43,6 +52,8 @@ L<FS::svc_Common> - Service base class
 
 L<FS::svc_acct> - Account (shell, RADIUS, POP3) class
 
+L<FS::radius_usergroup> - RADIUS groups
+
 L<FS::svc_domain> - Domain class
 
 L<FS::domain_record> - DNS zone entries
@@ -121,6 +132,8 @@ L<FS::queue> - Job queue
 
 L<FS::queue_arg> - Job arguments
 
+L<FS::msgcat> - Message catalogs
+
 =head1 Remote API modules
 
 L<FS::SignupClient>
@@ -131,11 +144,23 @@ L<FS::MailAdminServer>
 
 =head2 Command-line utilities
 
-L<freeside-email>
+L<freeside-adduser>
 
 L<freeside-queued>
 
-L<freeside-adduser>
+L<freeside-daily>
+
+L<freeside-expiration-alerter>
+
+L<freeside-email>
+
+L<freeside-cc-receipts-report>
+
+L<freeside-credit-report>
+
+L<freeside-receivables-report>
+
+L<freeside-tax-report>
 
 L<freeside-bill>
 
index 0c41980..b029132 100644 (file)
@@ -305,8 +305,8 @@ httemplate/docs/config.html
 
   {
     'key'         => 'cp_app',
-    'section'     => 'mail',
-    'description' => 'Integration with <a href="http://www.cp.net/">Critial Path Account Provisioning Protocol</a>, four lines: "host:port", username, password, and workgroup (for new users).',
+    'section'     => 'deprecated',
+    'description' => '<b>DEPRECATED</b>, add a <i>cp</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to integrate with <a href="http://www.cp.net/">Critial Path Account Provisioning Protocol</a>, four lines: "host:port", username, password, and workgroup (for new users).',
     'type'        => 'textarea',
   },
 
@@ -404,7 +404,7 @@ httemplate/docs/config.html
   {
     'key'         => 'icradiusmachines',
     'section'     => 'deprecated',
-    'description' => '<b>DEPRECATED</b>, add <i>sqlradius</i> exports to <a href="../browse/part_svc">Service definitions</a> instead.  This option used to enable radcheck and radreply table population - by default in the Freeside database, or in the database specified by the <a href="http://rootwood.haze.st/aspside/config/config-view.cgi#icradius_secrets">icradius_secrets</a> config option (the radcheck and radreply tables needs to be created manually).  You do not need to use MySQL for your Freeside database to export to an ICRADIUS/FreeRADIUS MySQL database with this option.  <blockquote><b>ADDITIONAL DEPRECATED FUNCTIONALITY</b> (instead use <a href="http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Database_Administration.html#Replication">MySQL replication</a> or point icradius_secrets to the external database) - your <a href="ftp://ftp.cheapnet.net/pub/icradius">ICRADIUS</a> machines or <a href="http://www.freeradius.org/">FreeRADIUS</a> (with MySQL authentication) machines, one per line.  Machines listed in this file will have the radcheck table exported to them.  Each line should contain four items, separted by whitespace: machine name, MySQL database name, MySQL username, and MySQL password.  For example: <CODE>"radius.isp.tld&nbsp;radius_db&nbsp;radius_user&nbsp;passw0rd"</CODE></blockquote>',
+    'description' => '<b>DEPRECATED</b>, add a <i>sqlradius</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to enable radcheck and radreply table population - by default in the Freeside database, or in the database specified by the <a href="http://rootwood.haze.st/aspside/config/config-view.cgi#icradius_secrets">icradius_secrets</a> config option (the radcheck and radreply tables needs to be created manually).  You do not need to use MySQL for your Freeside database to export to an ICRADIUS/FreeRADIUS MySQL database with this option.  <blockquote><b>ADDITIONAL DEPRECATED FUNCTIONALITY</b> (instead use <a href="http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Database_Administration.html#Replication">MySQL replication</a> or point icradius_secrets to the external database) - your <a href="ftp://ftp.cheapnet.net/pub/icradius">ICRADIUS</a> machines or <a href="http://www.freeradius.org/">FreeRADIUS</a> (with MySQL authentication) machines, one per line.  Machines listed in this file will have the radcheck table exported to them.  Each line should contain four items, separted by whitespace: machine name, MySQL database name, MySQL username, and MySQL password.  For example: <CODE>"radius.isp.tld&nbsp;radius_db&nbsp;radius_user&nbsp;passw0rd"</CODE></blockquote>',
     'type'        => [qw( checkbox textarea )],
   },
 
index 835f531..7ae00f0 100644 (file)
@@ -505,13 +505,22 @@ sub exporttype2svcdb {
         'password' => { label=>'Database password' },
       },
       'nodomain' => 'Y',
-      'notes' => 'Not specifying datasrc will export to the freeside database? (no...  notes on MySQL replication, DBI::Proxy, etc., from Conf.pm && export.html etc., reset with bin/sqlradius_reset',
+      'notes' => 'Real-time export of radcheck, radreply and usergroup tables to any SQL database for <a href="http://www.freeradius.org/">FreeRADIUS</a> or <a href="http://radius.innercite.com/">ICRADIUS</a>.  Use <a href="../docs/man/bin/freeside-sqlradius-reset">freeside-sqlradius-reset</a> to delete and repopulate the tables from the Freeside database.',
     },
     'cyrus' => {
       'desc' => 'Real-time export to Cyrus IMAP server',
     },
     'cp' => {
       'desc' => 'Real-time export to Critical Path Account Provisioning Protocol',
+      'options' => {
+        'host'      => { label=>'Hostname' },
+        'port'      => { label=>'Port number' },
+        'username'  => { label=>'Username' },
+        'password'  => { label=>'Password' },
+        'domain'    => { label=>'Domain' },
+        'workgroup' => { label=>'Default Workgroup' },
+      },
+      'notes' => 'Real-time export to <a href="http://www.cp.net/">Critial Path Account Provisioning Protocol</a>.  Requires installation of <a href="http://search.cpan.org/search?dist=Net-APP">Net::APP</a> from CPAN.',
     },
     'infostreet' => {
       'desc' => 'Real-time export to InfoStreet streetSmartAPI',
diff --git a/FS/FS/part_export/cp.pm b/FS/FS/part_export/cp.pm
new file mode 100644 (file)
index 0000000..58ac85e
--- /dev/null
@@ -0,0 +1,117 @@
+package FS::part_export::cp;
+
+use vars qw(@ISA);
+use FS::part_export;
+
+@ISA = qw(FS::part_export);
+
+sub rebless { shift; }
+
+sub _export_insert {
+  my( $self, $svc_acct ) = (shift, shift);
+  $self->cp_queue( $svc_acct->svcnum, 'create_mailbox',
+    Mailbox   => $svc_acct->username,
+    Password  => $svc_acct->_password,
+    Workgroup => $self->option('workgroup'),
+    Domain    => $svc_acct->domain,
+  );
+}
+
+sub _export_replace {
+  my( $self, $new, $old ) = (shift, shift, shift);
+  return "can't change domain with Critical Path"
+    if $old->domain ne $new->domain;
+  return '' unless $old->username  ne $new->username
+                || $old->_password ne $new->_password;
+  $self->cp_queue( $new->svcnum, 'replace', $new->domain,
+    $old->username, $new->username, $old->_password, $new->_password );
+}
+
+sub _export_delete {
+  my( $self, $svc_acct ) = (shift, shift);
+  $self->cp_queue( $svc_acct->svcnum, 'delete_mailbox',
+    Mailbox   => $svc_acct->username,
+    Domain    => $svc_acct->domain,
+  );
+}
+
+sub cp_queue {
+  my( $self, $svcnum, $method ) = (shift, shift, shift);
+  my $queue = new FS::queue {
+    'svcnum' => $svcnum,
+    'job'    => 'FS::part_export::cp::cp_command',
+  };
+  $queue->insert(
+    $self->option('host'),
+    $self->option('port'),
+    $self->option('username'),
+    $self->option('password'),
+    $self->option('domain'),
+    $method,
+    @_,
+  );
+}
+
+sub cp_command { #subroutine, not method
+  my($host, $port, $username, $password, $login_domain, $method, @args) = @_;
+
+  #quelle hack
+  if ( $method eq 'replace' ) {
+  
+    my( $domain, $old_username, $new_username, $old_password, $new_password)
+      = @args;
+
+    if ( $old_username ne $new_username ) {
+      cp_command($host, $port, $username, $password, 'rename_mailbox',
+        Domain        => $domain,
+        Old_Mailbox   => $old_username,
+        New_Mailbox   => $new_username,
+      );
+    }
+
+    if ( $new_password =~ /^\*SUSPENDED\* (.*)$/ ) {
+      $new_password = $1;
+      cp_command($host, $port, $username, $password, 'set_mailbox_status',
+        Domain       => $domain,
+        Mailbox      => $new_username,
+        Other        => 'T',
+        Other_Bounce => 'T',
+      );
+    } else {
+      cp_command($host, $port, $username, $password, 'set_mailbox_status',
+        Domain       => $domain,
+        Mailbox      => $new_username,
+        Other        => 'F',
+        Other_Bounce => 'F',
+      );
+    }
+
+    if ( $old_password ne $new_password ) {
+      cp_command($host, $port, $username, $password, 'change_mailbox',
+        Domain    => $domain,
+        Mailbox   => $new_username,
+        Password  => $new_password,
+      );
+    }
+
+    return;
+  }
+  #eof quelle hack
+
+  eval "use Net::APP;";
+
+  my $app = new Net::APP (
+    "$host:$port",
+    User     => $username,
+    Password => $password,
+    Domain   => $login_domain,
+    Timeout  => 60,
+    #Debug    => 1,
+  ) or die "$@\n";
+
+  $app->$method( @args );
+
+  die $app->message."\n" unless $app->ok;
+
+}
+
index 38e24c1..1e1cbb0 100644 (file)
@@ -8,7 +8,6 @@ use vars qw( @ISA $nossh_hack $noexport_hack $conf
              $username_noperiod $username_uppercase
              $shellmachine $useradd $usermod $userdel $mydomain
              $cyrus_server $cyrus_admin_user $cyrus_admin_pass
-             $cp_server $cp_user $cp_pass $cp_workgroup
              $dirhash
              @saltset @pw_set
              $rsync $ssh $exportdir $vpopdir);
@@ -80,16 +79,6 @@ $FS::UID::callback{'FS::svc_acct'} = sub {
     $cyrus_admin_user = '';
     $cyrus_admin_pass = '';
   }
-  if ( $conf->exists('cp_app') ) {
-    ($cp_server, $cp_user, $cp_pass, $cp_workgroup) =
-      $conf->config('cp_app');
-    eval "use Net::APP;"
-  } else {
-    $cp_server = '';
-    $cp_user = '';
-    $cp_pass = '';
-    $cp_workgroup = '';
-  }
 
   $dirhash = $conf->config('dirhash') || 0;
   $exportdir = "/usr/local/etc/freeside/export." . datasrc;
@@ -351,18 +340,6 @@ sub insert {
     }
   }
 
-  if ( $cp_server ) {
-    my $queue = new FS::queue {
-      'svcnum' => $self->svcnum,
-      'job'    => 'FS::svc_acct::cp_insert'
-    };
-    $error = $queue->insert($self->username, $self->_password);
-    if ( $error ) {
-      $dbh->rollback if $oldAutoCommit;
-      return "queueing job (transaction rolled back): $error";
-    }
-  }
-  
   if ( $vpopdir ) {
 
     my $vpopmail_queue =
@@ -423,27 +400,6 @@ sub cyrus_insert {
   1;
 }
 
-sub cp_insert {
-  my( $username, $password ) = @_;
-
-  my $app = new Net::APP ( $cp_server,
-                        User     => $cp_user,
-                        Password => $cp_pass,
-                        Domain   => $mydomain,
-                        Timeout  => 60,
-                        #Debug    => 1,
-                      ) or die "$@\n";
-
-  $app->create_mailbox(
-                        Mailbox   => $username,
-                        Password  => $password,
-                        Workgroup => $cp_workgroup,
-                        Domain    => $mydomain,
-                      );
-
-  die $app->message."\n" unless $app->ok;
-}
-
 sub vpopmail_insert {
   my( $username, $password, $domain, $vpopdir ) = @_;
   
@@ -633,15 +589,6 @@ sub delete {
     }
   }
   
-  if ( $cp_server ) {
-    my $queue = new FS::queue { 'job' => 'FS::svc_acct::cp_delete' };
-    $error = $queue->insert($self->username);
-    if ( $error ) {
-      $dbh->rollback if $oldAutoCommit;
-      return "queueing job (transaction rolled back): $error";
-    }
-  }
-
   if ( $vpopdir ) {
     my $queue = new FS::queue { 'job' => 'FS::svc_acct::vpopmail_delete' };
     $error = $queue->insert( $self->username, $self->domain );
@@ -679,24 +626,6 @@ sub cyrus_delete {
   1;
 }
 
-sub cp_delete {
-  my( $username ) = @_;
-  my $app = new Net::APP ( $cp_server,
-                        User     => $cp_user,
-                        Password => $cp_pass,
-                        Domain   => $mydomain,
-                        Timeout  => 60,
-                        #Debug    => 1,
-                      ) or die "$@\n";
-
-  $app->delete_mailbox(
-                        Mailbox   => $username,
-                        Domain    => $mydomain,
-                      );
-
-  die $app->message."\n" unless $app->ok;
-}
-
 sub vpopmail_delete {
   my( $username, $domain ) = @_;
   
@@ -871,18 +800,6 @@ sub replace {
     }
   }
 
-  if ( $cp_server && $old->_password ne $new->_password ) {
-    my $queue = new FS::queue {  
-      'svcnum' => $new->svcnum,
-      'job' => 'FS::svc_acct::cp_change'
-    };
-    $error = $queue->insert( $new->username, $new->_password );
-    if ( $error ) {
-      $dbh->rollback if $oldAutoCommit;
-      return "queueing job (transaction rolled back): $error";
-    }
-  }
-
   if ( $vpopdir ) {
     my $cpassword = crypt(
       $new->_password,$saltset[int(rand(64))].$saltset[int(rand(64))]
@@ -914,65 +831,6 @@ sub replace {
   ''; #no error
 }
 
-sub cp_rename {
-  my ( $old_username, $new_username ) = @_;
-
-  my $app = new Net::APP ( $cp_server,
-                        User     => $cp_user,
-                        Password => $cp_pass,
-                        Domain   => $mydomain,
-                        Timeout  => 60,
-                        #Debug    => 1,
-                      ) or die "$@\n";
-
-  $app->rename_mailbox(
-                        Domain        => $mydomain,
-                        Old_Mailbox   => $old_username,
-                        New_Mailbox   => $new_username,
-                      );
-
-  die $app->message."\n" unless $app->ok;
-
-}
-
-sub cp_change {
-  my ( $username, $password ) = @_;
-
-  my $app = new Net::APP ( $cp_server,
-                        User     => $cp_user,
-                        Password => $cp_pass,
-                        Domain   => $mydomain,
-                        Timeout  => 60,
-                        #Debug    => 1,
-                      ) or die "$@\n";
-
-  if ( $password =~ /^\*SUSPENDED\* (.*)$/ ) {
-    $password = $1;
-    $app->set_mailbox_status(
-                              Domain       => $mydomain,
-                              Mailbox      => $username,
-                              Other        => 'T',
-                              Other_Bounce => 'T',
-                            );
-  } else {
-    $app->set_mailbox_status(
-                              Domain       => $mydomain,
-                              Mailbox      => $username,
-                              Other        => 'F',
-                              Other_Bounce => 'F',
-                            );
-  }
-  die $app->message."\n" unless $app->ok;
-
-  $app->change_mailbox(
-                        Domain    => $mydomain,
-                        Mailbox   => $username,
-                        Password  => $password,
-                      );
-  die $app->message."\n" unless $app->ok;
-
-}
-
 sub vpopmail_replace_password {
   my( $username, $password, $domain ) = @_;
   
index db99e62..116245f 100755 (executable)
@@ -129,6 +129,9 @@ freeside-overdue - Perform actions on overdue and/or expired accounts.
 
 =head1 DESCRIPTION
 
+This script is deprecated in 1.4.0.  You should use freeside-daily and invoice
+events instead.
+
 Performs actions on overdue and/or expired accounts.
 
 Selection options (at least one selection option is required):
diff --git a/FS/bin/freeside-sqlradius-reset b/FS/bin/freeside-sqlradius-reset
new file mode 100755 (executable)
index 0000000..132be75
--- /dev/null
@@ -0,0 +1,73 @@
+#!/usr/bin/perl -Tw
+
+use strict;
+use FS::UID qw(adminsuidsetup);
+use FS::Record qw(qsearch qsearchs);
+use FS::part_export;
+use FS::svc_acct;
+use FS::cust_svc;
+
+my $user = shift or die &usage;
+adminsuidsetup $user;
+
+#my $machine = shift or die &usage;
+
+my @exports = qsearch('part_export', { 'exporttype' => 'sqlradius' } );
+
+foreach my $export ( @exports ) {
+  my $icradius_dbh = DBI->connect(
+    map { $export->option($_) } qw( datasrc username password )
+  ) or die $DBI::errstr;
+  for my $table (qw( radcheck radreply usergroup )) {
+    my $sth = $icradius_dbh->prepare("DELETE FROM $table");
+    $sth->execute or die "Can't reset $table table: ". $sth->errstr;
+  }
+}
+
+foreach my $export ( @exports ) {
+
+  #my @svcparts = map { $_->svcpart } $export->export_svc;
+
+  my @svc_acct =
+    map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) }
+      map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
+        grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
+          $export->export_svc;
+
+  foreach my $svc_acct ( @svc_acct ) {
+
+    #false laziness with FS::svc_acct::insert (like it matters)
+    my $error = $export->export_insert($svc_acct);
+    die $error if $error;
+
+  }
+}
+
+sub usage {
+  #die "Usage:\n\n  sqlradius_reset user machine\n";
+  die "Usage:\n\n  sqlradius_reset user\n";
+}
+
+=head1 NAME
+
+freeside-sqlradius-reset - Command line interface to reset and recreate RADIUS SQL tables
+
+=head1 SYNOPSIS
+
+  freeside-sqlradius-reset username
+
+=head1 DESCRIPTION
+
+Deletes the radcheck, radreply and usergroup tables and repopulates them from
+the Freeside database, for all sqlradius exports.
+
+B<username> is a username added by freeside-adduser.
+
+=head1 SEE ALSO
+
+<FS::part_export>, L<FS::part_export::sqlradius>
+
+=cut
+
+
+
diff --git a/bin/sqlradius_reset b/bin/sqlradius_reset
deleted file mode 100644 (file)
index 454043f..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::part_export;
-use FS::svc_acct;
-use FS::cust_svc;
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-#my $machine = shift or die &usage;
-
-my @exports = qsearch('part_export', { 'exporttype' => 'sqlradius' } );
-
-foreach my $export ( @exports ) {
-  my $icradius_dbh = DBI->connect(
-    map { $export->option($_) } qw( datasrc username password )
-  ) or die $DBI::errstr;
-  for my $table (qw( radcheck radreply usergroup )) {
-    my $sth = $icradius_dbh->prepare("DELETE FROM $table");
-    $sth->execute or die "Can't reset $table table: ". $sth->errstr;
-  }
-}
-
-foreach my $export ( @exports ) {
-
-  #my @svcparts = map { $_->svcpart } $export->export_svc;
-
-  my @svc_acct =
-    map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) }
-      map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
-        grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
-          $export->export_svc;
-
-  foreach my $svc_acct ( @svc_acct ) {
-
-    #false laziness with FS::svc_acct::insert (like it matters)
-    my $error = $export->export_insert($svc_acct);
-    die $error if $error;
-
-  }
-}
-
-sub usage {
-  #die "Usage:\n\n  sqlradius_reset user machine\n";
-  die "Usage:\n\n  sqlradius_reset user\n";
-}
-
-
index 77b80d0..b72b277 100644 (file)
@@ -39,12 +39,17 @@ my $widget = new HTML::Widgets::SelectLayers(
     my $layer = shift;
     my $html = qq!<INPUT TYPE="hidden" NAME="exporttype" VALUE="$layer">!.
                ntable("#cccccc",2);
+
+    $html .= '<TR><TD ALIGN="right">Description</TD><TD BGCOLOR=#ffffff>'.
+             $exports->{$layer}{notes}. '</TD></TR>'
+      if $layer;
+
     foreach my $option ( keys %{$exports->{$layer}{options}} ) {
 #    foreach my $option ( qw(url login password groupID ) ) {
       my $optinfo = $exports->{$layer}{options}{$option};
       my $label = $optinfo->{label};
       my $value = $cgi->param($option) || $part_export->option($option);
-      $html .= qq!<TR><TD ALIGN="right">$label</TD><TD>!.
+      $html .= qq!<TR><TD ALIGN="right">$label</TD>!.
                qq!<TD><INPUT TYPE="text" NAME="$option" VALUE="$value"></TD>!.
                '</TR>';
     }