sqlradius data volume report improvements, #18823
[freeside.git] / FS / FS / svc_acct.pm
index 6596354..7ce79ae 100644 (file)
@@ -1163,6 +1163,7 @@ sub check {
 
   my $cust_pkg;
   local $username_letter = $username_letter;
+  local $username_uppercase = $username_uppercase;
   if ($self->svcnum) {
     my $cust_svc = $self->cust_svc
       or return "no cust_svc record found for svcnum ". $self->svcnum;
@@ -1174,6 +1175,8 @@ sub check {
   if ($cust_pkg) {
     $username_letter =
       $conf->exists('username-letter', $cust_pkg->cust_main->agentnum);
+    $username_uppercase =
+      $conf->exists('username-uppercase', $cust_pkg->cust_main->agentnum);
   }
 
   my $ulen = $usernamemax || $self->dbdef_table->column('username')->length;
@@ -1464,7 +1467,7 @@ sub set_password {
   if ( !$encoding ) {
     # set encoding to system default
     ($encoding, $encryption) =
-      split(/-/, lc($conf->config('default-password-encoding')));
+      split(/-/, lc($conf->config('default-password-encoding') || ''));
     $encoding ||= 'legacy';
     $self->_password_encoding($encoding);
   }
@@ -2521,7 +2524,8 @@ sub check_password {
 
   if ( $self->_password_encoding eq 'ldap' ) {
 
-    my $auth = from_rfc2307 Authen::Passphrase $self->_password;
+    $password =~ s/^{PLAIN}/{CLEARTEXT}/;
+    my $auth = from_rfc2307 Authen::Passphrase $password;
     return $auth->match($check_password);
 
   } elsif ( $self->_password_encoding eq 'crypt' ) {
@@ -2804,6 +2808,13 @@ Arrayref of additional WHERE clauses, will be ANDed together.
 sub search {
   my ($class, $params) = @_;
 
+  my @from = (
+    ' LEFT JOIN cust_svc  USING ( svcnum  ) ',
+    ' LEFT JOIN part_svc  USING ( svcpart ) ',
+    ' LEFT JOIN cust_pkg  USING ( pkgnum  ) ',
+    ' LEFT JOIN cust_main USING ( custnum ) ',
+  );
+
   my @where = ();
 
   # domain
@@ -2848,6 +2859,17 @@ sub search {
     push @where, "svcpart = $1";
   }
 
+  if ( $params->{'exportnum'} =~ /^(\d+)$/ ) {
+    push @from, ' LEFT JOIN export_svc USING ( svcpart )';
+    push @where, "exportnum = $1";
+  }
+
+  # sector and tower
+  my @where_sector = $class->tower_sector_sql($params);
+  if ( @where_sector ) {
+    push @where, @where_sector;
+    push @from, ' LEFT JOIN tower_sector USING ( sectornum )';
+  }
 
   # here is the agent virtualization
   #if ($params->{CurrentUser}) {
@@ -2868,13 +2890,9 @@ sub search {
 
   push @where, @{ $params->{'where'} } if $params->{'where'};
 
+  my $addl_from = join(' ', @from);
   my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : '';
 
-  my $addl_from = ' LEFT JOIN cust_svc  USING ( svcnum  ) '.
-                  ' LEFT JOIN part_svc  USING ( svcpart ) '.
-                  ' LEFT JOIN cust_pkg  USING ( pkgnum  ) '.
-                  ' LEFT JOIN cust_main USING ( custnum ) ';
-
   my $count_query = "SELECT COUNT(*) FROM svc_acct $addl_from $extra_sql";
   #if ( keys %svc_acct ) {
   #  $count_query .= ' WHERE '.