- documentation updates
[freeside.git] / FS / FS / svc_acct.pm
index 197eec1..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);
@@ -28,6 +27,7 @@ use FS::svc_domain;
 use FS::raddb;
 use FS::queue;
 use FS::radius_usergroup;
+use FS::Msgcat qw(gettext);
 
 @ISA = qw( FS::svc_Common );
 
@@ -79,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;
@@ -170,6 +160,8 @@ FS::svc_Common.  The following fields are currently supported:
 
 =item _password - generated if blank
 
+=item sec_phrase - security phrase
+
 =item popnum - Point of presence (see L<FS::svc_acct_pop>)
 
 =item uid
@@ -260,7 +252,7 @@ sub insert {
   $error = $self->check;
   return $error if $error;
 
-  return "Username ". $self->username. " in use"
+  return gettext('username_in_use'). ": ". $self->username
     if qsearchs( 'svc_acct', { 'username' => $self->username,
                                'domsvc'   => $self->domsvc,
                              } );
@@ -348,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 =
@@ -420,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 ) = @_;
   
@@ -630,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 );
@@ -676,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 ) = @_;
   
@@ -868,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))]
@@ -911,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 ) = @_;
   
@@ -1079,30 +940,31 @@ sub check {
 
   my $error = $self->ut_numbern('svcnum')
               || $self->ut_number('domsvc')
+              || $self->ut_textn('sec_phrase')
   ;
   return $error if $error;
 
   my $ulen = $usernamemax || $self->dbdef_table->column('username')->length;
   if ( $username_uppercase ) {
     $recref->{username} =~ /^([a-z0-9_\-\.\&]{$usernamemin,$ulen})$/i
-      or return "Illegal username: ". $recref->{username};
+      or return gettext('illegal_username'). ": ". $recref->{username};
     $recref->{username} = $1;
   } else {
     $recref->{username} =~ /^([a-z0-9_\-\.\&]{$usernamemin,$ulen})$/
-      or return "Illegal username: ". $recref->{username};
+      or return gettext('illegal_username'). ": ". $recref->{username};
     $recref->{username} = $1;
   }
 
   if ( $username_letterfirst ) {
-    $recref->{username} =~ /^[a-z]/ or return "Illegal username";
+    $recref->{username} =~ /^[a-z]/ or return gettext('illegal_username');
   } elsif ( $username_letter ) {
-    $recref->{username} =~ /[a-z]/ or return "Illegal username";
+    $recref->{username} =~ /[a-z]/ or return gettext('illegal_username');
   }
   if ( $username_noperiod ) {
-    $recref->{username} =~ /\./ and return "Illegal username";
+    $recref->{username} =~ /\./ and return gettext('illegal_username');
   }
   unless ( $username_ampersand ) {
-    $recref->{username} =~ /\&/ and return "Illegal username";
+    $recref->{username} =~ /\&/ and return gettext('illegal_username');
   }
 
   $recref->{popnum} =~ /^(\d*)$/ or return "Illegal popnum: ".$recref->{popnum};
@@ -1218,7 +1080,7 @@ sub check {
     $recref->{_password} = '!!';
   } else {
     #return "Illegal password";
-    return "Illegal password: ". $recref->{_password};
+    return gettext('illegal_password'). ": ". $recref->{_password};
   }
 
   ''; #no error