diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php
index 94d8016b3b1..af3ff8abdc4 100644
--- a/htdocs/contact.class.php
+++ b/htdocs/contact.class.php
@@ -114,8 +114,11 @@ class Contact
// Fin appel triggers
// \todo Mettre en trigger
- $this->create_ldap($user);
-
+ if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE)
+ {
+ $this->create_ldap($user);
+ }
+
return $this->id;
}
else
@@ -188,7 +191,10 @@ class Contact
// Fin appel triggers
// \todo Mettre en trigger
- $this->update_ldap($user);
+ if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE)
+ {
+ $this->update_ldap($user);
+ }
}
@@ -257,7 +263,7 @@ class Contact
/**
- * \brief Mise à jour du contact dans l'arbre LDAP
+ * \brief Mise à jour dans l'arbre LDAP
* \param user Utilisateur qui effectue la mise à jour
* \return int <0 si ko, >0 si ok
*/
@@ -265,7 +271,7 @@ class Contact
{
global $conf, $langs;
- if (! $conf->ldap->enabled || ! $conf->global->LDAP_CONTACT_ACTIVE) return 0;
+ //if (! $conf->ldap->enabled || ! $conf->global->LDAP_CONTACT_ACTIVE) return 0;
$info = array();
@@ -626,8 +632,9 @@ class Contact
}
/*
- * \brief Efface le contact de la base et éventuellement de l'annuaire LDAP
- * \param id id du contact a effacer
+ * \brief Efface le contact de la base et éventuellement de l'annuaire LDAP
+ * \param id id du contact a effacer
+ * \return int <0 si ko, >0 si ok
*/
function delete($id)
{
@@ -664,19 +671,22 @@ class Contact
$result=$interface->run_triggers('CONTACT_DELETE',$this,$user,$langs,$conf);
// Fin appel triggers
-
// \todo Mettre en trigger
-
- // On modifie contact avec anciens noms
- $savname=$this->name;
- $savfirstname=$this->firstname;
- $this->name=$this->old_name;
- $this->firstname=$this->old_firstname;
-
- $this->delete_ldap($user);
-
- $this->name=$savname;
- $this->firstname=$savfirstname;
+ if ($conf->ldap->enabled && $conf->global->LDAP_CONTACT_ACTIVE)
+ {
+ // On modifie contact avec anciens noms
+ $savname=$this->name;
+ $savfirstname=$this->firstname;
+ $this->name=$this->old_name;
+ $this->firstname=$this->old_firstname;
+
+ $this->delete_ldap($user);
+
+ $this->name=$savname;
+ $this->firstname=$savfirstname;
+ }
+
+ return 1;
}
diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php
index 6f4d55366b5..e39d1803ca4 100644
--- a/htdocs/contact/ldap.php
+++ b/htdocs/contact/ldap.php
@@ -21,9 +21,9 @@
*/
/**
- \file htdocs/contact/exportimport.php
- \ingroup societe
- \brief Onglet exports-imports d'un contact
+ \file htdocs/contact/ldap.php
+ \ingroup ldap
+ \brief Page fiche LDAP contact
\version $Revision$
*/
@@ -127,15 +127,14 @@ print '
';
print_titre($langs->trans("LDAPInformationsForThisContact"));
-// Affichage actions sur contact
+// Affichage attributs LDAP
print '
| '.$langs->trans("LDAPAttribute").' | '; +print ''.$langs->trans("LDAPAttributes").' | '; print ''.$langs->trans("Value").' | '; print '|||||||||||||||||||||||||||||||||||||||||||||||
| '.$langs->trans("LDAPRecordNotFound").' | |||||||||||||||||||||||||||||||||||||||||||||||||
| '.$langs->trans("Login Boobkmark4u").' | '; + print "|||||||||||||||||||||||||||||||||||||||||||||||||
| '.$langs->trans("Login Bookmark4u").' | '; print '';
if ($bk4u->uid == 0)
diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php
index 4a9e43eb490..7053a89f6b1 100644
--- a/htdocs/user/clicktodial.php
+++ b/htdocs/user/clicktodial.php
@@ -27,7 +27,7 @@
*/
require("./pre.inc.php");
-require_once DOL_DOCUMENT_ROOT."/bookmark4u.class.php";
+require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
$langs->load("users");
@@ -64,43 +64,13 @@ if ($_GET["id"])
$fuser->fetch();
$fuser->fetch_clicktodial();
- $bk4u = new Bookmark4u($db);
- $bk4u->get_bk4u_uid($fuser);
- /*
- * Affichage onglets
- */
+ /*
+ * Affichage onglets
+ */
+ $head = user_prepare_head($fuser);
- $h = 0;
-
- $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id;
- $head[$h][1] = $langs->trans("UserCard");
- $h++;
-
- $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
- $head[$h][1] = $langs->trans("UserRights");
- $h++;
-
- $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$fuser->id;
- $head[$h][1] = $langs->trans("UserGUISetup");
- $h++;
-
- if ($conf->bookmark4u->enabled)
- {
- $head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
- $head[$h][1] = $langs->trans("Bookmark4u");
- $h++;
- }
-
- if ($conf->clicktodial->enabled)
- {
- $head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id;
- $head[$h][1] = $langs->trans("ClickToDial");
- $hselected=$h;
- $h++;
- }
-
- dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
+ dolibarr_fiche_head($head, 'clicktodial', $langs->trans("User").": ".$fuser->fullname);
/*
* Fiche en mode visu
diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php
index 475ee6ea182..bd7f3cbf57a 100644
--- a/htdocs/user/fiche.php
+++ b/htdocs/user/fiche.php
@@ -33,6 +33,7 @@
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php");
// Defini si peux creer un utilisateur ou gerer groupe sur un utilisateur
@@ -50,7 +51,6 @@ if ($_GET["id"])
$caneditpassword=( (($user->id == $_GET["id"]) && $user->rights->user->self->password)
|| (($user->id != $_GET["id"]) && $user->rights->user->user->password) );
}
-
if ($user->id <> $_GET["id"] && ! $canreadperms)
{
accessforbidden();
@@ -60,10 +60,10 @@ $langs->load("users");
$langs->load("companies");
$langs->load("ldap");
+$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
$form = new Form($db);
-$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
/**
@@ -116,7 +116,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
}
}
-//reactive un compte ldap
+// Reactive un compte ldap
if ($conf->ldap->enabled && $_GET["action"] == 'reactivate' && $candisableuser)
{
if ($_GET["id"] <> $user->id)
@@ -236,75 +236,75 @@ if ($_GET["action"] == 'removegroup' && $caneditfield)
}
}
-if ($_POST["action"] == 'update' && $caneditfield)
+if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $caneditfield)
{
- $message="";
+ $message="";
- $db->begin();
+ $db->begin();
- $edituser = new User($db, $_GET["id"]);
- $edituser->fetch();
-
- $edituser->oldpass = $edituser->pass;
+ $edituser = new User($db, $_GET["id"]);
+ $edituser->fetch();
- $edituser->nom = trim($_POST["nom"]);
- $edituser->prenom = trim($_POST["prenom"]);
- $edituser->login = trim($_POST["login"]);
- $edituser->pass = trim($_POST["pass"]);
- $edituser->admin = trim($_POST["admin"]);
- $edituser->office_phone = trim($_POST["office_phone"]);
- $edituser->office_fax = trim($_POST["office_fax"]);
- $edituser->user_mobile = trim($_POST["user_mobile"]);
- $edituser->email = trim($_POST["email"]);
- $edituser->note = trim($_POST["note"]);
- $edituser->webcal_login = trim($_POST["webcal_login"]);
+ $edituser->oldpass = $edituser->pass;
- $ret=$edituser->update();
- if ($ret < 0)
- {
- if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
- {
- $message.=' '.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).' ';
- }
- else
- {
- $message.=''.$edituser->error.' ';
- }
- }
- if ($ret >= 0 && isset($_POST["password"]) && $_POST["password"] !='' )
- {
- $ret=$edituser->password($user,$password,$conf->password_encrypted,1);
- if ($ret < 0)
- {
- $message.=''.$edituser->error.' ';
- }
- }
+ $edituser->nom = trim($_POST["nom"]);
+ $edituser->prenom = trim($_POST["prenom"]);
+ $edituser->login = trim($_POST["login"]);
+ $edituser->pass = trim($_POST["pass"]);
+ $edituser->admin = trim($_POST["admin"]);
+ $edituser->office_phone = trim($_POST["office_phone"]);
+ $edituser->office_fax = trim($_POST["office_fax"]);
+ $edituser->user_mobile = trim($_POST["user_mobile"]);
+ $edituser->email = trim($_POST["email"]);
+ $edituser->note = trim($_POST["note"]);
+ $edituser->webcal_login = trim($_POST["webcal_login"]);
- if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
- {
- // Si une photo est fournie avec le formulaire
- if (! is_dir($conf->users->dir_output))
- {
- create_exdir($conf->users->dir_output);
- }
- if (is_dir($conf->users->dir_output))
- {
- $newfile=$conf->users->dir_output . "/" . $edituser->id . ".jpg";
- if (! doliMoveFileUpload($_FILES['photo']['tmp_name'],$newfile))
- {
- $message .= ''.$langs->trans("ErrorFailedToSaveFile").' ';
- }
- }
- }
+ $ret=$edituser->update();
+ if ($ret < 0)
+ {
+ if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
+ {
+ $message.=''.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).' ';
+ }
+ else
+ {
+ $message.=''.$edituser->error.' ';
+ }
+ }
+ if ($ret >= 0 && isset($_POST["password"]) && $_POST["password"] !='' )
+ {
+ $ret=$edituser->password($user,$password,$conf->password_encrypted,1);
+ if ($ret < 0)
+ {
+ $message.=''.$edituser->error.' ';
+ }
+ }
- if ($ret >= 0)
- {
- $message.=''.$langs->trans("UserModified").' ';
- $db->commit();
- } else
- {
- $db->rollback;
- }
+ if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
+ {
+ // Si une photo est fournie avec le formulaire
+ if (! is_dir($conf->users->dir_output))
+ {
+ create_exdir($conf->users->dir_output);
+ }
+ if (is_dir($conf->users->dir_output))
+ {
+ $newfile=$conf->users->dir_output . "/" . $edituser->id . ".jpg";
+ if (! doliMoveFileUpload($_FILES['photo']['tmp_name'],$newfile))
+ {
+ $message .= ''.$langs->trans("ErrorFailedToSaveFile").' ';
+ }
+ }
+ }
+
+ if ($ret >= 0)
+ {
+ $message.=''.$langs->trans("UserModified").' ';
+ $db->commit();
+ } else
+ {
+ $db->rollback;
+ }
}
@@ -346,7 +346,9 @@ if ((($_POST["action"] == 'confirm_password' && $_POST["confirm"] == 'yes')
-
+/*
+ * Affichage page
+ */
llxHeader('',$langs->trans("UserCard"));
@@ -354,90 +356,108 @@ $html = new Form($db);
if (($action == 'create') || ($action == 'adduserldap'))
{
- /* ************************************************************************** */
- /* */
- /* Affichage fiche en mode création */
- /* */
- /* ************************************************************************** */
-
- print_titre($langs->trans("NewUser"));
- print ""; - + /* ************************************************************************** */ + /* */ + /* Affichage fiche en mode création */ + /* */ + /* ************************************************************************** */ + + print_titre($langs->trans("NewUser")); + print " "; + print $langs->trans("CreateInternalUserDesc"); - print " "; - print " "; + print " "; + print " "; + + if ($message) { print $message.' '; } + + /* + * Affiche formulaire d'ajout d'un compte depuis LDAP + * si on est en synchro LDAP vers Dolibarr + */ + if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') + { + $name = $conf->global->LDAP_FIELD_NAME; + $firstname = $conf->global->LDAP_FIELD_FIRSTNAME; + $mail = $conf->global->LDAP_FIELD_MAIL; + $phone = $conf->global->LDAP_FIELD_PHONE; + $fax = $conf->global->LDAP_FIELD_FAX; + $mobile = $conf->global->LDAP_FIELD_MOBILE; + $login = $conf->global->LDAP_FIELD_LOGIN_SAMBA; + $SID = "objectsid"; - if ($message) { print $message.' '; } - - /* - * ajout utilisateur ldap - */ - if ($conf->ldap->enabled) - { - if ($conf->global->LDAP_SERVER_HOST && $conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS) - { - $name = $conf->global->LDAP_FIELD_NAME; - $firstname = $conf->global->LDAP_FIELD_FIRSTNAME; - $mail = $conf->global->LDAP_FIELD_MAIL; - $phone = $conf->global->LDAP_FIELD_PHONE; - $fax = $conf->global->LDAP_FIELD_FAX; - $mobile = $conf->global->LDAP_FIELD_MOBILE; - $login = $conf->global->LDAP_FIELD_LOGIN_SAMBA; - $SID = "objectsid"; - - $ldap = new AuthLdap(); - - if ($ldap->connect()) - { - $justthese = array( $name, $firstname, $login); - $ldapusers = $ldap->getUsers('*', $justthese); - - if ($ldapusers) - { - $html = new Form($db); - - foreach ($ldapusers as $key => $ldapuser) - { - if($ldapuser[$name] != "") - $liste[$ldapuser[$login]] = utf8_decode($ldapuser[$name])." ".utf8_decode($ldapuser[$firstname]); - } - - print ''; - print " "; - } - - if ($action == 'adduserldap') - { - $selecteduser = $_POST['users']; - $justthese = array( $login, - $name, - $firstname, - $mail, - $phone, - $fax, - $mobile, - $SID); + $ldap = new AuthLdap(); - $selectedUser = $ldap->getUsers($selecteduser, $justthese); - - if ($selectedUser) - { - foreach ($selectedUser as $key => $attribute) - { - $ldap_nom = utf8_decode($attribute[$name]?$attribute[$name]:''); - $ldap_prenom = utf8_decode($attribute[$firstname]?$attribute[$firstname]:''); - $ldap_login = utf8_decode($attribute[$login]?$attribute[$login]:''); - $ldap_phone = utf8_decode($attribute[$phone]?$attribute[$phone]:''); - $ldap_fax = utf8_decode($attribute[$fax]?$attribute[$fax]:''); - $ldap_mobile = utf8_decode($attribute[$mobile]?$attribute[$mobile]:''); - $ldap_mail = utf8_decode($attribute[$mail]?$attribute[$mail]:''); - $ldap_SID = $attribute[$SID]; - //$ldap_SID = bin2hex($attribute[$SID]); - } + if ($ldap->connect()) + { + $bind=''; + if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS) + { + dolibarr_syslog("user/fiche.php authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG); + $bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS); + } + else + { + dolibarr_syslog("user/fiche.php bind",LOG_DEBUG); + $bind=$ldap->bind(); + } + if ($bind) + { + $justthese = array($name, $firstname, $login); + $ldapusers = $ldap->getUsers('*', $justthese); + + //print "eee".$justthese." r ".$ldapusers; + //print_r($justthese); + + foreach ($ldapusers as $key => $ldapuser) + { + if($ldapuser[$name] != "") + $liste[$ldapuser[$login]] = utf8_decode($ldapuser[$name])." ".utf8_decode($ldapuser[$firstname]); + } + + print ''; + print " "; + + // Action (a mettre dans actions) + if ($action == 'adduserldap') + { + $selecteduser = $_POST['users']; + $justthese = array( $login, + $name, + $firstname, + $mail, + $phone, + $fax, + $mobile, + $SID); + + $selectedUser = $ldap->getUsers($selecteduser, $justthese); + + if ($selectedUser) + { + foreach ($selectedUser as $key => $attribute) + { + $ldap_nom = utf8_decode($attribute[$name]?$attribute[$name]:''); + $ldap_prenom = utf8_decode($attribute[$firstname]?$attribute[$firstname]:''); + $ldap_login = utf8_decode($attribute[$login]?$attribute[$login]:''); + $ldap_phone = utf8_decode($attribute[$phone]?$attribute[$phone]:''); + $ldap_fax = utf8_decode($attribute[$fax]?$attribute[$fax]:''); + $ldap_mobile = utf8_decode($attribute[$mobile]?$attribute[$mobile]:''); + $ldap_mail = utf8_decode($attribute[$mail]?$attribute[$mail]:''); + $ldap_SID = $attribute[$SID]; + //$ldap_SID = bin2hex($attribute[$SID]); + } + } } } } @@ -446,158 +466,166 @@ if (($action == 'create') || ($action == 'adduserldap')) print $ldap->ldapErrorCode; print $ldap->ldapErrorText; } - if (!$ldap->close()) + if (! $ldap->close()) { print $ldap->ldapErrorCode; print $ldap->ldapErrorText; } } -} - - print '"; } else { @@ -660,40 +688,12 @@ else } } - /* - * Affichage onglets - */ - - $h = 0; - - $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id; - $head[$h][1] = $langs->trans("UserCard"); - $hselected=$h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id; - $head[$h][1] = $langs->trans("UserRights"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$fuser->id; - $head[$h][1] = $langs->trans("UserGUISetup"); - $h++; - - if ($conf->bookmark4u->enabled) - { - $head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id; - $head[$h][1] = $langs->trans("Bookmark4u"); - $h++; - } - - if ($conf->clicktodial->enabled) - { - $head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id; - $head[$h][1] = $langs->trans("ClickToDial"); - $h++; - } - - dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname); + /* + * Affichage onglets + */ + $head = user_prepare_head($fuser); + + dolibarr_fiche_head($head, 'user', $langs->trans("User").": ".$fuser->fullname); /* @@ -749,9 +749,11 @@ else { print '
'; + + +print_titre($langs->trans("LDAPInformationsForThisGroup")); + +// Affichage attributs LDAP +print '
'; + + +print_titre($langs->trans("LDAPInformationsForThisUser")); + +// Affichage attributs LDAP +print '
| ||||||||||||||||||||||||||||||||||||||||||||||||