fixed bug in creation of new groups under ldap, they get always the same id

This commit is contained in:
Ralf Becker 2005-12-14 23:33:07 +00:00
parent 36138f346e
commit b5197ce79d

View File

@ -116,6 +116,7 @@
{ {
$this->db = clone($GLOBALS['egw']->db); $this->db = clone($GLOBALS['egw']->db);
} }
$this->db->set_app('phpgwapi'); // to load the right table-definitions for insert, select, update, ...
if($account_id != '') if($account_id != '')
{ {
@ -542,10 +543,10 @@
/** /**
* Using the common functions next_id and last_id, find the next available account_id * Using the common functions next_id and last_id, find the next available account_id
* *
* NOTE: to my knowledge this is not used any more RalfBecker 2004/06/15 * NOTE: only used for the creation of LDAP accounts
* *
* @deprecated
* @param $string $account_type='u' (optional, default to 'u') * @param $string $account_type='u' (optional, default to 'u')
* @return int/boolean interger account_id or false if none is free anymore
*/ */
function get_nextid($account_type='u') function get_nextid($account_type='u')
{ {
@ -555,44 +556,26 @@
if ($account_type == 'g') if ($account_type == 'g')
{ {
$type = 'groups'; $type = 'groups';
$sign = -1;
} }
else else
{ {
$type = 'accounts'; $type = 'accounts';
$sign = 1;
} }
$nextid = (int)$GLOBALS['egw']->common->last_id($type,$min,$max);
/* Loop until we find a free id */ /* Loop until we find a free id */
$free = 0; do
while (!$free)
{ {
$account_lid = ''; $account_id = (int) $GLOBALS['egw']->common->next_id($type,$min,$max);
//echo '<br>calling search for id: '.$nextid; }
if ($this->exists($nextid)) while ($account_id && $this->exists($sign * $account_id)); // check need to include the sign!
{
$nextid = (int)$GLOBALS['egw']->common->next_id($type,$min,$max); if (!$account_id || $GLOBALS['egw_info']['server']['account_max_id'] &&
} $account_id > $GLOBALS['egw_info']['server']['account_max_id'])
else
{
$account_lid = $this->id2name($nextid);
/* echo '<br>calling search for lid: '.$account_lid . '(from account_id=' . $nextid . ')'; */
if ($this->exists($account_lid))
{
$nextid = (int)$GLOBALS['egw']->common->next_id($type,$min,$max);
}
else
{
$free = True;
}
}
}
if ($GLOBALS['egw_info']['server']['account_max_id'] &&
($nextid > $GLOBALS['egw_info']['server']['account_max_id']))
{ {
return False; return False;
} }
/* echo '<br>using'.$nextid;exit; */ return $account_id;
return $nextid;
} }
/** /**