Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2013-02-25 20:17:56 +01:00
commit e776e849ce
9 changed files with 89 additions and 56 deletions

View File

@ -28,6 +28,8 @@ For developers:
- Renamed some database fields, code variables and parameters from french to english.
- First change to manage margins on contracts.
- Add hook getFormMail.
- Function plimit of databases drivers accept -1 as value (it means default value set
into conf->liste_limit).
- New: Add option dol_hide_topmenu and dol_hide_leftmenu onto login page.
For translators:

View File

@ -874,9 +874,10 @@ class Ldap
* @param string $useridentifier Name of key field (Ex: uid)
* @param array $attributeArray Array of fields required. Note this array must also contains field $useridentifier (Ex: sn,userPassword)
* @param int $activefilter 1=use field this->filter as filter instead of parameter $search
* @param array $attributeAsArray Array of fields wanted as an array not a string
* @return array Array of [id_record][ldap_field]=value
*/
function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter=0)
function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter=0, $attributeAsArray=array())
{
$fulllist=array();
@ -955,7 +956,15 @@ class Ldap
}
else
{
$fulllist[$recordid][$attributeArray[$j]] = $this->convToOutputCharset($info[$i][$keyattributelower][0],$this->ldapcharset);
if(in_array($attributeArray[$j], $attributeAsArray) && is_array($info[$i][$keyattributelower])) {
$valueTab = array();
foreach($info[$i][$keyattributelower] as $key => $value) {
$valueTab[$key] = $this->convToOutputCharset($value,$this->ldapcharset);
}
$fulllist[$recordid][$attributeArray[$j]] = $valueTab;
} else {
$fulllist[$recordid][$attributeArray[$j]] = $this->convToOutputCharset($info[$i][$keyattributelower][0],$this->ldapcharset);
}
}
}
}

View File

@ -499,16 +499,16 @@ class DoliDBMssql
/**
* Define limits of request
*
* @param int $limit nombre maximum de lignes retournees
* @param int $offset numero de la ligne a partir de laquelle recuperer les ligne
* @return string chaine exprimant la syntax sql de la limite
* Define limits and offset of request
*
* @param int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
* @param int $offset Numero of line from where starting fetch
* @return string String with SQL syntax to add a limit and offset
*/
function plimit($limit=0,$offset=0)
{
global $conf;
if (! $limit) $limit=$conf->liste_limit;
if ($limit < 0) $limit=$conf->liste_limit;
if ($offset > 0) return " LIMIT $offset,$limit ";
else return " LIMIT $limit ";
}

View File

@ -479,16 +479,16 @@ class DoliDBMysql
/**
* Define limits of request
*
* @param int $limit nombre maximum de lignes retournees
* @param int $offset numero de la ligne a partir de laquelle recuperer les ligne
* @return string chaine exprimant la syntax sql de la limite
* Define limits and offset of request
*
* @param int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
* @param int $offset Numero of line from where starting fetch
* @return string String with SQL syntax to add a limit and offset
*/
function plimit($limit=0,$offset=0)
{
global $conf;
if (! $limit) $limit=$conf->liste_limit;
if ($limit < 0) $limit=$conf->liste_limit;
if ($offset > 0) return " LIMIT $offset,$limit ";
else return " LIMIT $limit ";
}

View File

@ -481,16 +481,16 @@ class DoliDBMysqli
/**
* Defini les limites de la requete
* Define limits and offset of request
*
* @param int $limit nombre maximum de lignes retournees
* @param int $offset numero de la ligne a partir de laquelle recuperer les ligne
* @return string chaine exprimant la syntax sql de la limite
* @param int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
* @param int $offset Numero of line from where starting fetch
* @return string String with SQL syntax to add a limit and offset
*/
function plimit($limit=0,$offset=0)
{
global $conf;
if (! $limit) $limit=$conf->liste_limit;
if ($limit < 0) $limit=$conf->liste_limit;
if ($offset > 0) return " LIMIT $offset,$limit ";
else return " LIMIT $limit ";
}

View File

@ -691,16 +691,16 @@ class DoliDBPgsql
/**
* Defini les limites de la requete
*
* @param int $limit nombre maximum de lignes retournees
* @param int $offset numero de la ligne a partir de laquelle recuperer les lignes
* @return string chaine exprimant la syntax sql de la limite
* Define limits and offset of request
*
* @param int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
* @param int $offset Numero of line from where starting fetch
* @return string String with SQL syntax to add a limit and offset
*/
function plimit($limit=0,$offset=0)
{
global $conf;
if (! $limit) $limit=$conf->liste_limit;
if ($limit < 0) $limit=$conf->liste_limit;
if ($offset > 0) return " LIMIT ".$limit." OFFSET ".$offset." ";
else return " LIMIT $limit ";
}

View File

