Author: ralfbecker
New Revision: 55592
URL: http://svn.stylite.de/viewvc/egroupware?rev=55592&view=rev
Log:
moving common::(next|last)_id methods to Api\Accounts\Ldap, storing ids now in egw_config instead of egw_nextid table (which will be droped), also fix “Protocol error” on creating new accouts r55591 on 14.x
Modified:
trunk/egroupware/api/src/Accounts/Ldap.php
trunk/phpgwapi/inc/class.common.inc.php
— trunk/egroupware/api/src/Accounts/Ldap.php (original)
+++ trunk/egroupware/api/src/Accounts/Ldap.php Fri Apr 1 10:07:03 2016
@@ -22,7 +22,6 @@
use EGroupware\Api;
// explicitly reference classes still in phpgwapi or old structure
-use common; // next_id
use setup_cmd_ldap;
/**
@@ -632,9 +631,13 @@
if (isset($data[‘homedirectory’])) $to_write[‘homedirectory’] = $data[‘homedirectory’];
if (isset($data[‘loginshell’])) $to_write[‘loginshell’] = $data[‘loginshell’] ? $data[‘loginshell’] : array();
}
-
if (($new_entry || isset($to_write['homedirectory'])) && empty($to_write['homedirectory']))
{
$to_write['homedirectory'] = '/dev/null'; // is a required attribute of posixAccount
-
}
-
if ($new_entry && empty($to_write['loginshell']))
-
{
-
unset($to_write['loginshell']); // setting array() for new entry gives "Protocol error", must not set it
}
return $to_write;
}
@@ -1187,7 +1190,7 @@
/* Loop until we find a free id */
do
{
-
$account_id = (int) self::next_id($type,$min,$max);
}
while ($account_id && ($this->frontend->exists($sign * $account_id) || // check need to include the sign!
$this->frontend->exists(-1 * $sign * $account_id) ||
@@ -1203,6 +1206,65 @@
}
/**
-
- Return a value for the next id an app/class may need to insert values into LDAP
-
-
-
@param string $location name for id eg. “groups” or “accounts”
-
-
@param int $min =0 if != 0 minimum id
-
-
@param int $max =0 if != 0 maximum id allowed, if it would be exceeded we return false
-
-
@return int|boolean the next id or false if $max given and exceeded
- */
- static function next_id($location,$min=0,$max=0)
- {
-
if (!$location)
-
{
-
return -1;
-
}
-
-
$id = (int)$GLOBALS['egw_info']['server'][$key='last_id_'.$location];
-
-
if ($max && $id >= $max)
-
{
-
return False;
-
}
-
++$id;
-
-
if($id < $min) $id = $min;
-
-
Api\Config::save_value($key, $id, 'phpgwapi', true);
-
$GLOBALS['egw_info']['server'][$key='last_id_'.$location] = $id;
-
-
return (int)$id;
- }
-
- /**
-
- Return a value for the last id entered, which an app may need to check values for LDAP
-
-
-
@param string $location name for id eg. “groups” or “accounts”
-
-
@param int $min =0 if != 0 minimum id
-
-
@param int $max =0 if != 0 maximum id allowed, if it would be exceeded we return false
-
-
@return int|boolean current id in the next_id table for a particular app/class or -1 for no app and false if $max is exceeded.
- */
- static function last_id($location,$min=0,$max=0)
- {
-
if (!$location)
-
{
-
return -1;
-
}
-
-
$id = (int)$GLOBALS['egw_info']['server'][$key='last_id_'.$location];
-
-
if (!$id || $id < $min)
-
{
-
return self::next_id($location,$min,$max);
-
}
-
if ($max && $id > $max)
-
{
-
return False;
-
}
-
return $id;
- }
-
- /**
- __wakeup function gets called by php while unserializing the object to reconnect with the ldap server
*/
function __wakeup()
— trunk/phpgwapi/inc/class.common.inc.php (original)
+++ trunk/phpgwapi/inc/class.common.inc.php Fri Apr 1 10:07:03 2016
@@ -1236,28 +1236,12 @@
* @param string $appname app-name
* @param int $min =0 if != 0 minimum id
* @param int $max =0 if != 0 maximum id allowed, if it would be exceeded we return false
-
-
@return int/boolean the next id or false if $max given and exceeded
-
-
@deprecated use Api\Accounts\Ldap::next_id($appname, $min, $max)
-
-
@return int|boolean the next id or false if $max given and exceeded
*/
static function next_id($appname,$min=0,$max=0)
{
-
if (!$appname)
-
{
-
return -1;
-
}
-
-
$id = (int) $GLOBALS['egw']->db->select(self::NEXTID_TABLE,'id',array('appname' => $appname),__LINE__,__FILE__)->fetchColumn();
-
-
if ($max && $id >= $max)
-
{
-
return False;
-
}
-
++$id;
-
-
if($id < $min) $id = $min;
-
-
$GLOBALS['egw']->db->insert(self::NEXTID_TABLE,array('id' => $id),array('appname' => $appname),__LINE__,__FILE__);
-
-
return (int)$id;
-
return Api\Accounts\Ldap::next_id($appname, $min, $max);
}
/**
@@ -1266,26 +1250,12 @@
-
@param string $appname app-name
-
@param int $min =0 if != 0 minimum id
-
@param int $max =0 if != 0 maximum id allowed, if it would be exceeded we return false
-
-
@return int current id in the next_id table for a particular app/class or -1 for no app and false if $max is exceeded.
-
-
@deprecated use Api\Accounts\Ldap::last_id($appname, $min, $max)
-
-
@return int|boolean current id in the next_id table for a particular app/class or -1 for no app and false if $max is exceeded.
*/
static function last_id($appname,$min=0,$max=0)
{
-
if (!$appname)
-
{
-
return -1;
-
}
-
-
$id = (int)$GLOBALS['egw']->db->select(self::NEXTID_TABLE,'id',array('appname' => $appname),__LINE__,__FILE__)->fetchColumn();
-
-
if (!$id || $id < $min)
-
{
-
return self::next_id($appname,$min,$max);
-
}
-
if ($max && $id > $max)
-
{
-
return False;
-
}
-
return $id;
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs