diff --git a/ChangeLog b/ChangeLog index 892e37a9eda..361cd1145ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,7 +30,7 @@ For users: - New: Add link to third party into sells and purchase journal. - New: Suggest a method to generate a backup file for user with no access to mysqldump binary. -- New: Can use extrafields on contacts/addresses. +- New: Can also use extrafields on contacts/addresses and users. - New: Support unique field for extrafields. - New: Extra fields supports more types (int, string, double, date, datetime). - New: Can correct stock of a warehouse from warehouse card. diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index bf9bec788d4..efa6c30c6e2 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -27,7 +27,9 @@ */ require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("admin"); $langs->load("members"); @@ -35,6 +37,9 @@ $langs->load("users"); if (! $user->admin) accessforbidden(); +$extrafields = new ExtraFields($db); + + /* * Action */ @@ -71,14 +76,17 @@ if (preg_match('/del_(.*)/',$action,$reg)) * View */ -llxHeader(); +$help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios'; +llxHeader('',$langs->trans("UsersSetup"),$help_url); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("UsersSetup"),$linkback,'setup'); -print "
"; -print_fiche_titre($langs->trans("MemberMainOptions"),'',''); +$head=user_admin_prepare_head(); + +dol_fiche_head($head,'card', $langs->trans("User"), 0, 'user'); + print ''; print ''; print ''; @@ -114,7 +122,8 @@ else print ''; print '
'.$langs->trans("Description").'
'; -print '

