diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 85a0628dc2e..24670b24b31 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -21,13 +21,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/** +/** * \file htdocs/user/fiche.php * \brief Onglet user et permissions de la fiche utilisateur * \version $Id$ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/user.class.php"); +require_once(DOL_DOCUMENT_ROOT."/usergroup.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php"); if ($conf->ldap->enabled) require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php"); @@ -42,11 +44,11 @@ $candisableperms=($user->admin || $user->rights->user->user->supprimer); // Defini si peux lire/modifier info user ou mot de passe if ($_GET["id"]) { - // $user est le user qui edite, $_GET["id"] est l'id de l'utilisateur edite - $caneditfield=( (($user->id == $_GET["id"]) && $user->rights->user->self->creer) - || (($user->id != $_GET["id"]) && $user->rights->user->user->creer) ); - $caneditpassword=( (($user->id == $_GET["id"]) && $user->rights->user->self->password) - || (($user->id != $_GET["id"]) && $user->rights->user->user->password) ); + // $user est le user qui edite, $_GET["id"] est l'id de l'utilisateur edite + $caneditfield=( (($user->id == $_GET["id"]) && $user->rights->user->self->creer) + || (($user->id != $_GET["id"]) && $user->rights->user->user->creer) ); + $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) { @@ -68,59 +70,59 @@ $form = new Form($db); */ if ($_GET["subaction"] == 'addrights' && $caneditperms) { - $edituser = new User($db,$_GET["id"]); - $edituser->addrights($_GET["rights"]); + $edituser = new User($db,$_GET["id"]); + $edituser->addrights($_GET["rights"]); } if ($_GET["subaction"] == 'delrights' && $caneditperms) { - $edituser = new User($db,$_GET["id"]); - $edituser->delrights($_GET["rights"]); + $edituser = new User($db,$_GET["id"]); + $edituser->delrights($_GET["rights"]); } if ($_POST["action"] == 'confirm_disable' && $_POST["confirm"] == "yes") { - if ($_GET["id"] <> $user->id) - { - $edituser = new User($db); + if ($_GET["id"] <> $user->id) + { + $edituser = new User($db); $edituser->id=$_GET["id"]; - $edituser->fetch(); - $edituser->setstatus(0); + $edituser->fetch(); + $edituser->setstatus(0); Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]); - exit; - } + exit; + } } if ($_POST["action"] == 'confirm_enable' && $_POST["confirm"] == "yes") { - if ($_GET["id"] <> $user->id) - { - $edituser = new User($db, $_GET["id"]); + if ($_GET["id"] <> $user->id) + { + $edituser = new User($db, $_GET["id"]); $edituser->id=$_GET["id"]; - $edituser->fetch(); - $edituser->setstatus(1); - Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]); - exit; - } + $edituser->fetch(); + $edituser->setstatus(1); + Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]); + exit; + } } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") { - if ($_GET["id"] <> $user->id) - { - $edituser = new User($db, $_GET["id"]); - $edituser->id=$_GET["id"]; - $result = $edituser->delete(); - if ($result < 0) - { + if ($_GET["id"] <> $user->id) + { + $edituser = new User($db, $_GET["id"]); + $edituser->id=$_GET["id"]; + $result = $edituser->delete(); + if ($result < 0) + { $langs->load("errors"); - $message='
'.$langs->trans("UserCannotBeDelete").'
'; - } - else - { - Header("Location: index.php"); - exit; - } - } + $message='
'.$langs->trans("UserCannotBeDelete").'
'; + } + else + { + Header("Location: index.php"); + exit; + } + } } // Action ajout user @@ -153,30 +155,30 @@ if ($_POST["action"] == 'add' && $canadduser) $edituser->phenix_pass = $_POST["phenix_pass"]; $edituser->note = $_POST["note"]; $edituser->ldap_sid = $_POST["ldap_sid"]; - + $db->begin(); - + $id = $edituser->create($user); - + if ($id > 0) { if (isset($_POST['password']) && trim($_POST['password'])) { $edituser->setPassword($user,trim($_POST['password']),$conf->global->DATABASE_PWD_ENCRYPTED); } - + $db->commit(); - + Header("Location: fiche.php?id=$id"); exit; } else { $db->rollback(); - + //$message='
'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'
'; $message='
'.$edituser->error.'
'; - + $action="create"; // Go back to create page } @@ -186,26 +188,26 @@ if ($_POST["action"] == 'add' && $canadduser) // Action ajout groupe utilisateur if ($_POST["action"] == 'addgroup' && $caneditfield) { - if ($_POST["group"]) - { - $edituser = new User($db, $_GET["id"]); - $edituser->SetInGroup($_POST["group"]); + if ($_POST["group"]) + { + $edituser = new User($db, $_GET["id"]); + $edituser->SetInGroup($_POST["group"]); - Header("Location: fiche.php?id=".$_GET["id"]); - exit; - } + Header("Location: fiche.php?id=".$_GET["id"]); + exit; + } } if ($_GET["action"] == 'removegroup' && $caneditfield) { - if ($_GET["group"]) - { - $edituser = new User($db, $_GET["id"]); - $edituser->RemoveFromGroup($_GET["group"]); + if ($_GET["group"]) + { + $edituser = new User($db, $_GET["id"]); + $edituser->RemoveFromGroup($_GET["group"]); - Header("Location: fiche.php?id=".$_GET["id"]); - exit; - } + Header("Location: fiche.php?id=".$_GET["id"]); + exit; + } } if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $caneditfield) @@ -296,38 +298,38 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $caneditfield) // Action modif mot de passe if ((($_POST["action"] == 'confirm_password' && $_POST["confirm"] == 'yes') - || $_GET["action"] == 'confirm_passwordsend') && $caneditpassword) +|| $_GET["action"] == 'confirm_passwordsend') && $caneditpassword) { - $edituser = new User($db, $_GET["id"]); - $edituser->fetch(); + $edituser = new User($db, $_GET["id"]); + $edituser->fetch(); - $newpassword=$edituser->setPassword($user,''); - if ($newpassword < 0) - { - // Echec - $message = '
'.$langs->trans("ErrorFailedToSaveFile").'
'; - } - else - { - // Succes - if ($_GET["action"] == 'confirm_passwordsend') - { - if ($edituser->send_password($user,$newpassword) > 0) - { - $message = '
'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'
'; - //$message.=$newpassword; - } - else - { - $message = '
'.$langs->trans("PasswordChangedTo",$newpassword).'
'; - $message.= '
'.$edituser->error.'
'; - } - } - else - { - $message = '
'.$langs->trans("PasswordChangedTo",$newpassword).'
'; - } - } + $newpassword=$edituser->setPassword($user,''); + if ($newpassword < 0) + { + // Echec + $message = '
'.$langs->trans("ErrorFailedToSaveFile").'
'; + } + else + { + // Succes + if ($_GET["action"] == 'confirm_passwordsend') + { + if ($edituser->send_password($user,$newpassword) > 0) + { + $message = '
'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'
'; + //$message.=$newpassword; + } + else + { + $message = '
'.$langs->trans("PasswordChangedTo",$newpassword).'
'; + $message.= '
'.$edituser->error.'
'; + } + } + else + { + $message = '
'.$langs->trans("PasswordChangedTo",$newpassword).'
'; + } + } } // Action initialisation donnees depuis record LDAP @@ -336,17 +338,17 @@ if ($_POST["action"] == 'adduserldap') $selecteduser = $_POST['users']; $required_fields = array( - $conf->global->LDAP_FIELD_NAME, - $conf->global->LDAP_FIELD_FIRSTNAME, - $conf->global->LDAP_FIELD_LOGIN, - $conf->global->LDAP_FIELD_LOGIN_SAMBA, - $conf->global->LDAP_FIELD_PASSWORD, - $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, - $conf->global->LDAP_FIELD_PHONE, - $conf->global->LDAP_FIELD_FAX, - $conf->global->LDAP_FIELD_MOBILE, - $conf->global->LDAP_FIELD_MAIL, - $conf->global->LDAP_FIELD_SID); + $conf->global->LDAP_FIELD_NAME, + $conf->global->LDAP_FIELD_FIRSTNAME, + $conf->global->LDAP_FIELD_LOGIN, + $conf->global->LDAP_FIELD_LOGIN_SAMBA, + $conf->global->LDAP_FIELD_PASSWORD, + $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, + $conf->global->LDAP_FIELD_PHONE, + $conf->global->LDAP_FIELD_FAX, + $conf->global->LDAP_FIELD_MOBILE, + $conf->global->LDAP_FIELD_MAIL, + $conf->global->LDAP_FIELD_SID); $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -399,10 +401,10 @@ if (($action == 'create') || ($action == 'adduserldap')) /* Affichage fiche en mode creation */ /* */ /* ************************************************************************** */ - + print_titre($langs->trans("NewUser")); print "
"; - + print $langs->trans("CreateInternalUserDesc"); print "
"; print "
"; @@ -410,24 +412,24 @@ if (($action == 'create') || ($action == 'adduserldap')) if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { /* - * Affiche formulaire d'ajout d'un compte depuis LDAP - * si on est en synchro LDAP vers Dolibarr - */ + * Affiche formulaire d'ajout d'un compte depuis LDAP + * si on est en synchro LDAP vers Dolibarr + */ $ldap = new Ldap(); $result = $ldap->connect_bind(); if ($result >= 0) { $required_fields=array($conf->global->LDAP_KEY_USERS, - $conf->global->LDAP_FIELD_FULLNAME, - $conf->global->LDAP_FIELD_NAME, - $conf->global->LDAP_FIELD_FIRSTNAME, - $conf->global->LDAP_FIELD_LOGIN, - $conf->global->LDAP_FIELD_LOGIN_SAMBA); - + $conf->global->LDAP_FIELD_FULLNAME, + $conf->global->LDAP_FIELD_NAME, + $conf->global->LDAP_FIELD_FIRSTNAME, + $conf->global->LDAP_FIELD_LOGIN, + $conf->global->LDAP_FIELD_LOGIN_SAMBA); + // Remove from required_fields all entries not configured in LDAP (empty) and duplicated $required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement"))); - + // Get from LDAP database an array of results $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1); if (is_array($ldapusers)) @@ -446,7 +448,7 @@ if (($action == 'create') || ($action == 'adduserldap')) } $liste[$key] = $label; } - + } else { @@ -458,16 +460,16 @@ if (($action == 'create') || ($action == 'adduserldap')) $message='
'.$ldap->error.'
'; } } - + if ($message) { print $message.'
'; } - + if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { // Si la liste des users est rempli, on affiche la liste deroulante if (is_array($liste)) { print "\n\n\n"; - + print '
'; print ''; print ''; + if ($fuser->ldap_sid && $fuser->statut==0) { - if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login && !$fuser->ldap_sid) - { - print ''.$langs->trans("ReinitPassword").''; - } - - if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->email && $fuser->login && !$fuser->ldap_sid) - { - print ''.$langs->trans("SendNewPassword").''; - } + print ''; + } + else + { + print ''; + } + print ''; + print ''; + + // Password + print ''; + if ($fuser->ldap_sid) + { + if ($passDoNotExpire) + { + print ''; + } + else if($userChangePassNextLogon) + { + print ''; + } + else if($userDisabled) + { + print ''; + } + else + { + print ''; + } + } + else + { + print '"; + } + print "\n"; + + // Administrateur + print ''; + print ''; + print "\n"; + + // Type + print ''; + print ''; + + // Company / Contact + print ''; + print ''; + print "\n"; + + // Tel pro + print ''; + print ''; + + // Tel mobile + print ''; + print ''; + + // Fax + print ''; + print ''; + + // EMail + print ''; + print ''; + print "\n"; + + // Statut + print ''; + print ''; + + print ''; + print ''; + print "\n"; + + print ''; + print ''; + print "\n"; + + // Autres caracteristiques issus des autres modules + + // Module Webcalendar + if ($conf->webcal->enabled) + { + $langs->load("other"); + print ''; + print ''; + print "\n"; } - // Activer - if ($user->id <> $_GET["id"] && $candisableperms && $fuser->statut == 0) - { - print ''.$langs->trans("Reactivate").''; - } - // Desactiver - if ($user->id <> $_GET["id"] && $candisableperms && $fuser->statut == 1) - { - print ''.$langs->trans("DisableUser").''; - } + // Module Phenix + if ($conf->phenix->enabled) + { + $langs->load("other"); + print ''; + print ''; + print "\n"; + print ''; + print ''; + print "\n"; + } - if ($user->id <> $_GET["id"] && $candisableperms) - { - print ''.$langs->trans("DeleteUser").''; - } + // Module Adherent + if ($conf->adherent->enabled) + { + $langs->load("members"); + print ''; + print ''; + print "\n"; + } - print "\n"; - print "
\n"; + print "
'; @@ -485,13 +487,13 @@ if (($action == 'create') || ($action == 'adduserldap')) print '
'; } } - + print ''; print ''; if ($ldap_sid) print ''; - + print ''; - + print ''; // Nom @@ -507,7 +509,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; } print ''; - + // Prenom print ''; print ''; - + // Login print ''; print ''; - + if (!$ldap_sid) { $generated_password=''; @@ -555,7 +557,7 @@ if (($action == 'create') || ($action == 'adduserldap')) } } $password=$generated_password; - + // Mot de passe print ''; print ''; - + // Administrateur if ($user->admin) { @@ -585,13 +587,13 @@ if (($action == 'create') || ($action == 'adduserldap')) print $form->selectyesno('admin',0,1); print "\n"; } - + // Type print ''; print ''; - + // Tel print ''; print ''; - + // Tel portable print ''; print ''; - + // Fax print ''; print ''; - + // EMail print ''; print ''; - + // Note print '\n"; - + // Autres caracteristiques issus des autres modules - + // Module Webcalendar if ($conf->webcal->enabled) { print "".''; print ''; } - + // Module Phenix if ($conf->phenix->enabled) { @@ -682,770 +684,760 @@ if (($action == 'create') || ($action == 'adduserldap')) print "".''; print ''; } - + print "".''; print "
'.$langs->trans("Firstname").''; @@ -521,7 +523,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; } print '
'.$langs->trans("Login").'*'; @@ -540,7 +542,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; } print '
'.$langs->trans("Password").''; @@ -576,7 +578,7 @@ if (($action == 'create') || ($action == 'adduserldap')) } } print '
'.$langs->trans("Type").''; print $html->textwithhelp($langs->trans("Internal"),$langs->trans("InternalExternalDesc")); print '
'.$langs->trans("PhonePro").''; @@ -605,7 +607,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; } print '
'.$langs->trans("PhoneMobile").''; @@ -619,7 +621,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; } print '
'.$langs->trans("Fax").''; @@ -633,7 +635,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; } print '
'.$langs->trans("EMail").''; @@ -647,7 +649,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; } print '
'; print $langs->trans("Note"); @@ -664,16 +666,16 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; } print "
'.$langs->trans("LoginWebcal").'
'.$langs->trans("PassPenix").'
\n"; print ""; } else { - /* ************************************************************************** */ - /* */ - /* Visu et edition */ - /* */ - /* ************************************************************************** */ + /* ************************************************************************** */ + /* */ + /* Visu et edition */ + /* */ + /* ************************************************************************** */ - if ($_GET["id"]) - { - $fuser = new User($db, $_GET["id"]); - $fuser->fetch(); + if ($_GET["id"]) + { + $fuser = new User($db, $_GET["id"]); + $fuser->fetch(); - // Connexion ldap - // pour recuperer passDoNotExpire et userChangePassNextLogon - if ($conf->ldap->enabled && $fuser->ldap_sid) - { - $ldap = new Ldap(); - $result=$ldap->connect_bind(); - if ($result > 0) - { - $entries = $ldap->fetch($fuser->login); - if (! $entries) - { - $message .= $ldap->error; - } - - $passDoNotExpire = 0; - $userChangePassNextLogon = 0; - $userDisabled = 0; - $statutUACF = ''; + // Connexion ldap + // pour recuperer passDoNotExpire et userChangePassNextLogon + if ($conf->ldap->enabled && $fuser->ldap_sid) + { + $ldap = new Ldap(); + $result=$ldap->connect_bind(); + if ($result > 0) + { + $entries = $ldap->fetch($fuser->login); + if (! $entries) + { + $message .= $ldap->error; + } + + $passDoNotExpire = 0; + $userChangePassNextLogon = 0; + $userDisabled = 0; + $statutUACF = ''; - //On verifie les options du compte - if (sizeof($ldap->uacf) > 0) - { - foreach ($ldap->uacf as $key => $statut) - { - if ($key == 65536) - { - $passDoNotExpire = 1; - $statutUACF = $statut; - } - } - } - else - { - $userDisabled = 1; - $statutUACF = "ACCOUNTDISABLE"; - } - - if ($ldap->pwdlastset == 0) - { - $userChangePassNextLogon = 1; - } - } - } + //On verifie les options du compte + if (sizeof($ldap->uacf) > 0) + { + foreach ($ldap->uacf as $key => $statut) + { + if ($key == 65536) + { + $passDoNotExpire = 1; + $statutUACF = $statut; + } + } + } + else + { + $userDisabled = 1; + $statutUACF = "ACCOUNTDISABLE"; + } + + if ($ldap->pwdlastset == 0) + { + $userChangePassNextLogon = 1; + } + } + } /* * Affichage onglets */ $head = user_prepare_head($fuser); - + dolibarr_fiche_head($head, 'user', $langs->trans("User")); - /* - * Confirmation reinitialisation mot de passe - */ - if ($action == 'password') - { - $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$fuser->login),"confirm_password"); - print '
'; - } + /* + * Confirmation reinitialisation mot de passe + */ + if ($action == 'password') + { + $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$fuser->login),"confirm_password"); + print '
'; + } - /* - * Confirmation envoi mot de passe - */ - if ($action == 'passwordsend') - { - $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$fuser->login),"confirm_passwordsend"); - print '
'; - } + /* + * Confirmation envoi mot de passe + */ + if ($action == 'passwordsend') + { + $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$fuser->login),"confirm_passwordsend"); + print '
'; + } - /* - * Confirmation desactivation - */ - if ($action == 'disable') - { - $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable"); - print '
'; - } + /* + * Confirmation desactivation + */ + if ($action == 'disable') + { + $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable"); + print '
'; + } - /* - * Confirmation activation - */ - if ($action == 'enable') - { - $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$fuser->login),"confirm_enable"); - print '
'; - } + /* + * Confirmation activation + */ + if ($action == 'enable') + { + $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$fuser->login),"confirm_enable"); + print '
'; + } - /* - * Confirmation suppression - */ - if ($action == 'delete') - { - $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete"); - print '
'; - } + /* + * Confirmation suppression + */ + if ($action == 'delete') + { + $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete"); + print '
'; + } - /* - * Fiche en mode visu - */ - if ($_GET["action"] != 'edit') - { - print ''; + /* + * Fiche en mode visu + */ + if ($_GET["action"] != 'edit') + { + print '
'; - // Ref - print ''; - print ''; + print ''; print ''; - // Nom - print ''; - print ''; - print "\n"; + // Nom + print ''; + print ''; + print "\n"; - // Prenom - print ''; - print ''; - print "\n"; + // Prenom + print ''; + print ''; + print "\n"; - $rowspan=12; + $rowspan=12; // Login - print ''; - if ($fuser->ldap_sid && $fuser->statut==0) - { - print ''; - } - else - { - print ''; - } - print ''; - print ''; - - // Password - print ''; - if ($fuser->ldap_sid) - { - if ($passDoNotExpire) - { - print ''; - } - else if($userChangePassNextLogon) - { - print ''; - } - else if($userDisabled) - { - print ''; - } - else - { - print ''; - } - } - else - { - print '"; - } - print "\n"; - - // Administrateur - print ''; - print ''; - print "\n"; - - // Type - print ''; - print ''; - - // Company / Contact - print ''; - print ''; - print "\n"; - - // Tel pro - print ''; - print ''; - - // Tel mobile - print ''; - print ''; - - // Fax - print ''; - print ''; - - // EMail - print ''; - print ''; - print "\n"; - - // Statut - print ''; - print ''; - - print ''; - print ''; - print "\n"; - - print ''; - print ''; - print "\n"; - - // Autres caracteristiques issus des autres modules - - // Module Webcalendar - if ($conf->webcal->enabled) - { - $langs->load("other"); - print ''; - print ''; - print "\n"; - } - - // Module Phenix - if ($conf->phenix->enabled) - { - $langs->load("other"); - print ''; - print ''; - print "\n"; - print ''; - print ''; - print "\n"; - } - - // Module Adherent - if ($conf->adherent->enabled) - { - $langs->load("members"); - print ''; - print ''; - print "\n"; - } - - print "
'.$langs->trans("Ref").''; + // Ref + print '
'.$langs->trans("Ref").''; print $html->showrefnav($fuser,'id','',$user->rights->user->user->lire || $user->admin); print '
'.$langs->trans("Lastname").''.$fuser->nom.'
'.$langs->trans("Lastname").''.$fuser->nom.'
'.$langs->trans("Firstname").''.$fuser->prenom.'
'.$langs->trans("Firstname").''.$fuser->prenom.'
'.$langs->trans("Login").''.$langs->trans("LoginAccountDisableInDolibarr").''.$fuser->login.''; - if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg")) - { - print ''; - } - else - { - print ''; - } - print '
'.$langs->trans("Password").''.$langs->trans("LdapUacf_".$statutUACF).''.$langs->trans("UserMustChangePassNextLogon",$ldap->domainFQDN).''.$langs->trans("LdapUacf_".$statutUACF,$ldap->domainFQDN).''.$langs->trans("DomainPassword").''; - if ($fuser->pass) print eregi_replace('.','*',$fuser->pass); - else - { - if ($user->admin) print $langs->trans("Crypted").': '.$fuser->pass_indatabase_crypted; - else print $langs->trans("Hidden"); - } - print "
'.$langs->trans("Administrator").''.yn($fuser->admin); - if ($fuser->admin) print ' '.img_picto($langs->trans("Administrator"),"star"); - print '
'.$langs->trans("Type").''; - if ($fuser->societe_id) - { - print $html->textwithhelp($langs->trans("External"),$langs->trans("InternalExternalDesc")); - } - else if ($fuser->ldap_sid) - { - print $langs->trans("DomainUser",$ldap->domainFQDN); - } - else - { - print $html->textwithhelp($langs->trans("Internal"),$langs->trans("InternalExternalDesc")); - } - print '
'.$langs->trans("Company").' / '.$langs->trans("Contact").''; - if ($fuser->societe_id > 0) - { - $societe = new Societe($db); - $societe->fetch($fuser->societe_id); - print ''.img_object($langs->trans("ShowCompany"),'company').' '.dolibarr_trunc($societe->nom,32).''; - } - else - { - print $langs->trans("ThisUserIsNot"); - } - if ($fuser->contact_id) - { - $contact = new Contact($db); - $contact->fetch($fuser->contact_id); - if ($fuser->societe_id > 0) print ' / '; - else print '
'; - print ''.img_object($langs->trans("ShowContact"),'contact').' '.dolibarr_trunc($contact->getFullName($langs),32).''; - } - print '
'.$langs->trans("PhonePro").''.$fuser->office_phone.'
'.$langs->trans("PhoneMobile").''.$fuser->user_mobile.'
'.$langs->trans("Fax").''.$fuser->office_fax.'
'.$langs->trans("EMail").''.$fuser->email.'
'.$langs->trans("Status").''; - print $fuser->getLibStatut(4); - print '
'.$langs->trans("LastConnexion").''.dolibarr_print_date($fuser->datelastlogin,"dayhour").'
'.$langs->trans("PreviousConnexion").''.dolibarr_print_date($fuser->datepreviouslogin,"dayhour").'
'.$langs->trans("LoginWebcal").''.$fuser->webcal_login.' 
'.$langs->trans("LoginPhenix").''.$fuser->phenix_login.' 
'.$langs->trans("PassPhenix").''.eregi_replace('.','*',$fuser->phenix_pass_crypted).' 
'.$langs->trans("MemberAccount").''; - if ($fuser->fk_member) - { - $adh=new Adherent($db); - $adh->fetch($fuser->fk_member); - $adh->ref=$adh->login; // Force to show login instead of id - print $adh->getNomUrl(1); - } - else - { - print $langs->trans("UserNotLinkedToMember"); - } - print '
\n"; - - print "\n"; - - if ($message) { print $message; } - - - /* - * Barre d'actions - */ - - print '
'; - - - if ($caneditfield) - { - print ''.$langs->trans("Modify").''; - } - elseif ($caneditpassword && ! $fuser->ldap_sid) - { - print ''.$langs->trans("EditPassword").''; - } - - // Si on a un gestionnaire de generation de mot de passe actif - if ($conf->global->USER_PASSWORD_GENERATED != 'none') + print '
'.$langs->trans("Login").''.$langs->trans("LoginAccountDisableInDolibarr").''.$fuser->login.''; + if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg")) + { + print ''; + } + else + { + print ''; + } + print '
'.$langs->trans("Password").''.$langs->trans("LdapUacf_".$statutUACF).''.$langs->trans("UserMustChangePassNextLogon",$ldap->domainFQDN).''.$langs->trans("LdapUacf_".$statutUACF,$ldap->domainFQDN).''.$langs->trans("DomainPassword").''; + if ($fuser->pass) print eregi_replace('.','*',$fuser->pass); + else + { + if ($user->admin) print $langs->trans("Crypted").': '.$fuser->pass_indatabase_crypted; + else print $langs->trans("Hidden"); + } + print "
'.$langs->trans("Administrator").''.yn($fuser->admin); + if ($fuser->admin) print ' '.img_picto($langs->trans("Administrator"),"star"); + print '
'.$langs->trans("Type").''; + if ($fuser->societe_id) + { + print $html->textwithhelp($langs->trans("External"),$langs->trans("InternalExternalDesc")); + } + else if ($fuser->ldap_sid) + { + print $langs->trans("DomainUser",$ldap->domainFQDN); + } + else + { + print $html->textwithhelp($langs->trans("Internal"),$langs->trans("InternalExternalDesc")); + } + print '
'.$langs->trans("Company").' / '.$langs->trans("Contact").''; + if ($fuser->societe_id > 0) + { + $societe = new Societe($db); + $societe->fetch($fuser->societe_id); + print ''.img_object($langs->trans("ShowCompany"),'company').' '.dolibarr_trunc($societe->nom,32).''; + } + else + { + print $langs->trans("ThisUserIsNot"); + } + if ($fuser->contact_id) + { + $contact = new Contact($db); + $contact->fetch($fuser->contact_id); + if ($fuser->societe_id > 0) print ' / '; + else print '
'; + print ''.img_object($langs->trans("ShowContact"),'contact').' '.dolibarr_trunc($contact->getFullName($langs),32).''; + } + print '
'.$langs->trans("PhonePro").''.$fuser->office_phone.'
'.$langs->trans("PhoneMobile").''.$fuser->user_mobile.'
'.$langs->trans("Fax").''.$fuser->office_fax.'
'.$langs->trans("EMail").''.$fuser->email.'
'.$langs->trans("Status").''; + print $fuser->getLibStatut(4); + print '
'.$langs->trans("LastConnexion").''.dolibarr_print_date($fuser->datelastlogin,"dayhour").'
'.$langs->trans("PreviousConnexion").''.dolibarr_print_date($fuser->datepreviouslogin,"dayhour").'
'.$langs->trans("LoginWebcal").''.$fuser->webcal_login.' 
'.$langs->trans("LoginPhenix").''.$fuser->phenix_login.' 
'.$langs->trans("PassPhenix").''.eregi_replace('.','*',$fuser->phenix_pass_crypted).' 
'.$langs->trans("MemberAccount").''; + if ($fuser->fk_member) + { + $adh=new Adherent($db); + $adh->fetch($fuser->fk_member); + $adh->ref=$adh->login; // Force to show login instead of id + print $adh->getNomUrl(1); + } + else + { + print $langs->trans("UserNotLinkedToMember"); + } + print '
\n"; + + print "\n"; + + if ($message) { print $message; } + + + /* + * Barre d'actions + */ + + print '
'; + + + if ($caneditfield) + { + print ''.$langs->trans("Modify").''; + } + elseif ($caneditpassword && ! $fuser->ldap_sid) + { + print ''.$langs->trans("EditPassword").''; + } + + // Si on a un gestionnaire de generation de mot de passe actif + if ($conf->global->USER_PASSWORD_GENERATED != 'none') + { + if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login && !$fuser->ldap_sid) + { + print ''.$langs->trans("ReinitPassword").''; + } + + if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->email && $fuser->login && !$fuser->ldap_sid) + { + print ''.$langs->trans("SendNewPassword").''; + } + } + + // Activer + if ($user->id <> $_GET["id"] && $candisableperms && $fuser->statut == 0) + { + print ''.$langs->trans("Reactivate").''; + } + // Desactiver + if ($user->id <> $_GET["id"] && $candisableperms && $fuser->statut == 1) + { + print ''.$langs->trans("DisableUser").''; + } + + if ($user->id <> $_GET["id"] && $candisableperms) + { + print ''.$langs->trans("DeleteUser").''; + } + + print "
\n"; + print "
\n"; - /* - * Liste des groupes dans lequel est l'utilisateur - */ + /* + * Liste des groupes dans lequel est l'utilisateur + */ - print_fiche_titre($langs->trans("ListOfGroupsForUser")); + print_fiche_titre($langs->trans("ListOfGroupsForUser")); - // On selectionne les groups - $uss = array(); + // On selectionne les groups + $uss = array(); - $sql = "SELECT ug.rowid, ug.nom "; - $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as ug "; - # $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user"; - # $sql .= " WHERE ug.fk_usergroup IS NULL"; - $sql .= " ORDER BY ug.nom"; + $sql = "SELECT ug.rowid, ug.nom "; + $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as ug "; + # $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user"; + # $sql .= " WHERE ug.fk_usergroup IS NULL"; + $sql .= " ORDER BY ug.nom"; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); + while ($i < $num) + { + $obj = $db->fetch_object($resql); - $uss[$obj->rowid] = $obj->nom; - $i++; - } - } - else { - dolibarr_print_error($db); - } + $uss[$obj->rowid] = $obj->nom; + $i++; + } + } + else { + dolibarr_print_error($db); + } - if ($caneditperms) - { - $form = new Form($db); - print '
'."\n"; - print ''; - print ''."\n"; - // print ''."\n"; - print ''."\n"; - print ''."\n"; - print '
'.$langs->trans("NonAffectedUsers").'
'.$langs->trans("GroupsToAdd").''; - print $form->select_array("group",$uss); - print '   '; - print ''; - print '
'."\n"; + if ($caneditperms) + { + $form = new Form($db); + print '
'."\n"; + print ''; + print ''."\n"; + // print ''."\n"; + print ''."\n"; + print ''."\n"; + print '
'.$langs->trans("NonAffectedUsers").'
'.$langs->trans("GroupsToAdd").''; + print $form->select_array("group",$uss); + print '   '; + print ''; + print '
'."\n"; - print '
'; - } + print '
'; + } - /* - * Groupes affectes - */ - $sql = "SELECT g.rowid, g.nom "; - $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; - $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql .= " WHERE ug.fk_usergroup = g.rowid"; - $sql .= " AND ug.fk_user = ".$_GET["id"]; - $sql .= " ORDER BY g.nom"; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; - - print ''; - print ''; - print ''; - print "\n"; - - if ($num) { - $var=True; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $var=!$var; - - print ""; - print ''; - print '\n"; - $i++; - } - } - else - { - print ''; - } - print "
'.$langs->trans("Group").' 
'; - if ($canreadperms) - { - print ''.img_object($langs->trans("ShowGroup"),"group").' '.$obj->nom.''; - } - else - { - print img_object($langs->trans("ShowGroup"),"group").' '.$obj->nom; - } - print ''; - - if ($caneditperms) - { - print 'rowid.'">'; - print img_delete($langs->trans("RemoveFromGroup")); - } - else - { - print "-"; - } - print "
'.$langs->trans("None").'
"; - print "
"; - $db->free($result); - } - else { - dolibarr_print_error($db); - } - - } - - /* - * Fiche en mode edition - */ - if ($_GET["action"] == 'edit' && ($caneditperms || ($user->id == $fuser->id))) - { - - print '
'; - print ''; - print ''; - - $rowspan=10; - - print ''; - print ''; - print ''; - - // Nom - print "".''; - print ''; - - // Prenom - print "".''; - print ''; - - // Login - print "".''; - print ''; - print ''; - print ''; - - // Pass - print ''; - print '\n"; - - // Administrateur - print "".''; - if ($fuser->societe_id > 0) - { - print ''; - } - else - { - print ''; - } - - // Type - print ''; - print ''; - - // Company / Contact - print ''; - print ''; - print "\n"; - - // Tel pro - print "".''; - print ''; - - // Tel mobile - print "".''; - print ''; - - // Fax - print "".''; - print ''; + /* + * Groupes affectes + */ + $usergroup=new UserGroup($db); + $listofgroups=$usergroup->listGroupsForUser($fuser); + $num=sizeof($listofgroups); - // EMail - print "".''; - print ''; - - // Statut - print ''; - print ''; - - // Autres caracteristiques issus des autres modules - - // Module Webcalendar - if ($conf->webcal->enabled) - { - $langs->load("other"); - print "".''; - print ''; - } - - // Module Phenix - if ($conf->phenix->enabled) - { - $langs->load("other"); - print "".''; - print ''; - print "".''; - print ''; - } + print '
'.$langs->trans("Ref").''; - print $fuser->id; - print '
'.$langs->trans("Name").'*'; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->nom; - } - print '
'.$langs->trans("Firstname").''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->prenom; - } - print '
'.$langs->trans("Login").'*'; - if ($user->admin && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->login; - } - print ''; - if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg")) - { - print ''; - } - else - { - print ''; - } - if ($caneditfield) - { - print '

