ispman/lib/CustomerMan UserMan.pm,1.6,1.7

Joerg Delker <[email protected]>
Newsgroups gmane.comp.isp.ispman.cvs
Message-ID <[email protected]>
Update of /cvsroot/ispman/ispman/lib/CustomerMan
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1380/lib/CustomerMan

Modified Files:
	UserMan.pm 
Log Message:
suggested patch from petkovsc
[ 930816 ] ctrl pnl Clients need to choose their own user names

Index: UserMan.pm
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/CustomerMan/UserMan.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- UserMan.pm	16 Apr 2004 20:20:38 -0000	1.6
+++ UserMan.pm	16 Apr 2004 20:51:34 -0000	1.7
@@ -35,6 +35,9 @@
    }
 
 
+   unless ($r->param("ispmanUserId")){
+      push @errors, "Username not defined";
+   }
    unless ($r->param("givenName")){
       push @errors, "Firstname not defined";
    }
@@ -58,6 +61,7 @@
    my $givenname=$r->param("givenName");
    my $sn=$r->param("sn");
    my $userpassword=$r->param("userPassword");
+   my $username=$r->param("ispmanUserId");
 
    $givenname=~s/^\s\s*//g;
    $givenname=~s/\s\s*$//g;
@@ -68,12 +72,12 @@
    $userpassword=~s/^\s\s*//g;
    $userpassword=~s/\s\s*$//g;
 
-
-   my $username;
+   $username=~s/^\s\s*//g;
+   $username=~s/\s\s*$//g;
 
    
-   unless ($username=$self->caclculateUsername($givenname, $sn, $domain)){
-      print "Sorry, couldnt find a suitable username";
+   if($self->userExists($username)) {
+      print "User account already exists.";
       return;
    }
    
@@ -371,48 +375,11 @@
    my $dn="uid=$uid, ou=users, $self->{'domaindn'}";
    #print "DN is $dn<br>";
 
-   return $self->{'ispman'}->userExists($dn);
-}
-
-
-
-sub caclculateUsername {
-   my $self=shift;
-   my ($givenname, $sn, $domain)=@_;
-
-   $givenname=~s/ //g;
-   $sn=~s/ //g;
-
-   $givenname=~s/[^a-zA-Z0-9]//g;
-   $sn=~s/[^a-zA-Z0-9]//g;
-
-
-   my $username;
-   
-   #first priority is aghaffar
-   $username=lc(join "", (substr($givenname, 0, 1), $sn));
-   return lc($username) unless $self->userExists($username);
-
-   #second priority atifghaffar
-   $username=join "", ($givenname, $sn);
-   return lc($username) unless $self->userExists($username);
-   
-   # third ghaffaratif
-   $username=join "", ($sn, $givenname);
-   return lc($username) unless $self->userExists($username);
-
-   for (1..length($givenname)) {
-      $username=lc(join "", (substr($givenname, 0, $_), $sn));
-      return lc($username) unless $self->userExists($username);
-   }
-   
-   return "";
-
+   return $self->{'ispman'}->getCount($dn);
 }
 
 
 
-
 1;
 
 



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.