From 94494835be39e34474d8564a8cde9fdd389fcdbe Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 1 Apr 2003 08:03:22 +0000 Subject: - update qsearch for Pg 7.3 - preliminary 1.5.0 upgrade docs - syntax error in main customer view --- FS/FS/Record.pm | 12 ++++++++++-- httemplate/docs/index.html | 1 + httemplate/docs/upgrade10.html | 6 ++++++ httemplate/view/cust_main.cgi | 7 +++++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 40215100f..c711f1214 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -223,13 +223,21 @@ sub qsearch { if ( ! defined( $record->{$_} ) || $record->{$_} eq '' ) { if ( $op eq '=' ) { if ( driver_name eq 'Pg' ) { - qq-( $column IS NULL OR $column = '' )-; + if ( $dbdef->table($table)->column($column)->type =~ /(int)/i ) { + qq-( $column IS NULL )-; + } else { + qq-( $column IS NULL OR $column = '' )-; + } } else { qq-( $column IS NULL OR $column = "" )-; } } elsif ( $op eq '!=' ) { if ( driver_name eq 'Pg' ) { - qq-( $column IS NOT NULL AND $column != '' )-; + if ( $dbdef->table($table)->column($column)->type =~ /(int)/i ) { + qq-( $column IS NOT NULL )-; + } else { + qq-( $column IS NOT NULL AND $column != '' )-; + } } else { qq-( $column IS NOT NULL AND $column != "" )-; } diff --git a/httemplate/docs/index.html b/httemplate/docs/index.html index 8f6f91378..b57b06feb 100644 --- a/httemplate/docs/index.html +++ b/httemplate/docs/index.html @@ -9,6 +9,7 @@
  • Upgrading from 1.3.0 to 1.3.1
  • Upgrading from 1.3.1 to 1.4.0
  • Upgrading from 1.4.0 to 1.4.1 +
  • Upgrading from 1.4.1 (or 1.4.2?) to 1.5.0 diff --git a/httemplate/docs/upgrade10.html b/httemplate/docs/upgrade10.html index 7aa26f698..6c4fe0c37 100644 --- a/httemplate/docs/upgrade10.html +++ b/httemplate/docs/upgrade10.html @@ -1,5 +1,8 @@ +
     this is very incomplete
     
    +install NetAddr::IP and Chart
    +
     CREATE TABLE cust_bill_pkg_detail (
       detailnum serial,
       pkgnum int NOT NULL,
    @@ -9,3 +12,6 @@ CREATE TABLE cust_bill_pkg_detail (
     );
     CREATE INDEX cust_bill_pkg_detail1 ON cust_bill_pkg_detail ( pkgnum, invnum );
     
    +create all of the new broadband tables
    +
    +
    diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 1d6243e23..01ad57373 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -365,8 +365,11 @@ if ( $conf->exists('hidecancelledpackages') ) { if ( @packages ) { #formatting + + my $colspan = $packages[0]->dbdef_table->column('last_bill') ? 6 : 5; + print &table(), "\n", - qq!Package!, + qq!Package!, qq!DatesServices\n!, qq!Setup!; @@ -375,7 +378,7 @@ if ( @packages ) { print qq!Next bill!, qq!Susp.!, - qq!Expire!!, + qq!Expire!, qq!Cancel!, qq!\n!; } -- cgit v1.2.1 From 2a5963390ddd68ecb2e40568ca272c0a2f8b831a Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 2 Apr 2003 03:25:15 +0000 Subject: fix disappearing email invoice on errors, finally (closes: Bug#35) --- httemplate/edit/cust_main.cgi | 6 +++++- httemplate/edit/process/cust_main.cgi | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 6fc086a12..706526865 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -17,6 +17,7 @@ my $conf = new FS::Conf; my $error = ''; my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart); +my(@invoicing_list); if ( $cgi->param('error') ) { $error = $cgi->param('error'); $cust_main = new FS::cust_main ( { @@ -32,6 +33,7 @@ if ( $cgi->param('error') ) { $username = $cgi->param('username'); $password = $cgi->param('_password'); $popnum = $cgi->param('popnum'); + @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') ); } elsif ( $cgi->keywords ) { #editing my( $query ) = $cgi->keywords; $query =~ /^(\d+)$/; @@ -41,6 +43,7 @@ if ( $cgi->param('error') ) { $username = ''; $password = ''; $popnum = 0; + @invoicing_list = $cust_main->invoicing_list; } else { $custnum=''; $cust_main = new FS::cust_main ( {} ); @@ -50,6 +53,7 @@ if ( $cgi->param('error') ) { $username = ''; $password = ''; $popnum = 0; + @invoicing_list = (); } $cgi->delete_all(); my $action = $custnum ? 'Edit' : 'Add'; @@ -383,7 +387,7 @@ if ( $payby_default eq 'HIDE' ) { print qq!>Tax Exempt!. qq!invoicing_list; + #my @invoicing_list = $cust_main->invoicing_list; print qq! CHECKED! if ( ! @invoicing_list && ! $conf->exists('disablepostalinvoicedefault') ) || grep { $_ eq 'POST' } @invoicing_list; diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index c15ea0321..5e6000c05 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -25,6 +25,7 @@ $cgi->param('otaker', &getotaker ); my @invoicing_list = split( /\s*\,\s*/, $cgi->param('invoicing_list') ); push @invoicing_list, 'POST' if $cgi->param('invoicing_list_POST'); +$cgi->param('invoicing_list', join(',', @invoicing_list) ); #create new record object -- cgit v1.2.1 From 856a62ca215f921ef3e9ddf4080626565727532a Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 2 Apr 2003 09:46:50 +0000 Subject: updated meta-import web UI to allow duplicate import tables --- httemplate/misc/process/meta-import.cgi | 37 +++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/httemplate/misc/process/meta-import.cgi b/httemplate/misc/process/meta-import.cgi index 9e374b508..2939c8fb2 100644 --- a/httemplate/misc/process/meta-import.cgi +++ b/httemplate/misc/process/meta-import.cgi @@ -31,7 +31,9 @@ function SafeOnsubmit() { VALUE="<%= $cgi->param($field) %>"> <% } - my %schema = (); + my %schema; + use Tie::DxHash; + tie %schema, 'Tie::DxHash'; if ( $cgi->param('schema') ) { my $schema_string = $cgi->param('schema'); %> <% @@ -57,14 +59,16 @@ function SafeOnsubmit() { <% + my %unique; foreach my $table ( keys %schema ) { my @from_columns = $schema->table($table)->columns; my @fs_columns = dbdef->table($schema{$table})->columns; %> - <%= hashmaker($table, \@from_columns => \@fs_columns, - $table => $schema{$table}, ) %> + <%= hashmaker( $table.'__'.$unique{$table}++, + \@from_columns => \@fs_columns, + $table => $schema{$table}, ) %>


    <% @@ -79,6 +83,7 @@ function SafeOnsubmit() { print "
    \n";
     
    +    my %unique;
         foreach my $table ( keys %schema ) {
           ( my $spaces = $table ) =~ s/./ /g;
           print "'$table' => { 'table' => '$schema{$table}',\n".
    @@ -88,7 +93,7 @@ function SafeOnsubmit() {
                              or die "guru meditation #420: $_";
                            ( $1 => $2 );
                          }
    -                 split( /\n/, $cgi->param($table) );
    +                 split( /\n/, $cgi->param($table.'__'.$unique{$table}++) );
           foreach ( keys %map ) {
             print "$spaces                     '$_' => '$map{$_}',\n";
           }
    @@ -116,11 +121,13 @@ function SafeOnsubmit() {
         "'.
           '';
     }
     
    -my $svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum});
    +my $svc_acct_pop = $svc_acct->popnum
    +                     ? qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum})
    +                     : '';
     print "".
           "'
       if $svc_acct_pop;
    -- 
    cgit v1.2.1
    
    
    From fdccb39f148b8fb2a8a7818e9a7999c20b2e05bd Mon Sep 17 00:00:00 2001
    From: ivan 
    Date: Sat, 19 Apr 2003 17:51:27 +0000
    Subject: /^\s*$/ setup/recur expressions now failsafe to 0 (closes: Bug#498)
     deprecate old 1.3-style qmail integration
    
    ---
     FS/FS/Conf.pm     | 4 ++--
     FS/FS/part_pkg.pm | 2 ++
     2 files changed, 4 insertions(+), 2 deletions(-)
    
    diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
    index f0a4c9f45..b00e78255 100644
    --- a/FS/FS/Conf.pm
    +++ b/FS/FS/Conf.pm
    @@ -527,8 +527,8 @@ httemplate/docs/config.html
     
       {
         'key'         => 'qmailmachines',
    -    'section'     => 'mail',
    -    'description' => 'Your qmail machines, one per line.  This enables export of `/var/qmail/control/virtualdomains\', `/var/qmail/control/recipientmap\', and `/var/qmail/control/rcpthosts\'.  Setting this option (even if empty) also turns on user `.qmail-extension\' file maintenance in conjunction with the shellmachine option.',
    +    'section'     => 'deprecated',
    +    'description' => 'DEPRECATED, add qmail and shellcommands exports instead.  This option used to export `/var/qmail/control/virtualdomains\', `/var/qmail/control/recipientmap\', and `/var/qmail/control/rcpthosts\'.  Setting this option (even if empty) also turns on user `.qmail-extension\' file maintenance in conjunction with the shellmachine option.',
         'type'        => [qw( checkbox textarea )],
       },
     
    diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
    index 99d88d56a..60b0e01f9 100644
    --- a/FS/FS/part_pkg.pm
    +++ b/FS/FS/part_pkg.pm
    @@ -180,6 +180,8 @@ insert and replace methods.
     sub check {
       my $self = shift;
     
    +  for (qw(setup recur)) { $self->set($_=>0) if $self->get($_) =~ /^\s*$/; }
    +
       my $conf = new FS::Conf;
       if ( $conf->exists('safe-part_pkg') ) {
     
    -- 
    cgit v1.2.1
    
    
    From 4eaa305a53b129021c3a40e9ed49196f4b4d8907 Mon Sep 17 00:00:00 2001
    From: khoff 
    Date: Mon, 21 Apr 2003 20:27:10 +0000
    Subject: excludeaddr option for svc_broadband
    
    ---
     FS/FS/Conf.pm       |  7 +++++++
     FS/FS/addr_block.pm | 10 ++++++++--
     2 files changed, 15 insertions(+), 2 deletions(-)
    
    diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
    index b00e78255..cb404ff03 100644
    --- a/FS/FS/Conf.pm
    +++ b/FS/FS/Conf.pm
    @@ -373,6 +373,13 @@ httemplate/docs/config.html
         'type'       => 'checkbox',
       },
     
    +  {
    +    'key'         => 'excludeaddr',
    +    'section'     => 'deprecated',
    +    'description' => 'Addresses to exclude from assignment, one per line.',
    +    'type'        => 'textarea',
    +  },
    +  
       {
         'key'         => 'erpcdmachines',
         'section'     => '',
    diff --git a/FS/FS/addr_block.pm b/FS/FS/addr_block.pm
    index b671723aa..c9305f6af 100755
    --- a/FS/FS/addr_block.pm
    +++ b/FS/FS/addr_block.pm
    @@ -5,6 +5,7 @@ use vars qw( @ISA );
     use FS::Record qw( qsearchs qsearch dbh );
     use FS::router;
     use FS::svc_broadband;
    +use FS::Conf;
     use NetAddr::IP;
     
     @ISA = qw( FS::Record );
    @@ -172,9 +173,14 @@ there are no free addresses, returns false.
     sub next_free_addr {
       my $self = shift;
     
    -  my @used = map { $_->NetAddr->addr } 
    +  my $conf = new FS::Conf;
    +  my @excludeaddr = $conf->config('excludeaddr');
    +  
    +  my @used = (
    +    map { $_->NetAddr->addr } 
           ($self, 
    -       qsearch('svc_broadband', { blocknum => $self->blocknum }) );
    +       qsearch('svc_broadband', { blocknum => $self->blocknum }) ),
    +     @excludeaddr );
     
       my @free = $self->NetAddr->hostenum;
       while (my $ip = shift @free) {
    -- 
    cgit v1.2.1
    
    
    From 6eedae5614eee808d0e0c4b9d9b3fe7d1217b776 Mon Sep 17 00:00:00 2001
    From: khoff 
    Date: Mon, 21 Apr 2003 20:31:20 +0000
    Subject: Bug fixes for sqlmail.  Added support for courier and dovecot
     authentication.
    
    ---
     FS/FS/part_export.pm         |  26 ++++++--
     FS/FS/part_export/sqlmail.pm | 152 +++++++++++++++++++++++++++++++------------
     2 files changed, 132 insertions(+), 46 deletions(-)
    
    diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm
    index 789e8450d..4471d6e00 100644
    --- a/FS/FS/part_export.pm
    +++ b/FS/FS/part_export.pm
    @@ -764,9 +764,27 @@ tie my %http_options, 'Tie::IxHash',
     ;
     
     tie my %sqlmail_options, 'Tie::IxHash',
    -  'datasrc'  => { label=>'DBI data source' },
    -  'username' => { label=>'Database username' },
    -  'password' => { label=>'Database password' },
    +  'datasrc'            => { label => 'DBI data source' },
    +  'username'           => { label => 'Database username' },
    +  'password'           => { label => 'Database password' },
    +  'server_type'        => {
    +    label   => 'Server type',
    +    type    => 'select',
    +    options => [qw(dovecot_plain dovecot_crypt dovecot_digest_md5 courier_plain
    +                   courier_crypt)],
    +    default => ['dovecot_plain'], },
    +  'svc_acct_table'     => { label => 'User Table', default => 'user_acct' },
    +  'svc_forward_table'  => { label => 'Forward Table', default => 'forward' },
    +  'svc_domain_table'   => { label => 'Domain Table', default => 'domain' },
    +  'svc_acct_fields'    => { label => 'svc_acct Export Fields',
    +                            default => 'username _password domsvc svcnum' },
    +  'svc_forward_fields' => { label => 'svc_forward Export Fields',
    +                            default => 'domain svcnum catchall' },
    +  'svc_domain_fields'  => { label => 'svc_domain Export Fields',
    +                            default => 'srcsvc dstsvc dst' },
    +  'resolve_dstsvc'     => { label => q{Resolve svc_forward.dstsvc to an email address and store it in dst. (Doesn't require that you also export dstsvc.)},
    +                            type => 'checkbox' },
    +
     ;
     
     tie my %ldap_options, 'Tie::IxHash',
    @@ -855,7 +873,7 @@ tie my %ldap_options, 'Tie::IxHash',
         'sqlmail' => {
           'desc' => 'Real-time export to SQL-backed mail server',
           'options' => \%sqlmail_options,
    -      'nodomain' => 'Y',
    +      'nodomain' => 'N',
           'notes' => 'Database schema can be made to work with Courier IMAP and Exim.  Others could work but are untested. (...extended description from pc-intouch?...)',
         },
     
    diff --git a/FS/FS/part_export/sqlmail.pm b/FS/FS/part_export/sqlmail.pm
    index 4194daf0c..0c0cb367b 100644
    --- a/FS/FS/part_export/sqlmail.pm
    +++ b/FS/FS/part_export/sqlmail.pm
    @@ -1,54 +1,74 @@
     package FS::part_export::sqlmail;
     
    -use vars qw(@ISA %fs_mail_table %fields);
    +use vars qw(@ISA);
    +use FS::Record qw(qsearchs);
     use FS::part_export;
    +use Digest::MD5 qw(md5_hex);
     
     @ISA = qw(FS::part_export);
     
    -%fs_mail_table = ( svc_acct => 'user',
    -                   svc_domain => 'domain' );
    -
    -# fields that need to be copied into the fs_mail tables
    -$fields{user} = [qw(username _password finger domsvc svcnum )];
    -$fields{domain} = [qw(domain svcnum catchall )];
    -
     sub rebless { shift; }
     
     sub _export_insert {
       my($self, $svc) = (shift, shift);
       # this is a svc_something.
     
    -  my $table = $fs_mail_table{$svc->cust_svc->part_svc->svcdb};
    -  my @attrib = map {$svc->$_} @{$fields{$table}};
    +  my $svcdb = $svc->cust_svc->part_svc->svcdb;
    +  my $export_table = $self->option($svcdb . '_table')
    +    or die('Export table not defined for svcdb: ' . $svcdb);
    +  my @export_fields = split(/\s+/, $self->option($svcdb . '_fields'));
    +  my $svchash = update_values($self, $svc, $svcdb);
    +
    +  foreach my $key (keys(%$svchash)) {
    +    unless (grep { $key eq $_ } @export_fields) {
    +      delete $svchash->{$key};
    +    }
    +  }
    +
       my $error = $self->sqlmail_queue( $svc->svcnum, 'insert',
    -      $table, @attrib );
    +    $self->option('server_type'), $export_table,
    +    (map { ($_, $svchash->{$_}); } keys(%$svchash)));
       return $error if $error;
       '';
    +
     }
     
     sub _export_replace {
       my( $self, $new, $old ) = (shift, shift, shift);
     
    -  my $table = $fs_mail_table{$new->cust_svc->part_svc->svcdb};
    -
    -  my @old = ($old->svcnum, 'delete', $table, $old->svcnum);
    -  my @narf = map {$new->$_} @{$fields{$table}};
    -  $self->sqlmail_queue($new->svcnum, 'replace', $table, 
    -      $new->svcnum, @narf);
    -
    +  my $svcdb = $new->cust_svc->part_svc->svcdb;
    +  my $export_table = $self->option($svcdb . '_table')
    +    or die('Export table not defined for svcdb: ' . $svcdb);
    +  my @export_fields = split(/\s+/, $self->option($svcdb . '_fields'));
    +  my $svchash = update_values($self, $new, $svcdb);
    +
    +  foreach my $key (keys(%$svchash)) {
    +    unless (grep { $key eq $_ } @export_fields) {
    +      delete $svchash->{$key};
    +    }
    +  }
    +
    +  my $error = $self->sqlmail_queue( $new->svcnum, 'replace',
    +    $old->svcnum, $self->option('server_type'), $export_table,
    +    (map { ($_, $svchash->{$_}); } keys(%$svchash)));
       return $error if $error;
       '';
    +
     }
     
     sub _export_delete {
       my( $self, $svc ) = (shift, shift);
    -  my $table = $fs_mail_table{$new->cust_svc->part_svc->svcdb};
    +
    +  my $svcdb = $svc->cust_svc->part_svc->svcdb;
    +  my $table = $self->option($svcdb . '_table')
    +    or die('Export table not defined for svcdb: ' . $svcdb);
    +
       $self->sqlmail_queue( $svc->svcnum, 'delete', $table,
         $svc->svcnum );
     }
     
     sub sqlmail_queue {
    -  my( $self, $svcnum, $method, $table ) = (shift, shift, shift);
    +  my( $self, $svcnum, $method ) = (shift, shift, shift);
       my $queue = new FS::queue {
         'svcnum' => $svcnum,
         'job'    => "FS::part_export::sqlmail::sqlmail_$method",
    @@ -63,49 +83,97 @@ sub sqlmail_queue {
     
     sub sqlmail_insert { #subroutine, not method
       my $dbh = sqlmail_connect(shift, shift, shift);
    -  my( $table, @attrib ) = @_;
    +  my( $server_type, $table ) = (shift, shift);
     
    -  my $sth = $dbh->prepare(
    -    "INSERT INTO $table (" . join (',', @{$fields{$table}}) .
    -    ") VALUES ('" . join ("','", @attrib) . "')"
    -  ) or die $dbh->errstr;
    -  $sth->execute() or die $sth->errstr;
    +  my %attrs = @_;
     
    +  map { $attrs{$_} = $attrs{$_} ? qq!'$attrs{$_}'! : 'NULL'; } keys(%attrs);
    +  my $query = sprintf("INSERT INTO %s (%s) values (%s)",
    +                      $table, join(",", keys(%attrs)),
    +                      join(',', values(%attrs)));
    +
    +  $dbh->do($query) or die $dbh->errstr;
       $dbh->disconnect;
    +
    +  '';
     }
     
     sub sqlmail_delete { #subroutine, not method
       my $dbh = sqlmail_connect(shift, shift, shift);
       my( $table, $svcnum ) = @_;
     
    -  my $sth = $dbh->prepare(
    -    "DELETE FROM $table WHERE svcnum = $svcnum"
    -  ) or die $dbh->errstr;
    -  $sth->execute() or die $sth->errstr;
    -
    +  $dbh->do("DELETE FROM $table WHERE svcnum = $svcnum") or die $dbh->errstr;
       $dbh->disconnect;
    +
    +  '';
     }
     
     sub sqlmail_replace {
       my $dbh = sqlmail_connect(shift, shift, shift);
    -  my( $table, $svcnum, @attrib ) = @_;
    +  my($oldsvcnum, $server_type, $table) = (shift, shift, shift);
    +
    +  my %attrs = @_;
    +  map { $attrs{$_} = $attrs{$_} ? qq!'$attrs{$_}'! : 'NULL'; } keys(%attrs);
     
    -  my %data;
    -  @data{@{$fields{$table}}} = @attrib;
    +  my $query = sprintf('UPDATE %s SET %s WHERE svcnum = %s',
    +                      $table, join(', ', map {"$_ = $attrs{$_}"} keys(%attrs)),
    +                      $oldsvcnum);
     
    -  my $sth = $dbh->prepare(
    -    "UPDATE $table SET " .
    -    ( join ',',  map {$_ . "='" . $data{$_} . "'"} keys(%data) ) .
    -    " WHERE svcnum = $svcnum"
    -    ) or die $dbh->errstr;
    -  $sth->execute() or die $sth->errstr;
    +  my $rv = $dbh->do($query) or die $dbh->errstr;
    +
    +  if ($rv == 0) {
    +    $query = sprintf("INSERT INTO %s (%s) values (%s)",
    +                     $table, join(",", keys(%attrs)),
    +                     join(',', values(%attrs)));
    +    $dbh->do($query) or die $dbh->errstr;
    +  }
     
       $dbh->disconnect;
    +
    +  '';
     }
     
     sub sqlmail_connect {
    -  #my($datasrc, $username, $password) = @_;
    -  #DBI->connect($datasrc, $username, $password) or die $DBI::errstr;
       DBI->connect(@_) or die $DBI::errstr;
     }
     
    +sub update_values {
    +
    +  # Update records to conform to a particular server_type.
    +
    +  my ($self, $svc, $svcdb) = (shift,shift,shift);
    +  my $svchash = $svc->hashref or return '';
    +
    +  if ($svcdb eq 'svc_acct') {
    +    if ($self->option('server_type') eq 'courier_crypt') {
    +      my $salt = join '', ('.', '/', 0..9,'A'..'Z', 'a'..'z')[rand 64, rand 64];
    +      $svchash->{_password} = crypt($svchash->{_password}, $salt);
    +
    +    } elsif ($self->option('server_type') eq 'dovecot_plain') {
    +      $svchash->{_password} = '{PLAIN}' . $svchash->{_password};
    +      
    +    } elsif ($self->option('server_type') eq 'dovecot_crypt') {
    +      my $salt = join '', ('.', '/', 0..9,'A'..'Z', 'a'..'z')[rand 64, rand 64];
    +      $svchash->{_password} = '{CRYPT}' . crypt($svchash->{_password}, $salt);
    +
    +    } elsif ($self->option('server_type') eq 'dovecot_digest_md5') {
    +      my $svc_domain = qsearchs('svc_domain', { svcnum => $svc->domsvc });
    +      die('Unable to lookup svc_domain with domsvc: ' . $svc->domsvc)
    +        unless ($svc_domain);
    +
    +      my $domain = $svc_domain->domain;
    +      my $md5hash = '{DIGEST-MD5}' . md5_hex(join(':', $svchash->{username},
    +                                             $domain, $svchash->{_password}));
    +      $svchash->{_password} = $md5hash;
    +    }
    +  } elsif ($svcdb eq 'svc_forward') {
    +    if ($self->option('resolve_dstsvc') && $svc->dstsvc_acct) {
    +      $svchash->{dst} = $svc->dstsvc_acct->username . '@' .
    +                        $svc->dstsvc_acct->svc_domain->domain;
    +    }
    +  }
    +
    +  return($svchash);
    +
    +}
    +
    -- 
    cgit v1.2.1
    
    
    From 030bef17868168b05a67d9f5866b55da1bb9439c Mon Sep 17 00:00:00 2001
    From: ivan 
    Date: Mon, 21 Apr 2003 20:53:57 +0000
    Subject: on-demand vs. automatic cards & checks: added DCRD and DCHK payment
     types
    
    ---
     FS/FS/Conf.pm                             |  4 ++--
     FS/FS/cust_main.pm                        | 17 ++++++++++-------
     FS/FS/part_bill_event.pm                  |  4 ++--
     FS/bin/freeside-daily                     |  2 +-
     FS/bin/freeside-expiration-alerter        |  6 +++---
     FS/bin/freeside-setup                     |  2 ++
     fs_signup/FS-SignupClient/cgi/signup.cgi  |  9 +++++----
     fs_signup/FS-SignupClient/cgi/signup.html |  4 ++++
     httemplate/docs/schema.html               |  4 ++--
     httemplate/edit/cust_main.cgi             | 16 ++++++++++------
     httemplate/edit/part_bill_event.cgi       |  2 +-
     httemplate/edit/process/cust_main.cgi     |  4 ++--
     httemplate/search/cust_main.cgi           |  4 +++-
     httemplate/view/cust_main.cgi             | 12 ++++++++----
     14 files changed, 55 insertions(+), 35 deletions(-)
    
    diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
    index cb404ff03..5681dde38 100644
    --- a/FS/FS/Conf.pm
    +++ b/FS/FS/Conf.pm
    @@ -905,7 +905,7 @@ httemplate/docs/config.html
         'section'     => '',
         'description' => 'Acceptable payment types for the signup server',
         'type'        => 'selectmultiple',
    -    'select_enum' => [ qw(CARD CHEK LECB PREPAY BILL COMP) ],
    +    'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB PREPAY BILL COMP) ],
       },
     
       {
    @@ -1013,7 +1013,7 @@ httemplate/docs/config.html
         'section'     => 'UI',
         'description' => 'Default payment type.  HIDE disables display of billing information and sets customers to BILL.',
         'type'        => 'select',
    -    'select_enum' => [ '', qw(CARD CHEK LECB BILL COMP HIDE) ],
    +    'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL COMP HIDE) ],
       },
     
       {
    diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
    index cde370c68..cefc7648f 100644
    --- a/FS/FS/cust_main.pm
    +++ b/FS/FS/cust_main.pm
    @@ -159,7 +159,7 @@ FS::Record.  The following fields are currently supported:
     
     =item ship_fax - phone (optional)
     
    -=item payby - `CARD' (credit cards), `CHEK' (electronic check), `LECB' (Phone bill billing), `BILL' (billing), `COMP' (free), or `PREPAY' (special billing type: applies a credit - see L and sets billing type to BILL)
    +=item payby - I (credit card - automatic), I (credit card - on-demand), I (electronic check - automatic), I (electronic check - on-demand), I (Phone bill billing), I (billing), I (free), or I (special billing type: applies a credit - see L and sets billing type to I)
     
     =item payinfo - card number, P.O., comp issuer (4-8 lowercase alphanumerics; think username) or prepayment identifier (see L)
     
    @@ -700,11 +700,11 @@ sub check {
         }
       }
     
    -  $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP|PREPAY)$/
    +  $self->payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP|PREPAY)$/
         or return "Illegal payby: ". $self->payby;
       $self->payby($1);
     
    -  if ( $self->payby eq 'CARD' ) {
    +  if ( $self->payby eq 'CARD' || $self->payby eq 'DCRD' ) {
     
         my $payinfo = $self->payinfo;
         $payinfo =~ s/\D//g;
    @@ -717,7 +717,7 @@ sub check {
         return gettext('unknown_card_type')
           if cardtype($self->payinfo) eq "Unknown";
     
    -  } elsif ( $self->payby eq 'CHEK' ) {
    +  } elsif ( $self->payby eq 'CHEK' || $self->payby eq 'DCHK' ) {
     
         my $payinfo = $self->payinfo;
         $payinfo =~ s/[^\d\@]//g;
    @@ -770,7 +770,9 @@ sub check {
       }
     
       if ( $self->payname eq '' && $self->payby ne 'CHEK' &&
    -       ( ! $conf->exists('require_cardname') || $self->payby ne 'CARD' ) ) {
    +       ( ! $conf->exists('require_cardname')
    +         || $self->payby !~ /^(CARD|DCRD)$/  ) 
    +  ) {
         $self->payname( $self->first. " ". $self->getfield('last') );
       } else {
         $self->payname =~ /^([\w \,\.\-\']+)$/
    @@ -1244,8 +1246,9 @@ sub bill {
     (Attempt to) collect money for this customer's outstanding invoices (see
     L).  Usually used after the bill method.
     
    -Depending on the value of `payby', this may print an invoice (`BILL'), charge
    -a credit card (`CARD'), or just add any necessary (pseudo-)payment (`COMP').
    +Depending on the value of `payby', this may print or email an invoice (I,
    +I, or I), charge a credit card (I), charge via electronic
    +check/ACH (I), or just add any necessary (pseudo-)payment (I).
     
     Most actions are now triggered by invoice events; see L
     and the invoice events web interface.
    diff --git a/FS/FS/part_bill_event.pm b/FS/FS/part_bill_event.pm
    index a75a011b0..e0e4f3f19 100644
    --- a/FS/FS/part_bill_event.pm
    +++ b/FS/FS/part_bill_event.pm
    @@ -37,7 +37,7 @@ FS::Record.  The following fields are currently supported:
     
     =item eventpart - primary key
     
    -=item payby - CARD, CHEK, LECB, BILL, or COMP
    +=item payby - CARD, DCRD, CHEK, DCHK, LECB, BILL, or COMP
     
     =item event - event name
     
    @@ -140,7 +140,7 @@ sub check {
       }
     
       my $error = $self->ut_numbern('eventpart')
    -    || $self->ut_enum('payby', [qw( CARD CHEK LECB BILL COMP )] )
    +    || $self->ut_enum('payby', [qw( CARD DCRD CHEK DCHK LECB BILL COMP )] )
         || $self->ut_text('event')
         || $self->ut_anything('eventcode')
         || $self->ut_number('seconds')
    diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily
    index 579d071ac..63e621b57 100755
    --- a/FS/bin/freeside-daily
    +++ b/FS/bin/freeside-daily
    @@ -113,7 +113,7 @@ the bill and collect methods of a cust_main object.  See L.
       -d: Pretend it's 'date'.  Date is in any format Date::Parse is happy with,
           but be careful.
     
    -  -p: Only process customers with the specified payby (CARD, CHEK, BILL, COMP, LECB)
    +  -p: Only process customers with the specified payby (I, I, I, I, I, I, I)
     
       -v: enable debugging
     
    diff --git a/FS/bin/freeside-expiration-alerter b/FS/bin/freeside-expiration-alerter
    index 5399f6d22..691fd3aa5 100755
    --- a/FS/bin/freeside-expiration-alerter
    +++ b/FS/bin/freeside-expiration-alerter
    @@ -97,7 +97,7 @@ foreach my $customer (@customers)
       my $expire_time = timelocal(0,0,0,$payday,--$paymonth,$payyear);
     
       #credit cards expire at the end of the month/year of their exp date
    -  if ($payby eq 'CARD') {
    +  if ($payby eq 'CARD' || $payby eq 'DCRD') {
         ($paymonth < 11) ? $paymonth++ : ($paymonth=0, $payyear++);
         $expire_time = timelocal(0,0,0,$payday,$paymonth,$payyear);
         $expire_time--;
    @@ -127,7 +127,7 @@ foreach my $customer (@customers)
             $FS::alerter::_template::first = $first;
             $FS::alerter::_template::last = $last;
             $FS::alerter::_template::company = $company;
    -        if ($payby eq 'CARD') {
    +        if ($payby eq 'CARD' || $payby eq 'DCRD') {
               $FS::alerter::_template::payby = "credit card (" .
                 substr($payinfo, 0, 2) . "xxxxxxxxxx" .
                 substr($payinfo, -4) . ")";
    @@ -202,7 +202,7 @@ user: From the mapsecrets file - see config.html from the base documentation
     
     =head1 VERSION
     
    -$Id: freeside-expiration-alerter,v 1.4 2002-09-16 09:27:14 ivan Exp $
    +$Id: freeside-expiration-alerter,v 1.5 2003-04-21 20:53:57 ivan Exp $
     
     =head1 BUGS
     
    diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup
    index 010ec4c14..8ec014186 100755
    --- a/FS/bin/freeside-setup
    +++ b/FS/bin/freeside-setup
    @@ -291,6 +291,8 @@ foreach my $aref (
       [ 'COMP', 'Comp invoice', '$cust_bill->comp();', 30, 'comp' ],
       [ 'CARD', 'Batch card', '$cust_bill->batch_card();', 40, 'batch-card' ],
       [ 'BILL', 'Send invoice', '$cust_bill->send();', 50, 'send' ],
    +  [ 'DCRD', 'Send invoice', '$cust_bill->send();', 50, 'send' ],
    +  [ 'DCHK', 'Send invoice', '$cust_bill->send();', 50, 'send' ],
     ) {
     
       my $part_bill_event = new FS::part_bill_event({
    diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi
    index 6672e605c..e384aaf8e 100755
    --- a/fs_signup/FS-SignupClient/cgi/signup.cgi
    +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi
    @@ -1,6 +1,6 @@
     #!/usr/bin/perl -Tw
     #
    -# $Id: signup.cgi,v 1.35 2002-12-24 23:03:27 ivan Exp $
    +# $Id: signup.cgi,v 1.36 2003-04-21 20:53:57 ivan Exp $
     
     use strict;
     use vars qw( @payby $cgi $locales $packages $pops $init_data $error
    @@ -160,9 +160,10 @@ if ( defined $cgi->param('magic') ) {
         }
     
         $payby = $cgi->param('payby');
    -    if ( $payby eq 'CHEK' ) {
    +    if ( $payby eq 'CHEK' || $payby eq 'DCHK' ) {
           #$payinfo = join('@', map { $cgi->param( $payby. "_payinfo$_" ) } (1,2) );
    -      $payinfo = $cgi->param('CHEK_payinfo1').'@'.$cgi->param('CHEK_payinfo2');
    +      $payinfo = $cgi->param($payby. '_payinfo1'). '@'. 
    +                 $cgi->param($payby. '_payinfo2');
         } else {
           $payinfo = $cgi->param( $payby. '_payinfo' );
         }
    @@ -212,7 +213,7 @@ if ( defined $cgi->param('magic') ) {
         } else {
           $password2 = $cgi->param('_password2');
     
    -      if ( $payby eq 'CARD' && $cgi->param('CARD_type') ) {
    +      if ( $payby =~ /^(CARD|DCRD)$/ && $cgi->param('CARD_type') ) {
             $payinfo =~ s/\D//g;
     
             $payinfo =~ /^(\d{13,16})$/
    diff --git a/fs_signup/FS-SignupClient/cgi/signup.html b/fs_signup/FS-SignupClient/cgi/signup.html
    index 724ffd7f8..80774099c 100755
    --- a/fs_signup/FS-SignupClient/cgi/signup.html
    +++ b/fs_signup/FS-SignupClient/cgi/signup.html
    @@ -92,7 +92,9 @@ Contact Information
       
         my %payby = (
           'CARD' => qq!Credit card
    *$cardselect
    *Exp !. expselect("CARD"). qq!
    *Name on card
    !, + 'DCRD' => qq!Credit card
    *$cardselect
    *Exp !. expselect("DCRD"). qq!
    *Name on card
    !, 'CHEK' => qq!Electronic check
    ${r}Account number
    ${r}ABA/Routing code
    ${r}Bank name !, + 'DCHK' => qq!Electronic check
    ${r}Account number
    ${r}ABA/Routing code
    ${r}Bank name !, 'LECB' => qq!Phone bill billing
    ${r}Phone number !, 'BILL' => qq!Billing
    P.O.
    *Exp !. expselect("BILL", "12-2037"). qq!
    *Attention
    !, 'COMP' => qq!Complimentary
    *Approved by
    *Exp !. expselect("COMP"), @@ -102,7 +104,9 @@ Contact Information my( $account, $aba ) = split('@', $payinfo); my %paybychecked = ( 'CARD' => qq!Credit card
    *$cardselect
    *Exp !. expselect("CARD", $paydate). qq!
    *Name on card
    !, + 'DCRD' => qq!Credit card
    *$cardselect
    *Exp !. expselect("DCRD", $paydate). qq!
    *Name on card
    !, 'CHEK' => qq!Electronic check
    ${r}Account number
    ${r}ABA/Routing code
    ${r}Bank name !, + 'DCHK' => qq!Electronic check
    ${r}Account number
    ${r}ABA/Routing code
    ${r}Bank name !, 'LECB' => qq!Phone bill billing
    ${r}Phone number !, 'BILL' => qq!Billing
    P.O.
    *Exp !. expselect("BILL", $paydate). qq!
    *Attention
    !, 'COMP' => qq!Complimentary
    *Approved by
    *Exp !. expselect("COMP", $paydate), diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html index 593ea82a0..a59755e76 100644 --- a/httemplate/docs/schema.html +++ b/httemplate/docs/schema.html @@ -39,7 +39,7 @@
  • part_bill_event - Invoice event definitions
    • eventpart - primary key -
    • payby - CARD, CHEK, LECB, BILL, or COMP +
    • payby - CARD, DCRD, CHEK, DCHK, LECB, BILL, or COMP
    • event - event name
    • eventcode - event action
    • seconds - how long after the invoice date (cust_bill._date) events of this type are triggered @@ -116,7 +116,7 @@
    • ship_daytime
    • ship_night
    • ship_fax -
    • payby - CARD, CHEK, LECB, BILL, or COMP +
    • payby - CARD, DCHK, CHEK, DCHK, LECB, BILL, or COMP
    • payinfo - card number, P.O.#, or comp issuer
    • paydate - expiration date
    • payname - billing name (name on card) diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index 706526865..d8edbcd8e 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -357,7 +357,7 @@ if ( $payby_default eq 'HIDE' ) { print qq!'; - foreach my $payby (qw( CARD CHEK LECB BILL COMP )) { + foreach my $payby (qw( CARD DCRD CHEK DCHK LECB BILL COMP )) { foreach my $field (qw( payinfo payname )) { print qq!'; @@ -405,8 +405,10 @@ if ( $payby_default eq 'HIDE' ) { ); my %payby = ( - 'CARD' => qq!Credit card
      ${r}
      ${r}Exp !. expselect("CARD"). qq!
      ${r}Name on card
      !, - 'CHEK' => qq!Electronic check
      ${r}Account number
      ${r}ABA/Routing code
      ${r}Bank name !, + 'CARD' => qq!Credit card (automatic)
      ${r}
      ${r}Exp !. expselect("CARD"). qq!
      ${r}Name on card
      !, + 'DCRD' => qq!Credit card (on-demand)
      ${r}
      ${r}Exp !. expselect("DCRD"). qq!
      ${r}Name on card
      !, + 'CHEK' => qq!Electronic check (automatic)
      ${r}Account number
      ${r}ABA/Routing code
      ${r}Bank name !, + 'DCHK' => qq!Electronic check (on-demand)
      ${r}Account number
      ${r}ABA/Routing code
      ${r}Bank name !, 'LECB' => qq!Phone bill billing
      ${r}Phone number !, 'BILL' => qq!Billing
      P.O.
      Attention
      !, 'COMP' => qq!Complimentary
      ${r}Approved by
      ${r}Exp !. expselect("COMP"), @@ -415,15 +417,17 @@ if ( $payby_default eq 'HIDE' ) { my( $account, $aba ) = split('@', $payinfo); my %paybychecked = ( - 'CARD' => qq!Credit card
      ${r}
      ${r}Exp !. expselect("CARD", $cust_main->paydate). qq!
      ${r}Name on card
      !, - 'CHEK' => qq!Electronic check
      ${r}Account number
      ${r}ABA/Routing code
      ${r}Bank name !, + 'CARD' => qq!Credit card (automatic)
      ${r}
      ${r}Exp !. expselect("CARD", $cust_main->paydate). qq!
      ${r}Name on card
      !, + 'DCRD' => qq!Credit card (on-demand)
      ${r}
      ${r}Exp !. expselect("DCRD", $cust_main->paydate). qq!
      ${r}Name on card
      !, + 'CHEK' => qq!Electronic check (automatic)
      ${r}Account number
      ${r}ABA/Routing code
      ${r}Bank name !, + 'DCHK' => qq!Electronic check (on-demand)
      ${r}Account number
      ${r}ABA/Routing code
      ${r}Bank name !, 'LECB' => qq!Phone bill billing
      ${r}Phone number !, 'BILL' => qq!Billing
      P.O.
      Attention
      !, 'COMP' => qq!Complimentary
      ${r}Approved by
      ${r}Exp !. expselect("COMP", $cust_main->paydate), ); $cust_main->payby($payby_default) unless $cust_main->payby; - for (qw(CARD CHEK LECB BILL COMP)) { + for (qw(CARD DCRD CHEK DCHK LECB BILL COMP)) { print qq!
  • !; diff --git a/httemplate/edit/part_bill_event.cgi b/httemplate/edit/part_bill_event.cgi index 2104b4530..6426eed93 100755 --- a/httemplate/edit/part_bill_event.cgi +++ b/httemplate/edit/part_bill_event.cgi @@ -41,7 +41,7 @@ print ntable("#cccccc",2), <', + print 'Credit card ', + ( $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' ), + '', '', '' ; - } elsif ( $cust_main->payby eq 'CHEK' ) { + } elsif ( $cust_main->payby eq 'CHEK' && $cust_main->payby eq 'DCHK') { my( $account, $aba ) = split('@', $cust_main->payinfo ); - print 'Electronic check', + print 'Electronic check', + ( $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' ), + '', '', '
    $labelfrom$labelto
    ". qq!\n". + "\n
    ". + qq!!. '
    '. qq!\n". + "\n
    ". + qq!!. '
    '. qq!!. @@ -146,6 +153,24 @@ function SafeOnsubmit() { object.options[index] = null; return value; } + function repack_${name}_from() { + var object = document.OneTrueForm.${name}_from; + object.options.length = 0; + ". join("\n", + map { "addOption_$name(object, '$_');\n" } + ( sort { $a cmp $b } @$from ) ). " + } + function repack_${name}_to() { + var object = document.OneTrueForm.${name}_to; + object.options.length = 0; + ". join("\n", + map { "addOption_$name(object, '$_');\n" } + ( sort { $a cmp $b } @$to ) ). " + } + function addOption_$name(object,value) { + var length = object.length; + object.options[length] = new Option(value, value, false, false); + } ". ''; } -- cgit v1.2.1 From 7ab5168716fcb97c01f0501d38780a85b9dfeaec Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 2 Apr 2003 11:38:51 +0000 Subject: better callbacks --- FS/FS/UID.pm | 53 ++++++++++++++++++++++++++++++++++++++++++++--------- FS/FS/cust_main.pm | 3 ++- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/FS/FS/UID.pm b/FS/FS/UID.pm index ebf9b96e5..f67005151 100644 --- a/FS/FS/UID.pm +++ b/FS/FS/UID.pm @@ -3,8 +3,8 @@ package FS::UID; use strict; use vars qw( @ISA @EXPORT_OK $cgi $dbh $freeside_uid $user - $conf_dir $secrets $datasrc $db_user $db_pass %callback $driver_name - $AutoCommit + $conf_dir $secrets $datasrc $db_user $db_pass %callback @callback + $driver_name $AutoCommit ); use subs qw( getsecrets cgisetotaker @@ -95,9 +95,33 @@ sub forksuidsetup { # breaks multi-database installs # delete $callback{$_}; #run once } + &{$_} foreach @callback; + $dbh; } +=item install_callback + +A package can install a callback to be run in adminsuidsetup by passing +a coderef to the FS::UID->install_callback class method. If adminsuidsetup has +run already, the callback will also be run immediately. + + $coderef = sub { warn "Hi, I'm returning your call!" }; + FS::UID->install_callback($coderef); + + install_callback FS::UID sub { + warn "Hi, I'm returning your call!" + }; + +=cut + +sub install_callback { + my $class = shift; + my $callback = shift; + push @callback, $callback; + &{$callback} if $dbh; +} + =item cgisuidsetup CGI_object Takes a single argument, which is a CGI (see L) or Apache (see L) @@ -246,17 +270,28 @@ sub getsecrets { =head1 CALLBACKS -Warning: this interface is likely to change in future releases. +Warning: this interface is (still) likely to change in future releases. -A package can install a callback to be run in adminsuidsetup by putting a -coderef into the hash %FS::UID::callback : +New (experimental) callback interface: + +A package can install a callback to be run in adminsuidsetup by passing +a coderef to the FS::UID->install_callback class method. If adminsuidsetup has +run already, the callback will also be run immediately. $coderef = sub { warn "Hi, I'm returning your call!" }; - $FS::UID::callback{'Package::Name'}; + FS::UID->install_callback($coderef); + + install_callback FS::UID sub { + warn "Hi, I'm returning your call!" + }; -=head1 VERSION +Old (deprecated) callback interface: -$Id: UID.pm,v 1.21 2002-09-27 12:14:12 ivan Exp $ +A package can install a callback to be run in adminsuidsetup by putting a +coderef into the hash %FS::UID::callback : + + $coderef = sub { warn "Hi, I'm returning your call!" }; + $FS::UID::callback{'Package::Name'} = $coderef; =head1 BUGS @@ -269,7 +304,7 @@ cgisuidsetup will go away as well. Goes through contortions to support non-OO syntax with multiple datasrc's. -Callbacks are inelegant. +Callbacks are (still) inelegant. =head1 SEE ALSO diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index d1e975406..886d492c4 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -38,7 +38,8 @@ $Debug = 0; $import = 0; #ask FS::UID to run this stuff for us later -$FS::UID::callback{'FS::cust_main'} = sub { +#$FS::UID::callback{'FS::cust_main'} = sub { +install_callback FS::UID sub { $conf = new FS::Conf; #yes, need it for stuff below (prolly should be cached) }; -- cgit v1.2.1 From a3d47fd14478fdd6df79d6d26ee5d5c37ad99d5e Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 2 Apr 2003 14:52:01 +0000 Subject: added order_pkgs sub --- FS/FS/cust_main.pm | 72 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 886d492c4..cde370c68 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -277,26 +277,10 @@ sub insert { } # packages - foreach my $cust_pkg ( keys %$cust_pkgs ) { - $cust_pkg->custnum( $self->custnum ); - $error = $cust_pkg->insert; - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return "inserting cust_pkg (transaction rolled back): $error"; - } - foreach my $svc_something ( @{$cust_pkgs->{$cust_pkg}} ) { - $svc_something->pkgnum( $cust_pkg->pkgnum ); - if ( $seconds && $svc_something->isa('FS::svc_acct') ) { - $svc_something->seconds( $svc_something->seconds + $seconds ); - $seconds = 0; - } - $error = $svc_something->insert; - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - #return "inserting svc_ (transaction rolled back): $error"; - return $error; - } - } + $error = $self->order_pkgs($cust_pkgs, \$seconds); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; } if ( $seconds ) { @@ -339,6 +323,54 @@ sub insert { } +=item order_pkgs + +document me. like ->insert(%cust_pkg) on an existing record + +=cut + +sub order_pkgs { + my $self = shift; + my $cust_pkgs = shift; + my $seconds = shift; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + foreach my $cust_pkg ( keys %$cust_pkgs ) { + $cust_pkg->custnum( $self->custnum ); + my $error = $cust_pkg->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "inserting cust_pkg (transaction rolled back): $error"; + } + foreach my $svc_something ( @{$cust_pkgs->{$cust_pkg}} ) { + $svc_something->pkgnum( $cust_pkg->pkgnum ); + if ( $seconds && $$seconds && $svc_something->isa('FS::svc_acct') ) { + $svc_something->seconds( $svc_something->seconds + $$seconds ); + $$seconds = 0; + } + $error = $svc_something->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + #return "inserting svc_ (transaction rolled back): $error"; + return $error; + } + } + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; #no error +} + =item delete NEW_CUSTNUM This deletes the customer. If there is an error, returns the error, otherwise -- cgit v1.2.1 From 2e9ff8b770519382f5767faf7a1dd15eb79eb7fe Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 18 Apr 2003 03:29:24 +0000 Subject: YA pg7.3 fix --- httemplate/view/svc_acct.cgi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi index 2e324c13c..f04e47163 100755 --- a/httemplate/view/svc_acct.cgi +++ b/httemplate/view/svc_acct.cgi @@ -1,4 +1,4 @@ - +<-- mason kludge --> <% my $conf = new FS::Conf; @@ -140,7 +140,9 @@ if ( $conf->exists('security_phrase') ) { $svc_acct->sec_phrase. '
    Access number". $svc_acct_pop->text. '
    payby eq "$_") { print qq! CHECKED> $paybychecked{$_}Payby
    Billing type', ; - if ( $cust_main->payby eq 'CARD' ) { + if ( $cust_main->payby eq 'CARD' && $cust_main->payby eq 'DCRD' ) { my $payinfo = $cust_main->payinfo; $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)); - print 'Credit card
    Card number', $payinfo, '
    Expiration', @@ -234,9 +236,11 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { '
    Name on card', $cust_main->payname, '
    Account number', $account, '
    ABA/Routing code', -- cgit v1.2.1 From 76e4bd639e70f707f7b9623b6228904146fbf07b Mon Sep 17 00:00:00 2001 From: khoff Date: Mon, 21 Apr 2003 21:12:09 +0000 Subject: Lines added for clairity --- httemplate/edit/router.cgi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/httemplate/edit/router.cgi b/httemplate/edit/router.cgi index d2279ff00..b524c6494 100755 --- a/httemplate/edit/router.cgi +++ b/httemplate/edit/router.cgi @@ -32,6 +32,10 @@ if($cgi->param('error')) { Router #<%=$routernum or "(NEW)"%>

    Name + +

    +Custom fields: +
    <%=table() %> <% -- cgit v1.2.1 From b938a41859030d3d3a126f39fa1b64b9211145a5 Mon Sep 17 00:00:00 2001 From: khoff Date: Mon, 21 Apr 2003 21:13:20 +0000 Subject: Fixed bug with $routernum and new routers. Navigation cleanup. --- httemplate/edit/process/router.cgi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httemplate/edit/process/router.cgi b/httemplate/edit/process/router.cgi index c0cb884f0..1b7fc3805 100644 --- a/httemplate/edit/process/router.cgi +++ b/httemplate/edit/process/router.cgi @@ -34,6 +34,7 @@ if($old) { } #else do nothing } else { $error = $new->insert; + $routernum = $new->routernum; } check($error); @@ -95,6 +96,6 @@ foreach($cgi->param) { # Yay, everything worked! $dbh->commit or die $dbh->errstr; -print $cgi->redirect(popurl(3). "edit/router.cgi?$routernum"); +print $cgi->redirect(popurl(3). "browse/router.cgi"); %> -- cgit v1.2.1 From fcfad3cd469df0df1beb2d54ea990a387915ebe2 Mon Sep 17 00:00:00 2001 From: khoff Date: Mon, 21 Apr 2003 21:29:35 +0000 Subject: Navigation fixes. --- httemplate/edit/part_router_field.cgi | 7 ++++--- httemplate/edit/process/generic.cgi | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/httemplate/edit/part_router_field.cgi b/httemplate/edit/part_router_field.cgi index c3e99be2c..02962b1c0 100644 --- a/httemplate/edit/part_router_field.cgi +++ b/httemplate/edit/part_router_field.cgi @@ -21,7 +21,10 @@ if ( $cgi->param('error') ) { my $action = $part_router_field->routerfieldpart ? 'Edit' : 'Add'; my $p1 = popurl(1); -print header("$action Router Extended Field Definition", ''); +print header("$action Router Extended Field Definition", + menubar('Main Menu' => $p, + 'View all Extended Fields' => $p. 'browse/generic.cgi?part_router_field') + ); print qq!Error: !, $cgi->param('error'), "" @@ -30,8 +33,6 @@ print qq!Error: !, $cgi->param('error'),
    - Field #<%=$routerfieldpart or "(NEW)"%>

    diff --git a/httemplate/edit/process/generic.cgi b/httemplate/edit/process/generic.cgi index 751987f7a..9c54feb1d 100644 --- a/httemplate/edit/process/generic.cgi +++ b/httemplate/edit/process/generic.cgi @@ -27,6 +27,7 @@ use DBIx::DBSchema::Table; my $error; my $p2 = popurl(2); +my $p3 = popurl(3); my $table = $cgi->param('table'); my $dbdef = dbdef or die "Cannot fetch dbdef!"; @@ -56,7 +57,7 @@ if($pkey_val and (my $old = qsearchs($table, { $pkey, $pkey_val} ))) { } my $redirect_ok = (($cgi->param('redirect_ok')) ? - $cgi->param('redirect_ok') : $p2."view/$table.cgi"); + $cgi->param('redirect_ok') : $p3."browse/generic.cgi?$table"); my $redirect_error = (($cgi->param('redirect_error')) ? $cgi->param('redirect_error') : $cgi->referer()); @@ -64,6 +65,6 @@ if($error) { $cgi->param('error', $error); print $cgi->redirect($redirect_error . '?' . $cgi->query_string); } else { - print $cgi->redirect($redirect_ok . '?' .$pkey_val); + print $cgi->redirect($redirect_ok); } %> -- cgit v1.2.1 From c302e891a8eb8dd565cb3b2dc83cdfa5c0a09537 Mon Sep 17 00:00:00 2001 From: khoff Date: Mon, 21 Apr 2003 21:40:00 +0000 Subject: renamed/clarified exclude_ip_addr option. --- FS/FS/Conf.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 5681dde38..545d8b77e 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -374,9 +374,9 @@ httemplate/docs/config.html }, { - 'key' => 'excludeaddr', - 'section' => 'deprecated', - 'description' => 'Addresses to exclude from assignment, one per line.', + 'key' => 'exclude_ip_addr', + 'section' => '', + 'description' => 'Exclude these from the list of available broadband service IP addresses. (One per line)', 'type' => 'textarea', }, -- cgit v1.2.1 From e27c01a149940c1f42da1f7246f775ab0533463b Mon Sep 17 00:00:00 2001 From: khoff Date: Mon, 21 Apr 2003 21:42:24 +0000 Subject: renamed config option excludeaddr --- FS/FS/addr_block.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS/FS/addr_block.pm b/FS/FS/addr_block.pm index c9305f6af..af4e5fb79 100755 --- a/FS/FS/addr_block.pm +++ b/FS/FS/addr_block.pm @@ -174,7 +174,7 @@ sub next_free_addr { my $self = shift; my $conf = new FS::Conf; - my @excludeaddr = $conf->config('excludeaddr'); + my @excludeaddr = $conf->config('exclude_ip_addr'); my @used = ( map { $_->NetAddr->addr } -- cgit v1.2.1 From 579c95a605ba3eeacd28e965d9c1ed7ad6f03374 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 21 Apr 2003 22:40:37 +0000 Subject: typo --- httemplate/view/svc_acct.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httemplate/view/svc_acct.cgi b/httemplate/view/svc_acct.cgi index f04e47163..599c1d8b9 100755 --- a/httemplate/view/svc_acct.cgi +++ b/httemplate/view/svc_acct.cgi @@ -1,4 +1,4 @@ -<-- mason kludge --> + <% my $conf = new FS::Conf; -- cgit v1.2.1 From 60527016538d1794227983d99ce3b77c8fcd7426 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 22 Apr 2003 04:39:40 +0000 Subject: - mysql 4.1 is available; update documentation - remove last vestiges of 1.3-style qmail/vpopmail exports from svc_domain and svc_forward; add appropriate exports (closes: Bug#299) --- FS/FS/Conf.pm | 2 +- FS/FS/part_export.pm | 20 ++- FS/FS/part_export/domain_shellcommands.pm | 18 ++- FS/FS/part_export/forward_shellcommands.pm | 110 +++++++++++++++++ FS/FS/svc_domain.pm | 59 ++------- FS/FS/svc_forward.pm | 192 +---------------------------- FS/MANIFEST | 2 + FS/t/part_export-forward_shellcommands.t | 5 + httemplate/docs/install.html | 16 ++- 9 files changed, 166 insertions(+), 258 deletions(-) create mode 100644 FS/FS/part_export/forward_shellcommands.pm create mode 100644 FS/t/part_export-forward_shellcommands.t diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 545d8b77e..d0ecf32a6 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -818,7 +818,7 @@ httemplate/docs/config.html { 'key' => 'vpopmailmachines', 'section' => 'deprecated', - 'description' => 'DEPRECATED, add a cp export instead. This option used to contain your vpopmail pop toasters, one per line. Each line is of the form "machinename vpopdir vpopuid vpopgid". For example: poptoaster.domain.tld /home/vpopmail 508 508 Note: vpopuid and vpopgid are values taken from the vpopmail machine\'s /etc/passwd', + 'description' => 'DEPRECATED, add a vpopmail export instead. This option used to contain your vpopmail pop toasters, one per line. Each line is of the form "machinename vpopdir vpopuid vpopgid". For example: poptoaster.domain.tld /home/vpopmail 508 508 Note: vpopuid and vpopgid are values taken from the vpopmail machine\'s /etc/passwd', 'type' => 'textarea', }, diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index 4471d6e00..f99dc6341 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -815,6 +815,18 @@ tie my %ldap_options, 'Tie::IxHash', 'radius' => { label=>'Export RADIUS attributes', type=>'checkbox', }, ; +tie my %forward_shellcommands_options, 'Tie::IxHash', + 'user' => { lable=>'Remote username', default=>'root' }, + 'useradd' => { label=>'Insert command', + default=>'', + }, + 'userdel' => { label=>'Delete command', + default=>'', + }, + 'usermod' => { label=>'Modify command', + default=>'', + }, +; #export names cannot have dashes... %exports = ( @@ -935,7 +947,7 @@ tie my %ldap_options, 'Tie::IxHash', 'domain_shellcommands' => { 'desc' => 'Run remote commands via SSH, for domains.', 'options' => \%domain_shellcommands_options, - 'notes' => 'Run remote commands via SSH, for domains. You will need to setup SSH for unattended operation.', + 'notes' => 'Run remote commands via SSH, for domains. You will need to setup SSH for unattended operation.

    Use these buttons for some useful presets:
    ', }, @@ -948,6 +960,12 @@ tie my %ldap_options, 'Tie::IxHash', #'nodomain' => 'Y', 'notes' => 'Database schema can be made to work with Courier IMAP and Exim. Others could work but are untested. (...extended description from pc-intouch?...)', }, + + 'forward_shellcommands' => { + 'desc' => 'Run remote commands via SSH, for forwards', + 'options' => \%forward_shellcommands_options, + 'notes' => 'Run remote commands via SSH, for forwards. You will need to setup SSH for unattended operation.

    Use these buttons for some useful presets:
    • /home/vpopmail/domains/$domain/$username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$domain/$username/.qmail; }"; this.form.userdel.value = "rm /home/vpopmail/domains/$domain/$username/.qmail"; this.form.usermod.value = "mv /home/vpopmail/domains/$old_domain/$old_username/.qmail /home/vpopmail/domains/$new_domain/$new_username; [ \"$old_destination\" != \"$new_destination\" ] && { echo \"$new_destination\" > /home/vpopmail/domains/$new_domain/$new_username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$new_domain/$new_username/.qmail; }";\'>
    ', + }, }, 'svc_www' => { diff --git a/FS/FS/part_export/domain_shellcommands.pm b/FS/FS/part_export/domain_shellcommands.pm index 5b3cd5d79..5b100e8c6 100644 --- a/FS/FS/part_export/domain_shellcommands.pm +++ b/FS/FS/part_export/domain_shellcommands.pm @@ -28,17 +28,15 @@ sub _export_command { no strict 'refs'; ${$_} = $svc_domain->getfield($_) foreach $svc_domain->fields; } + ( $qdomain = $domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES -# my $domain_record = $svc_www->domain_record; # or die ? -# my $zone = $domain_record->reczone; # or die ? -# unless ( $zone =~ /\.$/ ) { -# my $svc_domain = $domain_record->svc_domain; # or die ? -# $zone .= '.'. $svc_domain->domain; -# } - -# my $svc_acct = $svc_www->svc_acct; # or die ? -# my $username = $svc_acct->username; -# my $homedir = $svc_acct->dir; # or die ? + if ( $svc_domain->catchall ) { + no strict 'refs'; + my $svc_acct = $svc_domain->catchall_svc_acct; + ${$_} = $svc_acct->getfield($_) foreach qw(uid gid dir); + } else { + ${$_} = '' foreach qw(uid gid dir); + } #done setting variables for the command diff --git a/FS/FS/part_export/forward_shellcommands.pm b/FS/FS/part_export/forward_shellcommands.pm new file mode 100644 index 000000000..43d558a69 --- /dev/null +++ b/FS/FS/part_export/forward_shellcommands.pm @@ -0,0 +1,110 @@ +package FS::part_export::forward_shellcommands; + +use strict; +use vars qw(@ISA); +use FS::part_export; + +@ISA = qw(FS::part_export); + +sub rebless { shift; } + +sub _export_insert { + my($self) = shift; + $self->_export_command('useradd', @_); +} + +sub _export_delete { + my($self) = shift; + $self->_export_command('userdel', @_); +} + +sub _export_command { + my ( $self, $action, $svc_forward ) = (shift, shift, shift); + my $command = $self->option($action); + + #set variable for the command + no strict 'vars'; + { + no strict 'refs'; + ${$_} = $svc_forward->getfield($_) foreach $svc_forward->fields; + } + + my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $self->srcsvc } ); + $username = $svc_acct->username; + $domain = $svc_acct->domain; + if ($self->dstsvc) { + $destination = $self->dstsvc_acct->email; + } else { + $destination = $self->dst; + } + + #done setting variables for the command + + $self->shellcommands_queue( $svc_forward->svcnum, + user => $self->option('user')||'root', + host => $self->machine, + command => eval(qq("$command")), + ); +} + +sub _export_replace { + my( $self, $new, $old ) = (shift, shift, shift); + my $command = $self->option('usermod'); + + #set variable for the command + no strict 'vars'; + { + no strict 'refs'; + ${"old_$_"} = $old->getfield($_) foreach $old->fields; + ${"new_$_"} = $new->getfield($_) foreach $new->fields; + } + + my $old_svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $self->srcsvc } ); + $old_username = $old_svc_acct->username; + $old_domain = $old_svc_acct->domain; + if ($self->dstsvc) { + $old_destination = $self->dstsvc_acct->email; + } else { + $old_destination = $self->dst; + } + + my $new_svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $self->srcsvc } ); + $new_username = $new_svc_acct->username; + $new_domain = $new_svc_acct->domain; + if ($self->dstsvc) { + $new_destination = $self->dstsvc_acct->email; + } else { + $new_destination = $self->dst; + } + + #done setting variables for the command + + $self->shellcommands_queue( $new->svcnum, + user => $self->option('user')||'root', + host => $self->machine, + command => eval(qq("$command")), + ); +} + +#a good idea to queue anything that could fail or take any time +sub shellcommands_queue { + my( $self, $svcnum ) = (shift, shift); + my $queue = new FS::queue { + 'svcnum' => $svcnum, + 'job' => "FS::part_export::forward_shellcommands::ssh_cmd", + }; + $queue->insert( @_ ); +} + +sub ssh_cmd { #subroutine, not method + use Net::SSH '0.07'; + &Net::SSH::ssh_cmd( { @_ } ); +} + +#sub shellcommands_insert { #subroutine, not method +#} +#sub shellcommands_replace { #subroutine, not method +#} +#sub shellcommands_delete { #subroutine, not method +#} + diff --git a/FS/FS/svc_domain.pm b/FS/FS/svc_domain.pm index 3941d6eff..81edc337e 100644 --- a/FS/FS/svc_domain.pm +++ b/FS/FS/svc_domain.pm @@ -3,14 +3,13 @@ package FS::svc_domain; use strict; use vars qw( @ISA $whois_hack $conf $smtpmachine @defaultrecords $soadefaultttl $soaemail $soaexpire $soamachine - $soarefresh $soaretry $qshellmachine $nossh_hack + $soarefresh $soaretry ); use Carp; use Mail::Internet 1.44; use Mail::Header; use Date::Format; use Net::Whois 1.0; -use Net::SSH; use FS::Record qw(fields qsearch qsearchs dbh); use FS::Conf; use FS::svc_Common; @@ -37,9 +36,6 @@ $FS::UID::callback{'FS::domain'} = sub { $soarefresh = $conf->config('soarefresh'); $soaretry = $conf->config('soaretry'); - $qshellmachine = $conf->exists('qmailmachines') - ? $conf->config('shellmachine') - : ''; }; =head1 NAME @@ -120,21 +116,6 @@ If any records are defined in the I configuration file, appropriate records are added to the domain_record table (see L). -If a machine is defined in the I configuration value, the -I configuration file exists, and the I field points -to an an account with a home directory (see L), the command: - - [ -e $dir/.qmail-$qdomain-defualt ] || { - touch $dir/.qmail-$qdomain-default; - chown $uid:$gid $dir/.qmail-$qdomain-default; - } - -is executed on shellmachine via ssh (see L). -This behaviour can be supressed by setting $FS::svc_domain::nossh_hack true. - -a machine is defined -in the - =cut sub insert { @@ -211,28 +192,6 @@ sub insert { $dbh->commit or die $dbh->errstr if $oldAutoCommit; - if ( $qshellmachine && $self->catchall && ! $nossh_hack ) { - - my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $self->catchall } ) - or warn "WARNING: inserted unknown catchall: ". $self->catchall; - if ( $svc_acct && $svc_acct->dir ) { - my $qdomain = $self->domain; - $qdomain =~ s/\./:/g; #see manpage for 'dot-qmail': EXTENSION ADDRESSES - my ( $uid, $gid, $dir ) = ( - $svc_acct->uid, - $svc_acct->gid, - $svc_acct->dir, - ); - - my $queue = new FS::queue { - 'svcnum' => $self->svcnum, - 'job' => 'Net::SSH::ssh_cmd', - }; - $error = $queue->insert("root\@$qshellmachine", "[ -e $dir/.qmail-$qdomain-default ] || { touch $dir/.qmail-$qdomain-default; chown $uid:$gid $dir/.qmail-$qdomain-default; }" ); - - } - } - ''; #no error } @@ -411,6 +370,15 @@ sub domain_record { } +sub catchall_svc_acct { + my $self = shift; + if ( $self->catchall ) { + qsearchs( 'svc_acct', { 'svcnum' => $self->catchall } ); + } else { + ''; + } +} + =item whois Returns the Net::Whois::Domain object (see L) for this domain, or @@ -449,8 +417,6 @@ sub submit_internic { =head1 BUGS -All BIND/DNS fields should be included (and exported). - Delete doesn't send a registration template. All registries should be supported. @@ -462,9 +428,8 @@ The $recref stuff in sub check should be cleaned up. =head1 SEE ALSO L, L, L, L, -L, L, L, L, -L, schema.html from the base documentation, config.html from the -base documentation. +L, L, L, schema.html from the base +documentation, config.html from the base documentation. =cut diff --git a/FS/FS/svc_forward.pm b/FS/FS/svc_forward.pm index 1c5b5c40d..2b1fb9225 100644 --- a/FS/FS/svc_forward.pm +++ b/FS/FS/svc_forward.pm @@ -1,9 +1,7 @@ package FS::svc_forward; use strict; -use vars qw( @ISA $nossh_hack $conf $shellmachine @qmailmachines - @vpopmailmachines ); -use Net::SSH qw(ssh); +use vars qw( @ISA ); use FS::Conf; use FS::Record qw( fields qsearch qsearchs dbh ); use FS::svc_Common; @@ -13,21 +11,6 @@ use FS::svc_domain; @ISA = qw( FS::svc_Common ); -#ask FS::UID to run this stuff for us later -$FS::UID::callback{'FS::svc_forward'} = sub { - $conf = new FS::Conf; - if ( $conf->exists('qmailmachines') ) { - $shellmachine = $conf->config('shellmachine') - } else { - $shellmachine = ''; - } - if ( $conf->exists('vpopmailmachines') ) { - @vpopmailmachines = $conf->config('vpopmailmachines'); - } else { - @vpopmailmachines = (); - } -}; - =head1 NAME FS::svc_forward - Object methods for svc_forward records @@ -91,17 +74,6 @@ the error, otherwise returns false. The additional fields pkgnum and svcpart (see L) should be defined. An FS::cust_svc record will be created and inserted. -If the configuration value (see L) vpopmailmachines exists, then -the command: - - [ -d $vpopdir/domains/$domain/$source ] && { - echo "$destination" >> $vpopdir/domains/$domain/$username/.$qmail - chown $vpopuid:$vpopgid $vpopdir/domains/$domain/$username/.$qmail - } - -is executed on each vpopmailmachine via ssh (see the vpopmail documentation). -This behaviour can be supressed by setting $FS::svc_forward::nossh_hack true. - =cut sub insert { @@ -128,32 +100,6 @@ sub insert { return $error; } - my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $self->srcsvc } ); - my $username = $svc_acct->username; - my $domain = $svc_acct->domain; - my $destination; - if ($self->dstsvc) { - $destination = $self->dstsvc_acct->email; - } else { - $destination = $self->dst; - } - - foreach my $vpopmailmachine ( @vpopmailmachines ) { - my($machine, $vpopdir, $vpopuid, $vpopgid) = split(/\s+/, $vpopmailmachine); - my $queue = new FS::queue { - 'svcnum' => $self->svcnum, - 'job' => 'Net::SSH::ssh_cmd', - }; - # should be neater - my $error = $queue->insert("root\@$machine","[ -d $vpopdir/domains/$domain/$username ] && { echo \"$destination\" >> $vpopdir/domains/$domain/$username/.qmail; chown $vpopuid:$vpopgid $vpopdir/domains/$domain/$username/.qmail; }") - unless $nossh_hack; - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return "queueing job (transaction rolled back): $error"; - } - - } - $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; #no error @@ -166,19 +112,6 @@ returns the error, otherwise returns false. The corresponding FS::cust_svc record will be deleted as well. -If the configuration value vpopmailmachines exists, then the command: - - { sed -e '/^$destination/d' < - $vpopdir/domains/$srcdomain/$srcusername/.qmail > - $vpopdir/domains/$srcdomain/$srcusername/.qmail.temp; - mv $vpopdir/domains/$srcdomain/$srcusername/.qmail.temp - $vpopdir/domains/$srcdomain/$srcusername/.qmail; - chown $vpopuid.$vpopgid $vpopdir/domains/$srcdomain/$srcusername/.qmail; } - - -is executed on each vpopmailmachine via ssh. This behaviour can be supressed -by setting $FS::svc_forward_nossh_hack true. - =cut sub delete { @@ -201,37 +134,6 @@ sub delete { return $error; } - my $svc_acct = $self->srcsvc_acct; - my $username = $svc_acct->username; - my $domain = $svc_acct->domain; - my $destination; - if ($self->dstsvc) { - $destination = $self->dstsvc_acct->email; - } else { - $destination = $self->dst; - } - foreach my $vpopmailmachine ( @vpopmailmachines ) { - my($machine, $vpopdir, $vpopuid, $vpopgid) = - split(/\s+/, $vpopmailmachine); - my $queue = new FS::queue { 'job' => 'Net::SSH::ssh_cmd' }; - # should be neater - my $error = $queue->insert("root\@$machine", - "sed -e '/^$destination/d' " . - "< $vpopdir/domains/$domain/$username/.qmail" . - "> $vpopdir/domains/$domain/$username/.qmail.temp; " . - "mv $vpopdir/domains/$domain/$username/.qmail.temp " . - "$vpopdir/domains/$domain/$username/.qmail; " . - "chown $vpopuid.$vpopgid $vpopdir/domains/$domain/$username/.qmail;" - ) - unless $nossh_hack; - - if ($error ) { - $dbh->rollback if $oldAutoCommit; - return "queueing job (transaction rolled back): $error"; - } - - } - $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; } @@ -242,29 +144,6 @@ sub delete { Replaces OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false. -If the configuration value vpopmailmachines exists, then the command: - - { sed -e '/^$destination/d' < - $vpopdir/domains/$srcdomain/$srcusername/.qmail > - $vpopdir/domains/$srcdomain/$srcusername/.qmail.temp; - mv $vpopdir/domains/$srcdomain/$srcusername/.qmail.temp - $vpopdir/domains/$srcdomain/$srcusername/.qmail; - chown $vpopuid.$vpopgid $vpopdir/domains/$srcdomain/$srcusername/.qmail; } - - -is executed on each vpopmailmachine via ssh. This behaviour can be supressed -by setting $FS::svc_forward_nossh_hack true. - -Also, if the configuration value vpopmailmachines exists, then the command: - - [ -d $vpopdir/domains/$domain/$source ] && { - echo "$destination" >> $vpopdir/domains/$domain/$username/.$qmail - chown $vpopuid:$vpopgid $vpopdir/domains/$domain/$username/.$qmail - } - -is executed on each vpopmailmachine via ssh. This behaviour can be supressed -by setting $FS::svc_forward_nossh_hack true. - =cut sub replace { @@ -295,66 +174,6 @@ sub replace { return $error; } - my $old_svc_acct = $old->srcsvc_acct; - my $old_username = $old_svc_acct->username; - my $old_domain = $old_svc_acct->domain; - my $destination; - if ($old->dstsvc) { - $destination = $old->dstsvc_acct->email; - } else { - $destination = $old->dst; - } - foreach my $vpopmailmachine ( @vpopmailmachines ) { - my($machine, $vpopdir, $vpopuid, $vpopgid) = - split(/\s+/, $vpopmailmachine); - my $queue = new FS::queue { - 'svcnum' => $new->svcnum, - 'job' => 'Net::SSH::ssh_cmd', - }; - # should be neater - my $error = $queue->insert("root\@$machine", - "sed -e '/^$destination/d' " . - "< $vpopdir/domains/$old_domain/$old_username/.qmail" . - "> $vpopdir/domains/$old_domain/$old_username/.qmail.temp; " . - "mv $vpopdir/domains/$old_domain/$old_username/.qmail.temp " . - "$vpopdir/domains/$old_domain/$old_username/.qmail; " . - "chown $vpopuid.$vpopgid " . - "$vpopdir/domains/$old_domain/$old_username/.qmail;" - ) - unless $nossh_hack; - - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return "queueing job (transaction rolled back): $error"; - } - } - - #false laziness with stuff in insert, should subroutine - my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $new->srcsvc } ); - my $username = $svc_acct->username; - my $domain = $svc_acct->domain; - if ($new->dstsvc) { - $destination = $new->dstsvc_acct->email; - } else { - $destination = $new->dst; - } - - foreach my $vpopmailmachine ( @vpopmailmachines ) { - my($machine, $vpopdir, $vpopuid, $vpopgid) = split(/\s+/, $vpopmailmachine); - my $queue = new FS::queue { - 'svcnum' => $new->svcnum, - 'job' => 'Net::SSH::ssh_cmd', - }; - # should be neater - my $error = $queue->insert("root\@$machine","[ -d $vpopdir/domains/$domain/$username ] && { echo \"$destination\" >> $vpopdir/domains/$domain/$username/.qmail; chown $vpopuid:$vpopgid $vpopdir/domains/$domain/$username/.qmail; }") - unless $nossh_hack; - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return "queueing job (transaction rolled back): $error"; - } - } - #end subroutinable bits - $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; } @@ -450,19 +269,12 @@ sub dstsvc_acct { =back -=head1 VERSION - -$Id: svc_forward.pm,v 1.12 2002-05-31 17:50:37 ivan Exp $ - =head1 BUGS -The remote commands should be configurable. - =head1 SEE ALSO L, L, L, L, L, -L, L, L, L, L, -schema.html from the base documentation. +L, L, schema.html from the base documentation. =cut diff --git a/FS/MANIFEST b/FS/MANIFEST index 32a4e4f59..6397cc411 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -73,6 +73,7 @@ FS/part_export/bsdshell.pm FS/part_export/cp.pm FS/part_export/cyrus.pm FS/part_export/domain_shellcommands.pm +FS/part_export/forward_shellcommands.pm FS/part_export/http.pm FS/part_export/infostreet.pm FS/part_export/ldap.pm @@ -155,6 +156,7 @@ t/part_export-bsdshell.t t/part_export-cp.t t/part_export-cyrus.t t/part_export-domain_shellcommands.t +t/part_export-forward_shellcommands.t t/part_export-http.t t/part_export-infostreet.t t/part_export-ldap.t diff --git a/FS/t/part_export-forward_shellcommands.t b/FS/t/part_export-forward_shellcommands.t new file mode 100644 index 000000000..78ca68d10 --- /dev/null +++ b/FS/t/part_export-forward_shellcommands.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::part_export::forward_shellcommands; +$loaded=1; +print "ok 1\n"; diff --git a/httemplate/docs/install.html b/httemplate/docs/install.html index 51dce4da5..ed419a1ca 100644 --- a/httemplate/docs/install.html +++ b/httemplate/docs/install.html @@ -13,9 +13,9 @@ Before installing, you need:
  • A transactional database engine supported by Perl's DBI.
    • PostgreSQL is recommended (v7or later). -
    • MySQL versions before 4.1 do not support standard SQL subqueries and are NOT SUPPORTED. If you are a developer who wishes to contribute MySQL 3.x/4.0 support, see ticket #438 in the bug-tracking system and ask on the -devel mailing list. - +
    • MySQL MINIMUM VERSION 4.1 is untested but may work. Versions before 4.1 do not support standard SQL subqueries and are NOT SUPPORTED. If you are a developer who wishes to contribute MySQL 3.x/4.0 support, see ticket #438 in the bug-tracking system and ask on the -devel mailing list. + + MySQL's default MyISAM and ISAM table types are not supported. If you want to use MySQL, you must use one of the new transaction-safe table types such as BDB or InnoDB, and set it as the default table type using the --default-table-type=BDB or --default-table-type=InnoDB mysqld command-line option or by setting default-table-type=BDB or default-table-type=InnoDB in the my.cnf option file.
  • Perl modules (CPAN will query, download and build perl modules automatically)
  • Edit the top-level Makefile:
      -
    • Set DATASOURCE to your DBI data source, for example, DBI:Pg:dbname=freeside for PostgresSQL. See the DBI manpage and the manpage for your DBD for the exact syntax of your DBI data source. +
    • Set DATASOURCE to your DBI data source, for example, DBI:Pg:dbname=freeside for PostgresSQL or DBI:mysql:freeside for MySQL. See the DBI manpage and the manpage for your DBD for the exact syntax of your DBI data source.
    • Set DB_PASSWORD to the freeside database user's password.
  • Add the freeside database to your database engine: @@ -93,10 +92,9 @@ $ su
     $ su freeside
     $ createdb freeside
    -
  • Build and install the Perl modules:
     $ make perl-modules
    -- 
    cgit v1.2.1