ispman/lib/ISPMan ClientMan.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/ISPMan
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2741

Modified Files:
	ClientMan.pm 
Log Message:
fixes bug [ 947092 ] admin could not set client's reseller
thanks to micha137 for providing the patch


Index: ClientMan.pm
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/ISPMan/ClientMan.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ClientMan.pm	30 May 2004 23:35:37 -0000	1.6
+++ ClientMan.pm	14 Jun 2004 09:45:46 -0000	1.7
@@ -252,23 +252,53 @@
     my $self = shift;
     my $r    = shift;
 
+    my $dn   = $self->getClientDnById( $r->param("ispmanClientId") );
+    my $data = $self->getEntryAsHashRef($dn);
+
+    # take over easily changeable attributes
     my @ClientAttributes = $self->getClientAttributes();
-    my $data;
     for (@ClientAttributes) {
-        if ( $r->param($_) ) {
-            $data->{$_} = $self->as_arrayref( $r->param($_) );
-        }
+        $data->{$_} = $self->as_arrayref( $r->param($_) )
+          if ( $r->param($_) );
     }
 
-    #just in case Reseller's face name is changed. Change it also for the client
-    $data->{"ispmanResellerName"} =
-      $self->getResellerNameById( $r->param("ispmanResellerId") )
-      if $r->param("ispmanResellerId");
     $data->{'userPassword'} =
       $self->encryptPassWithMethod( $r->param("userPassword"),
         $self->getConf('userPassHashMethod') );
-    $self->updateEntryWithData(
-        $self->getClientDnById( $r->param("ispmanClientId") ), $data );
+
+    # only admin may change reseller this client belongs to
+    if ( $r->param("ispmanResellerId")
+        && $self->{'session'}->param('logintype') eq 'admin'
+        && $data->{'ispmanResellerId'} != $r->param("ispmanResellerId") )
+    {
+        $data->{'ispmanResellerId'}   = $r->param("ispmanResellerId");
+        $data->{"ispmanResellerName"} =
+          $self->getResellerNameById( $data->{'ispmanResellerId'} );
+
+        # move client's entry
+        #print "Deleting $dn<br>";
+        $self->deleteEntry($dn);
+        $dn =
+            'ispmanClientId='
+          . $data->{'ispmanClientId'}
+          . ', ispmanResellerId='
+          . $data->{'ispmanResellerId'}
+          . ', ou=ispman, '
+          . $self->{'Config'}{'ldapBaseDN'};
+
+        #print "Adding $dn<br>";
+        $self->addNewEntryWithData( $dn, $data );
+    }
+    else {
+
+    #just in case Reseller's face name is changed. Change it also for the client
+        $data->{"ispmanResellerName"} =
+          $self->getResellerNameById( $data->{'ispmanResellerId'} );
+
+        #print "Updating $dn<br>";
+        $self->updateEntryWithData( $dn, $data );
+    }
+
     $r->param( "mode", "showClients" );
     $self->showClients($r);
 }



-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
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.