@ -620,16 +620,16 @@ class DoliDBSqlite
/**
* Define limits of request
*
* @param int $limit nombre maximum de lignes retournees
* @param int $offset numero de la ligne a partir de laquelle recuperer les ligne
* @return string chaine exprimant la syntax sql de la limite
* Define limits and offset of request
*
* @param int $limit Maximum number of lines returned (-1=conf->liste_limit, 0=no limit)
* @param int $offset Numero of line from where starting fetch
* @return string String with SQL syntax to add a limit and offset
*/
function plimit($limit=0,$offset=0)
{
global $conf;
if (! $limit) $limit=$conf->liste_limit;
if ($limit < 0) $limit=$conf->liste_limit;
if ($offset > 0) return " LIMIT $offset,$limit ";
else return " LIMIT $limit ";
}

View File

@ -110,7 +110,7 @@ class InterfaceLdapsynchro
if ($action == 'USER_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{
$ldap=new Ldap();
$ldap->connect_bind();
@ -129,7 +129,7 @@ class InterfaceLdapsynchro
elseif ($action == 'USER_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{
$ldap=new Ldap();
$ldap->connect_bind();
@ -166,7 +166,7 @@ class InterfaceLdapsynchro
elseif ($action == 'USER_NEW_PASSWORD')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{
$ldap=new Ldap();
$ldap->connect_bind();
@ -207,7 +207,7 @@ class InterfaceLdapsynchro
elseif ($action == 'USER_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{
$ldap=new Ldap();
$ldap->connect_bind();
@ -226,7 +226,7 @@ class InterfaceLdapsynchro
elseif ($action == 'USER_SETINGROUP')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{
$ldap=new Ldap();
$ldap->connect_bind();
@ -264,7 +264,7 @@ class InterfaceLdapsynchro
elseif ($action == 'USER_REMOVEFROMGROUP')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{
$ldap=new Ldap();
$ldap->connect_bind();
@ -304,7 +304,7 @@ class InterfaceLdapsynchro
elseif ($action == 'GROUP_CREATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{
$ldap=new Ldap();
$ldap->connect_bind();
@ -327,7 +327,7 @@ class InterfaceLdapsynchro
elseif ($action == 'GROUP_MODIFY')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{
$ldap=new Ldap();
$ldap->connect_bind();
@ -364,7 +364,7 @@ class InterfaceLdapsynchro
elseif ($action == 'GROUP_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
if (! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
{
$ldap=new Ldap();
$ldap->connect_bind();

View File

@ -178,6 +178,8 @@ if ($result >= 0)
foreach ($ldaprecords as $key => $ldapuser)
{
$fuser = new User($db);
$fuser->fetch('','',$ldapuser[$conf->global->LDAP_KEY_USERS]); // Chargement du user concerné
// Propriete membre
$fuser->firstname=$ldapuser[$conf->global->LDAP_FIELD_FIRSTNAME];
@ -210,6 +212,7 @@ if ($result >= 0)
$fuser->fk_member=0;
$fuser->statut=1;
// TODO : revoir la gestion du status
/*if (isset($ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS]))
{
$fuser->datec=dol_stringtotime($ldapuser[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]);
@ -219,25 +222,44 @@ if ($result >= 0)
//if ($fuser->statut > 1) $fuser->statut=1;
//print_r($ldapuser);
// Group of user
// We should use here $groupid
// Creation member
print $langs->transnoentities("UserCreate").' # '.$key.': login='.$fuser->login.', fullname='.$fuser->getFullName($langs);
$fuser_id=$fuser->create($user);
if ($fuser_id > 0)
{
print ' --> Created member id='.$fuser_id.' login='.$fuser->login;
}
else
{
$error++;
print ' --> '.$fuser_id.' '.$fuser->error;
if($fuser->id > 0) { // User update
print $langs->transnoentities("UserUpdate").' # '.$key.': login='.$fuser->login.', fullname='.$fuser->getFullName($langs);
$res=$fuser->update($user);
if ($res < 0)
{
$error++;
print ' --> '.$res.' '.$fuser->error;
}
else
{
print ' --> Updated user id='.$fuser->id.' login='.$fuser->login;
}
} else { // User creation
print $langs->transnoentities("UserCreate").' # '.$key.': login='.$fuser->login.', fullname='.$fuser->getFullName($langs);
$res=$fuser->create($user);
if ($res > 0)
{
print ' --> Created user id='.$fuser->id.' login='.$fuser->login;
}
else
{
$error++;
print ' --> '.$res.' '.$fuser->error;
}
}
print "\n";
//print_r($fuser);
// Gestion des groupes
// TODO : revoir la gestion des groupes (ou script de sync groupes)
/*if(!$error) {
foreach ($ldapuser[$conf->global->LDAP_FIELD_USERGROUPS] as $groupdn) {
$groupdn;
}
}*/
}
if (! $error || $forcecommit)