'; + +dol_fiche_end(); llxFooter(); $db->close(); diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index a9e074a1fc5..a4e6a9623c5 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -150,6 +150,43 @@ function group_prepare_head($object) return $head; } + + +/** + * Prepare array with list of tabs + * + * @return array Array of tabs to shoc + */ +function user_admin_prepare_head() +{ + global $langs, $conf, $user; + + $langs->load("users"); + $h=0; + + $head[$h][0] = DOL_URL_ROOT.'/admin/user.php'; + $head[$h][1] = $langs->trans("Parameters"); + $head[$h][2] = 'card'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/user/admin/user_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'attributes'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'useradmin'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'useradmin','remove'); + + return $head; +} + + + /** * Prepare array with list of tabs * diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index b05d2c9232f..61735acebe6 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -841,4 +841,17 @@ INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) -- increase field size -ALTER TABLE llx_bank_account MODIFY COLUMN code_banque varchar(8); \ No newline at end of file +ALTER TABLE llx_bank_account MODIFY COLUMN code_banque varchar(8); + + + +create table llx_user_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, -- member id + import_key varchar(14) -- import key +)ENGINE=innodb; + +ALTER TABLE llx_user_extrafields ADD INDEX idx_user_extrafields (fk_object); + diff --git a/htdocs/install/mysql/tables/llx_user_extrafields.key.sql b/htdocs/install/mysql/tables/llx_user_extrafields.key.sql new file mode 100644 index 00000000000..a4af69a614a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_user_extrafields.key.sql @@ -0,0 +1,23 @@ +-- =================================================================== +-- Copyright (C) 2002-2003 Rodolphe Quiedeville +-- Copyright (C) 2002-2003 Jean-Louis Bergamo +-- Copyright (C) 2009 Regis Houssin +-- Copyright (C) 2011 Laurent Destailleur +-- +-- 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 2 of the License, or +-- (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 +-- along with this program. If not, see . +-- +-- =================================================================== + + +ALTER TABLE llx_user_extrafields ADD INDEX idx_user_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_user_extrafields.sql b/htdocs/install/mysql/tables/llx_user_extrafields.sql new file mode 100644 index 00000000000..96b4ec69601 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_user_extrafields.sql @@ -0,0 +1,27 @@ +-- =================================================================== +-- Copyright (C) 2002-2003 Rodolphe Quiedeville +-- Copyright (C) 2002-2003 Jean-Louis Bergamo +-- Copyright (C) 2009 Regis Houssin +-- +-- 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 2 of the License, or +-- (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 +-- along with this program. If not, see . +-- +-- =================================================================== + +create table llx_user_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, -- member id + import_key varchar(14) -- import key +)ENGINE=innodb; diff --git a/htdocs/user/admin/user_extrafields.php b/htdocs/user/admin/user_extrafields.php new file mode 100644 index 00000000000..dbe4ace030b --- /dev/null +++ b/htdocs/user/admin/user_extrafields.php @@ -0,0 +1,157 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * + * 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 2 of the License, or + * (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 + * along with this program. If not, see . + */ + +/** + * \file htdocs/adherents/admin/adherent_extrafields.php + * \ingroup member + * \brief Page to setup extra fields of members + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("users"); +$langs->load("admin"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=getStaticMember(get_class($extrafields),'type2label'); +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='user'; + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("Users"); + +$help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios'; +llxHeader('',$langs->trans("UsersSetup"),$help_url); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("UsersSetup"),$linkback,'setup'); + + +$head = user_admin_prepare_head(); + +dol_fiche_head($head, 'attributes', $langs->trans("User"), 0, 'user'); + + +print $langs->trans("DefineHereComplementaryAttributes",$textobject).'
'."\n"; +print '
'; + +dol_htmloutput_errors($mesg); + +// Load attribute_label +$extrafields->fetch_name_optionals_label($elementtype); + +print ""; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=True; +foreach($extrafields->attribute_type as $key => $value) +{ + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print ""; + // $i++; +} + +print "
'.$langs->trans("Label").''.$langs->trans("AttributeCode").''.$langs->trans("Type").''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").' 
".$extrafields->attribute_label[$key]."".$key."".$type2label[$extrafields->attribute_type[$key]]."'.$extrafields->attribute_size[$key]."'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.img_edit().''; + print "  ".img_delete()."
"; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation d'un champ optionnel + /* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition d'un champ optionnel */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 314a8b6d584..abf8ef515c8 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1189,6 +1189,25 @@ class User extends CommonObject } } + // Actions on extra fields (by external module or standard code) + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + $hookmanager->initHooks(array('userdao')); + $parameters=array('socid'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + if (! $error && ! $notrigger) { // Appel des triggers diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 3921afa6a6b..778617f686d 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -33,6 +33,7 @@ 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'); @@ -85,6 +86,8 @@ $langs->load("companies"); $langs->load("ldap"); $form = new Form($db); +$object = new User($db); +$extrafields = new ExtraFields($db); /** @@ -95,9 +98,8 @@ if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser) { if ($id <> $user->id) { - $edituser = new User($db); - $edituser->fetch($id); - $edituser->setstatus(0); + $object->fetch($id); + $object->setstatus(0); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); exit; } @@ -106,12 +108,11 @@ if ($action == 'confirm_enable' && $confirm == "yes" && $candisableuser) { if ($id <> $user->id) { - $edituser = new User($db); - $edituser->fetch($id); + $object->fetch($id); if (!empty($conf->file->main_limit_users)) { - $nb = $edituser->getNbOfUsers("active"); + $nb = $object->getNbOfUsers("active"); if ($nb >= $conf->file->main_limit_users) { $message='
'.$langs->trans("YourQuotaOfUsersIsReached").'
'; @@ -120,7 +121,7 @@ if ($action == 'confirm_enable' && $confirm == "yes" && $candisableuser) if (! $message) { - $edituser->setstatus(1); + $object->setstatus(1); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); exit; } @@ -131,9 +132,9 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser) { if ($id <> $user->id) { - $edituser = new User($db); - $edituser->id=$id; - $result = $edituser->delete(); + $object = new User($db); + $object->id=$id; + $result = $object->delete(); if ($result < 0) { $langs->load("errors"); @@ -161,11 +162,9 @@ if ($action == 'add' && $canadduser) $action="create"; // Go back to create page } - $edituser = new User($db); - if (! empty($conf->file->main_limit_users)) // If option to limit users is set { - $nb = $edituser->getNbOfUsers("active"); + $nb = $object->getNbOfUsers("active"); if ($nb >= $conf->file->main_limit_users) { $message='
'.$langs->trans("YourQuotaOfUsersIsReached").'
'; @@ -175,57 +174,66 @@ if ($action == 'add' && $canadduser) if (! $message) { - $edituser->lastname = $_POST["nom"]; - $edituser->firstname = $_POST["prenom"]; - $edituser->login = $_POST["login"]; - $edituser->admin = $_POST["admin"]; - $edituser->office_phone = $_POST["office_phone"]; - $edituser->office_fax = $_POST["office_fax"]; - $edituser->user_mobile = $_POST["user_mobile"]; - $edituser->email = $_POST["email"]; - $edituser->job = $_POST["job"]; - $edituser->signature = $_POST["signature"]; - $edituser->note = $_POST["note"]; - $edituser->ldap_sid = $_POST["ldap_sid"]; + $object->lastname = $_POST["nom"]; + $object->firstname = $_POST["prenom"]; + $object->login = $_POST["login"]; + $object->admin = $_POST["admin"]; + $object->office_phone = $_POST["office_phone"]; + $object->office_fax = $_POST["office_fax"]; + $object->user_mobile = $_POST["user_mobile"]; + $object->email = $_POST["email"]; + $object->job = $_POST["job"]; + $object->signature = $_POST["signature"]; + $object->note = $_POST["note"]; + $object->ldap_sid = $_POST["ldap_sid"]; + // Get extra fields + foreach($_POST as $key => $value) + { + if (preg_match("/^options_/",$key)) + { + $object->array_options[$key]=GETPOST($key); + } + } + // FIXME external module - $edituser->webcal_login = $_POST["webcal_login"]; - $edituser->phenix_login = $_POST["phenix_login"]; - $edituser->phenix_pass = $_POST["phenix_pass"]; + $object->webcal_login = $_POST["webcal_login"]; + $object->phenix_login = $_POST["phenix_login"]; + $object->phenix_pass = $_POST["phenix_pass"]; // If multicompany is off, admin users must all be on entity 0. if (! empty($conf->multicompany->enabled)) { if (! empty($_POST["superadmin"])) { - $edituser->entity = 0; + $object->entity = 0; } else if ($conf->multicompany->transverse_mode) { - $edituser->entity = 1; // all users in master entity + $object->entity = 1; // all users in master entity } else { - $edituser->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); + $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); } } else if (! empty($_POST["admin"])) { - $edituser->entity=0; + $object->entity=0; } else { - $edituser->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); + $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); } $db->begin(); - $id = $edituser->create($user); + $id = $object->create($user); if ($id > 0) { if (isset($_POST['password']) && trim($_POST['password'])) { - $edituser->setPassword($user,trim($_POST['password'])); + $object->setPassword($user,trim($_POST['password'])); } $db->commit(); @@ -237,8 +245,8 @@ if ($action == 'add' && $canadduser) { $langs->load("errors"); $db->rollback(); - if (is_array($edituser->errors) && count($edituser->errors)) $message='
'.join('
',$langs->trans($edituser->errors)).'
'; - else $message='
'.$langs->trans($edituser->error).'
'; + if (is_array($object->errors) && count($object->errors)) $message='
'.join('
',$langs->trans($object->errors)).'
'; + else $message='
'.$langs->trans($object->error).'
'; $action="create"; // Go back to create page } @@ -254,10 +262,9 @@ if (($action == 'addgroup' || $action == 'removegroup') && $caneditfield) $editgroup->fetch($group); $editgroup->oldcopy=dol_clone($editgroup); - $edituser = new User($db); - $edituser->fetch($id); - if ($action == 'addgroup') $edituser->SetInGroup($group,($conf->multicompany->transverse_mode?GETPOST("entity"):$editgroup->entity)); - if ($action == 'removegroup') $edituser->RemoveFromGroup($group,($conf->multicompany->transverse_mode?GETPOST("entity"):$editgroup->entity)); + $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)); if ($result > 0) { @@ -266,7 +273,7 @@ if (($action == 'addgroup' || $action == 'removegroup') && $caneditfield) } else { - $message.=$edituser->error; + $message.=$object->error; } } } @@ -291,83 +298,91 @@ if ($action == 'update' && ! $_POST["cancel"]) if (! $message) { $db->begin(); - $edituser = new User($db); - $edituser->fetch($id); + $object->fetch($id); - $edituser->oldcopy=dol_clone($edituser); + $object->oldcopy=dol_clone($object); - $edituser->lastname = $_POST["nom"]; - $edituser->firstname = $_POST["prenom"]; - $edituser->login = $_POST["login"]; - $edituser->pass = $_POST["password"]; - $edituser->admin = $_POST["admin"]; - $edituser->office_phone = $_POST["office_phone"]; - $edituser->office_fax = $_POST["office_fax"]; - $edituser->user_mobile = $_POST["user_mobile"]; - $edituser->email = $_POST["email"]; - $edituser->job = $_POST["job"]; - $edituser->signature = $_POST["signature"]; - $edituser->openid = $_POST["openid"]; + $object->lastname = $_POST["nom"]; + $object->firstname = $_POST["prenom"]; + $object->login = $_POST["login"]; + $object->pass = $_POST["password"]; + $object->admin = $_POST["admin"]; + $object->office_phone = $_POST["office_phone"]; + $object->office_fax = $_POST["office_fax"]; + $object->user_mobile = $_POST["user_mobile"]; + $object->email = $_POST["email"]; + $object->job = $_POST["job"]; + $object->signature = $_POST["signature"]; + $object->openid = $_POST["openid"]; + // Get extra fields + foreach($_POST as $key => $value) + { + if (preg_match("/^options_/",$key)) + { + $object->array_options[$key]=GETPOST($key); + } + } + // FIXME external module - $edituser->webcal_login = $_POST["webcal_login"]; - $edituser->phenix_login = $_POST["phenix_login"]; - $edituser->phenix_pass = $_POST["phenix_pass"]; + $object->webcal_login = $_POST["webcal_login"]; + $object->phenix_login = $_POST["phenix_login"]; + $object->phenix_pass = $_POST["phenix_pass"]; if (! empty($conf->multicompany->enabled)) { if (! empty($_POST["superadmin"])) { - $edituser->entity = 0; + $object->entity = 0; } else if ($conf->multicompany->transverse_mode) { - $edituser->entity = 1; // all users in master entity + $object->entity = 1; // all users in master entity } else { - $edituser->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); + $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); } } else if(! empty($_POST["admin"])) { - $edituser->entity=0; + $object->entity=0; } else { - $edituser->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); + $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); } - if (GETPOST('deletephoto')) $edituser->photo=''; - if (! empty($_FILES['photo']['name'])) $edituser->photo = dol_sanitizeFileName($_FILES['photo']['name']); + if (GETPOST('deletephoto')) $object->photo=''; + if (! empty($_FILES['photo']['name'])) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); - $ret=$edituser->update($user); + $ret=$object->update($user); if ($ret < 0) { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - $message.='
'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'
'; + $message.='
'.$langs->trans("ErrorLoginAlreadyExists",$object->login).'
'; } else { - $message.='
'.$edituser->error.'
'; + $message.='
'.$object->error.'
'; } } - if ($ret >=0 && ! count($edituser->errors)) + if ($ret >=0 && ! count($object->errors)) { - if (GETPOST('deletephoto') && $edituser->photo) + if (GETPOST('deletephoto') && $object->photo) { - $fileimg=$conf->user->dir_output.'/'.get_exdir($edituser->id,2,0,1).'/logos/'.$edituser->photo; - $dirthumbs=$conf->user->dir_output.'/'.get_exdir($edituser->id,2,0,1).'/logos/thumbs'; + $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'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { - $dir= $conf->user->dir_output . '/' . get_exdir($edituser->id,2,0,1); + $dir= $conf->user->dir_output . '/' . get_exdir($object->id,2,0,1); dol_mkdir($dir); @@ -394,7 +409,7 @@ if ($action == 'update' && ! $_POST["cancel"]) } } - if ($ret >= 0 && ! count($edituser->errors)) + if ($ret >= 0 && ! count($object->errors)) { $message.='
'.$langs->trans("UserModified").'
'; $db->commit(); @@ -407,15 +422,14 @@ if ($action == 'update' && ! $_POST["cancel"]) } else if ($caneditpassword) // Case we can edit only password { - $edituser = new User($db); - $edituser->fetch($id); + $object->fetch($id); - $edituser->oldcopy=dol_clone($edituser); + $object->oldcopy=dol_clone($object); - $ret=$edituser->setPassword($user,$_POST["password"]); + $ret=$object->setPassword($user,$_POST["password"]); if ($ret < 0) { - $message.='
'.$edituser->error.'
'; + $message.='
'.$object->error.'
'; } } } @@ -424,10 +438,9 @@ if ($action == 'update' && ! $_POST["cancel"]) if ((($action == 'confirm_password' && $confirm == 'yes') || ($action == 'confirm_passwordsend' && $confirm == 'yes')) && $caneditpassword) { - $edituser = new User($db); - $edituser->fetch($id); + $object->fetch($id); - $newpassword=$edituser->setPassword($user,''); + $newpassword=$object->setPassword($user,''); if ($newpassword < 0) { // Echec @@ -438,15 +451,15 @@ if ((($action == 'confirm_password' && $confirm == 'yes') // Succes if ($action == 'confirm_passwordsend' && $confirm == 'yes') { - if ($edituser->send_password($user,$newpassword) > 0) + if ($object->send_password($user,$newpassword) > 0) { - $message = '
'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'
'; + $message = '
'.$langs->trans("PasswordChangedAndSentTo",$object->email).'
'; //$message.=$newpassword; } else { $message = '
'.$langs->trans("PasswordChangedTo",$newpassword).'
'; - $message.= '
'.$edituser->error.'
'; + $message.= '
'.$object->error.'
'; } } else @@ -517,6 +530,9 @@ if ($action == 'adduserldap') * View */ +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('user'); + llxHeader('',$langs->trans("UserCard")); $form = new Form($db); @@ -853,8 +869,22 @@ if (($action == 'create') || ($action == 'adduserldap')) $doleditor->Create(); print "\n"; - // Autres caracteristiques issus des autres modules - + // 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)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } + // Module Webcalendar // TODO external module if (! empty($conf->webcalendar->enabled)) @@ -888,19 +918,20 @@ else if ($id) { - $fuser = new User($db); - $fuser->fetch($id); - + $object->fetch($id); + if ($res < 0) { dol_print_error($db,$object->error); exit; } + $res=$object->fetch_optionals($object->id,$extralabels); + // Connexion ldap // pour recuperer passDoNotExpire et userChangePassNextLogon - if (! empty($conf->ldap->enabled) && ! empty($fuser->ldap_sid)) + if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) { $ldap = new Ldap(); $result=$ldap->connect_bind(); if ($result > 0) { - $userSearchFilter = '('.$conf->global->LDAP_FILTER_CONNECTION.'('.$ldap->getUserIdentifier().'='.$fuser->login.'))'; - $entries = $ldap->fetch($fuser->login,$userSearchFilter); + $userSearchFilter = '('.$conf->global->LDAP_FILTER_CONNECTION.'('.$ldap->getUserIdentifier().'='.$object->login.'))'; + $entries = $ldap->fetch($object->login,$userSearchFilter); if (! $entries) { $message .= $ldap->error; @@ -937,7 +968,7 @@ else } // Show tabs - $head = user_prepare_head($fuser); + $head = user_prepare_head($object); $title = $langs->trans("User"); dol_fiche_head($head, 'user', $title, 0, 'user'); @@ -947,7 +978,7 @@ else */ if ($action == 'password') { - $ret=$form->form_confirm("fiche.php?id=$fuser->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$fuser->login),"confirm_password", '', 0, 1); + $ret=$form->form_confirm("fiche.php?id=$object->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$object->login),"confirm_password", '', 0, 1); if ($ret == 'html') print '
'; } @@ -956,7 +987,7 @@ else */ if ($action == 'passwordsend') { - $ret=$form->form_confirm("fiche.php?id=$fuser->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$fuser->login),"confirm_passwordsend", '', 0, 1); + $ret=$form->form_confirm("fiche.php?id=$object->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$object->login),"confirm_passwordsend", '', 0, 1); if ($ret == 'html') print '
'; } @@ -965,7 +996,7 @@ else */ if ($action == 'disable') { - $ret=$form->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable", '', 0, 1); + $ret=$form->form_confirm("fiche.php?id=$object->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$object->login),"confirm_disable", '', 0, 1); if ($ret == 'html') print '
'; } @@ -974,7 +1005,7 @@ else */ if ($action == 'enable') { - $ret=$form->form_confirm("fiche.php?id=$fuser->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$fuser->login),"confirm_enable", '', 0, 1); + $ret=$form->form_confirm("fiche.php?id=$object->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$object->login),"confirm_enable", '', 0, 1); if ($ret == 'html') print '
'; } @@ -983,7 +1014,7 @@ else */ if ($action == 'delete') { - $ret=$form->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete", '', 0, 1); + $ret=$form->form_confirm("fiche.php?id=$object->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$object->login),"confirm_delete", '', 0, 1); if ($ret == 'html') print '
'; } @@ -999,52 +1030,54 @@ else // Ref print ''.$langs->trans("Ref").''; print ''; - print $form->showrefnav($fuser,'id','',$user->rights->user->user->lire || $user->admin); + print $form->showrefnav($object,'id','',$user->rights->user->user->lire || $user->admin); print ''; print ''."\n"; - $rowspan=14; + $rowspan=15; + if (isset($conf->authmode) && preg_match('/myopenid/',$conf->authmode)) $rowspan++; if (! empty($conf->societe->enabled)) $rowspan++; if (! empty($conf->adherent->enabled)) $rowspan++; if (! empty($conf->webcalendar->enabled)) $rowspan++; // TODO external module if (! empty($conf->phenix->enabled)) $rowspan+=2; // TODO external module + // Lastname print ''.$langs->trans("Lastname").''; - print ''.$fuser->nom.''; + print ''.$object->nom.''; // Photo print ''; - print $form->showphoto('userphoto',$fuser,100); + print $form->showphoto('userphoto',$object,100); print ''; print ''."\n"; // Firstname print ''.$langs->trans("Firstname").''; - print ''.$fuser->prenom.''; + print ''.$object->prenom.''; print ''."\n"; // Position/Job print ''.$langs->trans("PostOrFunction").''; - print ''.$fuser->job.''; + print ''.$object->job.''; print ''."\n"; // Login print ''.$langs->trans("Login").''; - if (! empty($fuser->ldap_sid) && $fuser->statut==0) + if (! empty($object->ldap_sid) && $object->statut==0) { print ''.$langs->trans("LoginAccountDisableInDolibarr").''; } else { - print ''.$fuser->login.''; + print ''.$object->login.''; } print ''."\n"; // Password print ''.$langs->trans("Password").''; - if (! empty($fuser->ldap_sid)) + if (! empty($object->ldap_sid)) { if ($passDoNotExpire) { @@ -1066,10 +1099,10 @@ else else { print ''; - if ($fuser->pass) print preg_replace('/./i','*',$fuser->pass); + if ($object->pass) print preg_replace('/./i','*',$object->pass); else { - if ($user->admin) print $langs->trans("Crypted").': '.$fuser->pass_indatabase_crypted; + if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted; else print $langs->trans("Hidden"); } print ""; @@ -1078,17 +1111,17 @@ else // Administrator print ''.$langs->trans("Administrator").''; - if (! empty($conf->multicompany->enabled) && $fuser->admin && ! $fuser->entity) + if (! empty($conf->multicompany->enabled) && $object->admin && ! $object->entity) { - print $form->textwithpicto(yn($fuser->admin),$langs->trans("SuperAdministratorDesc"),1,"superadmin"); + print $form->textwithpicto(yn($object->admin),$langs->trans("SuperAdministratorDesc"),1,"superadmin"); } - else if ($fuser->admin) + else if ($object->admin) { - print $form->textwithpicto(yn($fuser->admin),$langs->trans("AdministratorDesc"),1,"admin"); + print $form->textwithpicto(yn($object->admin),$langs->trans("AdministratorDesc"),1,"admin"); } else { - print yn($fuser->admin); + print yn($object->admin); } print ''."\n"; @@ -1096,13 +1129,13 @@ else if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { print ''.$langs->trans("Entity").''; - if ($fuser->admin && ! $fuser->entity) + if ($object->admin && ! $object->entity) { print $langs->trans("AllEntities"); } else { - $mc->getInfo($fuser->entity); + $mc->getInfo($object->entity); print $mc->label; } print "\n"; @@ -1110,11 +1143,11 @@ else // Type print ''.$langs->trans("Type").''; - if ($fuser->societe_id) + if ($object->societe_id) { print $form->textwithpicto($langs->trans("External"),$langs->trans("InternalExternalDesc")); } - else if ($fuser->ldap_sid) + else if ($object->ldap_sid) { print $langs->trans("DomainUser",$ldap->domainFQDN); } @@ -1126,52 +1159,51 @@ else // Tel pro print ''.$langs->trans("PhonePro").''; - print ''.dol_print_phone($fuser->office_phone,'',0,0,1).''; + print ''.dol_print_phone($object->office_phone,'',0,0,1).''; print ''."\n"; // Tel mobile print ''.$langs->trans("PhoneMobile").''; - print ''.dol_print_phone($fuser->user_mobile,'',0,0,1).''; + print ''.dol_print_phone($object->user_mobile,'',0,0,1).''; print ''."\n"; // Fax print ''.$langs->trans("Fax").''; - print ''.dol_print_phone($fuser->office_fax,'',0,0,1).''; + print ''.dol_print_phone($object->office_fax,'',0,0,1).''; print ''."\n"; // EMail print ''.$langs->trans("EMail").''; - print ''.dol_print_email($fuser->email,0,0,1).''; + print ''.dol_print_email($object->email,0,0,1).''; print "\n"; // Signature print ''.$langs->trans('Signature').''; - print dol_textishtml($fuser->signature)?$fuser->signature:dol_nl2br($fuser->signature,1,false); + print dol_textishtml($object->signature)?$object->signature:dol_nl2br($object->signature,1,false); print "\n"; // Statut print ''.$langs->trans("Status").''; print ''; - print $fuser->getLibStatut(4); + print $object->getLibStatut(4); print ''; print ''."\n"; print ''.$langs->trans("LastConnexion").''; - print ''.dol_print_date($fuser->datelastlogin,"dayhour").''; + print ''.dol_print_date($object->datelastlogin,"dayhour").''; print "\n"; print ''.$langs->trans("PreviousConnexion").''; - print ''.dol_print_date($fuser->datepreviouslogin,"dayhour").''; + print ''.dol_print_date($object->datepreviouslogin,"dayhour").''; print "\n"; if (isset($conf->authmode) && preg_match('/myopenid/',$conf->authmode)) { print ''.$langs->trans("url_openid").''; - print ''.$fuser->openid.''; + print ''.$object->openid.''; print "\n"; } - // Autres caracteristiques issus des autres modules // Module Webcalendar // TODO external module @@ -1179,7 +1211,7 @@ else { $langs->load("other"); print ''.$langs->trans("LoginWebcal").''; - print ''.$fuser->webcal_login.' '; + print ''.$object->webcal_login.' '; print ''."\n"; } @@ -1189,10 +1221,10 @@ else { $langs->load("other"); print ''.$langs->trans("LoginPhenix").''; - print ''.$fuser->phenix_login.' '; + print ''.$object->phenix_login.' '; print "\n"; print ''.$langs->trans("PassPhenix").''; - print ''.preg_replace('/./i','*',$fuser->phenix_pass_crypted).' '; + print ''.preg_replace('/./i','*',$object->phenix_pass_crypted).' '; print ''."\n"; } @@ -1201,23 +1233,23 @@ else { print ''.$langs->trans("LinkToCompanyContact").''; print ''; - if (isset($fuser->societe_id) && $fuser->societe_id > 0) + if (isset($object->societe_id) && $object->societe_id > 0) { $societe = new Societe($db); - $societe->fetch($fuser->societe_id); + $societe->fetch($object->societe_id); print $societe->getNomUrl(1,''); } else { print $langs->trans("ThisUserIsNot"); } - if (! empty($fuser->contact_id)) + if (! empty($object->contact_id)) { $contact = new Contact($db); - $contact->fetch($fuser->contact_id); - if ($fuser->societe_id > 0) print ' / '; + $contact->fetch($object->contact_id); + if ($object->societe_id > 0) print ' / '; else print '
'; - print ''.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; + print ''.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; } print ''; print ''."\n"; @@ -1229,10 +1261,10 @@ else $langs->load("members"); print ''.$langs->trans("LinkedToDolibarrMember").''; print ''; - if ($fuser->fk_member) + if ($object->fk_member) { $adh=new Adherent($db); - $adh->fetch($fuser->fk_member); + $adh->fetch($object->fk_member); $adh->ref=$adh->getFullname($langs); // Force to show login instead of id print $adh->getNomUrl(1); } @@ -1244,7 +1276,23 @@ else print ''."\n"; } - print "\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)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''; + print $extrafields->showOutputField($key,$value); + print ''."\n"; + } + } + + print "\n"; print "\n"; @@ -1255,7 +1303,7 @@ else print '
'; - if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { @@ -1263,57 +1311,57 @@ else } else { - print ''.$langs->trans("Modify").''; + print ''.$langs->trans("Modify").''; } } - elseif ($caneditpassword && ! $fuser->ldap_sid && - (empty($conf->multicompany->enabled) || ! $user->entity || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + elseif ($caneditpassword && ! $object->ldap_sid && + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { - print ''.$langs->trans("EditPassword").''; + print ''.$langs->trans("EditPassword").''; } // Si on a un gestionnaire de generation de mot de passe actif if ($conf->global->USER_PASSWORD_GENERATED != 'none') { - if ($fuser->statut == 0) + if ($object->statut == 0) { print ''.$langs->trans("ReinitPassword").''; } - elseif (($user->id != $id && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && - (empty($conf->multicompany->enabled) || ! $user->entity || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { - print ''.$langs->trans("ReinitPassword").''; + print ''.$langs->trans("ReinitPassword").''; } - if ($fuser->statut == 0) + if ($object->statut == 0) { print ''.$langs->trans("SendNewPassword").''; } - else if (($user->id != $id && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && - (empty($conf->multicompany->enabled) || ! $user->entity || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + else if (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { - if ($fuser->email) print ''.$langs->trans("SendNewPassword").''; + if ($object->email) print ''.$langs->trans("SendNewPassword").''; else print ''.$langs->trans("SendNewPassword").''; } } // Activer - if ($user->id <> $id && $candisableuser && $fuser->statut == 0 && - (empty($conf->multicompany->enabled) || ! $user->entity || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + if ($user->id <> $id && $candisableuser && $object->statut == 0 && + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { - print ''.$langs->trans("Reactivate").''; + print ''.$langs->trans("Reactivate").''; } // Desactiver - if ($user->id <> $id && $candisableuser && $fuser->statut == 1 && - (empty($conf->multicompany->enabled) || ! $user->entity || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + if ($user->id <> $id && $candisableuser && $object->statut == 1 && + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { - print ''.$langs->trans("DisableUser").''; + print ''.$langs->trans("DisableUser").''; } // Delete if ($user->id <> $id && $candisableuser && - (empty($conf->multicompany->enabled) || ! $user->entity || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { - print ''.$langs->trans("DeleteUser").''; + print ''.$langs->trans("DeleteUser").''; } print "
\n"; @@ -1333,7 +1381,7 @@ else $exclude = array(); $usergroup=new UserGroup($db); - $groupslist = $usergroup->listGroupsForUser($fuser->id); + $groupslist = $usergroup->listGroupsForUser($object->id); if (! empty($groupslist)) { @@ -1355,7 +1403,7 @@ else print ''."\n"; print ''."\n"; print '
'.$langs->trans("GroupsToAdd").''; - print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $fuser->entity); + print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); print '   '; // Multicompany if (! empty($conf->multicompany->enabled)) @@ -1422,7 +1470,7 @@ else { $mc->getInfo($group_entity); print ($nb > 0 ? ', ' : '').$mc->label; - print ''; + print ''; print img_delete($langs->trans("RemoveFromGroup")); print ''; $nb++; @@ -1432,7 +1480,7 @@ else print ''; if ($caneditgroup && empty($conf->multicompany->transverse_mode)) { - print ''; + print ''; print img_delete($langs->trans("RemoveFromGroup")); print ''; } @@ -1457,15 +1505,15 @@ else * Fiche en mode edition */ - if ($action == 'edit' && ($canedituser || ($user->id == $fuser->id))) + if ($action == 'edit' && ($canedituser || ($user->id == $object->id))) { - print '
'; + print ''; print ''; print ''; print ''; print ''; - $rowspan=12; + $rowspan=13; if (! empty($conf->societe->enabled)) $rowspan++; if (! empty($conf->adherent->enabled)) $rowspan++; @@ -1474,7 +1522,7 @@ else print ''; print ''; print ''; @@ -1482,24 +1530,24 @@ else print ""; print ''; print ''; // Photo print '".''; print ''; // Position/Job print ''; print ''; // Login print "".''; print ''; print ''; @@ -1546,13 +1594,13 @@ else // Pass print ''; print '\n"; // Administrator print ''; - if ($fuser->societe_id > 0) + if ($object->societe_id > 0) { print ''; } @@ -1579,11 +1627,11 @@ else print ''; @@ -1647,7 +1695,7 @@ else if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { print "".''; - print "\n"; } else @@ -1660,11 +1708,11 @@ else // Type print ''; print '".''; print ''; // Tel mobile print "".''; print ''; // Fax print "".''; print ''; // EMail print "".''; print ''; // Signature print "".''; print ''; // openid @@ -1742,14 +1790,14 @@ else { print "".''; print ''; } @@ -1757,11 +1805,9 @@ else // Statut print ''; print ''; - // Autres caracteristiques issus des autres modules - // Module Webcalendar // TODO external module if (! empty($conf->webcalendar->enabled)) @@ -1769,8 +1815,8 @@ else $langs->load("other"); print "".''; print ''; } @@ -1781,13 +1827,13 @@ else $langs->load("other"); print "".''; print ''; print "".''; print ''; } @@ -1796,16 +1842,16 @@ else { print ''; print ''; print '\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)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''."\n"; + } + } + print '
'.$langs->trans("Ref").''; - print $fuser->id; + print $object->id; print '
'.$langs->trans("Lastname").''; - if ($caneditfield && !$fuser->ldap_sid) + if ($caneditfield && !$object->ldap_sid) { - print ''; + print ''; } else { - print ''; - print $fuser->nom; + print ''; + print $object->nom; } print ''; - print $form->showphoto('userphoto',$fuser); + print $form->showphoto('userphoto',$object); if ($caneditfield) { - if ($fuser->photo) print "
\n"; + if ($object->photo) print "
\n"; print ''; - if ($fuser->photo) print ''; + if ($object->photo) print ''; print ''; print ''; print '
'.$langs->trans("Delete").'

'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; @@ -1511,34 +1559,34 @@ else // Firstname print "
'.$langs->trans("Firstname").''; - if ($caneditfield && !$fuser->ldap_sid) + if ($caneditfield && !$object->ldap_sid) { - print ''; + print ''; } else { - print ''; - print $fuser->prenom; + print ''; + print $object->prenom; } print '
'.$langs->trans("PostOrFunction").''; - print ''; + print ''; print '
'.$langs->trans("Login").''; - if ($user->admin && !$fuser->ldap_sid) + if ($user->admin && !$object->ldap_sid) { - print ''; + print ''; } else { - print ''; - print $fuser->login; + print ''; + print $object->login; } print '
'.$langs->trans("Password").''; - if ($fuser->ldap_sid) + if ($object->ldap_sid) { $text=$langs->trans("DomainPassword"); } else if ($caneditpassword) { - $text=''; + $text=''; if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http') { $text=$form->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning'); @@ -1560,17 +1608,17 @@ else } else { - $text=preg_replace('/./i','*',$fuser->pass); + $text=preg_replace('/./i','*',$object->pass); } print $text; print "
'.$langs->trans("Administrator").''; - print ''.yn($fuser->admin); + print ''.yn($object->admin); print ' ('.$langs->trans("ExternalUser").')'; print '
'; $nbSuperAdmin = $user->getNbOfUsers('superadmin'); if ($user->admin - && ($user->id != $fuser->id) // Don't downgrade ourself - && ($fuser->entity > 0 || $nbSuperAdmin > 1) // Don't downgrade a superadmin if alone + && ($user->id != $object->id) // Don't downgrade ourself + && ($object->entity > 0 || $nbSuperAdmin > 1) // Don't downgrade a superadmin if alone ) { - print $form->selectyesno('admin',$fuser->admin,1); + print $form->selectyesno('admin',$object->admin,1); if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode)) { @@ -1626,16 +1674,16 @@ else '; } - $checked=(($fuser->admin && ! $fuser->entity) ? ' checked' : ''); + $checked=(($object->admin && ! $object->entity) ? ' checked' : ''); print ' '.$langs->trans("SuperAdministrator"); } } else { - $yn = yn($fuser->admin); - print ''; - print ''; - if (! empty($conf->multicompany->enabled) && empty($fuser->entity)) print $form->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning'); + $yn = yn($object->admin); + print ''; + print ''; + if (! empty($conf->multicompany->enabled) && empty($object->entity)) print $form->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning'); else print $yn; } print '
'.$langs->trans("Entity").'".$mc->select_entities($fuser->entity); + print "".$mc->select_entities($object->entity); print "
'.$langs->trans("Type").''; - if ($fuser->societe_id) + if ($object->societe_id) { print $langs->trans("External"); } - else if ($fuser->ldap_sid) + else if ($object->ldap_sid) { print $langs->trans("DomainUser"); } @@ -1678,63 +1726,63 @@ else // Tel pro print "
'.$langs->trans("PhonePro").''; - if ($caneditfield && empty($fuser->ldap_sid)) + if ($caneditfield && empty($object->ldap_sid)) { - print ''; + print ''; } else { - print ''; - print $fuser->office_phone; + print ''; + print $object->office_phone; } print '
'.$langs->trans("PhoneMobile").''; - if ($caneditfield && empty($fuser->ldap_sid)) + if ($caneditfield && empty($object->ldap_sid)) { - print ''; + print ''; } else { - print ''; - print $fuser->user_mobile; + print ''; + print $object->user_mobile; } print '
'.$langs->trans("Fax").''; - if ($caneditfield && empty($fuser->ldap_sid)) + if ($caneditfield && empty($object->ldap_sid)) { - print ''; + print ''; } else { - print ''; - print $fuser->office_fax; + print ''; + print $object->office_fax; } print '
global->USER_MAIL_REQUIRED)?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; - if ($caneditfield && empty($fuser->ldap_sid)) + if ($caneditfield && empty($object->ldap_sid)) { - print ''; + print ''; } else { - print ''; - print $fuser->email; + print ''; + print $object->email; } print '
'.$langs->trans("Signature").''; - print ''; + print ''; print '
'.$langs->trans("url_openid").''; - if ($caneditfield && !$fuser->ldap_sid) + if ($caneditfield && !$object->ldap_sid) { - print ''; + print ''; } else { - print ''; - print $fuser->openid; + print ''; + print $object->openid; } print '
'.$langs->trans("Status").''; - print $fuser->getLibStatut(4); + print $object->getLibStatut(4); print '
'.$langs->trans("LoginWebcal").''; - if ($caneditfield) print ''; - else print $fuser->webcal_login; + if ($caneditfield) print ''; + else print $object->webcal_login; print '
'.$langs->trans("LoginPhenix").''; - if ($caneditfield) print ''; - else print $fuser->phenix_login; + if ($caneditfield) print ''; + else print $object->phenix_login; print '
'.$langs->trans("PassPhenix").''; - if ($caneditfield) print ''; - else print preg_replace('/./i','*',$fuser->phenix_pass_crypted); + if ($caneditfield) print ''; + else print preg_replace('/./i','*',$object->phenix_pass_crypted); print '
'.$langs->trans("LinkToCompanyContact").''; - if ($fuser->societe_id > 0) + if ($object->societe_id > 0) { $societe = new Societe($db); - $societe->fetch($fuser->societe_id); + $societe->fetch($object->societe_id); print $societe->getNomUrl(1,''); - if ($fuser->contact_id) + if ($object->contact_id) { $contact = new Contact($db); - $contact->fetch($fuser->contact_id); - print ' / '.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; + $contact->fetch($object->contact_id); + print ' / '.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; } } else @@ -1822,10 +1868,10 @@ else $langs->load("members"); print '
'.$langs->trans("LinkedToDolibarrMember").''; - if ($fuser->fk_member) + if ($object->fk_member) { $adh=new Adherent($db); - $adh->fetch($fuser->fk_member); + $adh->fetch($object->fk_member); $adh->ref=$adh->login; // Force to show login instead of id print $adh->getNomUrl(1); } @@ -1837,6 +1883,22 @@ else print "
'; + print $extrafields->showInputField($key,$value); + print '
'; print '
'; @@ -1850,7 +1912,7 @@ else print ''; } - if (! empty($conf->ldap->enabled) && ! empty($fuser->ldap_sid)) $ldap->close; + if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) $ldap->close; } }