remove svc_acct_sm
[freeside.git] / FS / FS / svc_acct.pm
index 878d76b..bd348f8 100644 (file)
@@ -18,11 +18,9 @@ use FS::UID qw( datasrc );
 use FS::Conf;
 use FS::Record qw( qsearch qsearchs fields dbh );
 use FS::svc_Common;
-use Net::SSH;
 use FS::cust_svc;
 use FS::part_svc;
 use FS::svc_acct_pop;
-use FS::svc_acct_sm;
 use FS::cust_main_invoice;
 use FS::svc_domain;
 use FS::raddb;
@@ -246,7 +244,8 @@ sub insert {
 
   if ( @dup_user || @dup_userdomain || @dup_uid ) {
     my $exports = FS::part_export::export_info('svc_acct');
-    my( %conflict_user_svcpart, %conflict_userdomain_svcpart );
+    my %conflict_user_svcpart;
+    my %conflict_userdomain_svcpart = ( $self->svcpart => 'SELF', );
 
     foreach my $part_export ( $part_svc->part_export ) {
 
@@ -340,11 +339,20 @@ sub insert {
     return "queueing job (transaction rolled back): $error";
   }
 
-  #welcome email
   my $cust_pkg = $self->cust_svc->cust_pkg;
-  my( $cust_main, $to ) = ( '', '' );
+  my $cust_main = $cust_pkg->cust_main;
+
+  my $cust_pkg = $self->cust_svc->cust_pkg;
+
+  if ( $conf->exists('emailinvoiceauto') ) {
+    my @invoicing_list = $cust_main->invoicing_list;
+    push @invoicing_list, $self->email;
+    $cust_main->invoicing_list(@invoicing_list);
+  }
+
+  #welcome email
+  my $to = '';
   if ( $welcome_template && $cust_pkg ) {
-    my $cust_main = $cust_pkg->cust_main;
     my $to = join(', ', grep { $_ ne 'POST' } $cust_main->invoicing_list );
     if ( $to ) {
       my $wqueue = new FS::queue {
@@ -400,11 +408,6 @@ The corresponding FS::cust_svc record will be deleted as well.
 sub delete {
   my $self = shift;
 
-  if ( defined( $FS::Record::dbdef->table('svc_acct_sm') ) ) {
-    return "Can't delete an account which has (svc_acct_sm) mail aliases!"
-      if $self->uid && qsearch( 'svc_acct_sm', { 'domuid' => $self->uid } );
-  }
-
   return "Can't delete an account which is a (svc_forward) source!"
     if qsearch( 'svc_forward', { 'srcsvc' => $self->svcnum } );
 
@@ -705,15 +708,9 @@ sub check {
          && $recref->{username} ne 'root'
          && $recref->{username} ne 'toor';
 
-#    $error = $self->ut_textn('finger');
-#    return $error if $error;
-    $self->getfield('finger') =~
-      /^([\w \t\!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\*\<\>]*)$/
-        or return "Illegal finger: ". $self->getfield('finger');
-    $self->setfield('finger', $1);
 
     $recref->{dir} =~ /^([\/\w\-\.\&]*)$/
-      or return "Illegal directory";
+      or return "Illegal directory: ". $recref->{dir};
     $recref->{dir} = $1;
     return "Illegal directory"
       if $recref->{dir} =~ /(^|\/)\.+(\/|$)/; #no .. component
@@ -745,22 +742,25 @@ sub check {
       $recref->{shell} = '/bin/sync';
     }
 
-    $recref->{quota} =~ /^(\d*)$/ or return "Illegal quota (unimplemented)";
-    $recref->{quota} = $1;
-
   } else {
     $recref->{gid} ne '' ? 
       return "Can't have gid without uid" : ( $recref->{gid}='' );
-    $recref->{finger} ne '' ? 
-      return "Can't have finger-name without uid" : ( $recref->{finger}='' );
     $recref->{dir} ne '' ? 
       return "Can't have directory without uid" : ( $recref->{dir}='' );
     $recref->{shell} ne '' ? 
       return "Can't have shell without uid" : ( $recref->{shell}='' );
-    $recref->{quota} ne '' ? 
-      return "Can't have quota without uid" : ( $recref->{quota}='' );
   }
 
+  #  $error = $self->ut_textn('finger');
+  #  return $error if $error;
+  $self->getfield('finger') =~
+    /^([\w \t\!\@\#\$\%\&\(\)\-\+\;\'\"\,\.\?\/\*\<\>]*)$/
+      or return "Illegal finger: ". $self->getfield('finger');
+  $self->setfield('finger', $1);
+
+  $recref->{quota} =~ /^(\d*)$/ or return "Illegal quota";
+  $recref->{quota} = $1;
+
   unless ( $part_svc->part_svc_column('slipip')->columnflag eq 'F' ) {
     unless ( $recref->{slipip} eq '0e0' ) {
       $recref->{slipip} =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/
@@ -791,7 +791,7 @@ sub check {
     #$recref->{password} = $1.
     #  crypt($3,$saltset[int(rand(64))].$saltset[int(rand(64))]
     #;
-  } elsif ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([\w\.\/\$]{13,34})$/ ) {
+  } elsif ( $recref->{_password} =~ /^((\*SUSPENDED\* )?)([\w\.\/\$\;]{13,34})$/ ) {
     $recref->{_password} = $1.$3;
   } elsif ( $recref->{_password} eq '*' ) {
     $recref->{_password} = '*';
@@ -838,8 +838,8 @@ sub radius_reply {
       #$attrib =~ s/_/\-/g;
       ( $FS::raddb::attrib{lc($attrib)}, $self->getfield($column) );
     } grep { /^radius_/ && $self->getfield($_) } fields( $self->table );
-  if ( $self->ip && $self->ip ne '0e0' ) {
-    $reply{'Framed-IP-Address'} = $self->ip;
+  if ( $self->slipip && $self->slipip ne '0e0' ) {
+    $reply{'Framed-IP-Address'} = $self->slipip;
   }
   %reply;
 }
@@ -1141,7 +1141,7 @@ probably live somewhere else...
 L<FS::svc_Common>, edit/part_svc.cgi from an installed web interface,
 export.html from the base documentation, L<FS::Record>, L<FS::Conf>,
 L<FS::cust_svc>, L<FS::part_svc>, L<FS::cust_pkg>, L<FS::queue>,
-L<freeside-queued>), L<Net::SSH>, L<ssh>, L<FS::svc_acct_pop>,
+L<freeside-queued>), L<FS::svc_acct_pop>,
 schema.html from the base documentation.
 
 =cut