'; - print '
'.$langs->trans("PhotoFile").'
'; - print ''; - print '
'; - } - print '
'.$langs->trans("Password").''; - if ($fuser->ldap_sid) - { - $text=$langs->trans("DomainPassword"); - } - else if ($caneditpassword) - { - $text=''; - if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http') - { - $text=$html->textwithwarning($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication)); - } - } - else - { - $text=eregi_replace('.','*',$fuser->pass); - } - print $text; - print "
'.$langs->trans("Administrator").''; - print ''.yn($fuser->admin); - print '
'; - if ($user->admin) - { - print $form->selectyesno('admin',$fuser->admin,1); - } - else - { - print ''.yn($fuser->admin); - } - print '
'.$langs->trans("Type").''; - if ($fuser->societe_id) - { - print $langs->trans("External"); - } - else if ($fuser->ldap_sid) - { - print $langs->trans("DomainUser"); - } - else - { - print $langs->trans("Internal"); - } - print '
'.$langs->trans("Company").' / '.$langs->trans("Contact").''; - if ($fuser->societe_id > 0) - { - $societe = new Societe($db); - $societe->fetch($fuser->societe_id); - print ''.img_object($langs->trans("ShowCompany"),'company').' '.dolibarr_trunc($societe->nom,32).''; - if ($fuser->contact_id) - { - $contact = new Contact($db); - $contact->fetch($fuser->contact_id); - print ' / '.''.img_object($langs->trans("ShowContact"),'contact').' '.dolibarr_trunc($contact->getFullName($langs),32).''; - } - } - else - { - print $langs->trans("ThisUserIsNot"); - } - print '
'.$langs->trans("PhonePro").''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->office_phone; - } - print '
'.$langs->trans("PhoneMobile").''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->user_mobile; - } - print '
'.$langs->trans("Fax").''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->office_fax; - } - print '
'.$langs->trans("EMail").''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->email; - } - print '
'.$langs->trans("Status").''; - print $fuser->getLibStatut(4); - print '
'.$langs->trans("LoginWebcal").''; - if ($caneditfield) print ''; - else print $fuser->webcal_login; - print '
'.$langs->trans("LoginPhenix").''; - if ($caneditfield) print ''; - else print $fuser->phenix_login; - print '
'.$langs->trans("PassPhenix").''; - if ($caneditfield) print ''; - else print eregi_replace('.','*',$fuser->phenix_pass_crypted); - print '
'; + print ''; + print ''; + print "\n"; + + if ($num > 0) + { + $i = 0; - print ''; + $var=true; + while ($i < $num) + { + $group = $listofgroups[$i]; + $var=!$var; - print '
'.$langs->trans("Groups").' 
'; - print ''; - print '   '; - print ''; - print '
'; - print '
'; + print ""; + print ''; + if ($canreadperms) + { + print ''.img_object($langs->trans("ShowGroup"),"group").' '.$group->nom.''; + } + else + { + print img_object($langs->trans("ShowGroup"),"group").' '.$group->nom; + } + print ''; + print ''; - print ''; - } + if ($caneditperms) + { + print 'id.'">'; + print img_delete($langs->trans("RemoveFromGroup")); + } + else + { + print " "; + } + print "\n"; + $i++; + } + } + else + { + print ''.$langs->trans("None").''; + } + + print ""; + print "
"; + $db->free($result); + } - $ldap->close; - } + /* + * Fiche en mode edition + */ + if ($_GET["action"] == 'edit' && ($caneditperms || ($user->id == $fuser->id))) + { + + print '
'; + print ''; + print ''; + + $rowspan=10; + + print ''; + print ''; + print ''; + + // Nom + print "".''; + print ''; + + // Prenom + print "".''; + print ''; + + // Login + print "".''; + print ''; + print ''; + print ''; + + // Pass + print ''; + print '\n"; + + // Administrateur + print "".''; + if ($fuser->societe_id > 0) + { + print ''; + } + else + { + print ''; + } + + // Type + print ''; + print ''; + + // Company / Contact + print ''; + print ''; + print "\n"; + + // Tel pro + print "".''; + print ''; + + // Tel mobile + print "".''; + print ''; + + // Fax + print "".''; + print ''; + + // EMail + print "".''; + print ''; + + // Statut + print ''; + print ''; + + // Autres caracteristiques issus des autres modules + + // Module Webcalendar + if ($conf->webcal->enabled) + { + $langs->load("other"); + print "".''; + print ''; + } + + // Module Phenix + if ($conf->phenix->enabled) + { + $langs->load("other"); + print "".''; + print ''; + print "".''; + print ''; + } + + print ''; + + print '
'.$langs->trans("Ref").''; + print $fuser->id; + print '
'.$langs->trans("Name").'*'; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->nom; + } + print '
'.$langs->trans("Firstname").''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->prenom; + } + print '
'.$langs->trans("Login").'*'; + if ($user->admin && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->login; + } + print ''; + if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg")) + { + print ''; + } + else + { + print ''; + } + if ($caneditfield) + { + print '

