dolibarr/htdocs/user/fiche.php

1997 lines
76 KiB
PHP
Raw Normal View History

2004-10-20 23:06:45 +02:00
<?php
2006-12-04 12:38:34 +01:00
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
2004-12-22 21:50:38 +01:00
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
2009-04-30 15:28:08 +02:00
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
2011-08-19 09:22:17 +02:00
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
2012-09-10 09:06:37 +02:00
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
2002-05-06 21:10:48 +02:00
*
* 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
* the Free Software Foundation; either version 3 of the License, or
2002-05-06 21:10:48 +02:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2011-08-01 01:19:04 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2002-05-06 21:10:48 +02:00
*/
2008-08-28 14:08:02 +02:00
/**
2008-08-11 01:46:44 +02:00
* \file htdocs/user/fiche.php
2011-05-28 13:50:51 +02:00
* \brief Tab of user card
2008-08-11 01:46:44 +02:00
*/
2004-10-10 17:51:19 +02:00
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
if (! empty($conf->multicompany->enabled)) dol_include_once('/multicompany/class/actions_multicompany.class.php');
2011-11-02 20:17:55 +01:00
$id = GETPOST('id','int');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
$subaction = GETPOST('subaction','alpha');
2011-11-02 20:17:55 +01:00
$group = GETPOST("group","int",3);
// Define value to know what current user can do on users
$canadduser=(! empty($user->admin) || $user->rights->user->user->creer);
$canreaduser=(! empty($user->admin) || $user->rights->user->user->lire);
$canedituser=(! empty($user->admin) || $user->rights->user->user->creer);
$candisableuser=(! empty($user->admin) || $user->rights->user->user->supprimer);
2011-03-14 11:37:23 +01:00
$canreadgroup=$canreaduser;
$caneditgroup=$canedituser;
2010-11-08 12:40:52 +01:00
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
{
$canreadgroup=(! empty($user->admin) || $user->rights->user->group_advance->read);
$caneditgroup=(! empty($user->admin) || $user->rights->user->group_advance->write);
2010-11-08 12:40:52 +01:00
}
// Define value to know what current user can do on properties of edited user
if ($id)
{
// $user est le user qui edite, $id est l'id de l'utilisateur edite
2012-04-15 11:28:21 +02:00
$caneditfield=((($user->id == $id) && $user->rights->user->self->creer)
|| (($user->id != $id) && $user->rights->user->user->creer));
$caneditpassword=((($user->id == $id) && $user->rights->user->self->password)
|| (($user->id != $id) && $user->rights->user->user->password));
}
// Security check
$socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id;
$feature2='user';
if ($user->id == $id) { $feature2=''; $canreaduser=1; } // A user can always read its own card
if (!$canreaduser) {
$result = restrictedArea($user, 'user', $id, '&user', $feature2);
}
if ($user->id <> $id && ! $canreaduser) accessforbidden();
2005-08-23 13:40:19 +02:00
$langs->load("users");
2005-07-25 18:10:18 +02:00
$langs->load("companies");
2006-06-25 19:09:43 +02:00
$langs->load("ldap");
2012-12-02 11:03:23 +01:00
$object = new User($db);
$extrafields = new ExtraFields($db);
2002-05-06 21:10:48 +02:00
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
2012-12-13 13:08:03 +01:00
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('usercard'));
2012-12-12 11:57:56 +01:00
/**
* Actions
*/
2003-08-10 14:44:43 +02:00
if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser)
{
if ($id <> $user->id)
2011-06-29 12:23:32 +02:00
{
$object->fetch($id);
$object->setstatus(0);
2012-08-31 05:58:38 +02:00
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
2011-06-29 12:23:32 +02:00
exit;
}
2006-09-02 03:17:50 +02:00
}
if ($action == 'confirm_enable' && $confirm == "yes" && $candisableuser)
2006-09-02 03:17:50 +02:00
{
$error = 0;
if ($id <> $user->id)
2011-06-29 12:23:32 +02:00
{
$object->fetch($id);
2011-06-29 12:23:32 +02:00
if (!empty($conf->file->main_limit_users))
{
$nb = $object->getNbOfUsers("active");
2011-06-29 12:23:32 +02:00
if ($nb >= $conf->file->main_limit_users)
{
$error++;
setEventMessage($langs->trans("YourQuotaOfUsersIsReached"), 'errors');
2011-06-29 12:23:32 +02:00
}
}
if (! $error)
2011-06-29 12:23:32 +02:00
{
$object->setstatus(1);
2012-08-31 05:58:38 +02:00
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
2011-06-29 12:23:32 +02:00
exit;
}
}
}
if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser)
2003-08-10 14:44:43 +02:00
{
if ($id <> $user->id)
2011-06-29 12:23:32 +02:00
{
$object = new User($db);
$object->id=$id;
$result = $object->delete();
2011-06-29 12:23:32 +02:00
if ($result < 0)
{
$langs->load("errors");
setEventMessage($langs->trans("ErrorUserCannotBeDelete"), 'errors');
2011-06-29 12:23:32 +02:00
}
else
{
2012-08-31 05:58:38 +02:00
header("Location: index.php");
2011-06-29 12:23:32 +02:00
exit;
}
}
2003-08-10 14:44:43 +02:00
}
// Action ajout user
if ($action == 'add' && $canadduser)
2002-12-13 17:51:03 +01:00
{
$error = 0;
2013-02-23 11:42:12 +01:00
if (! $_POST["lastname"])
{
$error++;
setEventMessage($langs->trans("NameNotDefined"), 'errors');
2011-06-29 12:23:32 +02:00
$action="create"; // Go back to create page
}
if (! $_POST["login"])
{
$error++;
setEventMessage($langs->trans("LoginNotDefined"), 'errors');
2011-06-29 12:23:32 +02:00
$action="create"; // Go back to create page
}
if (! empty($conf->file->main_limit_users)) // If option to limit users is set
2011-06-29 12:23:32 +02:00
{
$nb = $object->getNbOfUsers("active");
2011-06-29 12:23:32 +02:00
if ($nb >= $conf->file->main_limit_users)
{
$error++;
setEventMessage($langs->trans("YourQuotaOfUsersIsReached"), 'errors');
2011-06-29 12:23:32 +02:00
$action="create"; // Go back to create page
}
}
if (!$error) {
$object->lastname = GETPOST("lastname",'alpha');
$object->firstname = GETPOST("firstname",'alpha');
$object->login = GETPOST("login",'alpha');
$object->admin = GETPOST("admin",'alpha');
$object->office_phone = GETPOST("office_phone",'alpha');
$object->office_fax = GETPOST("office_fax",'alpha');
$object->user_mobile = GETPOST("user_mobile");
2014-04-08 23:51:50 +02:00
$object->skype = GETPOST("skype");
$object->email = GETPOST("email",'alpha');
$object->job = GETPOST("job",'alpha');
$object->signature = GETPOST("signature");
$object->accountancy_code = GETPOST("accountancy_code");
$object->note = GETPOST("note");
$object->ldap_sid = GETPOST("ldap_sid");
2014-04-08 23:51:50 +02:00
$object->fk_user = GETPOST("fk_user")>0?GETPOST("fk_user"):0;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
2012-12-12 11:57:56 +01:00
2011-06-29 12:23:32 +02:00
// If multicompany is off, admin users must all be on entity 0.
2012-09-15 10:01:35 +02:00
if (! empty($conf->multicompany->enabled))
{
$entity=GETPOST('entity','int');
2012-07-07 10:57:54 +02:00
if (! empty($_POST["superadmin"]))
{
$object->entity = 0;
2012-07-07 10:57:54 +02:00
}
else if ($conf->multicompany->transverse_mode)
{
$object->entity = 1; // all users in master entity
}
else
{
$object->entity = (empty($entity) ? 0 : $entity);
}
}
2011-09-22 12:55:37 +02:00
else
{
$object->entity = (empty($entity) ? 0 : $entity);
}
2011-06-29 12:23:32 +02:00
$db->begin();
$id = $object->create($user);
2011-06-29 12:23:32 +02:00
if ($id > 0)
{
if (isset($_POST['password']) && trim($_POST['password']))
{
$object->setPassword($user,trim($_POST['password']));
2011-06-29 12:23:32 +02:00
}
$db->commit();
2012-08-31 05:58:38 +02:00
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
2011-06-29 12:23:32 +02:00
exit;
}
else
{
$langs->load("errors");
$db->rollback();
if (is_array($object->errors) && count($object->errors)) setEventMessage($object->errors,'errors');
else setEventMessage($object->error);
2011-06-29 12:23:32 +02:00
$action="create"; // Go back to create page
}
}
2005-02-27 15:12:16 +01:00
}
// Action ajout groupe utilisateur
2011-05-28 13:50:51 +02:00
if (($action == 'addgroup' || $action == 'removegroup') && $caneditfield)
2005-02-27 15:12:16 +01:00
{
2011-06-29 12:23:32 +02:00
if ($group)
{
2011-05-28 13:50:51 +02:00
$editgroup = new UserGroup($db);
$editgroup->fetch($group);
$editgroup->oldcopy=dol_clone($editgroup);
2008-08-28 14:08:02 +02:00
$object->fetch($id);
if ($action == 'addgroup') $object->SetInGroup($group,($conf->multicompany->transverse_mode?GETPOST("entity"):$editgroup->entity));
if ($action == 'removegroup') $object->RemoveFromGroup($group,($conf->multicompany->transverse_mode?GETPOST("entity"):$editgroup->entity));
2011-05-28 13:50:51 +02:00
if ($result > 0)
{
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
2011-05-28 13:50:51 +02:00
exit;
}
else
2011-06-29 12:23:32 +02:00
{
setEventMessage($object->error, 'errors');
2011-06-29 12:23:32 +02:00
}
}
2005-02-27 15:12:16 +01:00
}
if ($action == 'update' && ! $_POST["cancel"])
2002-12-13 17:51:03 +01:00
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
2011-06-29 12:23:32 +02:00
if ($caneditfield) // Case we can edit all field
{
$error=0;
2013-02-23 11:42:12 +01:00
if (! $_POST["lastname"])
2011-06-29 12:23:32 +02:00
{
setEventMessage($langs->trans("NameNotDefined"), 'errors');
2011-06-29 12:23:32 +02:00
$action="edit"; // Go back to create page
$error++;
2011-06-29 12:23:32 +02:00
}
if (! $_POST["login"])
{
setEventMessage($langs->trans("LoginNotDefined"), 'errors');
2011-06-29 12:23:32 +02:00
$action="edit"; // Go back to create page
$error++;
2011-06-29 12:23:32 +02:00
}
if (! $error)
2011-06-29 12:23:32 +02:00
{
$object->fetch($id);
// Test if new login
if (GETPOST("login") && GETPOST("login") != $object->login)
{
dol_syslog("New login ".$object->login." is requested. We test it does not exists.");
$tmpuser=new User($db);
$result=$tmpuser->fetch(0, GETPOST("login"));
if ($result > 0)
{
setEventMessage($langs->trans("ErrorLoginAlreadyExists"), 'errors');
$action="edit"; // Go back to create page
$error++;
}
}
}
if (! $error)
{
$db->begin();
$object->oldcopy=dol_clone($object);
$object->lastname = GETPOST("lastname",'alpha');
$object->firstname = GETPOST("firstname",'alpha');
$object->login = GETPOST("login",'alpha');
$object->pass = GETPOST("password");
2013-01-31 10:21:34 +01:00
$object->admin = empty($user->admin)?0:GETPOST("admin"); // A user can only be set admin by an admin
$object->office_phone=GETPOST("office_phone",'alpha');
$object->office_fax = GETPOST("office_fax",'alpha');
$object->user_mobile= GETPOST("user_mobile");
$object->skype = GETPOST("skype");
$object->email = GETPOST("email",'alpha');
$object->job = GETPOST("job",'alpha');
$object->signature = GETPOST("signature");
2014-04-08 23:51:50 +02:00
$object->accountancy_code = GETPOST("accountancy_code");
$object->openid = GETPOST("openid");
$object->fk_user = GETPOST("fk_user")>0?GETPOST("fk_user"):0;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
2012-12-12 11:57:56 +01:00
2012-09-15 10:01:35 +02:00
if (! empty($conf->multicompany->enabled))
{
2012-07-07 10:57:54 +02:00
if (! empty($_POST["superadmin"]))
{
$object->entity = 0;
2012-07-07 10:57:54 +02:00
}
else if ($conf->multicompany->transverse_mode)
{
$object->entity = 1; // all users in master entity
}
else
{
$object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]);
}
}
2011-09-22 12:55:37 +02:00
else
{
$object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]);
}
2011-11-02 14:14:46 +01:00
if (GETPOST('deletephoto')) $object->photo='';
if (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
2011-06-29 12:23:32 +02:00
$ret=$object->update($user);
2011-06-29 12:23:32 +02:00
if ($ret < 0)
{
$error++;
2011-06-29 12:23:32 +02:00
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
setEventMessage($langs->trans("ErrorLoginAlreadyExists",$object->login), 'errors');
2011-06-29 12:23:32 +02:00
}
else
2012-10-24 17:35:28 +02:00
{
setEventMessage($object->error, 'errors');
2011-06-29 12:23:32 +02:00
}
}
if (! $error && isset($_POST['contactid']))
{
$contactid=GETPOST('contactid');
if ($contactid > 0)
{
$contact=new Contact($db);
$contact->fetch($contactid);
2013-01-10 08:27:12 +01:00
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
$sql.= " SET fk_socpeople=".$db->escape($contactid);
if ($contact->socid) $sql.=", fk_societe=".$db->escape($contact->socid);
2013-01-10 08:27:12 +01:00
$sql.= " WHERE rowid=".$object->id;
}
else
{
2013-01-10 08:27:12 +01:00
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
$sql.= " SET fk_socpeople=NULL, fk_societe=NULL";
$sql.= " WHERE rowid=".$object->id;
}
dol_syslog("fiche::update", LOG_DEBUG);
2013-01-10 08:27:12 +01:00
$resql=$db->query($sql);
if (! $resql)
{
$error++;
setEventMessage($db->lasterror(), 'errors');
2013-01-10 08:27:12 +01:00
}
}
if (! $error && ! count($object->errors))
2011-06-29 12:23:32 +02:00
{
if (GETPOST('deletephoto') && $object->photo)
2011-06-11 22:58:08 +02:00
{
$fileimg=$conf->user->dir_output.'/'.get_exdir($object->id,2,0,1).'/logos/'.$object->photo;
$dirthumbs=$conf->user->dir_output.'/'.get_exdir($object->id,2,0,1).'/logos/thumbs';
2011-06-11 22:58:08 +02:00
dol_delete_file($fileimg);
dol_delete_dir_recursive($dirthumbs);
}
2011-06-29 12:23:32 +02:00
if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
{
$dir= $conf->user->dir_output . '/' . get_exdir($object->id,2,0,1);
2011-06-29 12:23:32 +02:00
dol_mkdir($dir);
2011-06-29 12:23:32 +02:00
if (@is_dir($dir))
{
$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
$result=dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']);
if (! $result > 0)
{
setEventMessage($langs->trans("ErrorFailedToSaveFile"), 'errors');
2011-06-29 12:23:32 +02:00
}
else
{
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
}
}
}
}
if (! $error && ! count($object->errors))
2011-06-29 12:23:32 +02:00
{
setEventMessage($langs->trans("UserModified"));
2011-06-29 12:23:32 +02:00
$db->commit();
$login=$_SESSION["dol_login"];
if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login
{
$_SESSION["dol_login"]=$object->login; // Set new login to avoid disconnect at next page
}
2011-06-29 12:23:32 +02:00
}
else
{
$db->rollback();
}
}
}
else if ($caneditpassword) // Case we can edit only password
{
$object->fetch($id);
2011-06-29 12:23:32 +02:00
$object->oldcopy=dol_clone($object);
$ret=$object->setPassword($user,$_POST["password"]);
2011-06-29 12:23:32 +02:00
if ($ret < 0)
{
setEventMessage($object->error, 'errors');
2011-06-29 12:23:32 +02:00
}
}
2002-12-19 19:55:38 +01:00
}
2002-05-06 21:10:48 +02:00
// Change password with a new generated one
2010-10-29 10:11:00 +02:00
if ((($action == 'confirm_password' && $confirm == 'yes')
|| ($action == 'confirm_passwordsend' && $confirm == 'yes')) && $caneditpassword)
2002-12-19 19:55:38 +01:00
{
$object->fetch($id);
2011-06-29 12:23:32 +02:00
$newpassword=$object->setPassword($user,'');
2011-06-29 12:23:32 +02:00
if ($newpassword < 0)
{
// Echec
setEventMessage($langs->trans("ErrorFailedToSetNewPassword"), 'errors');
2011-06-29 12:23:32 +02:00
}
else
{
// Succes
if ($action == 'confirm_passwordsend' && $confirm == 'yes')
{
if ($object->send_password($user,$newpassword) > 0)
2011-06-29 12:23:32 +02:00
{
setEventMessage($langs->trans("PasswordChangedAndSentTo",$object->email));
2011-06-29 12:23:32 +02:00
}
else
{
setEventMessage($object->error, 'errors');
2011-06-29 12:23:32 +02:00
}
}
else
{
setEventMessage($langs->trans("PasswordChangedTo",$newpassword), 'errors');
2011-06-29 12:23:32 +02:00
}
}
2002-05-06 21:10:48 +02:00
}
// Action initialisation donnees depuis record LDAP
if ($action == 'adduserldap')
{
2011-06-29 12:23:32 +02:00
$selecteduser = $_POST['users'];
$required_fields = array(
2012-10-24 17:35:28 +02:00
$conf->global->LDAP_KEY_USERS,
2011-06-29 12:23:32 +02:00
$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,
2013-11-07 13:17:08 +01:00
$conf->global->LDAP_FIELD_SKYPE,
2011-06-29 12:23:32 +02:00
$conf->global->LDAP_FIELD_MAIL,
$conf->global->LDAP_FIELD_TITLE,
$conf->global->LDAP_FIELD_DESCRIPTION,
2011-06-29 12:23:32 +02:00
$conf->global->LDAP_FIELD_SID);
$ldap = new Ldap();
$result = $ldap->connect_bind();
if ($result >= 0)
{
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
$required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement")));
2011-06-29 12:23:32 +02:00
$ldapusers = $ldap->getRecords($selecteduser, $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields);
//print_r($ldapusers);
if (is_array($ldapusers))
{
foreach ($ldapusers as $key => $attribute)
{
2013-02-23 15:26:39 +01:00
$ldap_lastname = $attribute[$conf->global->LDAP_FIELD_NAME];
$ldap_firstname = $attribute[$conf->global->LDAP_FIELD_FIRSTNAME];
$ldap_login = $attribute[$conf->global->LDAP_FIELD_LOGIN];
$ldap_loginsmb = $attribute[$conf->global->LDAP_FIELD_LOGIN_SAMBA];
$ldap_pass = $attribute[$conf->global->LDAP_FIELD_PASSWORD];
$ldap_pass_crypted = $attribute[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED];
$ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE];
$ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX];
$ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE];
2013-11-07 13:17:08 +01:00
$ldap_skype = $attribute[$conf->global->LDAP_FIELD_SKYPE];
$ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL];
$ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID];
2011-06-29 12:23:32 +02:00
}
}
}
else
{
setEventMessage($ldap->error, 'errors');
2011-06-29 12:23:32 +02:00
}
}
/*
2011-11-02 14:14:46 +01:00
* View
*/
2006-08-31 01:19:35 +02:00
$form = new Form($db);
2006-08-31 01:19:35 +02:00
llxHeader('',$langs->trans("UserCard"));
if (($action == 'create') || ($action == 'adduserldap'))
2002-12-13 17:51:03 +01:00
{
2011-06-29 12:23:32 +02:00
/* ************************************************************************** */
/* */
/* Affichage fiche en mode creation */
/* */
/* ************************************************************************** */
print_fiche_titre($langs->trans("NewUser"));
print $langs->trans("CreateInternalUserDesc");
print "<br>";
print "<br>";
if (! empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr'))
2011-06-29 12:23:32 +02:00
{
/*
* 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_PASSWORD,
$conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
2013-11-07 13:17:08 +01:00
$conf->global->LDAP_FIELD_PHONE,
$conf->global->LDAP_FIELD_FAX,
$conf->global->LDAP_FIELD_MOBILE,
2013-11-07 13:17:08 +01:00
$conf->global->LDAP_FIELD_SKYPE,
$conf->global->LDAP_FIELD_MAIL,
$conf->global->LDAP_FIELD_TITLE,
$conf->global->LDAP_FIELD_DESCRIPTION,
$conf->global->LDAP_FIELD_SID
);
2011-06-29 12:23:32 +02:00
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
$required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement")));
2011-06-29 12:23:32 +02:00
// Get from LDAP database an array of results
$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
2012-10-24 17:35:28 +02:00
2011-06-29 12:23:32 +02:00
if (is_array($ldapusers))
{
$liste=array();
foreach ($ldapusers as $key => $ldapuser)
{
// Define the label string for this user
$label='';
foreach ($required_fields as $value)
{
if ($value)
{
$label.=$value."=".$ldapuser[$value]." ";
}
}
$liste[$key] = $label;
}
}
else
{
setEventMessage($ldap->error, 'errors');
2011-06-29 12:23:32 +02:00
}
}
else
{
setEventMessage($ldap->error, 'errors');
2011-06-29 12:23:32 +02:00
}
// Si la liste des users est rempli, on affiche la liste deroulante
2012-10-24 17:35:28 +02:00
print "\n\n<!-- Form liste LDAP debut -->\n";
print '<form name="add_user_ldap" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table width="100%" class="border"><tr>';
print '<td width="160">';
print $langs->trans("LDAPUsers");
print '</td>';
print '<td>';
print '<input type="hidden" name="action" value="adduserldap">';
if (is_array($liste) && count($liste))
2011-06-29 12:23:32 +02:00
{
print $form->selectarray('users', $liste, '', 1);
2011-06-29 12:23:32 +02:00
}
2012-10-24 17:35:28 +02:00
print '</td><td align="center">';
print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Get')).'"'.(count($liste)?'':' disabled="disabled"').'>';
print '</td></tr></table>';
print '</form>';
print "\n<!-- Form liste LDAP fin -->\n\n";
print '<br>';
2011-06-29 12:23:32 +02:00
}
print dol_set_focus('#lastname');
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST" name="createuser">';
2011-06-29 12:23:32 +02:00
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
if (! empty($ldap_sid)) print '<input type="hidden" name="ldap_sid" value="'.$ldap_sid.'">';
2011-06-29 12:23:32 +02:00
print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
print '<table class="border" width="100%">';
print '<tr>';
2013-02-23 11:42:12 +01:00
// Lastname
2011-06-29 12:23:32 +02:00
print '<td valign="top" width="160"><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td>';
print '<td>';
2013-02-23 11:42:12 +01:00
if (! empty($ldap_lastname))
2011-06-29 12:23:32 +02:00
{
2013-02-23 11:42:12 +01:00
print '<input type="hidden" id="lastname" name="lastname" value="'.$ldap_lastname.'">';
print $ldap_lastname;
2011-06-29 12:23:32 +02:00
}
else
{
2013-02-23 11:42:12 +01:00
print '<input size="30" type="text" id="lastname" name="lastname" value="'.GETPOST('lastname').'">';
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
2013-02-23 15:26:39 +01:00
// Firstname
2011-06-29 12:23:32 +02:00
print '<tr><td valign="top">'.$langs->trans("Firstname").'</td>';
print '<td>';
2013-02-23 15:26:39 +01:00
if (! empty($ldap_firstname))
2011-06-29 12:23:32 +02:00
{
2013-02-23 15:26:39 +01:00
print '<input type="hidden" name="firstname" value="'.$ldap_firstname.'">';
print $ldap_firstname;
2011-06-29 12:23:32 +02:00
}
else
{
2013-02-23 15:26:39 +01:00
print '<input size="30" type="text" name="firstname" value="'.GETPOST('firstname').'">';
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
// Position/Job
print '<tr><td valign="top">'.$langs->trans("PostOrFunction").'</td>';
print '<td>';
print '<input size="30" type="text" name="job" value="'.GETPOST('job').'">';
print '</td></tr>';
2011-06-29 12:23:32 +02:00
// Login
print '<tr><td valign="top"><span class="fieldrequired">'.$langs->trans("Login").'</span></td>';
print '<td>';
if (! empty($ldap_login))
2011-06-29 12:23:32 +02:00
{
print '<input type="hidden" name="login" value="'.$ldap_login.'">';
print $ldap_login;
}
elseif (! empty($ldap_loginsmb))
2011-06-29 12:23:32 +02:00
{
print '<input type="hidden" name="login" value="'.$ldap_loginsmb.'">';
print $ldap_loginsmb;
}
else
{
print '<input size="20" maxsize="24" type="text" name="login" value="'.GETPOST('login').'">';
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
2008-08-28 14:08:02 +02:00
2010-08-04 17:41:13 +02:00
$generated_password='';
if (empty($ldap_sid)) // ldap_sid is for activedirectory
2011-06-29 12:23:32 +02:00
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
2014-04-28 04:27:49 +02:00
$generated_password=getRandomPassword(false);
2011-06-29 12:23:32 +02:00
}
$password=$generated_password;
// Mot de passe
2013-01-15 15:43:37 +01:00
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("Password").'</td>';
2011-06-29 12:23:32 +02:00
print '<td>';
if (! empty($ldap_sid))
2011-06-29 12:23:32 +02:00
{
print 'Mot de passe du domaine';
}
else
{
if (! empty($ldap_pass))
2011-06-29 12:23:32 +02:00
{
print '<input type="hidden" name="password" value="'.$ldap_pass.'">';
print preg_replace('/./i','*',$ldap_pass);
}
else
{
// We do not use a field password but a field text to show new password to use.
print '<input size="30" maxsize="32" type="text" name="password" value="'.$password.'" autocomplete="off">';
2011-06-29 12:23:32 +02:00
}
}
print '</td></tr>';
// Administrateur
if (! empty($user->admin))
2011-06-29 12:23:32 +02:00
{
print '<tr><td valign="top">'.$langs->trans("Administrator").'</td>';
print '<td>';
print $form->selectyesno('admin',GETPOST('admin'),1);
2011-06-29 12:23:32 +02:00
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode))
2011-06-29 12:23:32 +02:00
{
if (! empty($conf->use_javascript_ajax))
2011-06-29 12:23:32 +02:00
{
print '<script type="text/javascript">
$(function() {
$("select[name=admin]").change(function() {
if ( $(this).val() == 0 ) {
$("input[name=superadmin]")
.attr("disabled", true)
.attr("checked", false);
2011-08-20 00:15:22 +02:00
$("select[name=entity]")
.attr("disabled", false);
} else {
$("input[name=superadmin]")
.attr("disabled", false);
}
});
2011-08-20 00:15:22 +02:00
$("input[name=superadmin]").change(function() {
if ( $(this).attr("checked") == "checked" ) {
$("select[name=entity]")
.attr("disabled", true);
} else {
$("select[name=entity]")
.attr("disabled", false);
}
});
});
</script>';
2011-06-29 12:23:32 +02:00
}
$checked=($_POST["superadmin"]?' checked':'');
$disabled=($_POST["superadmin"]?'':' disabled');
print '<input type="checkbox" name="superadmin" value="1"'.$checked.$disabled.' /> '.$langs->trans("SuperAdministrator");
2011-08-19 11:26:41 +02:00
}
2011-06-29 12:23:32 +02:00
print "</td></tr>\n";
}
2011-06-29 12:23:32 +02:00
// Type
print '<tr><td valign="top">'.$langs->trans("Type").'</td>';
print '<td>';
print $form->textwithpicto($langs->trans("Internal"),$langs->trans("InternalExternalDesc"));
2011-06-29 12:23:32 +02:00
print '</td></tr>';
// Tel
print '<tr><td valign="top">'.$langs->trans("PhonePro").'</td>';
print '<td>';
if (! empty($ldap_phone))
2011-06-29 12:23:32 +02:00
{
print '<input type="hidden" name="office_phone" value="'.$ldap_phone.'">';
print $ldap_phone;
}
else
{
print '<input size="20" type="text" name="office_phone" value="'.GETPOST('office_phone').'">';
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
// Tel portable
print '<tr><td valign="top">'.$langs->trans("PhoneMobile").'</td>';
print '<td>';
if (! empty($ldap_mobile))
2011-06-29 12:23:32 +02:00
{
print '<input type="hidden" name="user_mobile" value="'.$ldap_mobile.'">';
print $ldap_mobile;
}
else
{
print '<input size="20" type="text" name="user_mobile" value="'.GETPOST('user_mobile').'">';
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
// Fax
print '<tr><td valign="top">'.$langs->trans("Fax").'</td>';
print '<td>';
if (! empty($ldap_fax))
2011-06-29 12:23:32 +02:00
{
print '<input type="hidden" name="office_fax" value="'.$ldap_fax.'">';
print $ldap_fax;
}
else
{
print '<input size="20" type="text" name="office_fax" value="'.GETPOST('office_fax').'">';
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
2014-04-08 23:51:50 +02:00
2013-11-07 13:17:08 +01:00
// Skype
if (! empty($conf->skype->enabled))
{
print '<tr><td valign="top">'.$langs->trans("Skype").'</td>';
print '<td>';
if (! empty($ldap_skype))
{
print '<input type="hidden" name="skype" value="'.$ldap_skype.'">';
print $ldap_skype;
}
else
{
print '<input size="40" type="text" name="skype" value="'.GETPOST('skype').'">';
}
print '</td></tr>';
}
2011-06-29 12:23:32 +02:00
// EMail
print '<tr><td valign="top"'.(! empty($conf->global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").'</td>';
2011-06-29 12:23:32 +02:00
print '<td>';
if (! empty($ldap_mail))
2011-06-29 12:23:32 +02:00
{
print '<input type="hidden" name="email" value="'.$ldap_mail.'">';
print $ldap_mail;
}
else
{
print '<input size="40" type="text" name="email" value="'.GETPOST('email').'">';
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
// Signature
print '<tr><td valign="top">'.$langs->trans("Signature").'</td>';
print '<td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2013-04-11 10:23:35 +02:00
$doleditor=new DolEditor('signature',GETPOST('signature'),'',138,'dolibarr_mailings','In',true,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,90);
print $doleditor->Create(1);
2011-06-29 12:23:32 +02:00
print '</td></tr>';
// Multicompany
if (! empty($conf->multicompany->enabled))
{
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity && is_object($mc))
{
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($conf->entity);
print "</td></tr>\n";
}
else
{
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
}
}
// Hierarchy
print '<tr><td valign="top">'.$langs->trans("HierarchicalResponsible").'</td>';
print '<td>';
print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$conf->entity);
print '</td>';
print "</tr>\n";
2011-06-29 12:23:32 +02:00
// Note
print '<tr><td valign="top">';
print $langs->trans("Note");
print '</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('note','','',180,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,90);
$doleditor->Create();
2011-06-29 12:23:32 +02:00
print "</td></tr>\n";
2012-12-02 11:03:23 +01:00
// Other attributes
$parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields,'edit');
2012-12-02 11:03:23 +01:00
}
2012-12-12 11:57:56 +01:00
print "</table>\n";
2011-11-02 14:14:46 +01:00
print '<center><br><input class="button" value="'.$langs->trans("CreateUser").'" name="create" type="submit"></center>';
2011-11-02 14:14:46 +01:00
2011-06-29 12:23:32 +02:00
print "</form>";
2002-12-13 17:51:03 +01:00
}
else
{
2011-06-29 12:23:32 +02:00
/* ************************************************************************** */
/* */
/* Visu et edition */
/* */
/* ************************************************************************** */
if ($id > 0)
2011-06-29 12:23:32 +02:00
{
$object->fetch($id);
if ($res < 0) { dol_print_error($db,$object->error); exit; }
2012-12-02 11:03:23 +01:00
$res=$object->fetch_optionals($object->id,$extralabels);
2012-12-12 11:57:56 +01:00
2011-06-29 12:23:32 +02:00
// Connexion ldap
// pour recuperer passDoNotExpire et userChangePassNextLogon
if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid))
2011-06-29 12:23:32 +02:00
{
$ldap = new Ldap();
$result=$ldap->connect_bind();
if ($result > 0)
{
$userSearchFilter = '('.$conf->global->LDAP_FILTER_CONNECTION.'('.$ldap->getUserIdentifier().'='.$object->login.'))';
$entries = $ldap->fetch($object->login,$userSearchFilter);
2011-06-29 12:23:32 +02:00
if (! $entries)
{
setEventMessage($ldap->error, 'errors');
2011-06-29 12:23:32 +02:00
}
$passDoNotExpire = 0;
$userChangePassNextLogon = 0;
$userDisabled = 0;
$statutUACF = '';
//On verifie les options du compte
if (count($ldap->uacf) > 0)
2011-06-29 12:23:32 +02:00
{
foreach ($ldap->uacf as $key => $statut)
{
if ($key == 65536)
{
$passDoNotExpire = 1;
$statutUACF = $statut;
}
}
}
else
{
$userDisabled = 1;
$statutUACF = "ACCOUNTDISABLE";
}
if ($ldap->pwdlastset == 0)
{
$userChangePassNextLogon = 1;
}
}
}
2011-11-02 14:14:46 +01:00
// Show tabs
$head = user_prepare_head($object);
2011-06-29 12:23:32 +02:00
$title = $langs->trans("User");
dol_fiche_head($head, 'user', $title, 0, 'user');
/*
* Confirmation reinitialisation mot de passe
*/
if ($action == 'password')
{
print $form->formconfirm("fiche.php?id=$object->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$object->login),"confirm_password", '', 0, 1);
2011-06-29 12:23:32 +02:00
}
/*
* Confirmation envoi mot de passe
*/
if ($action == 'passwordsend')
{
print $form->formconfirm("fiche.php?id=$object->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$object->login),"confirm_passwordsend", '', 0, 1);
2011-06-29 12:23:32 +02:00
}
/*
* Confirmation desactivation
*/
if ($action == 'disable')
{
print $form->formconfirm("fiche.php?id=$object->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$object->login),"confirm_disable", '', 0, 1);
2011-06-29 12:23:32 +02:00
}
/*
* Confirmation activation
*/
if ($action == 'enable')
{
print $form->formconfirm("fiche.php?id=$object->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$object->login),"confirm_enable", '', 0, 1);
2011-06-29 12:23:32 +02:00
}
/*
* Confirmation suppression
*/
if ($action == 'delete')
{
print $form->formconfirm("fiche.php?id=$object->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$object->login),"confirm_delete", '', 0, 1);
2011-06-29 12:23:32 +02:00
}
/*
* Fiche en mode visu
*/
if ($action != 'edit')
2011-06-29 12:23:32 +02:00
{
$rowspan=16;
2011-06-29 12:23:32 +02:00
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>';
print '<td colspan="2">';
print $form->showrefnav($object,'id','',$user->rights->user->user->lire || $user->admin);
2011-06-29 12:23:32 +02:00
print '</td>';
print '</tr>'."\n";
2013-09-18 21:22:24 +02:00
if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $rowspan++;
if (! empty($conf->societe->enabled)) $rowspan++;
if (! empty($conf->adherent->enabled)) $rowspan++;
if (! empty($conf->skype->enabled)) $rowspan++;
2012-12-12 11:57:56 +01:00
2011-06-29 12:23:32 +02:00
// Lastname
print '<tr><td valign="top">'.$langs->trans("Lastname").'</td>';
2013-03-11 17:41:38 +01:00
print '<td>'.$object->lastname.'</td>';
// Photo
print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
print $form->showphoto('userphoto',$object,100);
print '</td>';
2010-12-27 18:36:31 +01:00
print '</tr>'."\n";
2011-06-29 12:23:32 +02:00
// Firstname
print '<tr><td valign="top">'.$langs->trans("Firstname").'</td>';
print '<td>'.$object->firstname.'</td>';
2010-12-27 18:36:31 +01:00
print '</tr>'."\n";
2005-02-27 15:12:16 +01:00
// Position/Job
print '<tr><td valign="top">'.$langs->trans("PostOrFunction").'</td>';
print '<td>'.$object->job.'</td>';
print '</tr>'."\n";
2011-06-29 12:23:32 +02:00
// Login
print '<tr><td valign="top">'.$langs->trans("Login").'</td>';
if (! empty($object->ldap_sid) && $object->statut==0)
2011-06-29 12:23:32 +02:00
{
print '<td class="error">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>';
}
else
{
print '<td>'.$object->login.'</td>';
2011-06-29 12:23:32 +02:00
}
2010-12-27 18:36:31 +01:00
print '</tr>'."\n";
2008-08-28 14:08:02 +02:00
2011-06-29 12:23:32 +02:00
// Password
print '<tr><td valign="top">'.$langs->trans("Password").'</td>';
if (! empty($object->ldap_sid))
2011-06-29 12:23:32 +02:00
{
if ($passDoNotExpire)
{
print '<td>'.$langs->trans("LdapUacf_".$statutUACF).'</td>';
}
else if($userChangePassNextLogon)
{
print '<td class="warning">'.$langs->trans("UserMustChangePassNextLogon",$ldap->domainFQDN).'</td>';
}
else if($userDisabled)
{
print '<td class="warning">'.$langs->trans("LdapUacf_".$statutUACF,$ldap->domainFQDN).'</td>';
}
else
{
print '<td>'.$langs->trans("DomainPassword").'</td>';
}
}
else
{
print '<td>';
if ($object->pass) print preg_replace('/./i','*',$object->pass);
2011-06-29 12:23:32 +02:00
else
{
if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
2011-06-29 12:23:32 +02:00
else print $langs->trans("Hidden");
}
print "</td>";
}
print '</tr>'."\n";
// Administrator
print '<tr><td valign="top">'.$langs->trans("Administrator").'</td><td>';
if (! empty($conf->multicompany->enabled) && $object->admin && ! $object->entity)
2011-06-29 12:23:32 +02:00
{
print $form->textwithpicto(yn($object->admin),$langs->trans("SuperAdministratorDesc"),1,"superadmin");
2011-06-29 12:23:32 +02:00
}
else if ($object->admin)
2011-06-29 12:23:32 +02:00
{
print $form->textwithpicto(yn($object->admin),$langs->trans("AdministratorDesc"),1,"admin");
2011-06-29 12:23:32 +02:00
}
else
{
print yn($object->admin);
2011-06-29 12:23:32 +02:00
}
print '</td></tr>'."\n";
2011-06-29 12:23:32 +02:00
// Type
print '<tr><td valign="top">'.$langs->trans("Type").'</td><td>';
$type=$langs->trans("Internal");
if ($object->societe_id) $type=$langs->trans("External");
print $form->textwithpicto($type,$langs->trans("InternalExternalDesc"));
if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')';
print '</td></tr>'."\n";
2008-08-28 14:08:02 +02:00
// Ldap sid
2013-01-10 08:27:12 +01:00
if ($object->ldap_sid)
{
print '<tr><td valign="top">'.$langs->trans("Type").'</td><td>';
2013-01-10 08:27:12 +01:00
print $langs->trans("DomainUser",$ldap->domainFQDN);
print '</td></tr>'."\n";
2013-01-10 08:27:12 +01:00
}
2011-06-29 12:23:32 +02:00
// Tel pro
print '<tr><td valign="top">'.$langs->trans("PhonePro").'</td>';
print '<td>'.dol_print_phone($object->office_phone,'',0,0,1).'</td>';
2010-12-27 18:36:31 +01:00
print '</tr>'."\n";
2008-08-28 14:08:02 +02:00
2011-06-29 12:23:32 +02:00
// Tel mobile
print '<tr><td valign="top">'.$langs->trans("PhoneMobile").'</td>';
print '<td>'.dol_print_phone($object->user_mobile,'',0,0,1).'</td>';
2010-12-27 18:36:31 +01:00
print '</tr>'."\n";
2008-08-28 14:08:02 +02:00
2011-06-29 12:23:32 +02:00
// Fax
print '<tr><td valign="top">'.$langs->trans("Fax").'</td>';
print '<td>'.dol_print_phone($object->office_fax,'',0,0,1).'</td>';
2010-12-27 18:36:31 +01:00
print '</tr>'."\n";
2014-04-08 23:51:50 +02:00
2013-11-07 13:17:08 +01:00
// Skype
if (! empty($conf->skype->enabled))
{
print '<tr><td valign="top">'.$langs->trans("Skype").'</td>';
print '<td>'.dol_print_skype($object->skype,0,0,1).'</td>';
print "</tr>\n";
}
2008-08-28 14:08:02 +02:00
2011-06-29 12:23:32 +02:00
// EMail
print '<tr><td valign="top">'.$langs->trans("EMail").'</td>';
print '<td>'.dol_print_email($object->email,0,0,1).'</td>';
2011-06-29 12:23:32 +02:00
print "</tr>\n";
2008-08-28 14:08:02 +02:00
2011-06-29 12:23:32 +02:00
// Signature
2012-10-29 10:00:24 +01:00
print '<tr><td valign="top">'.$langs->trans('Signature').'</td><td>';
print dol_htmlentitiesbr($object->signature);
2012-10-29 10:00:24 +01:00
print "</td></tr>\n";
// Hierarchy
print '<tr><td valign="top">'.$langs->trans("HierarchicalResponsible").'</td>';
print '<td>';
if (empty($object->fk_user)) print $langs->trans("None");
else {
$huser=new User($db);
$huser->fetch($object->fk_user);
print $huser->getNomUrl(1);
}
print '</td>';
print "</tr>\n";
2013-09-18 21:22:24 +02:00
// Accountancy code
2013-07-23 19:48:21 +02:00
if (! empty($conf->global->USER_ENABLE_ACCOUNTANCY_CODE)) // For the moment field is not used so must not appeared.
{
$rowspan++;
print '<tr><td valign="top">'.$langs->trans("AccountancyCode").'</td>';
print '<td>'.$object->accountancy_code.'</td>';
}
2013-09-18 21:22:24 +02:00
// Status
2011-06-29 12:23:32 +02:00
print '<tr><td valign="top">'.$langs->trans("Status").'</td>';
print '<td>';
print $object->getLibStatut(4);
2011-06-29 12:23:32 +02:00
print '</td>';
2010-12-27 18:36:31 +01:00
print '</tr>'."\n";
2008-08-28 14:08:02 +02:00
2011-06-29 12:23:32 +02:00
print '<tr><td valign="top">'.$langs->trans("LastConnexion").'</td>';
print '<td>'.dol_print_date($object->datelastlogin,"dayhour").'</td>';
2011-06-29 12:23:32 +02:00
print "</tr>\n";
print '<tr><td valign="top">'.$langs->trans("PreviousConnexion").'</td>';
print '<td>'.dol_print_date($object->datepreviouslogin,"dayhour").'</td>';
2011-06-29 12:23:32 +02:00
print "</tr>\n";
2013-09-18 21:22:24 +02:00
if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER))
2011-06-29 12:23:32 +02:00
{
2013-09-18 21:22:24 +02:00
print '<tr><td valign="top">'.$langs->trans("OpenIDURL").'</td>';
print '<td>'.$object->openid.'</td>';
2011-06-29 12:23:32 +02:00
print "</tr>\n";
}
2011-06-29 12:23:32 +02:00
// Company / Contact
if (! empty($conf->societe->enabled))
2011-06-29 12:23:32 +02:00
{
print '<tr><td valign="top">'.$langs->trans("LinkToCompanyContact").'</td>';
print '<td>';
if (isset($object->societe_id) && $object->societe_id > 0)
2011-06-29 12:23:32 +02:00
{
$societe = new Societe($db);
$societe->fetch($object->societe_id);
2011-06-29 12:23:32 +02:00
print $societe->getNomUrl(1,'');
}
else
{
print $langs->trans("ThisUserIsNot");
}
if (! empty($object->contact_id))
2011-06-29 12:23:32 +02:00
{
$contact = new Contact($db);
$contact->fetch($object->contact_id);
if ($object->societe_id > 0) print ' / ';
2011-06-29 12:23:32 +02:00
else print '<br>';
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$object->contact_id.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).'</a>';
2011-06-29 12:23:32 +02:00
}
print '</td>';
2010-12-27 18:36:31 +01:00
print '</tr>'."\n";
2011-06-29 12:23:32 +02:00
}
// Module Adherent
if (! empty($conf->adherent->enabled))
2011-06-29 12:23:32 +02:00
{
$langs->load("members");
print '<tr><td valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>';
print '<td>';
if ($object->fk_member)
2011-06-29 12:23:32 +02:00
{
$adh=new Adherent($db);
$adh->fetch($object->fk_member);
2011-06-29 12:23:32 +02:00
$adh->ref=$adh->getFullname($langs); // Force to show login instead of id
print $adh->getNomUrl(1);
}
else
{
print $langs->trans("UserNotLinkedToMember");
}
print '</td>';
2010-12-27 18:36:31 +01:00
print '</tr>'."\n";
2011-06-29 12:23:32 +02:00
}
// Multicompany
// TODO This should be done with hook formObjectOption
if (is_object($mc))
{
if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
print '<tr><td valign="top">'.$langs->trans("Entity").'</td><td width="75%" class="valeur">';
if ($object->admin && ! $object->entity)
{
print $langs->trans("AllEntities");
}
else
{
$mc->getInfo($object->entity);
print $mc->label;
}
print "</td></tr>\n";
}
}
// Other attributes
$parameters=array('colspan' => ' colspan="2"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields);
}
2012-12-12 11:57:56 +01:00
print "</table>\n";
2011-06-29 12:23:32 +02:00
print "</div>\n";
/*
* Buttons actions
2011-06-29 12:23:32 +02:00
*/
print '<div class="tabsAction">';
if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
2011-06-29 12:23:32 +02:00
{
if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED))
{
2013-04-25 20:36:38 +02:00
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("DisabledInMonoUserMode")).'">'.$langs->trans("Modify").'</a></div>';
2011-06-29 12:23:32 +02:00
}
else
{
2013-04-25 20:36:38 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>';
2011-06-29 12:23:32 +02:00
}
}
elseif ($caneditpassword && ! $object->ldap_sid &&
(empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
2011-06-29 12:23:32 +02:00
{
2013-04-25 20:36:38 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("EditPassword").'</a></div>';
2011-06-29 12:23:32 +02:00
}
// Si on a un gestionnaire de generation de mot de passe actif
if ($conf->global->USER_PASSWORD_GENERATED != 'none')
{
if ($object->statut == 0)
{
2013-04-25 20:36:38 +02:00
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("ReinitPassword").'</a></div>';
}
elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
2013-01-23 15:41:17 +01:00
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
2011-06-29 12:23:32 +02:00
{
2013-04-25 20:36:38 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=password">'.$langs->trans("ReinitPassword").'</a></div>';
2011-06-29 12:23:32 +02:00
}
if ($object->statut == 0)
{
2013-04-25 20:36:38 +02:00
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("UserDisabled")).'">'.$langs->trans("SendNewPassword").'</a></div>';
}
else if (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid &&
2013-01-23 15:41:17 +01:00
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
2011-06-29 12:23:32 +02:00
{
2013-04-25 20:36:38 +02:00
if ($object->email) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=passwordsend">'.$langs->trans("SendNewPassword").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans("SendNewPassword").'</a></div>';
2011-06-29 12:23:32 +02:00
}
}
// Activer
if ($user->id <> $id && $candisableuser && $object->statut == 0 &&
2013-01-23 15:41:17 +01:00
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
2011-06-29 12:23:32 +02:00
{
2013-04-25 20:36:38 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=enable">'.$langs->trans("Reactivate").'</a></div>';
2011-06-29 12:23:32 +02:00
}
// Desactiver
if ($user->id <> $id && $candisableuser && $object->statut == 1 &&
2013-01-23 15:41:17 +01:00
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
2011-06-29 12:23:32 +02:00
{
2013-04-25 20:36:38 +02:00
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=disable&amp;id='.$object->id.'">'.$langs->trans("DisableUser").'</a></div>';
2011-06-29 12:23:32 +02:00
}
// Delete
if ($user->id <> $id && $candisableuser &&
2013-01-23 15:41:17 +01:00
((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)))
2011-06-29 12:23:32 +02:00
{
2013-01-10 08:27:12 +01:00
if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin
{
2013-04-25 20:36:38 +02:00
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&amp;id='.$object->id.'">'.$langs->trans("DeleteUser").'</a></div>';
}
else
{
2013-04-25 20:36:38 +02:00
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("MustBeAdminToDeleteOtherAdmin")).'">'.$langs->trans("DeleteUser").'</a></div>';
}
2011-06-29 12:23:32 +02:00
}
print "</div>\n";
print "<br>\n";
/*
* Liste des groupes dans lequel est l'utilisateur
*/
if ($canreadgroup)
{
print_fiche_titre($langs->trans("ListOfGroupsForUser"),'','');
// On selectionne les groupes auquel fait parti le user
$exclude = array();
$usergroup=new UserGroup($db);
$groupslist = $usergroup->listGroupsForUser($object->id);
2011-06-29 12:23:32 +02:00
2012-08-01 12:58:19 +02:00
if (! empty($groupslist))
2011-06-29 12:23:32 +02:00
{
2012-08-01 13:30:38 +02:00
if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)))
2012-08-01 12:58:19 +02:00
{
foreach($groupslist as $groupforuser)
{
$exclude[]=$groupforuser->id;
}
}
2011-06-29 12:23:32 +02:00
}
if ($caneditgroup)
{
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'."\n";
2011-08-20 00:15:22 +02:00
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="addgroup" />';
2011-06-29 12:23:32 +02:00
print '<table class="noborder" width="100%">'."\n";
2011-11-14 18:37:04 +01:00
print '<tr class="liste_titre"><th class="liste_titre" width="25%">'.$langs->trans("GroupsToAdd").'</th>'."\n";
print '<th>';
print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity);
2011-06-29 12:23:32 +02:00
print ' &nbsp; ';
2011-08-19 09:22:17 +02:00
// Multicompany
2011-08-21 12:01:36 +02:00
if (! empty($conf->multicompany->enabled))
2011-08-19 09:22:17 +02:00
{
if ($conf->entity == 1 && $conf->multicompany->transverse_mode)
2011-08-19 09:22:17 +02:00
{
print '</td><td valign="top">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($conf->entity);
}
else
{
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
}
}
else
2011-08-20 00:15:22 +02:00
{
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
}
print '<input type="submit" class="button" value="'.$langs->trans("Add").'" />';
2011-11-14 18:37:04 +01:00
print '</th></tr>'."\n";
2011-06-29 12:23:32 +02:00
print '</table></form>'."\n";
print '<br>';
}
/*
2013-04-14 02:54:54 +02:00
* Groups assigned to user
2011-06-29 12:23:32 +02:00
*/
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td class="liste_titre" width="25%">'.$langs->trans("Groups").'</td>';
if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
2011-08-20 00:15:22 +02:00
{
print '<td class="liste_titre" width="25%">'.$langs->trans("Entity").'</td>';
}
2011-06-29 12:23:32 +02:00
print "<td>&nbsp;</td></tr>\n";
if (! empty($groupslist))
{
$var=true;
foreach($groupslist as $group)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>';
if ($caneditgroup)
{
2013-04-14 02:54:54 +02:00
print '<a href="'.DOL_URL_ROOT.'/user/group/fiche.php?id='.$group->id.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$group->name.'</a>';
2011-06-29 12:23:32 +02:00
}
else
{
2013-04-14 02:54:54 +02:00
print img_object($langs->trans("ShowGroup"),"group").' '.$group->name;
2011-06-29 12:23:32 +02:00
}
print '</td>';
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
2011-08-19 09:22:17 +02:00
{
print '<td class="valeur">';
if (! empty($group->usergroup_entity))
{
$nb=0;
foreach($group->usergroup_entity as $group_entity)
{
$mc->getInfo($group_entity);
print ($nb > 0 ? ', ' : '').$mc->label;
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=removegroup&amp;group='.$group->id.'&amp;entity='.$group_entity.'">';
2012-07-10 13:35:22 +02:00
print img_delete($langs->trans("RemoveFromGroup"));
print '</a>';
$nb++;
}
}
2011-08-19 09:22:17 +02:00
}
2011-06-29 12:23:32 +02:00
print '<td align="right">';
2012-07-10 13:35:22 +02:00
if ($caneditgroup && empty($conf->multicompany->transverse_mode))
2011-06-29 12:23:32 +02:00
{
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=removegroup&amp;group='.$group->id.'">';
2011-06-29 12:23:32 +02:00
print img_delete($langs->trans("RemoveFromGroup"));
2012-07-10 13:35:22 +02:00
print '</a>';
2011-06-29 12:23:32 +02:00
}
else
{
print "&nbsp;";
}
print "</td></tr>\n";
}
}
else
{
2011-08-20 00:15:22 +02:00
print '<tr '.$bc[false].'><td colspan="3">'.$langs->trans("None").'</td></tr>';
2011-06-29 12:23:32 +02:00
}
print "</table>";
print "<br>";
}
}
/*
* Fiche en mode edition
*/
if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id)))
2011-06-29 12:23:32 +02:00
{
2013-09-18 21:22:24 +02:00
$rowspan=15;
if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $rowspan++;
if (! empty($conf->societe->enabled)) $rowspan++;
if (! empty($conf->adherent->enabled)) $rowspan++;
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST" name="updateuser" enctype="multipart/form-data">';
2011-06-29 12:23:32 +02:00
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
2013-01-23 15:41:17 +01:00
print '<input type="hidden" name="entity" value="'.$object->entity.'">';
2011-06-29 12:23:32 +02:00
print '<table width="100%" class="border">';
print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>';
print '<td colspan="2">';
print $object->id;
2011-06-29 12:23:32 +02:00
print '</td>';
print '</tr>';
// Lastname
print "<tr>";
print '<td valign="top" class="fieldrequired">'.$langs->trans("Lastname").'</td>';
print '<td>';
if ($caneditfield && !$object->ldap_sid)
2011-06-29 12:23:32 +02:00
{
2013-02-23 11:42:12 +01:00
print '<input size="30" type="text" class="flat" name="lastname" value="'.$object->lastname.'">';
2011-06-29 12:23:32 +02:00
}
else
{
2013-02-23 11:42:12 +01:00
print '<input type="hidden" name="lastname" value="'.$object->lastname.'">';
print $object->lastname;
2011-06-29 12:23:32 +02:00
}
print '</td>';
// Photo
print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
print $form->showphoto('userphoto',$object);
if ($caneditfield)
{
if ($object->photo) print "<br>\n";
2013-04-24 04:06:13 +02:00
print '<table class="nobordernopadding hideonsmartphone">';
if ($object->photo) print '<tr><td align="center"><input type="checkbox" class="flat" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
2011-06-11 22:58:08 +02:00
print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
print '</table>';
}
print '</td>';
2011-08-19 09:22:17 +02:00
2011-06-29 12:23:32 +02:00
print '</tr>';
// Firstname
print "<tr>".'<td valign="top">'.$langs->trans("Firstname").'</td>';
print '<td>';
if ($caneditfield && !$object->ldap_sid)
2011-06-29 12:23:32 +02:00
{
print '<input size="30" type="text" class="flat" name="firstname" value="'.$object->firstname.'">';
2011-06-29 12:23:32 +02:00
}
else
{
print '<input type="hidden" name="firstname" value="'.$object->firstname.'">';
print $object->firstname;
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
// Position/Job
print '<tr><td valign="top">'.$langs->trans("PostOrFunction").'</td>';
print '<td>';
if ($caneditfield)
{
print '<input size="30" type="text" name="job" value="'.$object->job.'">';
}
else
{
print '<input type="hidden" name="job" value="'.$object->job.'">';
print $object->job;
}
print '</td></tr>';
2011-06-29 12:23:32 +02:00
// Login
print "<tr>".'<td valign="top"><span class="fieldrequired">'.$langs->trans("Login").'</span></td>';
print '<td>';
if ($user->admin && !$object->ldap_sid)
2011-06-29 12:23:32 +02:00
{
print '<input size="12" maxlength="24" type="text" class="flat" name="login" value="'.$object->login.'">';
2011-06-29 12:23:32 +02:00
}
else
{
print '<input type="hidden" name="login" value="'.$object->login.'">';
print $object->login;
2011-06-29 12:23:32 +02:00
}
print '</td>';
print '</tr>';
// Pass
print '<tr><td valign="top">'.$langs->trans("Password").'</td>';
print '<td>';
if ($object->ldap_sid)
2011-06-29 12:23:32 +02:00
{
$text=$langs->trans("DomainPassword");
}
else if ($caneditpassword)
{
$text='<input size="12" maxlength="32" type="password" class="flat" name="password" value="'.$object->pass.'" autocomplete="off">';
2011-06-29 12:23:32 +02:00
if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http')
{
$text=$form->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning');
2011-06-29 12:23:32 +02:00
}
}
else
{
$text=preg_replace('/./i','*',$object->pass);
2011-06-29 12:23:32 +02:00
}
print $text;
print "</td></tr>\n";
// Administrator
2011-11-14 18:37:04 +01:00
print '<tr><td valign="top">'.$langs->trans("Administrator").'</td>';
if ($object->societe_id > 0)
2011-06-29 12:23:32 +02:00
{
$langs->load("admin");
2011-06-29 12:23:32 +02:00
print '<td>';
print '<input type="hidden" name="admin" value="'.$object->admin.'">'.yn($object->admin);
2011-06-29 12:23:32 +02:00
print ' ('.$langs->trans("ExternalUser").')';
print '</td></tr>';
}
else
{
print '<td>';
$nbSuperAdmin = $user->getNbOfUsers('superadmin');
if ($user->admin
&& ($user->id != $object->id) // Don't downgrade ourself
&& ($object->entity > 0 || $nbSuperAdmin > 1) // Don't downgrade a superadmin if alone
2011-06-29 12:23:32 +02:00
)
{
print $form->selectyesno('admin',$object->admin,1);
2011-06-29 12:23:32 +02:00
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode))
2011-06-29 12:23:32 +02:00
{
if ($conf->use_javascript_ajax)
{
print '<script type="text/javascript">
$(function() {
2011-08-20 00:15:22 +02:00
var admin = $("select[name=admin]").val();
if (admin == 0) {
$("input[name=superadmin]")
.attr("disabled", true)
.attr("checked", false);
}
2011-08-20 00:15:22 +02:00
if ($("input[name=superadmin]").attr("checked") == "checked") {
$("select[name=entity]")
.attr("disabled", true);
}
$("select[name=admin]").change(function() {
if ( $(this).val() == 0 ) {
$("input[name=superadmin]")
.attr("disabled", true)
.attr("checked", false);
2011-08-20 00:15:22 +02:00
$("select[name=entity]")
.attr("disabled", false);
} else {
$("input[name=superadmin]")
.attr("disabled", false);
}
});
2011-08-20 00:15:22 +02:00
$("input[name=superadmin]").change(function() {
if ( $(this).attr("checked") == "checked" ) {
$("select[name=entity]")
.attr("disabled", true);
} else {
$("select[name=entity]")
.attr("disabled", false);
}
});
});
</script>';
2011-06-29 12:23:32 +02:00
}
$checked=(($object->admin && ! $object->entity) ? ' checked' : '');
2011-06-29 12:23:32 +02:00
print '<input type="checkbox" name="superadmin" value="1"'.$checked.' /> '.$langs->trans("SuperAdministrator");
2011-08-19 11:26:41 +02:00
}
2011-06-29 12:23:32 +02:00
}
else
{
$yn = yn($object->admin);
print '<input type="hidden" name="admin" value="'.$object->admin.'">';
print '<input type="hidden" name="superadmin" value="'.(empty($object->entity) ? 1 : 0).'">';
if (! empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning');
2011-08-19 11:26:41 +02:00
else print $yn;
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
}
// Type
print '<tr><td width="25%" valign="top">'.$langs->trans("Type").'</td>';
print '<td>';
if ($user->id == $object->id || ! $user->admin)
{
2013-01-10 08:27:12 +01:00
$type=$langs->trans("Internal");
if ($object->societe_id) $type=$langs->trans("External");
print $form->textwithpicto($type,$langs->trans("InternalExternalDesc"));
if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')';
}
else
{
$type=0;
if ($object->contact_id) $type=$object->contact_id;
print $form->selectcontacts(0,$type,'contactid',2,'','',1,'',false,1);
if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')';
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
2011-06-29 12:23:32 +02:00
// Tel pro
print "<tr>".'<td valign="top">'.$langs->trans("PhonePro").'</td>';
print '<td>';
if ($caneditfield && empty($object->ldap_sid))
2011-06-29 12:23:32 +02:00
{
print '<input size="20" type="text" name="office_phone" class="flat" value="'.$object->office_phone.'">';
2011-06-29 12:23:32 +02:00
}
else
{
print '<input type="hidden" name="office_phone" value="'.$object->office_phone.'">';
print $object->office_phone;
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
// Tel mobile
print "<tr>".'<td valign="top">'.$langs->trans("PhoneMobile").'</td>';
print '<td>';
if ($caneditfield && empty($object->ldap_sid))
2011-06-29 12:23:32 +02:00
{
print '<input size="20" type="text" name="user_mobile" class="flat" value="'.$object->user_mobile.'">';
2011-06-29 12:23:32 +02:00
}
else
{
print '<input type="hidden" name="user_mobile" value="'.$object->user_mobile.'">';
print $object->user_mobile;
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
// Fax
print "<tr>".'<td valign="top">'.$langs->trans("Fax").'</td>';
print '<td>';
if ($caneditfield && empty($object->ldap_sid))
2011-06-29 12:23:32 +02:00
{
print '<input size="20" type="text" name="office_fax" class="flat" value="'.$object->office_fax.'">';
2011-06-29 12:23:32 +02:00
}
else
{
print '<input type="hidden" name="office_fax" value="'.$object->office_fax.'">';
print $object->office_fax;
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
2013-11-07 13:17:08 +01:00
// Skype
if (! empty($conf->skype->enabled))
{
print '<tr><td valign="top">'.$langs->trans("Skype").'</td>';
print '<td>';
if ($caneditfield && empty($object->ldap_sid))
{
print '<input size="40" type="text" name="skype" class="flat" value="'.$object->skype.'">';
}
else
{
print '<input type="hidden" name="skype" value="'.$object->skype.'">';
print $object->skype;
}
print '</td></tr>';
}
2014-04-08 23:51:50 +02:00
2011-06-29 12:23:32 +02:00
// EMail
print "<tr>".'<td valign="top"'.(! empty($conf->global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").'</td>';
2011-06-29 12:23:32 +02:00
print '<td>';
if ($caneditfield && empty($object->ldap_sid))
2011-06-29 12:23:32 +02:00
{
print '<input size="40" type="text" name="email" class="flat" value="'.$object->email.'">';
2011-06-29 12:23:32 +02:00
}
else
{
print '<input type="hidden" name="email" value="'.$object->email.'">';
print $object->email;
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
// Signature
print "<tr>".'<td valign="top">'.$langs->trans("Signature").'</td>';
print '<td>';
if ($caneditfield)
{
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2013-04-11 10:23:35 +02:00
$doleditor=new DolEditor('signature',$object->signature,'',138,'dolibarr_mailings','In',false,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,72);
print $doleditor->Create(1);
}
else
{
print dol_htmlentitiesbr($object->signature);
}
2011-06-29 12:23:32 +02:00
print '</td></tr>';
2013-09-18 21:22:24 +02:00
// OpenID url
if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER))
2011-06-29 12:23:32 +02:00
{
2013-09-18 21:22:24 +02:00
print "<tr>".'<td valign="top">'.$langs->trans("OpenIDURL").'</td>';
2011-06-29 12:23:32 +02:00
print '<td>';
2013-09-18 21:22:24 +02:00
if ($caneditfield)
2011-06-29 12:23:32 +02:00
{
2013-09-18 21:22:24 +02:00
print '<input size="40" type="url" name="openid" class="flat" value="'.$object->openid.'">';
2011-06-29 12:23:32 +02:00
}
else
2013-09-18 21:22:24 +02:00
{
print '<input type="hidden" name="openid" value="'.$object->openid.'">';
print $object->openid;
2011-06-29 12:23:32 +02:00
}
print '</td></tr>';
}
// Hierarchy
print '<tr><td valign="top">'.$langs->trans("HierarchicalResponsible").'</td>';
print '<td>';
if ($caneditfield)
{
print $form->select_dolusers($object->fk_user,'fk_user',1,array($object->id),0,'',0,$object->entity);
}
else
{
print '<input type="hidden" name="fk_user" value="'.$object->fk_user.'">';
$huser=new User($db);
$huser->fetch($object->fk_user);
print $huser->getNomUrl(1);
}
print '</td>';
print "</tr>\n";
2013-09-18 21:22:24 +02:00
// Accountancy code
2014-08-04 10:44:19 +02:00
if (! empty($conf->global->USER_ENABLE_ACCOUNTANCY_CODE)) // For the moment field is not used so must not appeared.
{
2014-08-04 10:44:19 +02:00
print "<tr>";
print '<td valign="top">'.$langs->trans("AccountancyCode").'</td>';
print '<td>';
if ($caneditfield)
{
print '<input size="30" type="text" class="flat" name="accountancy_code" value="'.$object->accountancy_code.'">';
}
else
{
print '<input type="hidden" name="accountancy_code" value="'.$object->accountancy_code.'">';
print $object->accountancy_code;
}
print '</td>';
print "</tr>";
}
// Status
2011-06-29 12:23:32 +02:00
print '<tr><td valign="top">'.$langs->trans("Status").'</td>';
print '<td>';
print $object->getLibStatut(4);
2011-06-29 12:23:32 +02:00
print '</td></tr>';
2011-06-29 12:23:32 +02:00
// Company / Contact
if (! empty($conf->societe->enabled))
2011-06-29 12:23:32 +02:00
{
print '<tr><td width="25%" valign="top">'.$langs->trans("LinkToCompanyContact").'</td>';
print '<td>';
if ($object->societe_id > 0)
2011-06-29 12:23:32 +02:00
{
$societe = new Societe($db);
$societe->fetch($object->societe_id);
2011-06-29 12:23:32 +02:00
print $societe->getNomUrl(1,'');
if ($object->contact_id)
2011-06-29 12:23:32 +02:00
{
$contact = new Contact($db);
$contact->fetch($object->contact_id);
print ' / <a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$object->contact_id.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).'</a>';
2011-06-29 12:23:32 +02:00
}
}
else
{
print $langs->trans("ThisUserIsNot");
}
2013-04-24 12:43:23 +02:00
print ' ('.$langs->trans("UseTypeFieldToChange").')';
2011-06-29 12:23:32 +02:00
print '</td>';
print "</tr>\n";
}
// Module Adherent
if (! empty($conf->adherent->enabled))
2011-06-29 12:23:32 +02:00
{
$langs->load("members");
print '<tr><td width="25%" valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>';
print '<td>';
if ($object->fk_member)
2011-06-29 12:23:32 +02:00
{
$adh=new Adherent($db);
$adh->fetch($object->fk_member);
2011-06-29 12:23:32 +02:00
$adh->ref=$adh->login; // Force to show login instead of id
print $adh->getNomUrl(1);
}
else
{
print $langs->trans("UserNotLinkedToMember");
}
print '</td>';
print "</tr>\n";
}
// Multicompany
if (! empty($conf->multicompany->enabled))
{
if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity)
{
print "<tr>".'<td valign="top">'.$langs->trans("Entity").'</td>';
print "<td>".$mc->select_entities($object->entity);
print "</td></tr>\n";
}
else
{
print '<input type="hidden" name="entity" value="'.$conf->entity.'" />';
}
}
2012-12-02 11:03:23 +01:00
// Other attributes
$parameters=array('colspan' => ' colspan="2"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields,'edit');
2012-12-02 11:03:23 +01:00
}
2012-12-12 11:57:56 +01:00
print '</table>';
print '<br><center>';
2011-06-29 12:23:32 +02:00
print '<input value="'.$langs->trans("Save").'" class="button" type="submit" name="save">';
print ' &nbsp; ';
print '<input value="'.$langs->trans("Cancel").'" class="button" type="submit" name="cancel">';
print '</center>';
2008-08-28 14:08:02 +02:00
2011-06-29 12:23:32 +02:00
print '</form>';
2008-08-28 14:08:02 +02:00
2011-06-29 12:23:32 +02:00
print '</div>';
}
2008-08-28 14:08:02 +02:00
if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) $ldap->close;
2011-06-29 12:23:32 +02:00
}
2002-05-06 21:10:48 +02:00
}
llxFooter();
$db->close();