New: Ajout de la gestion des triggers sur les actions sur les groupes
This commit is contained in:
parent
616fd81602
commit
2aa99d0fd9
@ -574,7 +574,7 @@ if ($action == 'create')
|
|||||||
print '<tr><td>'.$langs->trans("Password").'*</td><td><input type="password" name="member_pass" size="40" value="'.$adh->password.'"></td></tr>';
|
print '<tr><td>'.$langs->trans("Password").'*</td><td><input type="password" name="member_pass" size="40" value="'.$adh->password.'"></td></tr>';
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
print '<tr><td width="15%">'.$langs->trans("MemberType").'*</td><td width="35%">';
|
print '<tr><td">'.$langs->trans("MemberType").'*</td><td">';
|
||||||
$listetype=$adht->liste_array();
|
$listetype=$adht->liste_array();
|
||||||
if (sizeof($listetype)) {
|
if (sizeof($listetype)) {
|
||||||
$htmls->select_array("type", $listetype, $typeid);
|
$htmls->select_array("type", $listetype, $typeid);
|
||||||
@ -752,14 +752,14 @@ if ($rowid && $action != 'edit')
|
|||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
print '<tr><td>'.$langs->trans("Ref").'</td><td class="valeur" colspan="3">'.$adh->id.' </td></tr>';
|
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td class="valeur" colspan="3">'.$adh->id.' </td></tr>';
|
||||||
|
|
||||||
// Nom
|
// Nom
|
||||||
print '<tr><td>'.$langs->trans("Lastname").'*</td><td class="valeur">'.$adh->nom.' </td>';
|
print '<tr><td>'.$langs->trans("Lastname").'*</td><td class="valeur">'.$adh->nom.' </td>';
|
||||||
print '<td valign="top" width="50%">'.$langs->trans("Comments").'</td></tr>';
|
print '<td valign="top" width="50%">'.$langs->trans("Comments").'</td></tr>';
|
||||||
|
|
||||||
// Prenom
|
// Prenom
|
||||||
print '<tr><td width="15%">'.$langs->trans("Firstname").'*</td><td class="valeur" width="35%">'.$adh->prenom.' </td>';
|
print '<tr><td>'.$langs->trans("Firstname").'*</td><td class="valeur">'.$adh->prenom.' </td>';
|
||||||
print '<td rowspan="'.(13+count($adh->array_options)).'" valign="top" width="50%">';
|
print '<td rowspan="'.(13+count($adh->array_options)).'" valign="top" width="50%">';
|
||||||
print nl2br($adh->commentaire).' </td></tr>';
|
print nl2br($adh->commentaire).' </td></tr>';
|
||||||
|
|
||||||
|
|||||||
@ -93,7 +93,7 @@ dolibarr_fiche_head($head, 'ldap', $langs->trans("Member").": ".$adh->fullname);
|
|||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
print '<tr><td>'.$langs->trans("Ref").'</td><td class="valeur">'.$adh->id.' </td></tr>';
|
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td class="valeur">'.$adh->id.' </td></tr>';
|
||||||
|
|
||||||
// Nom
|
// Nom
|
||||||
print '<tr><td>'.$langs->trans("Lastname").'*</td><td class="valeur">'.$adh->nom.' </td>';
|
print '<tr><td>'.$langs->trans("Lastname").'*</td><td class="valeur">'.$adh->nom.' </td>';
|
||||||
@ -109,14 +109,18 @@ print '<tr><td>'.$langs->trans("Login").'*</td><td class="valeur">'.$adh->login.
|
|||||||
// Type
|
// Type
|
||||||
print '<tr><td>'.$langs->trans("Type").'*</td><td class="valeur">'.$adh->type."</td></tr>\n";
|
print '<tr><td>'.$langs->trans("Type").'*</td><td class="valeur">'.$adh->type."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP DN
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
print '<tr><td>'.$langs->trans("LDAPMemberDn").'*</td><td class="valeur">'.$conf->global->LDAP_MEMBER_DN."</td></tr>\n";
|
|
||||||
|
// LDAP DN
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPMemberDn").'</td><td class="valeur">'.$conf->global->LDAP_MEMBER_DN."</td></tr>\n";
|
||||||
|
|
||||||
|
// LDAP Clé
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_MEMBERS."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Server
|
// LDAP Server
|
||||||
print '<tr><td>'.$langs->trans("LDAPPrimaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
|
||||||
print '<tr><td>'.$langs->trans("LDAPSecondaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
|
||||||
print '<tr><td>'.$langs->trans("LDAPServerPort").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -116,19 +116,23 @@ print $form->civilite_name($contact->civilite_id);
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Nom
|
// Nom
|
||||||
print '<tr><td width="20%">'.$langs->trans("Lastname").'</td><td>'.$contact->name.'</td>';
|
print '<tr><td width="20%">'.$langs->trans("Lastname").'</td><td>'.$contact->name.'</td></tr>';
|
||||||
|
|
||||||
// Prenom
|
// Prenom
|
||||||
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->firstname.'</td></tr>';
|
print '<tr><td width="20%">'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->firstname.'</td></tr>';
|
||||||
|
|
||||||
|
$langs->load("admin");
|
||||||
|
|
||||||
// LDAP DN
|
// LDAP DN
|
||||||
$langs->load("admin");
|
print '<tr><td>LDAP '.$langs->trans("LDAPContactDn").'</td><td class="valeur">'.$conf->global->LDAP_CONTACT_DN."</td></tr>\n";
|
||||||
print '<tr><td>'.$langs->trans("LDAPContactDn").'*</td><td class="valeur">'.$conf->global->LDAP_CONTACT_DN."</td></tr>\n";
|
|
||||||
|
// LDAP Clé
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_CONTACTS."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Server
|
// LDAP Server
|
||||||
print '<tr><td>'.$langs->trans("LDAPPrimaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
|
||||||
print '<tr><td>'.$langs->trans("LDAPSecondaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
|
||||||
print '<tr><td>'.$langs->trans("LDAPServerPort").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -506,11 +506,11 @@ LDAPSynchronizeGroups=Synchronize Dolibarr groups with LDAP
|
|||||||
LDAPSynchronizeContacts=Synchronize Dolibarr contacts with LDAP
|
LDAPSynchronizeContacts=Synchronize Dolibarr contacts with LDAP
|
||||||
LDAPSynchronizeMembers=Synchronize members of Dolibarr fundation module with LDAP
|
LDAPSynchronizeMembers=Synchronize members of Dolibarr fundation module with LDAP
|
||||||
LDAPTypeExample=OpenLdap, Egroupware or Active Directory
|
LDAPTypeExample=OpenLdap, Egroupware or Active Directory
|
||||||
LDAPPrimaryServer=LDAP primary server
|
LDAPPrimaryServer=Primary server
|
||||||
LDAPSecondaryServer=LDAP secondary server
|
LDAPSecondaryServer=Secondary server
|
||||||
LDAPServerPort=LDAP server port
|
LDAPServerPort=Server port
|
||||||
LDAPServerPortExample=Default port : 389
|
LDAPServerPortExample=Default port : 389
|
||||||
LDAPServerProtocolVersion=LDAP protocol version
|
LDAPServerProtocolVersion=Protocol version
|
||||||
LDAPServerUseTLS=Use TLS
|
LDAPServerUseTLS=Use TLS
|
||||||
LDAPServerUseTLSExample=Your LDAP server use TLS
|
LDAPServerUseTLSExample=Your LDAP server use TLS
|
||||||
LDAPServerDn=Server DN
|
LDAPServerDn=Server DN
|
||||||
|
|||||||
@ -508,9 +508,9 @@ LDAPSynchronizeMembers=Synchronisation des membres du module adh
|
|||||||
LDAPTypeExample=OpenLdap, Egroupware ou Active Directory
|
LDAPTypeExample=OpenLdap, Egroupware ou Active Directory
|
||||||
LDAPPrimaryServer=Serveur primaire
|
LDAPPrimaryServer=Serveur primaire
|
||||||
LDAPSecondaryServer=Serveur secondaire
|
LDAPSecondaryServer=Serveur secondaire
|
||||||
LDAPServerPort=Port du serveur LDAP
|
LDAPServerPort=Port du serveur
|
||||||
LDAPServerPortExample=Port par défaut : 389
|
LDAPServerPortExample=Port par défaut : 389
|
||||||
LDAPServerProtocolVersion=Version du protocole LDAP
|
LDAPServerProtocolVersion=Version du protocole
|
||||||
LDAPServerUseTLS=Utiliser TLS
|
LDAPServerUseTLS=Utiliser TLS
|
||||||
LDAPServerUseTLSExample=Votre serveur utilise le TLS
|
LDAPServerUseTLSExample=Votre serveur utilise le TLS
|
||||||
LDAPServerDn=DN du serveur
|
LDAPServerDn=DN du serveur
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||||
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
|
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
|
||||||
* Copyright (C) 2005 Lionel COUSTEIX <etm_ltd@tiscali.co.uk>
|
* Copyright (C) 2005 Lionel COUSTEIX <etm_ltd@tiscali.co.uk>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -37,6 +37,7 @@
|
|||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once (DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +48,7 @@
|
|||||||
class User
|
class User
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
|
|
||||||
var $id;
|
var $id;
|
||||||
var $ldap_sid;
|
var $ldap_sid;
|
||||||
var $fullname;
|
var $fullname;
|
||||||
@ -72,12 +73,12 @@ class User
|
|||||||
var $datepreviouslogin;
|
var $datepreviouslogin;
|
||||||
var $statut;
|
var $statut;
|
||||||
var $lang;
|
var $lang;
|
||||||
|
|
||||||
var $error;
|
var $error;
|
||||||
var $userpref_limite_liste;
|
var $userpref_limite_liste;
|
||||||
var $all_permissions_are_loaded; /**< \private all_permissions_are_loaded */
|
var $all_permissions_are_loaded; /**< \private all_permissions_are_loaded */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructeur de la classe
|
* \brief Constructeur de la classe
|
||||||
* \param DB Handler accès base de données
|
* \param DB Handler accès base de données
|
||||||
@ -87,11 +88,11 @@ class User
|
|||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
// Preference utilisateur
|
// Preference utilisateur
|
||||||
$this->liste_limit = 0;
|
$this->liste_limit = 0;
|
||||||
$this->clicktodial_enabled = 0;
|
$this->clicktodial_enabled = 0;
|
||||||
|
|
||||||
$this->all_permissions_are_loaded = 0;
|
$this->all_permissions_are_loaded = 0;
|
||||||
$this->admin=0;
|
$this->admin=0;
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ class User
|
|||||||
{
|
{
|
||||||
$sql .= " WHERE u.rowid = ".$this->id;
|
$sql .= " WHERE u.rowid = ".$this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
dolibarr_syslog("User.class::fetch this->id=".$this->id." login=".$login);
|
dolibarr_syslog("User.class::fetch this->id=".$this->id." login=".$login);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
@ -136,7 +137,7 @@ class User
|
|||||||
$this->ldap_sid = $obj->ldap_sid;
|
$this->ldap_sid = $obj->ldap_sid;
|
||||||
$this->nom = $obj->name;
|
$this->nom = $obj->name;
|
||||||
$this->prenom = $obj->firstname;
|
$this->prenom = $obj->firstname;
|
||||||
|
|
||||||
$this->fullname = trim($this->prenom . ' ' . $this->nom);
|
$this->fullname = trim($this->prenom . ' ' . $this->nom);
|
||||||
$this->code = $obj->code;
|
$this->code = $obj->code;
|
||||||
$this->login = $obj->login;
|
$this->login = $obj->login;
|
||||||
@ -150,19 +151,19 @@ class User
|
|||||||
$this->note = $obj->note;
|
$this->note = $obj->note;
|
||||||
$this->statut = $obj->statut;
|
$this->statut = $obj->statut;
|
||||||
$this->lang = $obj->lang;
|
$this->lang = $obj->lang;
|
||||||
|
|
||||||
$this->datec = $obj->datec;
|
$this->datec = $obj->datec;
|
||||||
$this->datem = $obj->datem;
|
$this->datem = $obj->datem;
|
||||||
$this->datelastlogin = $obj->datel;
|
$this->datelastlogin = $obj->datel;
|
||||||
$this->datepreviouslogin = $obj->datep;
|
$this->datepreviouslogin = $obj->datep;
|
||||||
|
|
||||||
$this->webcal_login = $obj->webcal_login;
|
$this->webcal_login = $obj->webcal_login;
|
||||||
$this->societe_id = $obj->fk_societe;
|
$this->societe_id = $obj->fk_societe;
|
||||||
|
|
||||||
if (! $this->lang) $this->lang='fr_FR';
|
if (! $this->lang) $this->lang='fr_FR';
|
||||||
}
|
}
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -170,7 +171,7 @@ class User
|
|||||||
dolibarr_syslog("User.class::fetch Error -1, fails to get user - ".$this->error." - sql=".$sql);
|
dolibarr_syslog("User.class::fetch Error -1, fails to get user - ".$this->error." - sql=".$sql);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recupere parametrage global propre à l'utilisateur
|
// Recupere parametrage global propre à l'utilisateur
|
||||||
// \todo a stocker/recupérer en session pour eviter ce select a chaque page
|
// \todo a stocker/recupérer en session pour eviter ce select a chaque page
|
||||||
$sql = "SELECT param, value FROM ".MAIN_DB_PREFIX."user_param";
|
$sql = "SELECT param, value FROM ".MAIN_DB_PREFIX."user_param";
|
||||||
@ -198,7 +199,7 @@ class User
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recupere parametrage propre à la page et à l'utilisateur
|
// Recupere parametrage propre à la page et à l'utilisateur
|
||||||
// \todo SCRIPT_URL non defini sur tous serveurs
|
// \todo SCRIPT_URL non defini sur tous serveurs
|
||||||
// Paramétrage par page desactivé pour l'instant
|
// Paramétrage par page desactivé pour l'instant
|
||||||
if (1==2 && isset($_SERVER['SCRIPT_URL']))
|
if (1==2 && isset($_SERVER['SCRIPT_URL']))
|
||||||
{
|
{
|
||||||
@ -228,10 +229,10 @@ class User
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ajoute un droit a l'utilisateur
|
* \brief Ajoute un droit a l'utilisateur
|
||||||
* \param rid id du droit à ajouter
|
* \param rid id du droit à ajouter
|
||||||
@ -244,10 +245,10 @@ class User
|
|||||||
dolibarr_syslog("User::addrights $rid, $allmodule, $allperms");
|
dolibarr_syslog("User::addrights $rid, $allmodule, $allperms");
|
||||||
$err=0;
|
$err=0;
|
||||||
$whereforadd='';
|
$whereforadd='';
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
if ($rid)
|
if ($rid)
|
||||||
{
|
{
|
||||||
// Si on a demandé ajout d'un droit en particulier, on récupère
|
// Si on a demandé ajout d'un droit en particulier, on récupère
|
||||||
// les caractéristiques (module, perms et subperms) de ce droit.
|
// les caractéristiques (module, perms et subperms) de ce droit.
|
||||||
@ -255,7 +256,7 @@ class User
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
|
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
|
||||||
$sql.= " WHERE ";
|
$sql.= " WHERE ";
|
||||||
$sql.=" id = '".$rid."'";
|
$sql.=" id = '".$rid."'";
|
||||||
|
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
@ -287,7 +288,7 @@ class User
|
|||||||
$sql = "SELECT id";
|
$sql = "SELECT id";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
|
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
|
||||||
$sql.= " WHERE $whereforadd";
|
$sql.= " WHERE $whereforadd";
|
||||||
|
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@ -297,22 +298,22 @@ class User
|
|||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
$nid = $obj->id;
|
$nid = $obj->id;
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = $this->id AND fk_id=$nid";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = $this->id AND fk_id=$nid";
|
||||||
if (! $this->db->query($sql)) $err++;
|
if (! $this->db->query($sql)) $err++;
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (fk_user, fk_id) VALUES ($this->id, $nid)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (fk_user, fk_id) VALUES ($this->id, $nid)";
|
||||||
if (! $this->db->query($sql)) $err++;
|
if (! $this->db->query($sql)) $err++;
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$err++;
|
$err++;
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($err) {
|
if ($err) {
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -$err;
|
return -$err;
|
||||||
@ -321,7 +322,7 @@ class User
|
|||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -336,10 +337,10 @@ class User
|
|||||||
{
|
{
|
||||||
$err=0;
|
$err=0;
|
||||||
$wherefordel='';
|
$wherefordel='';
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
if ($rid)
|
if ($rid)
|
||||||
{
|
{
|
||||||
// Si on a demandé supression d'un droit en particulier, on récupère
|
// Si on a demandé supression d'un droit en particulier, on récupère
|
||||||
// les caractéristiques module, perms et subperms de ce droit.
|
// les caractéristiques module, perms et subperms de ce droit.
|
||||||
@ -347,7 +348,7 @@ class User
|
|||||||
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
|
$sql.= " FROM ".MAIN_DB_PREFIX."rights_def";
|
||||||
$sql.= " WHERE ";
|
$sql.= " WHERE ";
|
||||||
$sql.=" id = '".$rid."'";
|
$sql.=" id = '".$rid."'";
|
||||||
|
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
@ -389,20 +390,20 @@ class User
|
|||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
$nid = $obj->id;
|
$nid = $obj->id;
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = $this->id AND fk_id=$nid";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = $this->id AND fk_id=$nid";
|
||||||
if (! $this->db->query($sql)) $err++;
|
if (! $this->db->query($sql)) $err++;
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$err++;
|
$err++;
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($err) {
|
if ($err) {
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -$err;
|
return -$err;
|
||||||
@ -425,7 +426,7 @@ class User
|
|||||||
// Si les permissions ont déja été chargé pour ce user, on quitte
|
// Si les permissions ont déja été chargé pour ce user, on quitte
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Récupération des droits utilisateurs + récupération des droits groupes
|
// Récupération des droits utilisateurs + récupération des droits groupes
|
||||||
|
|
||||||
// D'abord les droits utilisateurs
|
// D'abord les droits utilisateurs
|
||||||
@ -441,7 +442,7 @@ class User
|
|||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row($result);
|
$row = $this->db->fetch_row($result);
|
||||||
|
|
||||||
if ($row[1])
|
if ($row[1])
|
||||||
{
|
{
|
||||||
if ($row[2])
|
if ($row[2])
|
||||||
@ -457,18 +458,18 @@ class User
|
|||||||
{
|
{
|
||||||
$this->rights->$row[0]->$row[1] = 1;
|
$this->rights->$row[0]->$row[1] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maintenant les droits groupes
|
// Maintenant les droits groupes
|
||||||
$sql = " SELECT r.module, r.perms, r.subperms";
|
$sql = " SELECT r.module, r.perms, r.subperms";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."usergroup_rights as gr, ".MAIN_DB_PREFIX."usergroup_user as gu, ".MAIN_DB_PREFIX."rights_def as r";
|
$sql .= " FROM ".MAIN_DB_PREFIX."usergroup_rights as gr, ".MAIN_DB_PREFIX."usergroup_user as gu, ".MAIN_DB_PREFIX."rights_def as r";
|
||||||
$sql .= " WHERE r.id = gr.fk_id AND gr.fk_usergroup = gu.fk_usergroup AND gu.fk_user = ".$this->id." AND r.perms IS NOT NULL";
|
$sql .= " WHERE r.id = gr.fk_id AND gr.fk_usergroup = gu.fk_usergroup AND gu.fk_user = ".$this->id." AND r.perms IS NOT NULL";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@ -477,10 +478,10 @@ class User
|
|||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row($result);
|
$row = $this->db->fetch_row($result);
|
||||||
|
|
||||||
if (strlen($row[1]) > 0)
|
if (strlen($row[1]) > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (strlen($row[2]) > 0)
|
if (strlen($row[2]) > 0)
|
||||||
{
|
{
|
||||||
$this->rights->$row[0]->$row[1]->$row[2] = 1;
|
$this->rights->$row[0]->$row[1]->$row[2] = 1;
|
||||||
@ -489,20 +490,20 @@ class User
|
|||||||
{
|
{
|
||||||
$this->rights->$row[0]->$row[1] = 1;
|
$this->rights->$row[0]->$row[1] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($module == '')
|
if ($module == '')
|
||||||
{
|
{
|
||||||
// Si module etait non defini, alors on a tout chargé, on peut donc considérer
|
// Si module etait non defini, alors on a tout chargé, on peut donc considérer
|
||||||
// que les droits sont en cache (car tous chargés) pour cet instance de user
|
// que les droits sont en cache (car tous chargés) pour cet instance de user
|
||||||
$this->all_permissions_are_loaded=1;
|
$this->all_permissions_are_loaded=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -513,9 +514,9 @@ class User
|
|||||||
function setstatus($statut)
|
function setstatus($statut)
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Désactive utilisateur
|
// Désactive utilisateur
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
||||||
$sql.= " SET statut = ".$statut;
|
$sql.= " SET statut = ".$statut;
|
||||||
@ -543,20 +544,26 @@ class User
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Supprime complètement un utilisateur
|
* \brief Supprime complètement un utilisateur
|
||||||
*/
|
*/
|
||||||
function delete()
|
function delete()
|
||||||
{
|
{
|
||||||
|
global $conf,$langs;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$this->fetch();
|
||||||
|
|
||||||
// Supprime droits
|
// Supprime droits
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = $this->id";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id;
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si contact, supprime lien
|
// Si contact, supprime lien
|
||||||
if ($this->contact_id)
|
if ($this->contact_id)
|
||||||
{
|
{
|
||||||
@ -570,8 +577,33 @@ class User
|
|||||||
// Supprime utilisateur
|
// Supprime utilisateur
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = $this->id";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = $this->id";
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('USER_DELETE',$this,$user,$lang,$conf);
|
||||||
|
if ($result < 0) $error++;
|
||||||
|
// Fin appel triggers
|
||||||
|
|
||||||
|
// \todo Mettre en trigger
|
||||||
|
if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||||
|
{
|
||||||
|
$this->delete_ldap($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Crée un utilisateur en base
|
* \brief Crée un utilisateur en base
|
||||||
@ -580,10 +612,10 @@ class User
|
|||||||
function create()
|
function create()
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
// Nettoyage parametres
|
// Nettoyage parametres
|
||||||
$this->login = trim($this->login);
|
$this->login = trim($this->login);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user";
|
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user";
|
||||||
@ -593,7 +625,7 @@ class User
|
|||||||
{
|
{
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
$this->error = $langs->trans("ErrorLoginAlreadyExists");
|
$this->error = $langs->trans("ErrorLoginAlreadyExists");
|
||||||
@ -603,20 +635,20 @@ class User
|
|||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user (datec,login,ldap_sid) VALUES(now(),'".addslashes($this->login)."','".$this->ldap_sid."')";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user (datec,login,ldap_sid) VALUES(now(),'".addslashes($this->login)."','".$this->ldap_sid."')";
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$table = "".MAIN_DB_PREFIX."user";
|
$table = "".MAIN_DB_PREFIX."user";
|
||||||
$this->id = $this->db->last_insert_id($table);
|
$this->id = $this->db->last_insert_id($table);
|
||||||
|
|
||||||
// Set default rights
|
// Set default rights
|
||||||
if ($this->set_default_rights() < 0)
|
if ($this->set_default_rights() < 0)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update minor fields
|
// Update minor fields
|
||||||
if ($this->update() < 0)
|
if ($this->update() < 0)
|
||||||
{
|
{
|
||||||
@ -624,14 +656,14 @@ class User
|
|||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
$result=$interface->run_triggers('USER_CREATE',$this,$user,$lang,$conf);
|
$result=$interface->run_triggers('USER_CREATE',$this,$user,$lang,$conf);
|
||||||
if ($result < 0) $error++;
|
if ($result < 0) $error++;
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
// \todo Mettre en trigger
|
// \todo Mettre en trigger
|
||||||
if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE)
|
if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||||
{
|
{
|
||||||
@ -675,7 +707,7 @@ class User
|
|||||||
function create_from_contact($contact)
|
function create_from_contact($contact)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
// Positionne paramètres
|
// Positionne paramètres
|
||||||
$this->nom = $contact->nom;
|
$this->nom = $contact->nom;
|
||||||
$this->prenom = $contact->prenom;
|
$this->prenom = $contact->prenom;
|
||||||
@ -684,12 +716,12 @@ class User
|
|||||||
$this->admin = 0;
|
$this->admin = 0;
|
||||||
|
|
||||||
$this->email = $contact->email;
|
$this->email = $contact->email;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Crée et positionne $this->id
|
// Crée et positionne $this->id
|
||||||
$result=$this->create();
|
$result=$this->create();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
||||||
@ -703,7 +735,7 @@ class User
|
|||||||
$sql.= " SET fk_user = ".$this->id;
|
$sql.= " SET fk_user = ".$this->id;
|
||||||
$sql.= " WHERE idp = ".$contact->id;
|
$sql.= " WHERE idp = ".$contact->id;
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
|
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
@ -716,7 +748,7 @@ class User
|
|||||||
|
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -735,7 +767,7 @@ class User
|
|||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -745,7 +777,7 @@ class User
|
|||||||
function set_default_rights()
|
function set_default_rights()
|
||||||
{
|
{
|
||||||
$sql = "SELECT id FROM ".MAIN_DB_PREFIX."rights_def WHERE bydefault = 1";
|
$sql = "SELECT id FROM ".MAIN_DB_PREFIX."rights_def WHERE bydefault = 1";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows();
|
||||||
@ -762,16 +794,16 @@ class User
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = $this->id AND fk_id=$rd[$i]";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = $this->id AND fk_id=$rd[$i]";
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (fk_user, fk_id) VALUES ($this->id, $rd[$i])";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (fk_user, fk_id) VALUES ($this->id, $rd[$i])";
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
if (! $result) return -1;
|
if (! $result) return -1;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $i;
|
return $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -783,12 +815,12 @@ class User
|
|||||||
function update($create=0)
|
function update($create=0)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
// Nettoyage parametres
|
// Nettoyage parametres
|
||||||
$this->nom=trim($this->nom);
|
$this->nom=trim($this->nom);
|
||||||
$this->prenom=trim($this->prenom);
|
$this->prenom=trim($this->prenom);
|
||||||
$this->login=trim($this->login);
|
$this->login=trim($this->login);
|
||||||
|
|
||||||
if ($conf->global->DATABASE_PWD_ENCRYPTED && $this->oldpass != $this->pass)
|
if ($conf->global->DATABASE_PWD_ENCRYPTED && $this->oldpass != $this->pass)
|
||||||
{
|
{
|
||||||
$this->pass = md5($this->pass);
|
$this->pass = md5($this->pass);
|
||||||
@ -797,12 +829,12 @@ class User
|
|||||||
{
|
{
|
||||||
$this->pass=trim($this->pass);
|
$this->pass=trim($this->pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->email=trim($this->email);
|
$this->email=trim($this->email);
|
||||||
$this->note=trim($this->note);
|
$this->note=trim($this->note);
|
||||||
$this->admin=$this->admin?$this->admin:0;
|
$this->admin=$this->admin?$this->admin:0;
|
||||||
if (!strlen($this->code)) $this->code = $this->login;
|
if (!strlen($this->code)) $this->code = $this->login;
|
||||||
|
|
||||||
dolibarr_syslog("User::update nom=".$this->nom.", prenom=".$this->prenom);
|
dolibarr_syslog("User::update nom=".$this->nom.", prenom=".$this->prenom);
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
@ -841,7 +873,7 @@ class User
|
|||||||
$this->update_ldap($user);
|
$this->update_ldap($user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -865,7 +897,7 @@ class User
|
|||||||
dolibarr_syslog ("Mise a jour date derniere connexion pour user->id=".$this->id);
|
dolibarr_syslog ("Mise a jour date derniere connexion pour user->id=".$this->id);
|
||||||
|
|
||||||
$now=time();
|
$now=time();
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
|
||||||
$sql.= " datepreviouslogin = datelastlogin,";
|
$sql.= " datepreviouslogin = datelastlogin,";
|
||||||
$sql.= " datelastlogin = ".$this->db->idate($now).",";
|
$sql.= " datelastlogin = ".$this->db->idate($now).",";
|
||||||
@ -884,8 +916,8 @@ class User
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Change le mot de passe d'un utilisateur
|
* \brief Change le mot de passe d'un utilisateur
|
||||||
* \param user Object user de l'utilisateur qui fait la modification
|
* \param user Object user de l'utilisateur qui fait la modification
|
||||||
@ -897,14 +929,14 @@ class User
|
|||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$longueurmotdepasse=8;
|
$longueurmotdepasse=8;
|
||||||
|
|
||||||
dolibarr_syslog("User.class::password user=".$user." password=--hidden-- isencrypted=".$isencrypted);
|
dolibarr_syslog("User.class::password user=".$user." password=--hidden-- isencrypted=".$isencrypted);
|
||||||
|
|
||||||
if (! $password)
|
if (! $password)
|
||||||
{
|
{
|
||||||
$password = strtolower(substr(md5(uniqid(rand())),0,$longueurmotdepasse));
|
$password = strtolower(substr(md5(uniqid(rand())),0,$longueurmotdepasse));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($isencrypted)
|
if ($isencrypted)
|
||||||
{
|
{
|
||||||
// Crypte avec systeme encodage par defaut du PHP
|
// Crypte avec systeme encodage par defaut du PHP
|
||||||
@ -917,7 +949,7 @@ class User
|
|||||||
}
|
}
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET pass = '".addslashes($sqlpass)."'";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET pass = '".addslashes($sqlpass)."'";
|
||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@ -955,12 +987,12 @@ class User
|
|||||||
function send_password($user, $password='')
|
function send_password($user, $password='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php";
|
require_once DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php";
|
||||||
|
|
||||||
$subject = $langs->trans("SubjectNewPassword");
|
$subject = $langs->trans("SubjectNewPassword");
|
||||||
$msgishtml=0;
|
$msgishtml=0;
|
||||||
|
|
||||||
$mesg .= "Bonjour,\n\n";
|
$mesg .= "Bonjour,\n\n";
|
||||||
$mesg .= "Votre mot de passe pour accéder à Dolibarr a été changé :\n\n";
|
$mesg .= "Votre mot de passe pour accéder à Dolibarr a été changé :\n\n";
|
||||||
$mesg .= $langs->trans("Login")." : $this->login\n";
|
$mesg .= $langs->trans("Login")." : $this->login\n";
|
||||||
@ -995,21 +1027,21 @@ class User
|
|||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Lecture des infos de click to dial
|
* \brief Lecture des infos de click to dial
|
||||||
*/
|
*/
|
||||||
function fetch_clicktodial()
|
function fetch_clicktodial()
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "SELECT login, pass, poste FROM ".MAIN_DB_PREFIX."user_clicktodial as u";
|
$sql = "SELECT login, pass, poste FROM ".MAIN_DB_PREFIX."user_clicktodial as u";
|
||||||
$sql .= " WHERE u.fk_user = ".$this->id;
|
$sql .= " WHERE u.fk_user = ".$this->id;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows())
|
if ($this->db->num_rows())
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object();
|
$obj = $this->db->fetch_object();
|
||||||
|
|
||||||
@ -1017,8 +1049,8 @@ class User
|
|||||||
$this->clicktodial_password = $obj->pass;
|
$this->clicktodial_password = $obj->pass;
|
||||||
$this->clicktodial_poste = $obj->poste;
|
$this->clicktodial_poste = $obj->poste;
|
||||||
|
|
||||||
if (strlen(trim($this->clicktodial_login)) &&
|
if (strlen(trim($this->clicktodial_login)) &&
|
||||||
strlen(trim($this->clicktodial_password)) &&
|
strlen(trim($this->clicktodial_password)) &&
|
||||||
strlen(trim($this->clicktodial_poste)))
|
strlen(trim($this->clicktodial_poste)))
|
||||||
{
|
{
|
||||||
$this->clicktodial_enabled = 1;
|
$this->clicktodial_enabled = 1;
|
||||||
@ -1039,7 +1071,7 @@ class User
|
|||||||
*/
|
*/
|
||||||
function update_clicktodial()
|
function update_clicktodial()
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_clicktodial";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_clicktodial";
|
||||||
$sql .= " WHERE fk_user = ".$this->id;
|
$sql .= " WHERE fk_user = ".$this->id;
|
||||||
|
|
||||||
@ -1051,10 +1083,10 @@ class User
|
|||||||
$sql .= ", '". $this->clicktodial_login ."'";
|
$sql .= ", '". $this->clicktodial_login ."'";
|
||||||
$sql .= ", '". $this->clicktodial_password ."'";
|
$sql .= ", '". $this->clicktodial_password ."'";
|
||||||
$sql .= ", '". $this->clicktodial_poste."')";
|
$sql .= ", '". $this->clicktodial_poste."')";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1075,12 +1107,12 @@ class User
|
|||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user";
|
||||||
$sql .= " WHERE fk_user = ".$this->id;
|
$sql .= " WHERE fk_user = ".$this->id;
|
||||||
$sql .= " AND fk_usergroup = ".$group;
|
$sql .= " AND fk_usergroup = ".$group;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_user (fk_user, fk_usergroup)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_user (fk_user, fk_usergroup)";
|
||||||
$sql .= " VALUES (".$this->id.",".$group.")";
|
$sql .= " VALUES (".$this->id.",".$group.")";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1094,7 +1126,7 @@ class User
|
|||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user";
|
||||||
$sql .= " WHERE fk_user = ".$this->id;
|
$sql .= " WHERE fk_user = ".$this->id;
|
||||||
$sql .= " AND fk_usergroup = ".$group;
|
$sql .= " AND fk_usergroup = ".$group;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1107,9 +1139,9 @@ class User
|
|||||||
function getNomUrl($withpicto=0,$option='')
|
function getNomUrl($withpicto=0,$option='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$result='';
|
$result='';
|
||||||
|
|
||||||
$lien = '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$this->id.'">';
|
$lien = '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$this->id.'">';
|
||||||
$lienfin='</a>';
|
$lienfin='</a>';
|
||||||
|
|
||||||
@ -1123,7 +1155,7 @@ class User
|
|||||||
$result.=$lien.$this->nom.' '.$this->prenom.$lienfin;
|
$result.=$lien.$this->nom.' '.$this->prenom.$lienfin;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie login clicable (avec eventuellement le picto)
|
* \brief Renvoie login clicable (avec eventuellement le picto)
|
||||||
* \param withpicto Inclut le picto dans le lien
|
* \param withpicto Inclut le picto dans le lien
|
||||||
@ -1133,9 +1165,9 @@ class User
|
|||||||
function getLoginUrl($withpicto=0,$option='')
|
function getLoginUrl($withpicto=0,$option='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$result='';
|
$result='';
|
||||||
|
|
||||||
$lien = '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$this->id.'">';
|
$lien = '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$this->id.'">';
|
||||||
$lienfin='</a>';
|
$lienfin='</a>';
|
||||||
|
|
||||||
@ -1149,7 +1181,7 @@ class User
|
|||||||
$result.=$lien.$this->login.$lienfin;
|
$result.=$lien.$this->login.$lienfin;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retourne le libellé du statut d'un user (actif, inactif)
|
* \brief Retourne le libellé du statut d'un user (actif, inactif)
|
||||||
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long
|
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long
|
||||||
@ -1202,7 +1234,7 @@ class User
|
|||||||
if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
|
if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
|
||||||
if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1216,7 +1248,7 @@ class User
|
|||||||
return $this->update_ldap($user);
|
return $this->update_ldap($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Mise à jour dans l'arbre LDAP
|
* \brief Mise à jour dans l'arbre LDAP
|
||||||
* \param user Utilisateur qui effectue la mise à jour
|
* \param user Utilisateur qui effectue la mise à jour
|
||||||
@ -1231,7 +1263,7 @@ class User
|
|||||||
$info = array();
|
$info = array();
|
||||||
|
|
||||||
dolibarr_syslog("User.class::update_ldap this->id=".$this->id,LOG_DEBUG);
|
dolibarr_syslog("User.class::update_ldap this->id=".$this->id,LOG_DEBUG);
|
||||||
|
|
||||||
$ldap=new AuthLdap();
|
$ldap=new AuthLdap();
|
||||||
$result=$ldap->connect();
|
$result=$ldap->connect();
|
||||||
if ($result)
|
if ($result)
|
||||||
@ -1265,13 +1297,13 @@ class User
|
|||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
$this->error = ldap_errno($ldap->connection)." ".ldap_error($ldap->connection)." ".$ldap->error;
|
$this->error = ldap_errno($ldap->connection)." ".ldap_error($ldap->connection)." ".$ldap->error;
|
||||||
dolibarr_syslog("User.class::update_ldap ".$this->error,LOG_ERROR);
|
dolibarr_syslog("User.class::update_ldap ".$this->error,LOG_ERROR);
|
||||||
//print_r($info);
|
//print_r($info);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("User.class::update_ldap rowid=".$this->id." added in LDAP");
|
dolibarr_syslog("User.class::update_ldap rowid=".$this->id." added in LDAP");
|
||||||
}
|
}
|
||||||
|
|
||||||
$ldap->unbind();
|
$ldap->unbind();
|
||||||
@ -1306,7 +1338,7 @@ class User
|
|||||||
//if (! $conf->ldap->enabled || ! $conf->global->LDAP_SYNCHRO_ACTIVE) return 0;
|
//if (! $conf->ldap->enabled || ! $conf->global->LDAP_SYNCHRO_ACTIVE) return 0;
|
||||||
|
|
||||||
dolibarr_syslog("User.class::delete_ldap this->id=".$this->id,LOG_DEBUG);
|
dolibarr_syslog("User.class::delete_ldap this->id=".$this->id,LOG_DEBUG);
|
||||||
|
|
||||||
$ldap=new AuthLdap();
|
$ldap=new AuthLdap();
|
||||||
$result=$ldap->connect();
|
$result=$ldap->connect();
|
||||||
if ($result)
|
if ($result)
|
||||||
@ -1322,14 +1354,14 @@ class User
|
|||||||
dolibarr_syslog("User.class::delete_ldap bind",LOG_DEBUG);
|
dolibarr_syslog("User.class::delete_ldap bind",LOG_DEBUG);
|
||||||
$bind=$ldap->bind();
|
$bind=$ldap->bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bind)
|
if ($bind)
|
||||||
{
|
{
|
||||||
$info=$this->_load_ldap_info($info);
|
$info=$this->_load_ldap_info($info);
|
||||||
|
|
||||||
$dn = $conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS].",".$conf->global->LDAP_USER_DN;
|
$dn = $conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS].",".$conf->global->LDAP_USER_DN;
|
||||||
$result=$ldap->delete($dn);
|
$result=$ldap->delete($dn);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1340,13 +1372,13 @@ class User
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _load_ldap_info($info)
|
function _load_ldap_info($info)
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
|
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
|
||||||
{
|
{
|
||||||
$info["objectclass"]=array("top",
|
$info["objectclass"]=array("top",
|
||||||
"person",
|
"person",
|
||||||
@ -1359,9 +1391,9 @@ class User
|
|||||||
"person",
|
"person",
|
||||||
"organizationalPerson",
|
"organizationalPerson",
|
||||||
"inetOrgPerson");
|
"inetOrgPerson");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Champs
|
// Champs
|
||||||
if ($this->fullname && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname;
|
if ($this->fullname && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname;
|
||||||
if ($this->nom && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom;
|
if ($this->nom && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom;
|
||||||
if ($this->prenom && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->prenom;
|
if ($this->prenom && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->prenom;
|
||||||
@ -1371,7 +1403,7 @@ class User
|
|||||||
{
|
{
|
||||||
$soc = new Societe($this->db);
|
$soc = new Societe($this->db);
|
||||||
$soc->fetch($this->societe_id);
|
$soc->fetch($this->societe_id);
|
||||||
|
|
||||||
$info["o"] = $soc->nom;
|
$info["o"] = $soc->nom;
|
||||||
if ($soc->client == 1) $info["businessCategory"] = "Customers";
|
if ($soc->client == 1) $info["businessCategory"] = "Customers";
|
||||||
if ($soc->client == 2) $info["businessCategory"] = "Prospects";
|
if ($soc->client == 2) $info["businessCategory"] = "Prospects";
|
||||||
@ -1386,36 +1418,36 @@ class User
|
|||||||
if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax;
|
if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax;
|
||||||
if ($this->note) $info["description"] = $this->note;
|
if ($this->note) $info["description"] = $this->note;
|
||||||
if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
|
if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
|
||||||
|
|
||||||
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
|
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
|
||||||
{
|
{
|
||||||
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
|
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
|
||||||
|
|
||||||
$info['uidnumber'] = $this->id;
|
$info['uidnumber'] = $this->id;
|
||||||
|
|
||||||
$info['phpgwTz'] = 0;
|
$info['phpgwTz'] = 0;
|
||||||
$info['phpgwMailType'] = 'INTERNET';
|
$info['phpgwMailType'] = 'INTERNET';
|
||||||
$info['phpgwMailHomeType'] = 'INTERNET';
|
$info['phpgwMailHomeType'] = 'INTERNET';
|
||||||
|
|
||||||
$info["phpgwContactTypeId"] = 'n';
|
$info["phpgwContactTypeId"] = 'n';
|
||||||
$info["phpgwContactCatId"] = 0;
|
$info["phpgwContactCatId"] = 0;
|
||||||
$info["phpgwContactAccess"] = "public";
|
$info["phpgwContactAccess"] = "public";
|
||||||
|
|
||||||
if (strlen($this->egroupware_id) == 0)
|
if (strlen($this->egroupware_id) == 0)
|
||||||
{
|
{
|
||||||
$this->egroupware_id = 1;
|
$this->egroupware_id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$info["phpgwContactOwner"] = $this->egroupware_id;
|
$info["phpgwContactOwner"] = $this->egroupware_id;
|
||||||
|
|
||||||
if ($this->email) $info["rfc822Mailbox"] = $this->email;
|
if ($this->email) $info["rfc822Mailbox"] = $this->email;
|
||||||
if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
|
if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialise le user avec valeurs fictives aléatoire
|
* \brief Initialise le user avec valeurs fictives aléatoire
|
||||||
*/
|
*/
|
||||||
@ -1467,7 +1499,7 @@ class User
|
|||||||
|
|
||||||
$socid = rand(1, $num_socs);
|
$socid = rand(1, $num_socs);
|
||||||
$this->societe_id = $socids[$socid];
|
$this->societe_id = $socids[$socid];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -109,7 +109,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
|
|||||||
if ($_GET["id"] <> $user->id)
|
if ($_GET["id"] <> $user->id)
|
||||||
{
|
{
|
||||||
$edituser = new User($db, $_GET["id"]);
|
$edituser = new User($db, $_GET["id"]);
|
||||||
$edituser->fetch($_GET["id"]);
|
$edituser->id=$_GET["id"];
|
||||||
$edituser->delete();
|
$edituser->delete();
|
||||||
Header("Location: index.php");
|
Header("Location: index.php");
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@ -85,14 +85,18 @@ print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>';
|
|||||||
print '<td class="valeur">'.nl2br($fgroup->note).' </td>';
|
print '<td class="valeur">'.nl2br($fgroup->note).' </td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
// LDAP DN
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
print '<tr><td>'.$langs->trans("LDAPGroupDn").'*</td><td class="valeur">'.$conf->global->LDAP_GROUP_DN."</td></tr>\n";
|
|
||||||
|
// LDAP DN
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPGroupDn").'</td><td class="valeur">'.$conf->global->LDAP_GROUP_DN."</td></tr>\n";
|
||||||
|
|
||||||
|
// LDAP Clé
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_GROUPS."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Server
|
// LDAP Server
|
||||||
print '<tr><td>'.$langs->trans("LDAPPrimaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
|
||||||
print '<tr><td>'.$langs->trans("LDAPSecondaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
|
||||||
print '<tr><td>'.$langs->trans("LDAPServerPort").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
||||||
|
|||||||
@ -100,14 +100,18 @@ else
|
|||||||
}
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// LDAP DN
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
print '<tr><td>'.$langs->trans("LDAPUserDn").'*</td><td class="valeur">'.$conf->global->LDAP_USER_DN."</td></tr>\n";
|
|
||||||
|
// LDAP DN
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPUserDn").'</td><td class="valeur">'.$conf->global->LDAP_USER_DN."</td></tr>\n";
|
||||||
|
|
||||||
|
// LDAP Clé
|
||||||
|
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_USERS."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Server
|
// LDAP Server
|
||||||
print '<tr><td>'.$langs->trans("LDAPPrimaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
|
||||||
print '<tr><td>'.$langs->trans("LDAPSecondaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
|
||||||
print '<tr><td>'.$langs->trans("LDAPServerPort").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,9 @@
|
|||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once (DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class UserGroup
|
\class UserGroup
|
||||||
\brief Classe permettant la gestion des groupes d'utilisateur
|
\brief Classe permettant la gestion des groupes d'utilisateur
|
||||||
@ -336,37 +339,53 @@ class UserGroup
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Efface un groupe de la base
|
* \brief Efface un groupe de la base
|
||||||
* \return < 0 si erreur, > 0 si ok
|
* \return < 0 si erreur, > 0 si ok
|
||||||
*/
|
*/
|
||||||
function delete()
|
function delete()
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
global $conf,$langs;
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights";
|
$this->db->begin();
|
||||||
$sql .= " WHERE fk_usergroup = ".$this->id;
|
|
||||||
$this->db->query($sql);
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights";
|
||||||
|
$sql .= " WHERE fk_usergroup = ".$this->id;
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user";
|
$this->db->query($sql);
|
||||||
$sql .= " WHERE fk_usergroup = ".$this->id;
|
|
||||||
$this->db->query($sql);
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user";
|
||||||
|
$sql .= " WHERE fk_usergroup = ".$this->id;
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup";
|
$this->db->query($sql);
|
||||||
$sql .= " WHERE rowid = ".$this->id;
|
|
||||||
$result=$this->db->query($sql);
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup";
|
||||||
if ($result)
|
$sql .= " WHERE rowid = ".$this->id;
|
||||||
{
|
$result=$this->db->query($sql);
|
||||||
$this->db->commit();
|
if ($result)
|
||||||
return 1;
|
{
|
||||||
}
|
// Appel des triggers
|
||||||
else
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
{
|
$interface=new Interfaces($this->db);
|
||||||
$this->db->rollback();
|
$result=$interface->run_triggers('USER_DELETE',$this,$user,$lang,$conf);
|
||||||
dolibarr_print_error($this->db);
|
if ($result < 0) $error++;
|
||||||
return -1;
|
// Fin appel triggers
|
||||||
}
|
|
||||||
}
|
// \todo Mettre en trigger
|
||||||
|
if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||||
|
{
|
||||||
|
$this->delete_ldap($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Crée un groupe en base
|
* \brief Crée un groupe en base
|
||||||
@ -613,10 +632,8 @@ class UserGroup
|
|||||||
"inetOrgPerson");
|
"inetOrgPerson");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Champs
|
// Champs
|
||||||
if ($this->fullname && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname;
|
if ($this->nom && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->nom;
|
||||||
if ($this->name && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->name;
|
|
||||||
if ($this->firstname && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->firstname;
|
|
||||||
if ($this->note) $info["description"] = $this->note;
|
if ($this->note) $info["description"] = $this->note;
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user