+ *
+ * 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 '| '.$langs->trans("Label").' | ';
+print ''.$langs->trans("AttributeCode").' | ';
+print ''.$langs->trans("Type").' | ';
+print ''.$langs->trans("Size").' | ';
+print ''.$langs->trans("Unique").' | ';
+print ''.$langs->trans("Required").' | ';
+print ' | ';
+print "
\n";
+
+$var=True;
+foreach($extrafields->attribute_type as $key => $value)
+{
+ $var=!$var;
+ print "";
+ print "| ".$extrafields->attribute_label[$key]." | \n";
+ print "".$key." | \n";
+ print "".$type2label[$extrafields->attribute_type[$key]]." | \n";
+ print ''.$extrafields->attribute_size[$key]." | \n";
+ print ''.yn($extrafields->attribute_unique[$key])." | \n";
+ print ''.yn($extrafields->attribute_required[$key])." | \n";
+ print ''.img_edit().'';
+ print " ".img_delete()." | \n";
+ print "
";
+ // $i++;
+}
+
+print "
";
+
+dol_fiche_end();
+
+
+// Buttons
+if ($action != 'create' && $action != 'edit')
+{
+ 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 '| '.$langs->trans("GroupsToAdd").' | '."\n";
print '';
- 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 ' |
|---|