phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] phpgwapi/inc class.accounts_ldap.inc.php, 1.101.2.13.


From: skwashd
Subject: [Phpgroupware-cvs] phpgwapi/inc class.accounts_ldap.inc.php, 1.101.2.13.2.39
Date: Wed, 16 Nov 2005 11:00:00 +0100

Update of phpgwapi/inc

Modified Files:
     Branch: Version-0_9_16-branch
            class.accounts_ldap.inc.php lines: +29 -29

Log Message:
fix exists and some other problems(blame skwashd), fix uid gen (blame Caeies 
not skwashd

====================================================
Index: phpgwapi/inc/class.accounts_ldap.inc.php
diff -u phpgwapi/inc/class.accounts_ldap.inc.php:1.101.2.13.2.38 
phpgwapi/inc/class.accounts_ldap.inc.php:1.101.2.13.2.39
--- phpgwapi/inc/class.accounts_ldap.inc.php:1.101.2.13.2.38    Fri Sep 30 
17:03:42 2005
+++ phpgwapi/inc/class.accounts_ldap.inc.php    Wed Nov 16 10:00:55 2005
@@ -558,7 +558,7 @@
                {
                        if ($id)
                        {
-                               $result = ldap_search($this->ds, 
$this->group_context, '(&(gidnumber='.$id.')(objectclass=posixgroup))');
+                               $result = ldap_search($this->ds, 
$this->group_context, '(&(phpgwGroupID='.$id.')(objectclass=phpgwGroup))');
                                $allValues = ldap_get_entries($this->ds, 
$result);
                                if ($allValues[0]['dn'])
                                {
@@ -583,7 +583,7 @@
                {
                        if ($id)
                        {
-                               $result = ldap_search($this->ds, 
$this->user_context, '(&(uidnumber='.$id.')(objectclass=posixaccount))');
+                               $result = ldap_search($this->ds, 
$this->user_context, '(&(phpgwAccountID='.$id.')(objectclass=phpgwAccount))');
                                $allValues = ldap_get_entries($this->ds, 
$result);
                                if ($allValues[0]['dn'])
                                {
@@ -654,7 +654,7 @@
                */
                function exists($id)
                {
-                       if (!is_int($id) && $id != '')
+                       if (!is_numeric($id) && $id != '')
                        {
                                $id = $this->name2id($id);
                        }
@@ -1181,11 +1181,11 @@
                        /* search the dn for the given uid */
                        if ( ($acct_type == 'g') && $this->group_context )
                        {
-                               $sri = ldap_search($this->ds, 
$this->group_context, 'gidnumber='.$account_id);
+                               $sri = ldap_search($this->ds, 
$this->group_context, "phpgwGroupID={$account_id}");
                        }
                        else
                        {
-                               $sri = ldap_search($this->ds, 
$this->user_context, 'uidnumber='.$account_id);
+                               $sri = ldap_search($this->ds, 
$this->user_context, "phpgwAccountID={$account_id}");
                        }
                        $allValues = ldap_get_entries($this->ds, $sri);

@@ -1193,7 +1193,7 @@
                        {
                                $account_name[$account_id]['lid']   = 
$allValues[0]['cn'][0];
                                $account_name[$account_id]['fname'] = 
utf8_decode($allValues[0]['cn'][0]);
-                               $account_name[$account_id]['lname'] = 'Group';
+                               $account_name[$account_id]['lname'] = 
lang('group');
                        }
                        else
                        {
@@ -1331,40 +1331,40 @@
                function idTester($IDs, $min = 1, $max = 0)
                {

-                       $interval = intval($max) - intval($min);
-                       $base = intval($min) ? intval($min) : 1;
-                       if ($interval > 0)
+                       if ( count($IDs) )
                        {
-                               $pointer = $start = 
$IDs[count($IDs)-1]%$interval;
+                               $maxid = max($IDs) + 1;
                        }
                        else
                        {
-                               $pointer = $IDs[count($IDs)-1];
+                               return $min;
                        }
-                       if (is_array($IDs))
+                       if ( $maxid <= $max && $maxid > $min )
                        {
+                               return $maxid;
+                       }
+                       elseif ( $maxid > $max )
+                       {
+                               //We need to found another id (one deleted 
account for example ?
+                               //KISS : start from the min and lookup for the 
value
+                               if ( count($IDs) == $max - $min + 1 )
+                               {
+                                       //No more free ID
+                                       die('no free id found');
+                                       return False;
+                               }
+                               $maxid = $min;
                                do
                                {
-                                       if ($interval > 0)
-                                       {
-                                               $pointer = 
($pointer+1)%$interval;
-                                               if ($pointer == $start)
-                                               {
-                                                       die('no free id found');
-                                               }
-                                       }
-                                       else
+                                       if ( ! in_array($maxid,$IDs) )
                                        {
-                                               $pointer++;
+                                               return $maxid;
                                        }
+                                       ++$maxid;
                                }
-                               while (in_array($base + $pointer, $IDs) && 
$pointer != $start);
-                       }
-                       else
-                       {
-                               $pointer = 0;
+                               while ( $maxid <= $max );
                        }
-                       return $base + $pointer;
+                       die('no free id found');
                }

                function get_homedirectory($newValue, $login)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]