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 >
2004-06-09 12:39:40 +02:00
* Copyright ( C ) 2002 - 2003 Jean - Louis Bergamo < jlb @ j1b . org >
2010-02-13 23:32:12 +01:00
* Copyright ( C ) 2004 - 2010 Laurent Destailleur < eldy @ users . sourceforge . net >
2004-12-22 21:50:38 +01:00
* Copyright ( C ) 2004 Eric Seigne < eric . seigne @ ryxeo . com >
2010-06-07 07:11:45 +02:00
* Copyright ( C ) 2005 - 2010 Regis Houssin < regis @ dolibarr . fr >
2009-04-30 15:28:08 +02:00
* Copyright ( C ) 2005 Lionel Cousteix < etm_ltd @ tiscali . co . uk >
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 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 , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
2008-08-28 14:08:02 +02:00
/**
2008-08-11 01:46:44 +02:00
* \file htdocs / user / fiche . php
* \brief Onglet user et permissions de la fiche utilisateur
* \version $Id $
*/
2004-10-10 17:51:19 +02:00
2010-03-01 09:08:49 +01:00
require ( " ../main.inc.php " );
2010-04-29 17:23:21 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /user/class/user.class.php " );
2010-05-06 20:06:19 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /user/class/usergroup.class.php " );
2010-04-28 09:55:43 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /contact/class/contact.class.php " );
2010-02-13 23:32:12 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/images.lib.php " );
2006-11-19 17:02:53 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/usergroups.lib.php " );
2007-09-20 01:28:27 +02:00
if ( $conf -> ldap -> enabled ) require_once ( DOL_DOCUMENT_ROOT . " /lib/ldap.class.php " );
2010-04-25 12:50:09 +02:00
if ( $conf -> adherent -> enabled ) require_once ( DOL_DOCUMENT_ROOT . " /adherents/class/adherent.class.php " );
2005-09-26 03:01:53 +02:00
2009-07-04 19:29:26 +02:00
// Define value to know what current user can do on users
2006-06-14 00:50:36 +02:00
$canadduser = ( $user -> admin || $user -> rights -> user -> user -> creer );
2009-08-17 19:32:38 +02:00
$canreaduser = ( $user -> admin || $user -> rights -> user -> user -> lire );
2010-10-29 09:27:33 +02:00
$canedituser = ( $user -> admin || $user -> rights -> user -> user -> creer );
$candisableuser = ( $user -> admin || $user -> rights -> user -> user -> supprimer );
2010-11-08 12:40:52 +01:00
$canreadgroup = true ;
$caneditgroup = true ;
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ))
{
$canreadgroup = ( $user -> admin || $user -> rights -> user -> group_advance -> read );
$caneditgroup = ( $user -> admin || $user -> rights -> user -> group_advance -> write );
}
2009-07-04 19:29:26 +02:00
// Define value to know what current user can do on properties of edited user
2006-06-14 00:50:36 +02:00
if ( $_GET [ " id " ])
{
2008-08-28 14:08:02 +02:00
// $user est le user qui edite, $_GET["id"] est l'id de l'utilisateur edite
$caneditfield = ( (( $user -> id == $_GET [ " id " ]) && $user -> rights -> user -> self -> creer )
|| (( $user -> id != $_GET [ " id " ]) && $user -> rights -> user -> user -> creer ) );
$caneditpassword = ( (( $user -> id == $_GET [ " id " ]) && $user -> rights -> user -> self -> password )
|| (( $user -> id != $_GET [ " id " ]) && $user -> rights -> user -> user -> password ) );
2006-06-14 00:50:36 +02:00
}
2009-04-27 22:37:50 +02:00
2010-10-29 10:11:00 +02:00
$action = GETPOST ( " action " );
$confirm = GETPOST ( " confirm " );
2009-04-27 22:37:50 +02:00
// Security check
2009-08-06 15:07:25 +02:00
$socid = 0 ;
2010-11-10 11:53:39 +01:00
if ( $user -> societe_id > 0 ) $socid = $user -> societe_id ;
$feature2 = 'user' ;
if ( $user -> id == $_GET [ " id " ]) { $feature2 = '' ; $canreaduser = 1 ; } // A user can always read its own card
2009-08-06 15:07:25 +02:00
$result = restrictedArea ( $user , 'user' , $_GET [ " id " ], '' , $feature2 );
2009-08-17 19:32:38 +02:00
if ( $user -> id <> $_GET [ " id " ] && ! $canreaduser ) accessforbidden ();
2005-08-23 13:40:19 +02:00
2004-07-31 17:27:37 +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 " );
2004-07-31 17:27:37 +02:00
2003-02-20 18:40:42 +01:00
$form = new Form ( $db );
2002-05-06 21:10:48 +02:00
2010-02-13 23:32:12 +01:00
// Define size of logo small and mini (might be set into other pages)
$maxwidthsmall = 270 ; $maxheightsmall = 150 ;
$maxwidthmini = 128 ; $maxheightmini = 72 ;
$quality = 80 ;
2004-06-09 12:39:40 +02:00
2004-10-01 20:05:38 +02:00
2005-01-28 21:35:01 +01:00
/**
* Actions
*/
2010-10-29 09:27:33 +02:00
if ( $_GET [ " subaction " ] == 'addrights' && $canedituser )
2003-08-10 14:44:43 +02:00
{
2010-05-02 08:39:40 +02:00
$edituser = new User ( $db );
$edituser -> fetch ( $_GET [ " id " ]);
2008-08-28 14:08:02 +02:00
$edituser -> addrights ( $_GET [ " rights " ]);
2003-08-10 14:44:43 +02:00
}
2010-10-29 09:27:33 +02:00
if ( $_GET [ " subaction " ] == 'delrights' && $canedituser )
2003-08-10 14:44:43 +02:00
{
2010-05-02 08:39:40 +02:00
$edituser = new User ( $db );
$edituser -> fetch ( $_GET [ " id " ]);
2008-08-28 14:08:02 +02:00
$edituser -> delrights ( $_GET [ " rights " ]);
2003-08-10 14:44:43 +02:00
}
2010-11-10 11:53:39 +01:00
if ( $action == 'confirm_disable' && $confirm == " yes " && $candisableuser )
2005-02-26 15:23:54 +01:00
{
2008-08-28 14:08:02 +02:00
if ( $_GET [ " id " ] <> $user -> id )
{
$edituser = new User ( $db );
2010-04-28 09:31:34 +02:00
$edituser -> fetch ( $_GET [ " id " ]);
2008-08-28 14:08:02 +02:00
$edituser -> setstatus ( 0 );
2008-03-20 22:22:35 +01:00
Header ( " Location: " . DOL_URL_ROOT . '/user/fiche.php?id=' . $_GET [ " id " ]);
2008-08-28 14:08:02 +02:00
exit ;
}
2006-09-02 03:17:50 +02:00
}
2010-11-10 11:53:39 +01:00
if ( $action == 'confirm_enable' && $confirm == " yes " && $candisableuser )
2006-09-02 03:17:50 +02:00
{
2008-08-28 14:08:02 +02:00
if ( $_GET [ " id " ] <> $user -> id )
{
2010-06-07 08:00:25 +02:00
$message = '' ;
2010-07-27 09:43:38 +02:00
2010-04-28 09:31:34 +02:00
$edituser = new User ( $db );
$edituser -> fetch ( $_GET [ " id " ]);
2010-07-27 09:43:38 +02:00
2010-06-07 08:00:25 +02:00
if ( ! empty ( $conf -> file -> main_limit_users ))
{
$nb = $edituser -> getNbOfUsers ( 1 );
if ( $nb >= $conf -> file -> main_limit_users )
{
$message = '<div class="error">' . $langs -> trans ( " YourQuotaOfUsersIsReached " ) . '</div>' ;
}
}
if ( ! $message )
{
$edituser -> setstatus ( 1 );
Header ( " Location: " . DOL_URL_ROOT . '/user/fiche.php?id=' . $_GET [ " id " ]);
exit ;
}
2008-08-28 14:08:02 +02:00
}
2005-02-26 15:23:54 +01:00
}
2010-11-10 11:53:39 +01:00
if ( $action == 'confirm_delete' && $confirm == " yes " && $candisableuser )
2003-08-10 14:44:43 +02:00
{
2008-08-28 14:08:02 +02:00
if ( $_GET [ " id " ] <> $user -> id )
{
2010-04-28 09:31:34 +02:00
$edituser = new User ( $db );
2008-08-28 14:08:02 +02:00
$edituser -> id = $_GET [ " id " ];
$result = $edituser -> delete ();
if ( $result < 0 )
{
2007-12-16 21:05:55 +01:00
$langs -> load ( " errors " );
2008-09-04 19:56:55 +02:00
$message = '<div class="error">' . $langs -> trans ( " ErrorUserCannotBeDelete " ) . '</div>' ;
2008-08-28 14:08:02 +02:00
}
else
{
Header ( " Location: index.php " );
exit ;
}
}
2003-08-10 14:44:43 +02:00
}
2005-07-09 13:13:08 +02:00
// Action ajout user
2006-06-14 00:50:36 +02:00
if ( $_POST [ " action " ] == 'add' && $canadduser )
2002-12-13 17:51:03 +01:00
{
2006-11-24 00:21:43 +01:00
$message = " " ;
if ( ! $_POST [ " nom " ]) {
$message = '<div class="error">' . $langs -> trans ( " NameNotDefined " ) . '</div>' ;
$action = " create " ; // Go back to create page
}
if ( ! $_POST [ " login " ]) {
$message = '<div class="error">' . $langs -> trans ( " LoginNotDefined " ) . '</div>' ;
$action = " create " ; // Go back to create page
}
2010-07-27 09:43:38 +02:00
2010-06-07 07:11:45 +02:00
$edituser = new User ( $db );
2010-07-27 09:43:38 +02:00
2010-11-13 01:49:11 +01:00
if ( ! empty ( $conf -> file -> main_limit_users )) // If option to limit users is set
2010-06-07 07:11:45 +02:00
{
$nb = $edituser -> getNbOfUsers ( 1 );
if ( $nb >= $conf -> file -> main_limit_users )
{
$message = '<div class="error">' . $langs -> trans ( " YourQuotaOfUsersIsReached " ) . '</div>' ;
$action = " create " ; // Go back to create page
}
}
2006-11-24 00:21:43 +01:00
if ( ! $message )
{
2007-10-02 11:19:11 +02:00
$edituser -> nom = $_POST [ " nom " ];
$edituser -> prenom = $_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 -> webcal_login = $_POST [ " webcal_login " ];
$edituser -> phenix_login = $_POST [ " phenix_login " ];
2007-10-02 15:54:34 +02:00
$edituser -> phenix_pass = $_POST [ " phenix_pass " ];
2007-10-02 11:19:11 +02:00
$edituser -> note = $_POST [ " note " ];
$edituser -> ldap_sid = $_POST [ " ldap_sid " ];
2010-11-13 01:49:11 +01:00
$edituser -> entity = ( $_POST [ " admin " ] && empty ( $conf -> multicompany -> enabled )) ? 0 : $_POST [ " entity " ]; // If multicompany is off, admin users must all be on entity 0.
2008-08-28 14:08:02 +02:00
2007-02-27 21:40:19 +01:00
$db -> begin ();
2008-08-28 14:08:02 +02:00
2007-02-27 21:40:19 +01:00
$id = $edituser -> create ( $user );
if ( $id > 0 )
2006-11-24 00:21:43 +01:00
{
2007-02-27 21:40:19 +01:00
if ( isset ( $_POST [ 'password' ]) && trim ( $_POST [ 'password' ]))
{
2009-04-16 17:31:48 +02:00
$edituser -> setPassword ( $user , trim ( $_POST [ 'password' ]));
2007-02-27 21:40:19 +01:00
}
2009-01-20 01:35:09 +01:00
2007-02-27 21:40:19 +01:00
$db -> commit ();
2009-01-20 01:35:09 +01:00
2007-02-27 21:40:19 +01:00
Header ( " Location: fiche.php?id= $id " );
exit ;
}
else
{
2008-11-20 22:53:56 +01:00
$langs -> load ( " errors " );
2007-02-27 21:40:19 +01:00
$db -> rollback ();
2010-01-08 18:33:30 +01:00
if ( is_array ( $edituser -> errors ) && sizeof ( $edituser -> errors )) $message = '<div class="error">' . join ( '<br>' , $langs -> trans ( $edituser -> errors )) . '</div>' ;
else $message = '<div class="error">' . $langs -> trans ( $edituser -> error ) . '</div>' ;
2007-02-27 21:40:19 +01:00
$action = " create " ; // Go back to create page
2006-11-24 00:21:43 +01:00
}
}
2005-02-27 15:12:16 +01:00
}
2005-07-09 13:13:08 +02:00
// Action ajout groupe utilisateur
2006-06-14 00:50:36 +02:00
if ( $_POST [ " action " ] == 'addgroup' && $caneditfield )
2005-02-27 15:12:16 +01:00
{
2008-08-28 14:08:02 +02:00
if ( $_POST [ " group " ])
{
2010-05-02 20:02:43 +02:00
$edituser = new User ( $db );
$edituser -> fetch ( $_GET [ " id " ]);
2008-08-28 14:08:02 +02:00
$edituser -> SetInGroup ( $_POST [ " group " ]);
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
exit ;
}
2005-02-27 15:12:16 +01:00
}
2006-06-14 00:50:36 +02:00
if ( $_GET [ " action " ] == 'removegroup' && $caneditfield )
2005-02-27 15:12:16 +01:00
{
2008-08-28 14:08:02 +02:00
if ( $_GET [ " group " ])
{
2010-05-02 20:02:43 +02:00
$edituser = new User ( $db );
$edituser -> fetch ( $_GET [ " id " ]);
2008-08-28 14:08:02 +02:00
$edituser -> RemoveFromGroup ( $_GET [ " group " ]);
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
exit ;
}
2002-05-06 21:10:48 +02:00
}
2010-02-27 17:14:52 +01:00
if ( $_POST [ " action " ] == 'update' && ! $_POST [ " cancel " ])
2002-12-13 17:51:03 +01:00
{
2010-05-01 16:28:48 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/files.lib.php " );
2010-02-27 17:14:52 +01:00
if ( $caneditfield ) // Case we can edit all field
2006-11-19 17:02:53 +01:00
{
2010-02-27 17:14:52 +01:00
$message = " " ;
2006-11-19 17:02:53 +01:00
2010-02-27 17:14:52 +01:00
if ( ! $_POST [ " nom " ])
2006-11-19 17:02:53 +01:00
{
2010-02-27 17:14:52 +01:00
$message = '<div class="error">' . $langs -> trans ( " NameNotDefined " ) . '</div>' ;
$action = " edit " ; // Go back to create page
}
if ( ! $_POST [ " login " ])
{
$message = '<div class="error">' . $langs -> trans ( " LoginNotDefined " ) . '</div>' ;
$action = " edit " ; // Go back to create page
2006-11-19 17:02:53 +01:00
}
2009-05-04 23:45:20 +02:00
2010-02-27 17:14:52 +01:00
if ( ! $message )
2006-11-19 17:02:53 +01:00
{
2010-02-27 17:14:52 +01:00
$db -> begin ();
2010-04-28 09:31:34 +02:00
$edituser = new User ( $db );
$edituser -> fetch ( $_GET [ " id " ]);
2010-02-27 17:14:52 +01:00
$edituser -> oldcopy = dol_clone ( $edituser );
$edituser -> nom = $_POST [ " nom " ];
$edituser -> prenom = $_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 " ];
2010-12-01 22:38:00 +01:00
$edituser -> openid = $_POST [ " openid " ];
2010-02-27 17:14:52 +01:00
$edituser -> webcal_login = $_POST [ " webcal_login " ];
$edituser -> phenix_login = $_POST [ " phenix_login " ];
$edituser -> phenix_pass = $_POST [ " phenix_pass " ];
$edituser -> entity = $_POST [ " entity " ];
2010-05-01 16:28:48 +02:00
if ( ! empty ( $_FILES [ 'photo' ][ 'name' ])) $edituser -> photo = $_FILES [ 'photo' ][ 'name' ];
2010-02-27 17:14:52 +01:00
$ret = $edituser -> update ( $user );
2007-02-27 21:40:19 +01:00
if ( $ret < 0 )
2006-11-19 17:02:53 +01:00
{
2010-02-27 17:14:52 +01:00
if ( $db -> errno () == 'DB_ERROR_RECORD_ALREADY_EXISTS' )
{
$langs -> load ( " errors " );
$message .= '<div class="error">' . $langs -> trans ( " ErrorLoginAlreadyExists " , $edituser -> login ) . '</div>' ;
}
else
{
$message .= '<div class="error">' . $edituser -> error . '</div>' ;
}
2006-11-19 17:02:53 +01:00
}
2009-05-04 23:45:20 +02:00
2010-02-27 17:14:52 +01:00
if ( $ret >= 0 && ! sizeof ( $edituser -> errors ) && isset ( $_POST [ " password " ]) && $_POST [ " password " ] != '' )
2007-02-27 21:40:19 +01:00
{
2010-02-27 17:14:52 +01:00
$ret = $edituser -> setPassword ( $user , $_POST [ " password " ]);
if ( $ret < 0 )
{
$message .= '<div class="error">' . $edituser -> error . '</div>' ;
}
}
2010-02-13 23:32:12 +01:00
2010-02-27 17:14:52 +01:00
if ( $ret >= 0 && ! sizeof ( $edituser -> errors ))
{
if ( isset ( $_FILES [ 'photo' ][ 'tmp_name' ]) && trim ( $_FILES [ 'photo' ][ 'tmp_name' ]))
2007-02-27 21:40:19 +01:00
{
2010-02-27 17:14:52 +01:00
$dir = $conf -> user -> dir_output . '/' . get_exdir ( $edituser -> id , 2 , 0 , 1 );
create_exdir ( $dir );
if ( @ is_dir ( $dir ))
2010-02-13 23:32:12 +01:00
{
2010-02-27 17:14:52 +01:00
$newfile = $dir . '/' . $_FILES [ 'photo' ][ 'name' ];
2010-05-01 16:28:48 +02:00
$result = dol_move_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ], $newfile , 1 , 0 , $_FILES [ 'photo' ][ 'error' ]);
if ( ! $result > 0 )
2010-02-27 17:14:52 +01:00
{
$message .= '<div class="error">' . $langs -> trans ( " ErrorFailedToSaveFile " ) . '</div>' ;
}
else
{
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette ( $newfile , $maxwidthsmall , $maxheightsmall , '_small' , $quality );
2010-02-13 23:32:12 +01:00
2010-02-27 17:14:52 +01:00
// 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 );
}
2010-02-13 23:32:12 +01:00
}
2007-02-27 21:40:19 +01:00
}
}
2005-02-03 16:04:53 +01:00
2010-02-27 17:14:52 +01:00
if ( $ret >= 0 && ! sizeof ( $edituser -> errors ))
{
$message .= '<div class="ok">' . $langs -> trans ( " UserModified " ) . '</div>' ;
$db -> commit ();
}
else
{
$db -> rollback ();
}
2009-08-12 01:42:21 +02:00
}
2010-02-27 17:14:52 +01:00
}
else if ( $caneditpassword ) // Case we can edit only password
{
2010-04-28 09:31:34 +02:00
$edituser = new User ( $db );
$edituser -> fetch ( $_GET [ " id " ]);
2010-02-27 17:14:52 +01:00
$ret = $edituser -> setPassword ( $user , $_POST [ " password " ]);
if ( $ret < 0 )
2007-02-27 21:40:19 +01:00
{
2010-02-27 17:14:52 +01:00
$message .= '<div class="error">' . $edituser -> error . '</div>' ;
2007-02-27 21:40:19 +01:00
}
}
2002-12-19 19:55:38 +01:00
}
2002-05-06 21:10:48 +02:00
2010-02-27 17:14:52 +01: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
{
2010-04-28 09:31:34 +02:00
$edituser = new User ( $db );
$edituser -> fetch ( $_GET [ " id " ]);
2008-08-28 14:08:02 +02:00
$newpassword = $edituser -> setPassword ( $user , '' );
if ( $newpassword < 0 )
{
// Echec
2010-02-27 17:14:52 +01:00
$message = '<div class="error">' . $langs -> trans ( " ErrorFailedToSetNewPassword " ) . '</div>' ;
2008-08-28 14:08:02 +02:00
}
else
{
// Succes
2010-10-29 10:11:00 +02:00
if ( $action == 'confirm_passwordsend' && $confirm == 'yes' )
2008-08-28 14:08:02 +02:00
{
if ( $edituser -> send_password ( $user , $newpassword ) > 0 )
{
$message = '<div class="ok">' . $langs -> trans ( " PasswordChangedAndSentTo " , $edituser -> email ) . '</div>' ;
//$message.=$newpassword;
}
else
{
$message = '<div class="ok">' . $langs -> trans ( " PasswordChangedTo " , $newpassword ) . '</div>' ;
$message .= '<div class="error">' . $edituser -> error . '</div>' ;
}
}
else
{
$message = '<div class="ok">' . $langs -> trans ( " PasswordChangedTo " , $newpassword ) . '</div>' ;
}
}
2002-05-06 21:10:48 +02:00
}
2006-11-26 01:24:10 +01:00
// Action initialisation donnees depuis record LDAP
if ( $_POST [ " action " ] == 'adduserldap' )
{
$selecteduser = $_POST [ 'users' ];
2007-04-26 02:08:06 +02:00
$required_fields = array (
2008-08-28 14:08:02 +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 ,
$conf -> global -> LDAP_FIELD_MAIL ,
$conf -> global -> LDAP_FIELD_SID );
2006-11-26 01:24:10 +01:00
$ldap = new Ldap ();
$result = $ldap -> connect_bind ();
if ( $result >= 0 )
{
2007-04-26 02:08:06 +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 , " dolValidElement " )));
2007-04-26 02:08:06 +02:00
$ldapusers = $ldap -> getRecords ( $selecteduser , $conf -> global -> LDAP_USER_DN , $conf -> global -> LDAP_KEY_USERS , $required_fields );
2007-04-26 02:08:06 +02:00
//print_r($ldapusers);
2006-11-26 01:24:10 +01:00
if ( is_array ( $ldapusers ))
{
foreach ( $ldapusers as $key => $attribute )
{
$ldap_nom = $attribute [ $conf -> global -> LDAP_FIELD_NAME ];
2006-12-20 18:18:58 +01:00
$ldap_prenom = $attribute [ $conf -> global -> LDAP_FIELD_FIRSTNAME ];
2007-01-17 10:10:13 +01:00
$ldap_login = $attribute [ $conf -> global -> LDAP_FIELD_LOGIN ];
$ldap_loginsmb = $attribute [ $conf -> global -> LDAP_FIELD_LOGIN_SAMBA ];
2007-04-26 02:08:06 +02:00
$ldap_pass = $attribute [ $conf -> global -> LDAP_FIELD_PASSWORD ];
$ldap_pass_crypted = $attribute [ $conf -> global -> LDAP_FIELD_PASSWORD_CRYPTED ];
2006-12-20 18:18:58 +01:00
$ldap_phone = $attribute [ $conf -> global -> LDAP_FIELD_PHONE ];
$ldap_fax = $attribute [ $conf -> global -> LDAP_FIELD_FAX ];
$ldap_mobile = $attribute [ $conf -> global -> LDAP_FIELD_MOBILE ];
$ldap_mail = $attribute [ $conf -> global -> LDAP_FIELD_MAIL ];
$ldap_sid = $attribute [ $conf -> global -> LDAP_FIELD_SID ];
2006-11-26 01:24:10 +01:00
}
}
}
else
{
$message = '<div class="error">' . $ldap -> error . '</div>' ;
}
}
2004-06-09 12:39:40 +02:00
2005-07-09 13:13:08 +02:00
2006-11-19 17:02:53 +01:00
/*
* Affichage page
*/
2006-08-31 01:19:35 +02:00
2005-02-27 15:12:16 +01:00
llxHeader ( '' , $langs -> trans ( " UserCard " ));
2002-12-13 17:51:03 +01:00
2006-08-31 01:19:35 +02:00
$html = new Form ( $db );
2006-06-24 17:13:29 +02:00
if (( $action == 'create' ) || ( $action == 'adduserldap' ))
2002-12-13 17:51:03 +01:00
{
2006-11-19 17:02:53 +01:00
/* ************************************************************************** */
/* */
2008-01-05 10:25:18 +01:00
/* Affichage fiche en mode creation */
2006-11-19 17:02:53 +01:00
/* */
/* ************************************************************************** */
2008-08-28 14:08:02 +02:00
2009-03-02 20:07:12 +01:00
print_fiche_titre ( $langs -> trans ( " NewUser " ));
2008-08-28 14:08:02 +02:00
2006-11-19 17:02:53 +01:00
print $langs -> trans ( " CreateInternalUserDesc " );
print " <br> " ;
print " <br> " ;
2006-11-21 23:51:05 +01:00
2006-11-19 17:02:53 +01:00
if ( $conf -> ldap -> enabled && $conf -> global -> LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr' )
{
2006-11-26 01:24:10 +01:00
/*
2008-08-28 14:08:02 +02:00
* Affiche formulaire d 'ajout d' un compte depuis LDAP
* si on est en synchro LDAP vers Dolibarr
*/
2006-11-19 17:02:53 +01:00
2006-11-21 17:57:36 +01:00
$ldap = new Ldap ();
2006-11-26 01:24:10 +01:00
$result = $ldap -> connect_bind ();
if ( $result >= 0 )
2006-11-19 17:02:53 +01:00
{
2007-04-26 02:08:06 +02:00
$required_fields = array ( $conf -> global -> LDAP_KEY_USERS ,
2008-08-28 14:08:02 +02:00
$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 );
2009-01-20 01:35:09 +01:00
2007-04-26 02:08:06 +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 , " dolValidElement " )));
2009-01-20 01:35:09 +01:00
2007-04-26 02:08:06 +02:00
// Get from LDAP database an array of results
2007-04-26 02:08:06 +02:00
$ldapusers = $ldap -> getRecords ( '*' , $conf -> global -> LDAP_USER_DN , $conf -> global -> LDAP_KEY_USERS , $required_fields , 1 );
2006-11-26 01:24:10 +01:00
if ( is_array ( $ldapusers ))
2006-11-19 17:02:53 +01:00
{
2006-11-26 01:24:10 +01:00
$liste = array ();
2006-11-19 17:02:53 +01:00
foreach ( $ldapusers as $key => $ldapuser )
{
2007-04-26 02:08:06 +02:00
// Define the label string for this user
$label = '' ;
foreach ( $required_fields as $value )
2006-11-21 23:51:05 +01:00
{
2006-11-26 01:24:10 +01:00
if ( $value )
{
2007-04-26 02:08:06 +02:00
$label .= $value . " = " . $ldapuser [ $value ] . " " ;
2006-11-26 01:24:10 +01:00
}
2006-11-21 23:51:05 +01:00
}
2007-04-26 02:08:06 +02:00
$liste [ $key ] = $label ;
2006-11-19 17:02:53 +01:00
}
2008-08-28 14:08:02 +02:00
2006-11-26 01:24:10 +01:00
}
else
{
$message = '<div class="error">' . $ldap -> error . '</div>' ;
2006-06-24 17:13:29 +02:00
}
}
else
{
2006-11-26 01:24:10 +01:00
$message = '<div class="error">' . $ldap -> error . '</div>' ;
2006-06-24 17:13:29 +02:00
}
2007-04-26 02:08:06 +02:00
}
2008-08-28 14:08:02 +02:00
2007-04-26 02:08:06 +02:00
if ( $message ) { print $message . '<br>' ; }
2008-08-28 14:08:02 +02:00
2007-04-26 02:08:06 +02:00
if ( $conf -> ldap -> enabled && $conf -> global -> LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr' )
{
// Si la liste des users est rempli, on affiche la liste deroulante
if ( is_array ( $liste ))
{
print " \n \n <!-- Form liste LDAP debut --> \n " ;
2008-08-28 14:08:02 +02:00
2007-04-26 02:08:06 +02:00
print '<form name="add_user_ldap" action="' . $_SERVER [ " PHP_SELF " ] . '" method="post">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2007-04-26 02:08:06 +02:00
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">' ;
2010-08-19 17:20:25 +02:00
print $html -> selectarray ( 'users' , $liste , '' , 1 );
2007-04-26 02:08:06 +02:00
print '</td><td align="center">' ;
print '<input type="submit" class="button" value="' . $langs -> trans ( 'Get' ) . '">' ;
print '</td></tr></table>' ;
print '</form>' ;
print " \n <!-- Form liste LDAP fin --> \n \n " ;
print '<br>' ;
}
2006-07-08 16:44:09 +02:00
}
2008-08-28 14:08:02 +02:00
2006-11-19 17:02:53 +01:00
print '<form action="fiche.php" method="post" name="createuser">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2006-11-19 17:02:53 +01:00
print '<input type="hidden" name="action" value="add">' ;
2006-11-26 03:59:09 +01:00
if ( $ldap_sid ) print '<input type="hidden" name="ldap_sid" value="' . $ldap_sid . '">' ;
2009-04-27 22:37:50 +02:00
print '<input type="hidden" name="entity" value="' . $conf -> entity . '">' ;
2008-08-28 14:08:02 +02:00
2006-11-19 17:02:53 +01:00
print '<table class="border" width="100%">' ;
2008-08-28 14:08:02 +02:00
2007-04-26 02:08:06 +02:00
print '<tr>' ;
2006-11-19 17:02:53 +01:00
// Nom
2010-02-04 20:54:58 +01:00
print '<td valign="top" width="160"><span class="fieldrequired">' . $langs -> trans ( " Lastname " ) . '</span></td>' ;
2006-11-19 17:02:53 +01:00
print '<td>' ;
if ( $ldap_nom )
{
print '<input type="hidden" name="nom" value="' . $ldap_nom . '">' ;
print $ldap_nom ;
}
else
{
2010-01-09 17:30:48 +01:00
print '<input size="30" type="text" name="nom" value="' . $_POST [ " nom " ] . '">' ;
2006-11-19 17:02:53 +01:00
}
print '</td></tr>' ;
2008-08-28 14:08:02 +02:00
2006-11-19 17:02:53 +01:00
// Prenom
2007-04-26 02:08:06 +02:00
print '<tr><td valign="top">' . $langs -> trans ( " Firstname " ) . '</td>' ;
2006-11-19 17:02:53 +01:00
print '<td>' ;
if ( $ldap_prenom )
{
print '<input type="hidden" name="prenom" value="' . $ldap_prenom . '">' ;
print $ldap_prenom ;
}
else
{
2010-01-09 17:30:48 +01:00
print '<input size="30" type="text" name="prenom" value="' . $_POST [ " prenom " ] . '">' ;
2006-11-19 17:02:53 +01:00
}
print '</td></tr>' ;
2008-08-28 14:08:02 +02:00
2006-11-19 17:02:53 +01:00
// Login
2010-02-04 20:54:58 +01:00
print '<tr><td valign="top"><span class="fieldrequired">' . $langs -> trans ( " Login " ) . '</span></td>' ;
2006-11-19 17:02:53 +01:00
print '<td>' ;
if ( $ldap_login )
{
print '<input type="hidden" name="login" value="' . $ldap_login . '">' ;
print $ldap_login ;
}
2007-01-17 10:10:13 +01:00
elseif ( $ldap_loginsmb )
{
print '<input type="hidden" name="login" value="' . $ldap_loginsmb . '">' ;
print $ldap_loginsmb ;
}
2006-11-19 17:02:53 +01:00
else
{
2010-01-09 17:30:48 +01:00
print '<input size="20" maxsize="24" type="text" name="login" value="' . $_POST [ " login " ] . '">' ;
2006-11-19 17:02:53 +01:00
}
print '</td></tr>' ;
2008-08-28 14:08:02 +02:00
2010-08-04 17:41:13 +02:00
$generated_password = '' ;
2006-11-26 03:59:09 +01:00
if ( ! $ldap_sid )
2006-11-19 17:02:53 +01:00
{
if ( $conf -> global -> USER_PASSWORD_GENERATED )
{
$nomclass = " modGeneratePass " . ucfirst ( $conf -> global -> USER_PASSWORD_GENERATED );
$nomfichier = $nomclass . " .class.php " ;
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
require_once ( DOL_DOCUMENT_ROOT . " /includes/modules/security/generate/ " . $nomfichier );
2008-04-10 01:07:13 +02:00
$genhandler = new $nomclass ( $db , $conf , $langs , $user );
2006-11-19 17:02:53 +01:00
$generated_password = $genhandler -> getNewGeneratedPassword ();
}
}
2007-04-26 02:08:06 +02:00
$password = $generated_password ;
2008-08-28 14:08:02 +02:00
2006-11-19 17:02:53 +01:00
// Mot de passe
print '<tr><td valign="top">' . $langs -> trans ( " Password " ) . '</td>' ;
print '<td>' ;
2006-11-26 03:59:09 +01:00
if ( $ldap_sid )
2006-11-19 17:02:53 +01:00
{
2007-04-26 02:08:06 +02:00
print 'Mot de passe du domaine' ;
2006-11-19 17:02:53 +01:00
}
else
{
2007-04-26 02:08:06 +02:00
if ( $ldap_pass )
{
print '<input type="hidden" name="password" value="' . $ldap_pass . '">' ;
2009-10-21 16:02:14 +02:00
print preg_replace ( '/./i' , '*' , $ldap_pass );
2007-04-26 02:08:06 +02:00
}
else
{
2009-05-04 23:45:20 +02:00
// We do not use a field password but a field text to show new password to use.
2007-04-26 02:08:06 +02:00
print '<input size="30" maxsize="32" type="text" name="password" value="' . $password . '">' ;
}
2006-11-19 17:02:53 +01:00
}
print '</td></tr>' ;
2008-08-28 14:08:02 +02:00
2006-11-19 17:02:53 +01:00
// Administrateur
if ( $user -> admin )
{
print '<tr><td valign="top">' . $langs -> trans ( " Administrator " ) . '</td>' ;
print '<td>' ;
2010-01-09 17:30:48 +01:00
print $form -> selectyesno ( 'admin' , $_POST [ " admin " ], 1 );
2006-11-19 17:02:53 +01:00
print " </td></tr> \n " ;
}
2008-08-28 14:08:02 +02:00
2006-11-19 17:02:53 +01:00
// Type
print '<tr><td valign="top">' . $langs -> trans ( " Type " ) . '</td>' ;
print '<td>' ;
2009-05-04 21:02:32 +02:00
print $html -> textwithpicto ( $langs -> trans ( " Internal " ), $langs -> trans ( " InternalExternalDesc " ));
2006-11-19 17:02:53 +01:00
print '</td></tr>' ;
2008-08-28 14:08:02 +02:00
2006-11-19 17:02:53 +01:00
// Tel
2007-09-10 02:06:17 +02:00
print '<tr><td valign="top">' . $langs -> trans ( " PhonePro " ) . '</td>' ;
2006-11-19 17:02:53 +01:00
print '<td>' ;
if ( $ldap_phone )
{
print '<input type="hidden" name="office_phone" value="' . $ldap_phone . '">' ;
print $ldap_phone ;
}
else
{
2010-01-09 17:30:48 +01:00
print '<input size="20" type="text" name="office_phone" value="' . $_POST [ " office_phone " ] . '">' ;
2006-11-19 17:02:53 +01:00
}
print '</td></tr>' ;
2008-08-28 14:08:02 +02:00
2007-09-10 02:06:17 +02:00
// Tel portable
print '<tr><td valign="top">' . $langs -> trans ( " PhoneMobile " ) . '</td>' ;
2006-11-19 17:02:53 +01:00
print '<td>' ;
2007-09-10 02:06:17 +02:00
if ( $ldap_mobile )
2006-11-19 17:02:53 +01:00
{
2007-09-10 02:06:17 +02:00
print '<input type="hidden" name="user_mobile" value="' . $ldap_mobile . '">' ;
print $ldap_mobile ;
2006-11-19 17:02:53 +01:00
}
else
{
2010-01-09 17:30:48 +01:00
print '<input size="20" type="text" name="user_mobile" value="' . $_POST [ " user_mobile " ] . '">' ;
2006-11-19 17:02:53 +01:00
}
print '</td></tr>' ;
2008-08-28 14:08:02 +02:00
2007-09-10 02:06:17 +02:00
// Fax
print '<tr><td valign="top">' . $langs -> trans ( " Fax " ) . '</td>' ;
2006-11-19 17:02:53 +01:00
print '<td>' ;
2007-09-10 02:06:17 +02:00
if ( $ldap_fax )
2006-11-19 17:02:53 +01:00
{
2007-09-10 02:06:17 +02:00
print '<input type="hidden" name="office_fax" value="' . $ldap_fax . '">' ;
print $ldap_fax ;
2006-11-19 17:02:53 +01:00
}
else
{
2010-01-09 17:30:48 +01:00
print '<input size="20" type="text" name="office_fax" value="' . $_POST [ " office_fax " ] . '">' ;
2006-11-19 17:02:53 +01:00
}
print '</td></tr>' ;
2008-08-28 14:08:02 +02:00
2006-09-02 03:17:50 +02:00
// EMail
2010-01-08 18:33:30 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " EMail " ) . ( $conf -> global -> USER_MAIL_REQUIRED ? '*' : '' ) . '</td>' ;
2006-11-19 17:02:53 +01:00
print '<td>' ;
if ( $ldap_mail )
{
print '<input type="hidden" name="email" value="' . $ldap_mail . '">' ;
print $ldap_mail ;
}
else
{
2010-01-09 17:30:48 +01:00
print '<input size="40" type="text" name="email" value="' . $_POST [ " email " ] . '">' ;
2006-11-19 17:02:53 +01:00
}
print '</td></tr>' ;
2008-08-28 14:08:02 +02:00
2006-11-19 17:02:53 +01:00
// Note
print '<tr><td valign="top">' ;
print $langs -> trans ( " Note " );
print '</td><td>' ;
2007-09-28 10:45:10 +02:00
if ( $conf -> fckeditor -> enabled && $conf -> global -> FCKEDITOR_ENABLE_USER )
2006-09-01 01:43:47 +02:00
{
2006-11-19 17:02:53 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /lib/doleditor.class.php " );
2006-09-01 01:43:47 +02:00
$doleditor = new DolEditor ( 'note' , '' , 180 , 'dolibarr_notes' , '' , false );
$doleditor -> Create ();
}
else
{
print '<textarea class="flat" name="note" rows="' . ROWS_4 . '" cols="90">' ;
2010-01-09 17:30:48 +01:00
print $_POST [ " note " ];
2006-09-01 01:43:47 +02:00
print '</textarea>' ;
}
2006-11-19 17:02:53 +01:00
print " </td></tr> \n " ;
2008-08-28 14:08:02 +02:00
2008-01-05 10:25:18 +01:00
// Autres caracteristiques issus des autres modules
2008-08-28 14:08:02 +02:00
2007-10-02 11:19:11 +02:00
// Module Webcalendar
2006-11-19 17:02:53 +01:00
if ( $conf -> webcal -> enabled )
{
print " <tr> " . '<td valign="top">' . $langs -> trans ( " LoginWebcal " ) . '</td>' ;
2010-01-09 17:30:48 +01:00
print '<td><input size="30" type="text" name="webcal_login" value="' . $_POST [ " webcal_login " ] . '"></td></tr>' ;
2006-11-19 17:02:53 +01:00
}
2008-08-28 14:08:02 +02:00
2007-10-02 11:19:11 +02:00
// Module Phenix
if ( $conf -> phenix -> enabled )
{
print " <tr> " . '<td valign="top">' . $langs -> trans ( " LoginPenix " ) . '</td>' ;
2010-01-09 17:30:48 +01:00
print '<td><input size="30" type="text" name="phenix_login" value="' . $_POST [ " phenix_login " ] . '"></td></tr>' ;
2007-10-02 15:54:34 +02:00
print " <tr> " . '<td valign="top">' . $langs -> trans ( " PassPenix " ) . '</td>' ;
2010-01-09 17:30:48 +01:00
print '<td><input size="30" type="text" name="phenix_pass" value="' . $_POST [ " phenix_pass " ] . '"></td></tr>' ;
2007-10-02 11:19:11 +02:00
}
2008-08-28 14:08:02 +02:00
2006-11-19 17:02:53 +01:00
print " <tr> " . '<td align="center" colspan="2"><input class="button" value="' . $langs -> trans ( " CreateUser " ) . '" type="submit"></td></tr>' ;
print " </table> \n " ;
print " </form> " ;
2002-12-13 17:51:03 +01:00
}
else
{
2008-08-28 14:08:02 +02:00
/* ************************************************************************** */
/* */
/* Visu et edition */
/* */
/* ************************************************************************** */
if ( $_GET [ " id " ])
{
2010-04-28 09:31:34 +02:00
$fuser = new User ( $db );
$fuser -> fetch ( $_GET [ " id " ]);
2008-08-28 14:08:02 +02:00
// Connexion ldap
// pour recuperer passDoNotExpire et userChangePassNextLogon
if ( $conf -> ldap -> enabled && $fuser -> ldap_sid )
{
$ldap = new Ldap ();
$result = $ldap -> connect_bind ();
if ( $result > 0 )
{
$entries = $ldap -> fetch ( $fuser -> login );
if ( ! $entries )
{
$message .= $ldap -> error ;
}
2009-01-20 01:35:09 +01:00
2008-08-28 14:08:02 +02:00
$passDoNotExpire = 0 ;
$userChangePassNextLogon = 0 ;
$userDisabled = 0 ;
$statutUACF = '' ;
//On verifie les options du compte
if ( sizeof ( $ldap -> uacf ) > 0 )
{
foreach ( $ldap -> uacf as $key => $statut )
{
if ( $key == 65536 )
{
$passDoNotExpire = 1 ;
$statutUACF = $statut ;
}
}
}
else
{
$userDisabled = 1 ;
$statutUACF = " ACCOUNTDISABLE " ;
}
2009-01-20 01:35:09 +01:00
2008-08-28 14:08:02 +02:00
if ( $ldap -> pwdlastset == 0 )
{
$userChangePassNextLogon = 1 ;
}
}
}
2005-10-22 15:48:19 +02:00
2006-11-19 17:02:53 +01:00
/*
* Affichage onglets
*/
$head = user_prepare_head ( $fuser );
2009-05-04 20:38:01 +02:00
2009-05-04 21:12:47 +02:00
$title = $langs -> trans ( " User " );
2009-08-05 19:19:55 +02:00
dol_fiche_head ( $head , 'user' , $title , 0 , 'user' );
2004-07-31 17:27:37 +02:00
2008-08-28 14:08:02 +02:00
/*
* Confirmation reinitialisation mot de passe
*/
if ( $action == 'password' )
{
2009-05-06 18:27:45 +02:00
$ret = $html -> form_confirm ( " fiche.php?id= $fuser->id " , $langs -> trans ( " ReinitPassword " ), $langs -> trans ( " ConfirmReinitPassword " , $fuser -> login ), " confirm_password " , '' , 0 , 1 );
2009-05-06 15:39:43 +02:00
if ( $ret == 'html' ) print '<br>' ;
2008-08-28 14:08:02 +02:00
}
/*
* Confirmation envoi mot de passe
*/
if ( $action == 'passwordsend' )
{
2009-05-06 18:27:45 +02:00
$ret = $html -> form_confirm ( " fiche.php?id= $fuser->id " , $langs -> trans ( " SendNewPassword " ), $langs -> trans ( " ConfirmSendNewPassword " , $fuser -> login ), " confirm_passwordsend " , '' , 0 , 1 );
2009-05-06 15:39:43 +02:00
if ( $ret == 'html' ) print '<br>' ;
2008-08-28 14:08:02 +02:00
}
/*
* Confirmation desactivation
*/
if ( $action == 'disable' )
{
2009-05-06 18:27:45 +02:00
$ret = $html -> form_confirm ( " fiche.php?id= $fuser->id " , $langs -> trans ( " DisableAUser " ), $langs -> trans ( " ConfirmDisableUser " , $fuser -> login ), " confirm_disable " , '' , 0 , 1 );
2009-05-06 15:39:43 +02:00
if ( $ret == 'html' ) print '<br>' ;
2008-08-28 14:08:02 +02:00
}
/*
* Confirmation activation
*/
if ( $action == 'enable' )
{
2009-05-06 18:27:45 +02:00
$ret = $html -> form_confirm ( " fiche.php?id= $fuser->id " , $langs -> trans ( " EnableAUser " ), $langs -> trans ( " ConfirmEnableUser " , $fuser -> login ), " confirm_enable " , '' , 0 , 1 );
2009-05-06 15:39:43 +02:00
if ( $ret == 'html' ) print '<br>' ;
2008-08-28 14:08:02 +02:00
}
/*
* Confirmation suppression
*/
if ( $action == 'delete' )
{
2009-05-06 18:27:45 +02:00
$ret = $html -> form_confirm ( " fiche.php?id= $fuser->id " , $langs -> trans ( " DeleteAUser " ), $langs -> trans ( " ConfirmDeleteUser " , $fuser -> login ), " confirm_delete " , '' , 0 , 1 );
2009-05-06 15:39:43 +02:00
if ( $ret == 'html' ) print '<br>' ;
2008-08-28 14:08:02 +02:00
}
/*
* Fiche en mode visu
*/
if ( $_GET [ " action " ] != 'edit' )
{
print '<table class="border" width="100%">' ;
// Ref
print '<tr><td width="25%" valign="top">' . $langs -> trans ( " Ref " ) . '</td>' ;
print '<td colspan="2">' ;
2007-09-01 00:06:14 +02:00
print $html -> showrefnav ( $fuser , 'id' , '' , $user -> rights -> user -> user -> lire || $user -> admin );
2007-02-04 02:15:51 +01:00
print '</td>' ;
2007-09-01 00:06:14 +02:00
print '</tr>' ;
2005-02-27 15:12:16 +01:00
2008-08-28 14:08:02 +02:00
// Nom
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " Lastname " ) . '</td>' ;
2008-08-28 14:08:02 +02:00
print '<td colspan="2">' . $fuser -> nom . '</td>' ;
print " </tr> \n " ;
2006-11-19 17:02:53 +01:00
2008-08-28 14:08:02 +02:00
// Prenom
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " Firstname " ) . '</td>' ;
2008-08-28 14:08:02 +02:00
print '<td colspan="2">' . $fuser -> prenom . '</td>' ;
print " </tr> \n " ;
2005-02-27 15:12:16 +01:00
2009-05-18 11:17:30 +02:00
$rowspan = 11 ;
2009-05-07 01:30:49 +02:00
if ( $conf -> societe -> enabled ) $rowspan ++ ;
if ( $conf -> adherent -> enabled ) $rowspan ++ ;
2009-05-18 11:12:52 +02:00
if ( $conf -> webcal -> enabled ) $rowspan ++ ;
2009-05-18 11:17:30 +02:00
if ( $conf -> phenix -> enabled ) $rowspan += 2 ;
2007-09-01 00:06:14 +02:00
// Login
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " Login " ) . '</td>' ;
2008-08-28 14:08:02 +02:00
if ( $fuser -> ldap_sid && $fuser -> statut == 0 )
{
print '<td width="50%" class="error">' . $langs -> trans ( " LoginAccountDisableInDolibarr " ) . '</td>' ;
}
else
{
print '<td width="50%">' . $fuser -> login . '</td>' ;
}
2009-07-19 18:34:13 +02:00
// Photo
2007-09-01 00:06:14 +02:00
print '<td align="center" valign="middle" width="25%" rowspan="' . $rowspan . '">' ;
2010-12-01 22:38:00 +01:00
print $html -> showphoto ( 'userphoto' , $fuser , 100 , 1 );
2008-08-28 14:08:02 +02:00
print '</td>' ;
print '</tr>' ;
// Password
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " Password " ) . '</td>' ;
2008-08-28 14:08:02 +02:00
if ( $fuser -> ldap_sid )
{
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>' ;
2009-10-21 16:02:14 +02:00
if ( $fuser -> pass ) print preg_replace ( '/./i' , '*' , $fuser -> pass );
2008-08-28 14:08:02 +02:00
else
{
if ( $user -> admin ) print $langs -> trans ( " Crypted " ) . ': ' . $fuser -> pass_indatabase_crypted ;
else print $langs -> trans ( " Hidden " );
}
print " </td> " ;
}
print " </tr> \n " ;
2009-07-19 18:34:13 +02:00
// Administrator
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " Administrator " ) . '</td>' ;
2008-08-28 14:08:02 +02:00
print '<td>' . yn ( $fuser -> admin );
2009-05-04 22:57:26 +02:00
if ( ! empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) && $fuser -> admin && ! $fuser -> entity )
2009-04-27 22:37:50 +02:00
{
2009-05-04 17:45:44 +02:00
print ' ' . img_redstar ( $langs -> trans ( " SuperAdministrator " ));
2009-04-27 22:37:50 +02:00
}
else if ( $fuser -> admin )
{
print ' ' . img_picto ( $langs -> trans ( " Administrator " ), " star " );
}
2008-08-28 14:08:02 +02:00
print '</td>' ;
print " </tr> \n " ;
// Type
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " Type " ) . '</td>' ;
2008-08-28 14:08:02 +02:00
print '<td>' ;
if ( $fuser -> societe_id )
{
2009-05-04 21:02:32 +02:00
print $html -> textwithpicto ( $langs -> trans ( " External " ), $langs -> trans ( " InternalExternalDesc " ));
2008-08-28 14:08:02 +02:00
}
else if ( $fuser -> ldap_sid )
{
print $langs -> trans ( " DomainUser " , $ldap -> domainFQDN );
}
2009-05-04 22:57:26 +02:00
else if ( empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) || ! empty ( $fuser -> entity ))
2008-08-28 14:08:02 +02:00
{
2009-05-04 21:02:32 +02:00
print $html -> textwithpicto ( $langs -> trans ( " Internal " ), $langs -> trans ( " InternalExternalDesc " ));
2008-08-28 14:08:02 +02:00
}
2009-04-27 22:37:50 +02:00
else
{
2009-05-04 21:02:32 +02:00
print $html -> textwithpicto ( $langs -> trans ( " SuperAdministrator " ), $langs -> trans ( " SuperAdministratorDesc " ));
2009-04-27 22:37:50 +02:00
}
2008-08-28 14:08:02 +02:00
print '</td></tr>' ;
// Tel pro
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " PhonePro " ) . '</td>' ;
2009-01-09 22:22:58 +01:00
print '<td>' . dol_print_phone ( $fuser -> office_phone , '' , 0 , 0 , 1 ) . '</td>' ;
2008-08-28 14:08:02 +02:00
// Tel mobile
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " PhoneMobile " ) . '</td>' ;
2009-01-09 22:22:58 +01:00
print '<td>' . dol_print_phone ( $fuser -> user_mobile , '' , 0 , 0 , 1 ) . '</td>' ;
2008-08-28 14:08:02 +02:00
// Fax
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " Fax " ) . '</td>' ;
2009-01-09 22:22:58 +01:00
print '<td>' . dol_print_phone ( $fuser -> office_fax , '' , 0 , 0 , 1 ) . '</td>' ;
2008-08-28 14:08:02 +02:00
// EMail
2010-12-01 22:38:00 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " EMail " ) . '</td>' ;
2009-01-09 22:22:58 +01:00
print '<td>' . dol_print_email ( $fuser -> email , 0 , 0 , 1 ) . '</td>' ;
2008-08-28 14:08:02 +02:00
print " </tr> \n " ;
// Statut
print '<tr><td valign="top">' . $langs -> trans ( " Status " ) . '</td>' ;
print '<td>' ;
print $fuser -> getLibStatut ( 4 );
print '</td></tr>' ;
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " LastConnexion " ) . '</td>' ;
2009-02-20 23:53:15 +01:00
print '<td>' . dol_print_date ( $fuser -> datelastlogin , " dayhour " ) . '</td>' ;
2008-08-28 14:08:02 +02:00
print " </tr> \n " ;
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " PreviousConnexion " ) . '</td>' ;
2009-02-20 23:53:15 +01:00
print '<td>' . dol_print_date ( $fuser -> datepreviouslogin , " dayhour " ) . '</td>' ;
2008-08-28 14:08:02 +02:00
print " </tr> \n " ;
2010-12-01 22:38:00 +01:00
if ( preg_match ( '/myopenid/' , $conf -> authmode ))
{
print '<tr><td valign="top">' . $langs -> trans ( " url_openid " ) . '</td>' ;
print '<td>' . $fuser -> openid . '</td>' ;
print " </tr> \n " ;
}
2008-08-28 14:08:02 +02:00
// Autres caracteristiques issus des autres modules
// Module Webcalendar
if ( $conf -> webcal -> enabled )
{
$langs -> load ( " other " );
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " LoginWebcal " ) . '</td>' ;
2009-05-18 11:12:52 +02:00
print '<td>' . $fuser -> webcal_login . ' </td>' ;
2008-08-28 14:08:02 +02:00
print " </tr> \n " ;
}
// Module Phenix
if ( $conf -> phenix -> enabled )
{
$langs -> load ( " other " );
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " LoginPhenix " ) . '</td>' ;
2009-05-18 11:12:52 +02:00
print '<td>' . $fuser -> phenix_login . ' </td>' ;
2008-08-28 14:08:02 +02:00
print " </tr> \n " ;
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " PassPhenix " ) . '</td>' ;
2009-10-21 16:02:14 +02:00
print '<td>' . preg_replace ( '/./i' , '*' , $fuser -> phenix_pass_crypted ) . ' </td>' ;
2008-08-28 14:08:02 +02:00
print " </tr> \n " ;
}
2009-05-07 01:30:49 +02:00
// Company / Contact
if ( $conf -> societe -> enabled )
{
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " LinkToCompanyContact " ) . '</td>' ;
2009-05-07 01:30:49 +02:00
print '<td>' ;
if ( $fuser -> societe_id > 0 )
{
$societe = new Societe ( $db );
$societe -> fetch ( $fuser -> societe_id );
print $societe -> getNomUrl ( 1 , '' );
}
else
{
print $langs -> trans ( " ThisUserIsNot " );
}
if ( $fuser -> contact_id )
{
$contact = new Contact ( $db );
$contact -> fetch ( $fuser -> contact_id );
if ( $fuser -> societe_id > 0 ) print ' / ' ;
else print '<br>' ;
print '<a href="' . DOL_URL_ROOT . '/contact/fiche.php?id=' . $fuser -> contact_id . '">' . img_object ( $langs -> trans ( " ShowContact " ), 'contact' ) . ' ' . dol_trunc ( $contact -> getFullName ( $langs ), 32 ) . '</a>' ;
}
print '</td>' ;
print " </tr> \n " ;
}
2008-08-28 14:08:02 +02:00
// Module Adherent
if ( $conf -> adherent -> enabled )
{
$langs -> load ( " members " );
2010-02-27 17:14:52 +01:00
print '<tr><td valign="top">' . $langs -> trans ( " LinkedToDolibarrMember " ) . '</td>' ;
2009-05-07 01:30:49 +02:00
print '<td>' ;
2008-08-28 14:08:02 +02:00
if ( $fuser -> fk_member )
{
$adh = new Adherent ( $db );
$adh -> fetch ( $fuser -> fk_member );
2010-10-01 09:23:11 +02:00
$adh -> ref = $adh -> getFullname ( $langs ); // Force to show login instead of id
2008-08-28 14:08:02 +02:00
print $adh -> getNomUrl ( 1 );
}
else
{
print $langs -> trans ( " UserNotLinkedToMember " );
}
print '</td>' ;
print " </tr> \n " ;
}
print " </table> \n " ;
print " </div> \n " ;
if ( $message ) { print $message ; }
/*
* Barre d ' actions
*/
2009-01-20 01:35:09 +01:00
2008-08-28 14:08:02 +02:00
print '<div class="tabsAction">' ;
2009-05-04 23:45:20 +02:00
if ( $caneditfield &&
2009-05-05 11:28:56 +02:00
( empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) || (( $fuser -> entity == $conf -> entity ) || $fuser -> entity == $user -> entity )) )
2008-08-28 14:08:02 +02:00
{
2010-05-12 01:56:12 +02:00
if ( ! empty ( $conf -> global -> MAIN_ONLY_LOGIN_ALLOWED ))
{
print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " DisabledInMonoUserMode " )) . '">' . $langs -> trans ( " Modify " ) . '</a>' ;
}
else
{
print '<a class="butAction" href="fiche.php?id=' . $fuser -> id . '&action=edit">' . $langs -> trans ( " Modify " ) . '</a>' ;
}
2008-08-28 14:08:02 +02:00
}
2009-05-04 23:45:20 +02:00
elseif ( $caneditpassword && ! $fuser -> ldap_sid &&
( empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) || ( $fuser -> entity == $conf -> entity )) )
2008-08-28 14:08:02 +02:00
{
print '<a class="butAction" href="fiche.php?id=' . $fuser -> id . '&action=edit">' . $langs -> trans ( " EditPassword " ) . '</a>' ;
}
// Si on a un gestionnaire de generation de mot de passe actif
2006-04-01 14:03:31 +02:00
if ( $conf -> global -> USER_PASSWORD_GENERATED != 'none' )
{
2009-05-04 23:45:20 +02:00
if (( $user -> id != $_GET [ " id " ] && $caneditpassword ) && $fuser -> login && ! $fuser -> ldap_sid &&
( empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) || ( $fuser -> entity == $conf -> entity )))
2008-08-28 14:08:02 +02:00
{
print '<a class="butAction" href="fiche.php?id=' . $fuser -> id . '&action=password">' . $langs -> trans ( " ReinitPassword " ) . '</a>' ;
}
2009-01-20 01:35:09 +01:00
2010-07-27 09:43:38 +02:00
if (( $user -> id != $_GET [ " id " ] && $caneditpassword ) && $fuser -> login && ! $fuser -> ldap_sid &&
2009-05-04 23:45:20 +02:00
( empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) || ( $fuser -> entity == $conf -> entity )) )
2008-08-28 14:08:02 +02:00
{
2010-07-27 09:43:38 +02:00
if ( $fuser -> email ) print '<a class="butAction" href="fiche.php?id=' . $fuser -> id . '&action=passwordsend">' . $langs -> trans ( " SendNewPassword " ) . '</a>' ;
else print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " NoEMail " )) . '">' . $langs -> trans ( " SendNewPassword " ) . '</a>' ;
2008-08-28 14:08:02 +02:00
}
}
// Activer
2010-10-29 09:27:33 +02:00
if ( $user -> id <> $_GET [ " id " ] && $candisableuser && $fuser -> statut == 0 &&
2009-05-04 23:45:20 +02:00
( empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) || ( $fuser -> entity == $conf -> entity )) )
2008-08-28 14:08:02 +02:00
{
print '<a class="butAction" href="fiche.php?id=' . $fuser -> id . '&action=enable">' . $langs -> trans ( " Reactivate " ) . '</a>' ;
}
// Desactiver
2010-10-29 09:27:33 +02:00
if ( $user -> id <> $_GET [ " id " ] && $candisableuser && $fuser -> statut == 1 &&
2009-05-04 23:45:20 +02:00
( empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) || ( $fuser -> entity == $conf -> entity )) )
2008-08-28 14:08:02 +02:00
{
print '<a class="butActionDelete" href="fiche.php?action=disable&id=' . $fuser -> id . '">' . $langs -> trans ( " DisableUser " ) . '</a>' ;
}
2009-05-04 18:09:24 +02:00
// Delete
2010-10-29 09:27:33 +02:00
if ( $user -> id <> $_GET [ " id " ] && $candisableuser &&
2009-05-04 23:45:20 +02:00
( empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) || ( $fuser -> entity == $conf -> entity )) )
2008-08-28 14:08:02 +02:00
{
print '<a class="butActionDelete" href="fiche.php?action=delete&id=' . $fuser -> id . '">' . $langs -> trans ( " DeleteUser " ) . '</a>' ;
}
print " </div> \n " ;
print " <br> \n " ;
/*
* Liste des groupes dans lequel est l ' utilisateur
*/
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
if ( $canreadgroup )
2009-05-04 23:45:20 +02:00
{
2010-10-29 10:41:18 +02:00
print_fiche_titre ( $langs -> trans ( " ListOfGroupsForUser " ), '' , '' );
2010-11-13 01:49:11 +01:00
2010-11-09 12:41:42 +01:00
// On selectionne les groupes auquel fait parti le user
// TODO move sql query to dao class
2010-10-29 10:41:18 +02:00
$grouplistid = array ();
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
$sql = " SELECT ug.fk_usergroup " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " usergroup_user as ug " ;
$sql .= " , " . MAIN_DB_PREFIX . " usergroup as u " ;
$sql .= " WHERE ug.fk_user = " . $fuser -> id ;
$sql .= " AND ug.fk_usergroup = u.rowid " ;
$sql .= " AND u.entity IN (0, " . $conf -> entity . " ) " ;
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
$result = $db -> query ( $sql );
if ( $result )
2009-05-04 23:45:20 +02:00
{
2010-10-29 10:41:18 +02:00
$num = $db -> num_rows ( $result );
2009-05-04 23:45:20 +02:00
$i = 0 ;
2010-11-13 01:49:11 +01:00
2009-05-04 23:45:20 +02:00
while ( $i < $num )
{
2010-10-29 10:41:18 +02:00
$obj = $db -> fetch_object ( $result );
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
$grouplistid [] = $obj -> fk_usergroup ;
2009-05-04 23:45:20 +02:00
$i ++ ;
}
}
else {
dol_print_error ( $db );
}
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
$db -> free ( $resql );
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
if ( $caneditgroup )
{
$form = new Form ( $db );
print '<form action="fiche.php?id=' . $_GET [ " id " ] . '" method="post">' . " \n " ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="addgroup">' ;
print '<table class="noborder" width="100%">' . " \n " ;
print '<tr class="liste_titre"><td class="liste_titre" width="25%">' . $langs -> trans ( " GroupsToAdd " ) . '</td>' . " \n " ;
print '<td>' ;
2010-11-08 20:04:52 +01:00
print $form -> select_dolgroups ( '' , 'group' , 0 , $grouplistid );
2010-10-29 10:41:18 +02:00
print ' ' ;
print '<input type="submit" class="button" value="' . $langs -> trans ( " Add " ) . '">' ;
print '</td></tr>' . " \n " ;
print '</table></form>' . " \n " ;
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
print '<br>' ;
}
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
/*
* Groupes affectes
*/
$usergroup = new UserGroup ( $db );
$listofgroups = $usergroup -> listGroupsForUser ( $fuser );
$num = sizeof ( $listofgroups );
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
print '<td class="liste_titre" width="25%">' . $langs -> trans ( " Groups " ) . '</td>' ;
print " <td> </td></tr> \n " ;
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
if ( $num > 0 )
{
$i = 0 ;
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
$var = true ;
while ( $i < $num )
2008-08-28 14:08:02 +02:00
{
2010-10-29 10:41:18 +02:00
$group = $listofgroups [ $i ];
$var =! $var ;
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
print " <tr " . $bc [ $var ] . " > " ;
print '<td>' ;
if ( $caneditgroup )
{
print '<a href="' . DOL_URL_ROOT . '/user/group/fiche.php?id=' . $group -> id . '">' . img_object ( $langs -> trans ( " ShowGroup " ), " group " ) . ' ' . $group -> nom . '</a>' ;
}
else
{
print img_object ( $langs -> trans ( " ShowGroup " ), " group " ) . ' ' . $group -> nom ;
}
print '</td>' ;
print '<td align="right">' ;
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
if ( $caneditgroup )
{
print '<a href="fiche.php?id=' . $_GET [ " id " ] . '&action=removegroup&group=' . $group -> id . '">' ;
print img_delete ( $langs -> trans ( " RemoveFromGroup " ));
}
else
{
print " " ;
}
print " </td></tr> \n " ;
$i ++ ;
2008-08-28 14:08:02 +02:00
}
}
2010-10-29 10:41:18 +02:00
else
{
print '<tr ' . $bc [ false ] . '><td colspan=2>' . $langs -> trans ( " None " ) . '</td></tr>' ;
}
2010-11-13 01:49:11 +01:00
2010-10-29 10:41:18 +02:00
print " </table> " ;
print " <br> " ;
2008-08-28 14:08:02 +02:00
}
}
2010-10-29 10:41:18 +02:00
2008-08-28 14:08:02 +02:00
/*
* Fiche en mode edition
*/
2009-05-04 23:45:20 +02:00
2010-10-29 09:27:33 +02:00
if ( $_GET [ " action " ] == 'edit' && ( $canedituser || ( $user -> id == $fuser -> id )))
2008-08-28 14:08:02 +02:00
{
print '<form action="fiche.php?id=' . $fuser -> id . '" method="post" name="updateuser" enctype="multipart/form-data">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2008-08-28 14:08:02 +02:00
print '<input type="hidden" name="action" value="update">' ;
2009-04-27 22:37:50 +02:00
print '<input type="hidden" name="entity" value="' . $conf -> entity . '">' ;
2008-08-28 14:08:02 +02:00
print '<table width="100%" class="border">' ;
2009-05-18 11:17:30 +02:00
$rowspan = 9 ;
2009-05-07 01:30:49 +02:00
if ( $conf -> societe -> enabled ) $rowspan ++ ;
if ( $conf -> adherent -> enabled ) $rowspan ++ ;
2009-05-18 11:12:52 +02:00
if ( $conf -> webcal -> enabled ) $rowspan ++ ;
2009-05-18 11:17:30 +02:00
if ( $conf -> phenix -> enabled ) $rowspan += 2 ;
2008-08-28 14:08:02 +02:00
print '<tr><td width="25%" valign="top">' . $langs -> trans ( " Ref " ) . '</td>' ;
print '<td colspan="2">' ;
print $fuser -> id ;
print '</td>' ;
print '</tr>' ;
// Nom
2010-12-01 22:38:00 +01:00
print " <tr> " . '<td valign="top" class="fieldrequired">' . $langs -> trans ( " Lastname " ) . '</span></td>' ;
2008-08-28 14:08:02 +02:00
print '<td colspan="2">' ;
if ( $caneditfield && ! $fuser -> ldap_sid )
{
print '<input size="30" type="text" class="flat" name="nom" value="' . $fuser -> nom . '">' ;
}
else
{
print '<input type="hidden" name="nom" value="' . $fuser -> nom . '">' ;
print $fuser -> nom ;
}
print '</td></tr>' ;
// Prenom
2010-02-27 17:14:52 +01:00
print " <tr> " . '<td valign="top">' . $langs -> trans ( " Firstname " ) . '</td>' ;
2008-08-28 14:08:02 +02:00
print '<td colspan="2">' ;
if ( $caneditfield && ! $fuser -> ldap_sid )
{
print '<input size="30" type="text" class="flat" name="prenom" value="' . $fuser -> prenom . '">' ;
}
else
{
print '<input type="hidden" name="prenom" value="' . $fuser -> prenom . '">' ;
print $fuser -> prenom ;
}
print '</td></tr>' ;
// Login
2010-02-04 20:54:58 +01:00
print " <tr> " . '<td valign="top"><span class="fieldrequired">' . $langs -> trans ( " Login " ) . '</span></td>' ;
2008-08-28 14:08:02 +02:00
print '<td>' ;
if ( $user -> admin && ! $fuser -> ldap_sid )
{
print '<input size="12" maxlength="24" type="text" class="flat" name="login" value="' . $fuser -> login . '">' ;
}
else
{
print '<input type="hidden" name="login" value="' . $fuser -> login . '">' ;
print $fuser -> login ;
}
print '</td>' ;
2009-07-19 18:34:13 +02:00
// Photo
2008-08-28 14:08:02 +02:00
print '<td align="center" valign="middle" width="25%" rowspan="' . $rowspan . '">' ;
2009-07-19 18:34:13 +02:00
print $html -> showphoto ( 'userphoto' , $fuser );
2008-08-28 14:08:02 +02:00
if ( $caneditfield )
{
2009-07-19 18:34:13 +02:00
print '<br><br><table class="nobordernopadding"><tr><td>' . $langs -> trans ( " PhotoFile " ) . '</td></tr>' ;
2008-08-28 14:08:02 +02:00
print '<tr><td>' ;
print '<input type="file" class="flat" name="photo">' ;
print '</td></tr></table>' ;
}
print '</td>' ;
print '</tr>' ;
// Pass
print '<tr><td valign="top">' . $langs -> trans ( " Password " ) . '</td>' ;
print '<td>' ;
if ( $fuser -> ldap_sid )
{
$text = $langs -> trans ( " DomainPassword " );
}
else if ( $caneditpassword )
{
2009-05-04 23:45:20 +02:00
$text = '<input size="12" maxlength="32" type="password" class="flat" name="password" value="' . $fuser -> pass . '">' ;
2008-08-28 14:08:02 +02:00
if ( $dolibarr_main_authentication && $dolibarr_main_authentication == 'http' )
{
2009-05-04 20:45:56 +02:00
$text = $html -> textwithpicto ( $text , $langs -> trans ( " DolibarrInHttpAuthenticationSoPasswordUseless " , $dolibarr_main_authentication ), 1 , 'warning' );
2008-08-28 14:08:02 +02:00
}
}
else
{
2009-10-21 16:02:14 +02:00
$text = preg_replace ( '/./i' , '*' , $fuser -> pass );
2008-08-28 14:08:02 +02:00
}
print $text ;
print " </td></tr> \n " ;
2009-07-19 18:34:13 +02:00
// Administrator
2008-08-28 14:08:02 +02:00
print " <tr> " . '<td valign="top">' . $langs -> trans ( " Administrator " ) . '</td>' ;
if ( $fuser -> societe_id > 0 )
{
print '<td>' ;
print '<input type="hidden" name="admin" value="' . $fuser -> admin . '">' . yn ( $fuser -> admin );
2009-06-30 01:22:46 +02:00
print ' (' . $langs -> trans ( " ExternalUser " ) . ')' ;
2008-08-28 14:08:02 +02:00
print '</td></tr>' ;
}
else
{
print '<td>' ;
2009-06-29 15:59:18 +02:00
if ( $user -> admin && $fuser -> entity != 0 ) // On ne doit pas rétrograder le superadmin
2008-08-28 14:08:02 +02:00
{
print $form -> selectyesno ( 'admin' , $fuser -> admin , 1 );
}
else
{
2009-05-04 17:42:04 +02:00
$yn = yn ( $fuser -> admin );
print '<input type="hidden" name="admin" value="' . $fuser -> admin . '">' ;
2009-05-04 23:45:20 +02:00
if ( ! empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY )) print $html -> textwithpicto ( $yn , $langs -> trans ( " DontChangeSuperAdmin " ), 1 , 'warning' );
else print $yn ;
2008-08-28 14:08:02 +02:00
}
print '</td></tr>' ;
}
// Type
print '<tr><td width="25%" valign="top">' . $langs -> trans ( " Type " ) . '</td>' ;
print '<td>' ;
if ( $fuser -> societe_id )
{
print $langs -> trans ( " External " );
}
else if ( $fuser -> ldap_sid )
{
print $langs -> trans ( " DomainUser " );
}
2009-05-04 23:45:20 +02:00
else if ( ! empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) && $fuser -> admin && ! $fuser -> entity )
2008-08-28 14:08:02 +02:00
{
2009-05-04 17:42:04 +02:00
print $langs -> trans ( " SuperAdministrator " );
print ' ' . img_picto ( $langs -> trans ( " SuperAdministrator " ), " redstar " );
2008-08-28 14:08:02 +02:00
}
2009-04-27 22:37:50 +02:00
else
{
2009-05-04 17:42:04 +02:00
print $langs -> trans ( " Internal " );
2009-04-27 22:37:50 +02:00
}
2008-08-28 14:08:02 +02:00
print '</td></tr>' ;
// Tel pro
print " <tr> " . '<td valign="top">' . $langs -> trans ( " PhonePro " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && ! $fuser -> ldap_sid )
{
print '<input size="20" type="text" name="office_phone" class="flat" value="' . $fuser -> office_phone . '">' ;
}
else
{
print '<input type="hidden" name="office_phone" value="' . $fuser -> office_phone . '">' ;
print $fuser -> office_phone ;
}
print '</td></tr>' ;
// Tel mobile
print " <tr> " . '<td valign="top">' . $langs -> trans ( " PhoneMobile " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && ! $fuser -> ldap_sid )
{
print '<input size="20" type="text" name="user_mobile" class="flat" value="' . $fuser -> user_mobile . '">' ;
}
else
{
print '<input type="hidden" name="user_mobile" value="' . $fuser -> user_mobile . '">' ;
print $fuser -> user_mobile ;
}
print '</td></tr>' ;
// Fax
print " <tr> " . '<td valign="top">' . $langs -> trans ( " Fax " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && ! $fuser -> ldap_sid )
{
print '<input size="20" type="text" name="office_fax" class="flat" value="' . $fuser -> office_fax . '">' ;
}
else
{
print '<input type="hidden" name="office_fax" value="' . $fuser -> office_fax . '">' ;
print $fuser -> office_fax ;
}
print '</td></tr>' ;
2009-01-20 01:35:09 +01:00
2008-08-28 14:08:02 +02:00
// EMail
2010-12-01 22:38:00 +01:00
print " <tr> " . '<td valign="top"' . ( $conf -> global -> USER_MAIL_REQUIRED ? ' class="fieldrequired"' : '' ) . '>' . $langs -> trans ( " EMail " ) . '</td>' ;
2008-08-28 14:08:02 +02:00
print '<td>' ;
if ( $caneditfield && ! $fuser -> ldap_sid )
{
print '<input size="40" type="text" name="email" class="flat" value="' . $fuser -> email . '">' ;
}
else
{
print '<input type="hidden" name="email" value="' . $fuser -> email . '">' ;
print $fuser -> email ;
}
print '</td></tr>' ;
2010-12-01 22:38:00 +01:00
// openid
if ( preg_match ( '/myopenid/' , $conf -> authmode ))
{
print " <tr> " . '<td valign="top">' . $langs -> trans ( " url_openid " ) . '</td>' ;
print '<td>' ;
if ( $caneditfield && ! $fuser -> ldap_sid )
{
print '<input size="40" type="text" name="openid" class="flat" value="' . $fuser -> openid . '">' ;
}
else
{
print '<input type="hidden" name="openid" value="' . $fuser -> openid . '">' ;
print $fuser -> openid ;
}
print '</td></tr>' ;
}
2008-08-28 14:08:02 +02:00
// Statut
print '<tr><td valign="top">' . $langs -> trans ( " Status " ) . '</td>' ;
print '<td>' ;
print $fuser -> getLibStatut ( 4 );
print '</td></tr>' ;
// Autres caracteristiques issus des autres modules
// Module Webcalendar
if ( $conf -> webcal -> enabled )
{
$langs -> load ( " other " );
print " <tr> " . '<td valign="top">' . $langs -> trans ( " LoginWebcal " ) . '</td>' ;
2009-05-18 11:12:52 +02:00
print '<td>' ;
2008-08-28 14:08:02 +02:00
if ( $caneditfield ) print '<input size="30" type="text" class="flat" name="webcal_login" value="' . $fuser -> webcal_login . '">' ;
else print $fuser -> webcal_login ;
print '</td></tr>' ;
}
// Module Phenix
if ( $conf -> phenix -> enabled )
{
$langs -> load ( " other " );
print " <tr> " . '<td valign="top">' . $langs -> trans ( " LoginPhenix " ) . '</td>' ;
2009-05-18 11:12:52 +02:00
print '<td>' ;
2008-08-28 14:08:02 +02:00
if ( $caneditfield ) print '<input size="30" type="text" class="flat" name="phenix_login" value="' . $fuser -> phenix_login . '">' ;
else print $fuser -> phenix_login ;
print '</td></tr>' ;
print " <tr> " . '<td valign="top">' . $langs -> trans ( " PassPhenix " ) . '</td>' ;
2009-05-18 11:12:52 +02:00
print '<td>' ;
2008-08-28 14:08:02 +02:00
if ( $caneditfield ) print '<input size="30" type="password" class="flat" name="phenix_pass" value="' . $fuser -> phenix_pass_crypted . '">' ;
2009-10-21 16:02:14 +02:00
else print preg_replace ( '/./i' , '*' , $fuser -> phenix_pass_crypted );
2008-08-28 14:08:02 +02:00
print '</td></tr>' ;
}
2009-05-07 01:30:49 +02:00
// Company / Contact
if ( $conf -> societe -> enabled )
{
print '<tr><td width="25%" valign="top">' . $langs -> trans ( " LinkToCompanyContact " ) . '</td>' ;
print '<td>' ;
if ( $fuser -> societe_id > 0 )
{
$societe = new Societe ( $db );
$societe -> fetch ( $fuser -> societe_id );
print $societe -> getNomUrl ( 1 , '' );
if ( $fuser -> contact_id )
{
$contact = new Contact ( $db );
$contact -> fetch ( $fuser -> contact_id );
print ' / ' . '<a href="' . DOL_URL_ROOT . '/contact/fiche.php?id=' . $fuser -> contact_id . '">' . img_object ( $langs -> trans ( " ShowContact " ), 'contact' ) . ' ' . dol_trunc ( $contact -> getFullName ( $langs ), 32 ) . '</a>' ;
}
}
else
{
print $langs -> trans ( " ThisUserIsNot " );
}
print '</td>' ;
print " </tr> \n " ;
}
// Module Adherent
if ( $conf -> adherent -> enabled )
{
$langs -> load ( " members " );
print '<tr><td width="25%" valign="top">' . $langs -> trans ( " LinkedToDolibarrMember " ) . '</td>' ;
print '<td>' ;
if ( $fuser -> fk_member )
{
$adh = new Adherent ( $db );
$adh -> fetch ( $fuser -> fk_member );
$adh -> ref = $adh -> login ; // Force to show login instead of id
print $adh -> getNomUrl ( 1 );
}
else
{
print $langs -> trans ( " UserNotLinkedToMember " );
}
print '</td>' ;
print " </tr> \n " ;
}
2008-08-28 14:08:02 +02:00
print '<tr><td align="center" colspan="3">' ;
print '<input value="' . $langs -> trans ( " Save " ) . '" class="button" type="submit" name="save">' ;
print ' ' ;
print '<input value="' . $langs -> trans ( " Cancel " ) . '" class="button" type="submit" name="cancel">' ;
print '</td></tr>' ;
print '</table>' ;
print '</form>' ;
print '</div>' ;
}
$ldap -> close ;
}
2002-05-06 21:10:48 +02:00
}
$db -> close ();
2007-04-26 02:08:06 +02:00
function dolValidElement ( $element ) {
return ( trim ( $element ) != '' );
}
2005-07-09 13:13:08 +02:00
llxFooter ( '$Date$ - $Revision$' );
2007-09-08 11:02:22 +02:00
?>