'; + print '
'.$langs->trans("PhotoFile").'
'; + print ''; + print '
'; + } + print '
'.$langs->trans("Password").''; + if ($fuser->ldap_sid) + { + $text=$langs->trans("DomainPassword"); + } + else if ($caneditpassword) + { + $text=''; + if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http') + { + $text=$html->textwithwarning($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication)); + } + } + else + { + $text=eregi_replace('.','*',$fuser->pass); + } + print $text; + print "
'.$langs->trans("Administrator").''; + print ''.yn($fuser->admin); + print '
'; + if ($user->admin) + { + print $form->selectyesno('admin',$fuser->admin,1); + } + else + { + print ''.yn($fuser->admin); + } + print '
'.$langs->trans("Type").''; + if ($fuser->societe_id) + { + print $langs->trans("External"); + } + else if ($fuser->ldap_sid) + { + print $langs->trans("DomainUser"); + } + else + { + print $langs->trans("Internal"); + } + print '
'.$langs->trans("Company").' / '.$langs->trans("Contact").''; + if ($fuser->societe_id > 0) + { + $societe = new Societe($db); + $societe->fetch($fuser->societe_id); + print ''.img_object($langs->trans("ShowCompany"),'company').' '.dolibarr_trunc($societe->nom,32).''; + if ($fuser->contact_id) + { + $contact = new Contact($db); + $contact->fetch($fuser->contact_id); + print ' / '.''.img_object($langs->trans("ShowContact"),'contact').' '.dolibarr_trunc($contact->getFullName($langs),32).''; + } + } + else + { + print $langs->trans("ThisUserIsNot"); + } + print '
'.$langs->trans("PhonePro").''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->office_phone; + } + print '
'.$langs->trans("PhoneMobile").''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->user_mobile; + } + print '
'.$langs->trans("Fax").''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->office_fax; + } + print '
'.$langs->trans("EMail").''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->email; + } + print '
'.$langs->trans("Status").''; + print $fuser->getLibStatut(4); + print '
'.$langs->trans("LoginWebcal").''; + if ($caneditfield) print ''; + else print $fuser->webcal_login; + print '
'.$langs->trans("LoginPhenix").''; + if ($caneditfield) print ''; + else print $fuser->phenix_login; + print '
'.$langs->trans("PassPhenix").''; + if ($caneditfield) print ''; + else print eregi_replace('.','*',$fuser->phenix_pass_crypted); + print '
'; + print ''; + print '   '; + print ''; + print '
'; + print '
'; + + print ''; + } + + $ldap->close; + } } $db->close();