From 484d5ce81a2fdb6eb75ac2e113ef230df4dba14a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Jun 2011 10:23:32 +0000 Subject: [PATCH] Add patch to add signature on user. --- htdocs/core/class/html.formmail.class.php | 1140 ++++---- .../install/mysql/migration/3.0.0-3.1.0.sql | 5 +- htdocs/install/mysql/tables/llx_user.sql | 5 +- htdocs/user/class/user.class.php | 20 +- htdocs/user/fiche.php | 2539 +++++++++-------- 5 files changed, 1873 insertions(+), 1836 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 85f49aabe8c..59ecd27e2c1 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -21,7 +21,7 @@ * \file htdocs/core/class/html.formmail.class.php * \ingroup core * \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire - * \version $Id$ + * \version $Id: html.formmail.class.php,v 1.26 2011/06/29 10:23:33 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php"); @@ -34,620 +34,630 @@ require_once(DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php"); */ class FormMail { - var $db; - - var $withform; + var $db; - var $fromname; - var $frommail; - var $replytoname; - var $replytomail; - var $toname; - var $tomail; + var $withform; - var $withsubstit; // Show substitution array - var $withfrom; - var $withto; - var $withtofree; - var $withtocc; - var $withtopic; - var $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files - var $withbody; + var $fromname; + var $frommail; + var $replytoname; + var $replytomail; + var $toname; + var $tomail; - var $withfromreadonly; - var $withreplytoreadonly; - var $withtoreadonly; - var $withtoccreadonly; - var $withtopicreadonly; - var $withfilereadonly; - var $withdeliveryreceipt; - var $withcancel; + var $withsubstit; // Show substitution array + var $withfrom; + var $withto; + var $withtofree; + var $withtocc; + var $withtopic; + var $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files + var $withbody; - var $substit=array(); - var $param=array(); + var $withfromreadonly; + var $withreplytoreadonly; + var $withtoreadonly; + var $withtoccreadonly; + var $withtopicreadonly; + var $withfilereadonly; + var $withdeliveryreceipt; + var $withcancel; - var $error; + var $substit=array(); + var $param=array(); + + var $error; - /** - * \brief Constructeur - * \param DB handler d'acces base de donnee - */ - function FormMail($DB) - { - $this->db = $DB; - - $this->withform=1; + /** + * \brief Constructeur + * \param DB handler d'acces base de donnee + */ + function FormMail($DB) + { + $this->db = $DB; - $this->withfrom=1; - $this->withto=1; - $this->withtofree=1; - $this->withtocc=1; - $this->withtoccc=0; - $this->witherrorsto=0; - $this->withtopic=1; - $this->withfile=0; - $this->withbody=1; + $this->withform=1; - $this->withfromreadonly=1; - $this->withreplytoreadonly=1; - $this->withtoreadonly=0; - $this->withtoccreadonly=0; - $this->witherrorstoreadonly=0; - $this->withtopicreadonly=0; - $this->withfilereadonly=0; - $this->withbodyreadonly=0; - $this->withdeliveryreceiptreadonly=0; + $this->withfrom=1; + $this->withto=1; + $this->withtofree=1; + $this->withtocc=1; + $this->withtoccc=0; + $this->witherrorsto=0; + $this->withtopic=1; + $this->withfile=0; + $this->withbody=1; - return 1; - } + $this->withfromreadonly=1; + $this->withreplytoreadonly=1; + $this->withtoreadonly=0; + $this->withtoccreadonly=0; + $this->witherrorstoreadonly=0; + $this->withtopicreadonly=0; + $this->withfilereadonly=0; + $this->withbodyreadonly=0; + $this->withdeliveryreceiptreadonly=0; - /** - * Clear list of attached files in send mail form (stored in session) - */ - function clear_attached_files() - { - global $conf,$user; + return 1; + } + + /** + * Clear list of attached files in send mail form (stored in session) + */ + function clear_attached_files() + { + global $conf,$user; require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); - // Set tmp user directory - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir = $vardir.'/temp/'; - if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir); + // Set tmp user directory + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir = $vardir.'/temp/'; + if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir); - unset($_SESSION["listofpaths"]); - unset($_SESSION["listofnames"]); - unset($_SESSION["listofmimes"]); - } + unset($_SESSION["listofpaths"]); + unset($_SESSION["listofnames"]); + unset($_SESSION["listofmimes"]); + } - /** - * Add a file into the list of attached files (stored in SECTION array) - * - * @param $path - * @param $file - * @param $type - */ - function add_attached_files($path,$file,$type) - { - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); - if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); - if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); - if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); - if (! in_array($file,$listofnames)) - { - $listofpaths[]=$path; - $listofnames[]=$file; - $listofmimes[]=$type; - $_SESSION["listofpaths"]=join(';',$listofpaths); - $_SESSION["listofnames"]=join(';',$listofnames); - $_SESSION["listofmimes"]=join(';',$listofmimes); - } - } + /** + * Add a file into the list of attached files (stored in SECTION array) + * + * @param $path + * @param $file + * @param $type + */ + function add_attached_files($path,$file,$type) + { + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); + if (! in_array($file,$listofnames)) + { + $listofpaths[]=$path; + $listofnames[]=$file; + $listofmimes[]=$type; + $_SESSION["listofpaths"]=join(';',$listofpaths); + $_SESSION["listofnames"]=join(';',$listofnames); + $_SESSION["listofmimes"]=join(';',$listofmimes); + } + } - /** - * Remove a file from the list of attached files (stored in SECTION array) - * - * @param $keytodelete Key in file array - */ - function remove_attached_files($keytodelete) - { - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); - if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); - if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); - if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); - if ($keytodelete >= 0) - { - unset ($listofpaths[$keytodelete]); - unset ($listofnames[$keytodelete]); - unset ($listofmimes[$keytodelete]); - $_SESSION["listofpaths"]=join(';',$listofpaths); - $_SESSION["listofnames"]=join(';',$listofnames); - $_SESSION["listofmimes"]=join(';',$listofmimes); - //var_dump($_SESSION['listofpaths']); - } - } + /** + * Remove a file from the list of attached files (stored in SECTION array) + * + * @param $keytodelete Key in file array + */ + function remove_attached_files($keytodelete) + { + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); + if ($keytodelete >= 0) + { + unset ($listofpaths[$keytodelete]); + unset ($listofnames[$keytodelete]); + unset ($listofmimes[$keytodelete]); + $_SESSION["listofpaths"]=join(';',$listofpaths); + $_SESSION["listofnames"]=join(';',$listofnames); + $_SESSION["listofmimes"]=join(';',$listofmimes); + //var_dump($_SESSION['listofpaths']); + } + } - /** - * Return list of attached files (stored in SECTION array) - * - * @return array array('paths'=> ,'names'=>, 'mimes'=> ) - */ - function get_attached_files() - { - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); - if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); - if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); - if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); - return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes); - } - - /** - * Show the form to input an email + /** + * Return list of attached files (stored in SECTION array) + * + * @return array array('paths'=> ,'names'=>, 'mimes'=> ) + */ + function get_attached_files() + { + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); + return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes); + } + + /** + * Show the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files - * @param addfileaction Name of action when posting file attachments - * @param removefileaction Name of action when removing file attachments - */ - function show_form($addfileaction='addfile',$removefileaction='removefile') - { - print $this->get_form($addfileaction,$removefileaction); - } + * @param addfileaction Name of action when posting file attachments + * @param removefileaction Name of action when removing file attachments + */ + function show_form($addfileaction='addfile',$removefileaction='removefile') + { + print $this->get_form($addfileaction,$removefileaction); + } - /** - * Get the form to input an email + /** + * Get the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files - * @param addfileaction Name of action when posting file attachments - * @param removefileaction Name of action when removing file attachments - */ - function get_form($addfileaction='addfile',$removefileaction='removefile') - { - global $conf, $langs, $user; + * @param addfileaction Name of action when posting file attachments + * @param removefileaction Name of action when removing file attachments + */ + function get_form($addfileaction='addfile',$removefileaction='removefile') + { + global $conf, $langs, $user; - $langs->load("other"); - $langs->load("mails"); - - $out=''; + $langs->load("other"); + $langs->load("mails"); - // Define list of attached files - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); - if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); - if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); - if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); + $out=''; + + // Define list of attached files + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); - $form=new Form($DB); + $form=new Form($DB); - $out.= "\n\n"; - if ($this->withform) - { - $out.= '
'."\n"; - $out.= ''; - } - foreach ($this->param as $key=>$value) - { - $out.= ''."\n"; - } - $out.= ''."\n"; + $out.= "\n\n"; + if ($this->withform) + { + $out.= ''."\n"; + $out.= ''; + } + foreach ($this->param as $key=>$value) + { + $out.= ''."\n"; + } + $out.= '
'."\n"; - // Substitution array - if ($this->withsubstit) - { - $out.= '\n"; - } + // Substitution array + if ($this->withsubstit) + { + $out.= '\n"; + } - // From - if ($this->withfrom) - { - if ($this->withfromreadonly) - { - $out.= ''; - $out.= ''; - $out.= '\n"; - $out.= "\n"; - } - else - { - $out.= "\n"; - } - } + // From + if ($this->withfrom) + { + if ($this->withfromreadonly) + { + $out.= ''; + $out.= ''; + $out.= '\n"; + $out.= "\n"; + } + else + { + $out.= "\n"; + } + } - // Replyto - if ($this->withreplyto) - { - if ($this->withreplytoreadonly) - { - $out.= ''; - $out.= ''; - $out.= "\n"; - } - } + // Replyto + if ($this->withreplyto) + { + if ($this->withreplytoreadonly) + { + $out.= ''; + $out.= ''; + $out.= "\n"; + } + } - // Errorsto - if ($this->witherrorsto) - { - //if (! $this->errorstomail) $this->errorstomail=$this->frommail; - if ($this->witherrorstoreadonly) - { - $out.= ''; - $out.= '\n"; - } - else - { - $out.= '\n"; - } - } + // Errorsto + if ($this->witherrorsto) + { + //if (! $this->errorstomail) $this->errorstomail=$this->frommail; + if ($this->witherrorstoreadonly) + { + $out.= ''; + $out.= '\n"; + } + else + { + $out.= '\n"; + } + } - // To - if ($this->withto || is_array($this->withto)) - { - $out.= '\n"; - } + // To + if ($this->withto || is_array($this->withto)) + { + $out.= '\n"; + } - // CC - if ($this->withtocc || is_array($this->withtocc)) - { - $out.= '\n"; - } + // CC + if ($this->withtocc || is_array($this->withtocc)) + { + $out.= '\n"; + } - // CCC - if ($this->withtoccc || is_array($this->withtoccc)) - { - $out.= '\n"; - } + // CCC + if ($this->withtoccc || is_array($this->withtoccc)) + { + $out.= '\n"; + } - // Ask delivery receipt - if ($this->withdeliveryreceipt) - { - $out.= '\n"; - } + $out.= "\n"; + } - // Topic - if ($this->withtopic) - { - $this->withtopic=make_substitutions($this->withtopic,$this->substit); + // Topic + if ($this->withtopic) + { + $this->withtopic=make_substitutions($this->withtopic,$this->substit); - $out.= ''; - $out.= ''; - $out.= '\n"; - } + $out.= ''; + $out.= ''; + $out.= '\n"; + } - // Attached files - if ($this->withfile) - { - $out.= ''; - $out.= ''; - $out.= '\n"; - } + // Attached files + if ($this->withfile) + { + $out.= ''; + $out.= ''; + $out.= '\n"; + } - // Message - if ($this->withbody) - { - $defaultmessage=""; + // Message + if ($this->withbody) + { + $defaultmessage=""; - // TODO A partir du type, proposer liste de messages dans table llx_models - if ($this->param["models"]=='body') { $defaultmessage=$this->withbody; } - if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } - if ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - if ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } - if ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } - if ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - if ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - if ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } - - if ($conf->paypal->enabled && $conf->global->PAYPAL_ADD_PAYMENT_URL) - { - require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypal.lib.php"); - - $langs->load('paypal'); - - if ($this->param["models"]=='order_send') - { - $url=getPaymentUrl('order',$this->substit['__ORDERREF__']); - $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrderWithPaypalLink",$url); - } - if ($this->param["models"]=='facture_send') - { - $url=getPaymentUrl('invoice',$this->substit['__FACREF__']); - $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceWithPaypalLink",$url); - } - } - - $defaultmessage=make_substitutions($defaultmessage,$this->substit); - if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; - $defaultmessage=str_replace('\n',"\n",$defaultmessage); + // TODO A partir du type, proposer liste de messages dans table llx_models + if ($this->param["models"]=='body') { $defaultmessage=$this->withbody; } + if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } + if ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + if ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } + if ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } + if ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + if ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + if ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } - $out.= ''; - $out.= ''; - $out.= '\n"; - } - - if ($this->withform) - { - $out.= ''."\n"; - } - - $out.= '
'; - $help=""; - foreach($this->substit as $key => $val) - { - $help.=$key.' -> '.$langs->trans($val).'
'; - } - $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); - $out.= "
'; + $help=""; + foreach($this->substit as $key => $val) + { + $help.=$key.' -> '.$langs->trans($val).'
'; + } + $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); + $out.= "
'.$langs->trans("MailFrom").''; - if ($this->fromtype == 'user') - { - $langs->load("users"); - $fuser=new User($this->db); - $fuser->fetch($this->fromid); - $out.= $fuser->getNomUrl(1); - } - else - { - $out.= $this->fromname; - } - if ($this->frommail) - { - $out.= " <".$this->frommail.">"; - } - else - { - if ($this->fromtype) - { - $langs->load("errors"); - $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; - } - } - $out.= "
".$langs->trans("MailFrom").""; - $out.= $langs->trans("Name").':'; - $out.= '    '; - $out.= $langs->trans("EMail").':<>'; - $out.= "
'.$langs->trans("MailFrom").''; + if ($this->fromtype == 'user' && $this->fromid > 0) + { + $langs->load("users"); + $fuser=new User($this->db); + $fuser->fetch($this->fromid); + $out.= $fuser->getNomUrl(1); + } + else + { + $out.= $this->fromname; + } + if ($this->frommail) + { + $out.= " <".$this->frommail.">"; + } + else + { + if ($this->fromtype) + { + $langs->load("errors"); + $out.= ' <'.$langs->trans("ErrorNoMailDefinedForThisUser").'> '; + } + } + $out.= "
".$langs->trans("MailFrom").""; + $out.= $langs->trans("Name").':'; + $out.= '    '; + $out.= $langs->trans("EMail").':<>'; + $out.= "
".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); - $out.= "
".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); + $out.= "
'.$langs->trans("MailErrorsTo").''; - $out.= $this->errorstomail; - $out.= "
'.$langs->trans("MailErrorsTo").''; - $out.= ''; - $out.= "
'.$langs->trans("MailErrorsTo").''; + $out.= $this->errorstomail; + $out.= "
'.$langs->trans("MailErrorsTo").''; + $out.= ''; + $out.= "
'; - if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - else $out.= $langs->trans("MailTo"); - $out.= ''; - if ($this->withtoreadonly) - { - if (! empty($this->toname) && ! empty($this->tomail)) - { - $out.= ''; - $out.= ''; - if ($this->totype == 'thirdparty') - { - $soc=new Societe($this->db); - $soc->fetch($this->toid); - $out.= $soc->getNomUrl(1); - } - else if ($this->totype == 'contact') - { - $contact=new Contact($this->db); - $contact->fetch($this->toid); - $out.= $contact->getNomUrl(1); - } - else - { - $out.= $this->toname; - } - $out.= ' <'.$this->tomail.'>'; - if ($this->withtofree) - { - $out.= '
'.$langs->trans("or").' withto) :"").'" />'; - } - } - else - { - $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; - } - } - else - { - if ($this->withtofree) - { - $out.= 'withto) :"").'" />'; - } - if ($this->withtosocid > 0) - { - $liste=array(); - $liste[0]=' '; - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value) - { - $liste[$key]=$value; - } - if ($this->withtofree) $out.= " ".$langs->trans("or")." "; - //var_dump($_REQUEST);exit; - $out.= $form->selectarray("receiver", $liste, isset($_REQUEST["receiver"])?$_REQUEST["receiver"]:0); - } - } - $out.= "
'; + if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + else $out.= $langs->trans("MailTo"); + $out.= ''; + if ($this->withtoreadonly) + { + if (! empty($this->toname) && ! empty($this->tomail)) + { + $out.= ''; + $out.= ''; + if ($this->totype == 'thirdparty') + { + $soc=new Societe($this->db); + $soc->fetch($this->toid); + $out.= $soc->getNomUrl(1); + } + else if ($this->totype == 'contact') + { + $contact=new Contact($this->db); + $contact->fetch($this->toid); + $out.= $contact->getNomUrl(1); + } + else + { + $out.= $this->toname; + } + $out.= ' <'.$this->tomail.'>'; + if ($this->withtofree) + { + $out.= '
'.$langs->trans("or").' withto) :"").'" />'; + } + } + else + { + $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:""; + } + } + else + { + if ($this->withtofree) + { + $out.= 'withto) :"").'" />'; + } + if ($this->withtosocid > 0) + { + $liste=array(); + $liste[0]=' '; + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value) + { + $liste[$key]=$value; + } + if ($this->withtofree) $out.= " ".$langs->trans("or")." "; + //var_dump($_REQUEST);exit; + $out.= $form->selectarray("receiver", $liste, isset($_REQUEST["receiver"])?$_REQUEST["receiver"]:0); + } + } + $out.= "
'; - $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if ($this->withtoccreadonly) - { - $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; - } - else - { - $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; - if ($this->withtoccsocid > 0) - { - $liste=array(); - $liste[0]=' '; - $soc=new Societe($this->db); - $soc->fetch($this->withtoccsocid); - foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $liste, isset($_REQUEST["receivercc"])?$_REQUEST["receivercc"]:0); - } - } - $out.= "
'; + $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if ($this->withtoccreadonly) + { + $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:""; + } + else + { + $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />'; + if ($this->withtoccsocid > 0) + { + $liste=array(); + $liste[0]=' '; + $soc=new Societe($this->db); + $soc->fetch($this->withtoccsocid); + foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $liste, isset($_REQUEST["receivercc"])?$_REQUEST["receivercc"]:0); + } + } + $out.= "
'; - $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if ($this->withtocccreadonly) - { - $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; - } - else - { - $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; - if ($this->withtocccsocid > 0) - { - $liste=array(); - $liste[0]=' '; - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $liste, isset($_REQUEST["receiverccc"])?$_REQUEST["receiverccc"]:0); - } - } - //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); - $out.= "
'; + $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if ($this->withtocccreadonly) + { + $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; + } + else + { + $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; + if ($this->withtocccsocid > 0) + { + $liste=array(); + $liste[0]=' '; + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array() as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $liste, isset($_REQUEST["receiverccc"])?$_REQUEST["receiverccc"]:0); + } + } + //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); + $out.= "
'.$langs->trans("DeliveryReceipt").''; + // Ask delivery receipt + if ($this->withdeliveryreceipt) + { + $out.= '
'.$langs->trans("DeliveryReceipt").''; - if ($this->withdeliveryreceiptreadonly) - { - $out.= yn($this->withdeliveryreceipt); - } - else - { - $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0) ,1); - } + if ($this->withdeliveryreceiptreadonly) + { + $out.= yn($this->withdeliveryreceipt); + } + else + { + $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0) ,1); + } - $out.= "
'.$langs->trans("MailTopic").''; - if ($this->withtopicreadonly) - { - $out.= $this->withtopic; - $out.= ''; - } - else - { - $out.= 'withtopic) .'" />'; - } - $out.= "
'.$langs->trans("MailTopic").''; + if ($this->withtopicreadonly) + { + $out.= $this->withtopic; + $out.= ''; + } + else + { + $out.= 'withtopic) .'" />'; + } + $out.= "
'.$langs->trans("MailFile").''; - //print '
'; - if (sizeof($listofpaths)) - { - foreach($listofpaths as $key => $val) - { - $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; - if (! $this->withfilereadonly) $out.= ' '; - $out.= '
'; - } - } - else - { - $out.= $langs->trans("NoAttachedFiles").'
'; - } - if ($this->withfile == 2) // Can add other files - { - //print '
'; - $out.= ''; - $out.= ' '; - $out.= ''; - //print '
'; - } - $out.= "
'.$langs->trans("MailFile").''; + //print '
'; + if (sizeof($listofpaths)) + { + foreach($listofpaths as $key => $val) + { + $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; + if (! $this->withfilereadonly) $out.= ' '; + $out.= '
'; + } + } + else + { + $out.= $langs->trans("NoAttachedFiles").'
'; + } + if ($this->withfile == 2) // Can add other files + { + //print '
'; + $out.= ''; + $out.= ' '; + $out.= ''; + //print '
'; + } + $out.= "
'.$langs->trans("MailText").''; - if ($this->withbodyreadonly) - { - $out.= nl2br($defaultmessage); - $out.= ''; - } - else - { - // Editeur wysiwyg - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('message',$defaultmessage,'',280,'dolibarr_notes','In',true,false,$this->withfckeditor,8,72); - $out.= $doleditor->Create(1); - } - $out.= "
'; - $out.= 'withfile == 2 && $conf->use_javascript_ajax) - { - $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; - } - $out.= ' />'; - if ($this->withcancel) - { - $out.= '     '; - $out.= ''; - } - $out.= '
'."\n"; + if ($conf->paypal->enabled && $conf->global->PAYPAL_ADD_PAYMENT_URL) + { + require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypal.lib.php"); - if ($this->withform) $out.= '
'."\n"; - $out.= "\n"; - - return $out; - } + $langs->load('paypal'); + + if ($this->param["models"]=='order_send') + { + $url=getPaymentUrl('order',$this->substit['__ORDERREF__']); + $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrderWithPaypalLink",$url); + } + if ($this->param["models"]=='facture_send') + { + $url=getPaymentUrl('invoice',$this->substit['__FACREF__']); + $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceWithPaypalLink",$url); + } + } + + $defaultmessage=make_substitutions($defaultmessage,$this->substit); + if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; + $defaultmessage=str_replace('\n',"\n",$defaultmessage); + + $out.= ''; + $out.= ''.$langs->trans("MailText").''; + $out.= ''; + if ($this->withbodyreadonly) + { + $out.= nl2br($defaultmessage); + $out.= ''; + } + else + { + if(! empty($conf->global->MAIL_USE_SIGN) && $this->fromid > 0) + { + $fuser=new User($this->db); + $fuser->fetch($this->fromid); + + if(!empty($fuser->signature)) { + $defaultmessage.=dol_htmlentitiesbr_decode($fuser->signature); + } + } + + // Editor wysiwyg + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('message',$defaultmessage,'',280,'dolibarr_notes','In',true,false,$this->withfckeditor,8,72); + $out.= $doleditor->Create(1); + } + $out.= "\n"; + } + + if ($this->withform) + { + $out.= '
'; + $out.= 'withfile == 2 && $conf->use_javascript_ajax) + { + $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; + } + $out.= ' />'; + if ($this->withcancel) + { + $out.= '     '; + $out.= ''; + } + $out.= '
'."\n"; + } + + $out.= ''."\n"; + + if ($this->withform) $out.= ''."\n"; + $out.= "\n"; + + return $out; + } - /** - * \brief Affiche la partie de formulaire pour saisie d'un mail - * \param withtopic 1 pour proposer a la saisie le sujet - * \param withbody 1 pour proposer a la saisie le corps du message - * \param withfile 1 pour proposer a la saisie l'ajout d'un fichier joint - * \todo Fonction a virer quand fichier /comm/mailing.php vire (= quand ecran dans /comm/mailing prets) - */ - function mail_topicmessagefile($withtopic=1,$withbody=1,$withfile=1,$defaultbody) - { - global $langs; + /** + * \brief Affiche la partie de formulaire pour saisie d'un mail + * \param withtopic 1 pour proposer a la saisie le sujet + * \param withbody 1 pour proposer a la saisie le corps du message + * \param withfile 1 pour proposer a la saisie l'ajout d'un fichier joint + * \todo Fonction a virer quand fichier /comm/mailing.php vire (= quand ecran dans /comm/mailing prets) + */ + function mail_topicmessagefile($withtopic=1,$withbody=1,$withfile=1,$defaultbody) + { + global $langs; - $langs->load("other"); + $langs->load("other"); - print ""; + print "
"; - // Topic - if ($withtopic) - { - print ""; - print ""; - print ""; - } + // Topic + if ($withtopic) + { + print ""; + print ""; + print ""; + } - // Message - if ($withbody) - { - print ""; - print ""; - print ""; - } + // Message + if ($withbody) + { + print ""; + print ""; + print ""; + } - // Si fichier joint - if ($withfile) - { - print ""; - print ""; - print ""; - } + // Si fichier joint + if ($withfile) + { + print ""; + print ""; + print ""; + } - print "
".$langs->trans("MailTopic").""; - print ""; - print "
".$langs->trans("MailTopic").""; + print ""; + print "
".$langs->trans("MailText").""; - print ""; - print "
".$langs->trans("MailText").""; + print ""; + print "
".$langs->trans("MailFile").""; - print "trans("Upload")."\"/>"; - print "
".$langs->trans("MailFile").""; + print "trans("Upload")."\"/>"; + print "
"; - } + print ""; + } } diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql index 52a1b61ab26..78e1c62b6ff 100755 --- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql +++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql @@ -1,5 +1,5 @@ -- --- $Id: 3.0.0-3.1.0.sql,v 1.75 2011/06/28 07:47:10 eldy Exp $ +-- $Id: 3.0.0-3.1.0.sql,v 1.76 2011/06/29 10:23:33 eldy Exp $ -- -- Be carefull to requests order. -- This file must be loaded by calling /install/index.php page @@ -425,3 +425,6 @@ ALTER TABLE llx_c_type_contact ADD COLUMN module varchar(32) NULL; ALTER TABLE llx_c_typent ADD COLUMN module varchar(32) NULL; ALTER TABLE llx_c_effectif ADD COLUMN module varchar(32) NULL; ALTER TABLE llx_c_forme_juridique ADD COLUMN module varchar(32) NULL; + +ALTER TABLE llx_user ADD signature text DEFAULT NULL AFTER email; + diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index a1f35145739..307b3e136e5 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -1,6 +1,6 @@ -- ============================================================================ -- Copyright (C) 2001-2003 Rodolphe Quiedeville --- Copyright (C) 2006-2009 Laurent Destailleur +-- Copyright (C) 2006-2011 Laurent Destailleur -- Copyright (C) 2007-2009 Regis Houssin -- -- This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- --- $Id$ +-- $Id: llx_user.sql,v 1.8 2011/06/29 10:23:33 eldy Exp $ -- =========================================================================== create table llx_user @@ -39,6 +39,7 @@ create table llx_user office_fax varchar(20), user_mobile varchar(20), email varchar(255), + signature text DEFAULT NULL, admin smallint DEFAULT 0, webcal_login varchar(25), -- TODO move to an extra table (ex: llx_extra_fields) phenix_login varchar(25), -- TODO move to an extra table (ex: llx_extra_fields) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 45cf96ee311..3425b0fe346 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -25,7 +25,7 @@ /** * \file htdocs/user/class/user.class.php * \brief Fichier de la classe utilisateur - * \version $Id$ + * \version $Id: user.class.php,v 1.43 2011/06/29 10:23:32 eldy Exp $ */ require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); @@ -53,6 +53,7 @@ class User extends CommonObject var $firstname; var $note; var $email; + var $signature; var $office_phone; var $office_fax; var $user_mobile; @@ -116,7 +117,7 @@ class User extends CommonObject } /** - * Charge un objet user avec toutes ces caracteristiques depuis un id ou login + * Load a user from database with its id or ref (login) * @param id Si defini, id a utiliser pour recherche * @param login Si defini, login a utiliser pour recherche * @param sid Si defini, sid a utiliser pour recherche @@ -127,11 +128,11 @@ class User extends CommonObject { global $conf; - // Nettoyage parametres + // Clean parameters $login=trim($login); - // Recupere utilisateur - $sql = "SELECT u.rowid, u.name, u.firstname, u.email, u.office_phone, u.office_fax, u.user_mobile,"; + // Get user + $sql = "SELECT u.rowid, u.name, u.firstname, u.email, u.signature, u.office_phone, u.office_fax, u.user_mobile,"; $sql.= " u.admin, u.login, u.webcal_login, u.phenix_login, u.phenix_pass, u.note,"; $sql.= " u.pass, u.pass_crypted, u.pass_temp,"; $sql.= " u.fk_societe, u.fk_socpeople, u.fk_member, u.ldap_sid,"; @@ -184,6 +185,7 @@ class User extends CommonObject $this->office_fax = $obj->office_fax; $this->user_mobile = $obj->user_mobile; $this->email = $obj->email; + $this->signature = $obj->signature; $this->admin = $obj->admin; $this->note = $obj->note; $this->statut = $obj->statut; @@ -1008,6 +1010,7 @@ class User extends CommonObject $this->office_fax = trim($this->office_fax); $this->user_mobile = trim($this->user_mobile); $this->email = trim($this->email); + $this->signature = trim($this->signature); $this->note = trim($this->note); $this->openid = trim(empty($this->openid)?'':$this->openid); // Avoid warning $this->webcal_login = trim($this->webcal_login); @@ -1038,6 +1041,7 @@ class User extends CommonObject $sql.= ", office_fax = '".$this->db->escape($this->office_fax)."'"; $sql.= ", user_mobile = '".$this->db->escape($this->user_mobile)."'"; $sql.= ", email = '".$this->db->escape($this->email)."'"; + $sql.= ", signature = '".addslashes($this->signature)."'"; $sql.= ", webcal_login = '".$this->db->escape($this->webcal_login)."'"; $sql.= ", phenix_login = '".$this->db->escape($this->phenix_login)."'"; $sql.= ", phenix_pass = '".$this->db->escape($this->phenix_pass)."'"; @@ -1483,7 +1487,7 @@ class User extends CommonObject function SetInGroup($group, $entity, $notrigger=0) { global $conf, $langs, $user; - + $error=0; $this->db->begin(); @@ -1510,7 +1514,7 @@ class User extends CommonObject if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers } - + if (! $error) { $this->db->commit(); @@ -1540,7 +1544,7 @@ class User extends CommonObject function RemoveFromGroup($group, $entity, $notrigger=0) { global $conf,$langs,$user; - + $error=0; $this->db->begin(); diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 908a9ee5485..956c98924f0 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -24,7 +24,7 @@ /** * \file htdocs/user/fiche.php * \brief Tab of user card - * \version $Id$ + * \version $Id: fiche.php,v 1.273 2011/06/29 10:23:33 eldy Exp $ */ require("../main.inc.php"); @@ -45,17 +45,17 @@ $canreadgroup=$canreaduser; $caneditgroup=$canedituser; 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); + $canreadgroup=($user->admin || $user->rights->user->group_advance->read); + $caneditgroup=($user->admin || $user->rights->user->group_advance->write); } // Define value to know what current user can do on properties of edited user if ($_GET["id"]) { - // $user est le user qui edite, $_GET["id"] est l'id de l'utilisateur edite - $caneditfield=( (($user->id == $_GET["id"]) && $user->rights->user->self->creer) - || (($user->id != $_GET["id"]) && $user->rights->user->user->creer) ); - $caneditpassword=( (($user->id == $_GET["id"]) && $user->rights->user->self->password) - || (($user->id != $_GET["id"]) && $user->rights->user->user->password) ); + // $user est le user qui edite, $_GET["id"] est l'id de l'utilisateur edite + $caneditfield=( (($user->id == $_GET["id"]) && $user->rights->user->self->creer) + || (($user->id != $_GET["id"]) && $user->rights->user->user->creer) ); + $caneditpassword=( (($user->id == $_GET["id"]) && $user->rights->user->self->password) + || (($user->id != $_GET["id"]) && $user->rights->user->user->password) ); } $action=GETPOST("action"); @@ -82,151 +82,152 @@ $form = new Form($db); */ if ($_GET["subaction"] == 'addrights' && $canedituser) { - $edituser = new User($db); - $edituser->fetch($_GET["id"]); - $edituser->addrights($_GET["rights"]); + $edituser = new User($db); + $edituser->fetch($_GET["id"]); + $edituser->addrights($_GET["rights"]); } if ($_GET["subaction"] == 'delrights' && $canedituser) { - $edituser = new User($db); - $edituser->fetch($_GET["id"]); - $edituser->delrights($_GET["rights"]); + $edituser = new User($db); + $edituser->fetch($_GET["id"]); + $edituser->delrights($_GET["rights"]); } if ($action == 'confirm_disable' && $confirm == "yes" && $candisableuser) { - if ($_GET["id"] <> $user->id) - { - $edituser = new User($db); - $edituser->fetch($_GET["id"]); - $edituser->setstatus(0); - Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]); - exit; - } + if ($_GET["id"] <> $user->id) + { + $edituser = new User($db); + $edituser->fetch($_GET["id"]); + $edituser->setstatus(0); + Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]); + exit; + } } if ($action == 'confirm_enable' && $confirm == "yes" && $candisableuser) { - if ($_GET["id"] <> $user->id) - { - $message=''; + if ($_GET["id"] <> $user->id) + { + $message=''; - $edituser = new User($db); - $edituser->fetch($_GET["id"]); + $edituser = new User($db); + $edituser->fetch($_GET["id"]); - if (!empty($conf->file->main_limit_users)) - { - $nb = $edituser->getNbOfUsers("active"); - if ($nb >= $conf->file->main_limit_users) - { - $message='
'.$langs->trans("YourQuotaOfUsersIsReached").'
'; - } - } + if (!empty($conf->file->main_limit_users)) + { + $nb = $edituser->getNbOfUsers("active"); + if ($nb >= $conf->file->main_limit_users) + { + $message='
'.$langs->trans("YourQuotaOfUsersIsReached").'
'; + } + } - if (! $message) - { - $edituser->setstatus(1); - Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]); - exit; - } - } + if (! $message) + { + $edituser->setstatus(1); + Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]); + exit; + } + } } if ($action == 'confirm_delete' && $confirm == "yes" && $candisableuser) { - if ($_GET["id"] <> $user->id) - { - $edituser = new User($db); - $edituser->id=$_GET["id"]; - $result = $edituser->delete(); - if ($result < 0) - { - $langs->load("errors"); - $message='
'.$langs->trans("ErrorUserCannotBeDelete").'
'; - } - else - { - Header("Location: index.php"); - exit; - } - } + if ($_GET["id"] <> $user->id) + { + $edituser = new User($db); + $edituser->id=$_GET["id"]; + $result = $edituser->delete(); + if ($result < 0) + { + $langs->load("errors"); + $message='
'.$langs->trans("ErrorUserCannotBeDelete").'
'; + } + else + { + Header("Location: index.php"); + exit; + } + } } // Action ajout user if ($_POST["action"] == 'add' && $canadduser) { - $message=""; - if (! $_POST["nom"]) { - $message='
'.$langs->trans("NameNotDefined").'
'; - $action="create"; // Go back to create page - } - if (! $_POST["login"]) { - $message='
'.$langs->trans("LoginNotDefined").'
'; - $action="create"; // Go back to create page - } + $message=""; + if (! $_POST["nom"]) { + $message='
'.$langs->trans("NameNotDefined").'
'; + $action="create"; // Go back to create page + } + if (! $_POST["login"]) { + $message='
'.$langs->trans("LoginNotDefined").'
'; + $action="create"; // Go back to create page + } - $edituser = new User($db); + $edituser = new User($db); - if (!empty($conf->file->main_limit_users)) // If option to limit users is set - { - $nb = $edituser->getNbOfUsers("active"); - if ($nb >= $conf->file->main_limit_users) - { - $message='
'.$langs->trans("YourQuotaOfUsersIsReached").'
'; - $action="create"; // Go back to create page - } - } + if (!empty($conf->file->main_limit_users)) // If option to limit users is set + { + $nb = $edituser->getNbOfUsers("active"); + if ($nb >= $conf->file->main_limit_users) + { + $message='
'.$langs->trans("YourQuotaOfUsersIsReached").'
'; + $action="create"; // Go back to create page + } + } - if (! $message) - { - $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"]; - $edituser->phenix_pass = $_POST["phenix_pass"]; - $edituser->note = $_POST["note"]; - $edituser->ldap_sid = $_POST["ldap_sid"]; - // If multicompany is off, admin users must all be on entity 0. - $edituser->entity = ( ! empty($_POST["admin"]) && (! empty($_POST["superadmin"]) || empty($conf->multicompany->enabled)) ? 0 : $_POST["entity"]); + if (! $message) + { + $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->signature = $_POST["signature"]; + $edituser->phenix_login = $_POST["phenix_login"]; + $edituser->phenix_pass = $_POST["phenix_pass"]; + $edituser->note = $_POST["note"]; + $edituser->ldap_sid = $_POST["ldap_sid"]; + // If multicompany is off, admin users must all be on entity 0. + $edituser->entity = ( ! empty($_POST["admin"]) && (! empty($_POST["superadmin"]) || empty($conf->multicompany->enabled)) ? 0 : $_POST["entity"]); - $db->begin(); + $db->begin(); - $id = $edituser->create($user); - if ($id > 0) - { - if (isset($_POST['password']) && trim($_POST['password'])) - { - $edituser->setPassword($user,trim($_POST['password'])); - } + $id = $edituser->create($user); + if ($id > 0) + { + if (isset($_POST['password']) && trim($_POST['password'])) + { + $edituser->setPassword($user,trim($_POST['password'])); + } - $db->commit(); + $db->commit(); - Header("Location: fiche.php?id=$id"); - exit; - } - else - { - $langs->load("errors"); - $db->rollback(); - if (is_array($edituser->errors) && sizeof($edituser->errors)) $message='
'.join('
',$langs->trans($edituser->errors)).'
'; - else $message='
'.$langs->trans($edituser->error).'
'; - $action="create"; // Go back to create page - } + Header("Location: fiche.php?id=$id"); + exit; + } + else + { + $langs->load("errors"); + $db->rollback(); + if (is_array($edituser->errors) && sizeof($edituser->errors)) $message='
'.join('
',$langs->trans($edituser->errors)).'
'; + else $message='
'.$langs->trans($edituser->error).'
'; + $action="create"; // Go back to create page + } - } + } } // Action ajout groupe utilisateur if (($action == 'addgroup' || $action == 'removegroup') && $caneditfield) { - if ($group) - { + if ($group) + { $editgroup = new UserGroup($db); $editgroup->fetch($group); $editgroup->oldcopy=dol_clone($editgroup); @@ -242,73 +243,74 @@ if (($action == 'addgroup' || $action == 'removegroup') && $caneditfield) exit; } else - { - $message.=$edituser->error; - } - } + { + $message.=$edituser->error; + } + } } if ($action == 'update' && ! $_POST["cancel"]) { - require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); + require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); - if ($caneditfield) // Case we can edit all field - { - $message=""; + if ($caneditfield) // Case we can edit all field + { + $message=""; - if (! $_POST["nom"]) - { - $message='
'.$langs->trans("NameNotDefined").'
'; - $action="edit"; // Go back to create page - } - if (! $_POST["login"]) - { - $message='
'.$langs->trans("LoginNotDefined").'
'; - $action="edit"; // Go back to create page - } + if (! $_POST["nom"]) + { + $message='
'.$langs->trans("NameNotDefined").'
'; + $action="edit"; // Go back to create page + } + if (! $_POST["login"]) + { + $message='
'.$langs->trans("LoginNotDefined").'
'; + $action="edit"; // Go back to create page + } - if (! $message) - { - $db->begin(); - $edituser = new User($db); - $edituser->fetch($_GET["id"]); + if (! $message) + { + $db->begin(); + $edituser = new User($db); + $edituser->fetch($_GET["id"]); - $edituser->oldcopy=dol_clone($edituser); + $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"]; - $edituser->openid = $_POST["openid"]; - $edituser->webcal_login = $_POST["webcal_login"]; - $edituser->phenix_login = $_POST["phenix_login"]; - $edituser->phenix_pass = $_POST["phenix_pass"]; - $edituser->entity = ( (! empty($_POST["superadmin"]) && ! empty($_POST["admin"])) ? 0 : $_POST["entity"]); + $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"]; + $edituser->signature = $_POST["signature"]; + $edituser->openid = $_POST["openid"]; + $edituser->webcal_login = $_POST["webcal_login"]; + $edituser->phenix_login = $_POST["phenix_login"]; + $edituser->phenix_pass = $_POST["phenix_pass"]; + $edituser->entity = ( (! empty($_POST["superadmin"]) && ! empty($_POST["admin"])) ? 0 : $_POST["entity"]); if (GETPOST('deletephoto')) $edituser->photo=''; - if (! empty($_FILES['photo']['name'])) $edituser->photo = dol_sanitizeFileName($_FILES['photo']['name']); + if (! empty($_FILES['photo']['name'])) $edituser->photo = dol_sanitizeFileName($_FILES['photo']['name']); - $ret=$edituser->update($user); - if ($ret < 0) - { - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $langs->load("errors"); - $message.='
'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'
'; - } - else - { - $message.='
'.$edituser->error.'
'; - } - } + $ret=$edituser->update($user); + if ($ret < 0) + { + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $message.='
'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'
'; + } + else + { + $message.='
'.$edituser->error.'
'; + } + } - if ($ret >=0 && ! sizeof($edituser->errors)) - { - if (GETPOST('deletephoto') && $edituser->photo) + if ($ret >=0 && ! sizeof($edituser->errors)) + { + if (GETPOST('deletephoto') && $edituser->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'; @@ -316,145 +318,145 @@ if ($action == 'update' && ! $_POST["cancel"]) 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); + if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) + { + $dir= $conf->user->dir_output . '/' . get_exdir($edituser->id,2,0,1); - create_exdir($dir); + create_exdir($dir); - if (@is_dir($dir)) - { - $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - $result=dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']); + if (@is_dir($dir)) + { + $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $result=dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']); - if (! $result > 0) - { - $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; - } - else - { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + if (! $result > 0) + { + $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; + } + else + { + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); - // Create mini thumbs for company (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); - } - } - } - } + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); + } + } + } + } - if ($ret >= 0 && ! sizeof($edituser->errors)) - { - $message.='
'.$langs->trans("UserModified").'
'; - $db->commit(); - } - else - { - $db->rollback(); - } - } - } - else if ($caneditpassword) // Case we can edit only password - { - $edituser = new User($db); - $edituser->fetch($_GET["id"]); + if ($ret >= 0 && ! sizeof($edituser->errors)) + { + $message.='
'.$langs->trans("UserModified").'
'; + $db->commit(); + } + else + { + $db->rollback(); + } + } + } + else if ($caneditpassword) // Case we can edit only password + { + $edituser = new User($db); + $edituser->fetch($_GET["id"]); - $ret=$edituser->setPassword($user,$_POST["password"]); - if ($ret < 0) - { - $message.='
'.$edituser->error.'
'; - } - } + $ret=$edituser->setPassword($user,$_POST["password"]); + if ($ret < 0) + { + $message.='
'.$edituser->error.'
'; + } + } } // Change password with a new generated one if ((($action == 'confirm_password' && $confirm == 'yes') || ($action == 'confirm_passwordsend' && $confirm == 'yes')) && $caneditpassword) { - $edituser = new User($db); - $edituser->fetch($_GET["id"]); + $edituser = new User($db); + $edituser->fetch($_GET["id"]); - $newpassword=$edituser->setPassword($user,''); - if ($newpassword < 0) - { - // Echec - $message = '
'.$langs->trans("ErrorFailedToSetNewPassword").'
'; - } - else - { - // Succes - if ($action == 'confirm_passwordsend' && $confirm == 'yes') - { - if ($edituser->send_password($user,$newpassword) > 0) - { - $message = '
'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'
'; - //$message.=$newpassword; - } - else - { - $message = '
'.$langs->trans("PasswordChangedTo",$newpassword).'
'; - $message.= '
'.$edituser->error.'
'; - } - } - else - { - $message = '
'.$langs->trans("PasswordChangedTo",$newpassword).'
'; - } - } + $newpassword=$edituser->setPassword($user,''); + if ($newpassword < 0) + { + // Echec + $message = '
'.$langs->trans("ErrorFailedToSetNewPassword").'
'; + } + else + { + // Succes + if ($action == 'confirm_passwordsend' && $confirm == 'yes') + { + if ($edituser->send_password($user,$newpassword) > 0) + { + $message = '
'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'
'; + //$message.=$newpassword; + } + else + { + $message = '
'.$langs->trans("PasswordChangedTo",$newpassword).'
'; + $message.= '
'.$edituser->error.'
'; + } + } + else + { + $message = '
'.$langs->trans("PasswordChangedTo",$newpassword).'
'; + } + } } // Action initialisation donnees depuis record LDAP if ($_POST["action"] == 'adduserldap') { - $selecteduser = $_POST['users']; + $selecteduser = $_POST['users']; - $required_fields = array( - $conf->global->LDAP_FIELD_NAME, - $conf->global->LDAP_FIELD_FIRSTNAME, - $conf->global->LDAP_FIELD_LOGIN, - $conf->global->LDAP_FIELD_LOGIN_SAMBA, - $conf->global->LDAP_FIELD_PASSWORD, - $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, - $conf->global->LDAP_FIELD_PHONE, - $conf->global->LDAP_FIELD_FAX, - $conf->global->LDAP_FIELD_MOBILE, - $conf->global->LDAP_FIELD_MAIL, - $conf->global->LDAP_FIELD_SID); + $required_fields = array( + $conf->global->LDAP_FIELD_NAME, + $conf->global->LDAP_FIELD_FIRSTNAME, + $conf->global->LDAP_FIELD_LOGIN, + $conf->global->LDAP_FIELD_LOGIN_SAMBA, + $conf->global->LDAP_FIELD_PASSWORD, + $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, + $conf->global->LDAP_FIELD_PHONE, + $conf->global->LDAP_FIELD_FAX, + $conf->global->LDAP_FIELD_MOBILE, + $conf->global->LDAP_FIELD_MAIL, + $conf->global->LDAP_FIELD_SID); - $ldap = new Ldap(); - $result = $ldap->connect_bind(); - if ($result >= 0) - { - // Remove from required_fields all entries not configured in LDAP (empty) and duplicated - $required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement"))); + $ldap = new Ldap(); + $result = $ldap->connect_bind(); + if ($result >= 0) + { + // Remove from required_fields all entries not configured in LDAP (empty) and duplicated + $required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement"))); - $ldapusers = $ldap->getRecords($selecteduser, $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields); - //print_r($ldapusers); + $ldapusers = $ldap->getRecords($selecteduser, $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields); + //print_r($ldapusers); - if (is_array($ldapusers)) - { - foreach ($ldapusers as $key => $attribute) - { - $ldap_nom = $attribute[$conf->global->LDAP_FIELD_NAME]; - $ldap_prenom = $attribute[$conf->global->LDAP_FIELD_FIRSTNAME]; - $ldap_login = $attribute[$conf->global->LDAP_FIELD_LOGIN]; - $ldap_loginsmb = $attribute[$conf->global->LDAP_FIELD_LOGIN_SAMBA]; - $ldap_pass = $attribute[$conf->global->LDAP_FIELD_PASSWORD]; - $ldap_pass_crypted = $attribute[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED]; - $ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE]; - $ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX]; - $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE]; - $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL]; - $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID]; - } - } - } - else - { - $message='
'.$ldap->error.'
'; - } + if (is_array($ldapusers)) + { + foreach ($ldapusers as $key => $attribute) + { + $ldap_nom = $attribute[$conf->global->LDAP_FIELD_NAME]; + $ldap_prenom = $attribute[$conf->global->LDAP_FIELD_FIRSTNAME]; + $ldap_login = $attribute[$conf->global->LDAP_FIELD_LOGIN]; + $ldap_loginsmb = $attribute[$conf->global->LDAP_FIELD_LOGIN_SAMBA]; + $ldap_pass = $attribute[$conf->global->LDAP_FIELD_PASSWORD]; + $ldap_pass_crypted = $attribute[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED]; + $ldap_phone = $attribute[$conf->global->LDAP_FIELD_PHONE]; + $ldap_fax = $attribute[$conf->global->LDAP_FIELD_FAX]; + $ldap_mobile = $attribute[$conf->global->LDAP_FIELD_MOBILE]; + $ldap_mail = $attribute[$conf->global->LDAP_FIELD_MAIL]; + $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID]; + } + } + } + else + { + $message='
'.$ldap->error.'
'; + } } @@ -469,197 +471,197 @@ $html = new Form($db); if (($action == 'create') || ($action == 'adduserldap')) { - /* ************************************************************************** */ - /* */ - /* Affichage fiche en mode creation */ - /* */ - /* ************************************************************************** */ + /* ************************************************************************** */ + /* */ + /* Affichage fiche en mode creation */ + /* */ + /* ************************************************************************** */ - print_fiche_titre($langs->trans("NewUser")); + print_fiche_titre($langs->trans("NewUser")); - print $langs->trans("CreateInternalUserDesc"); - print "
"; - print "
"; + print $langs->trans("CreateInternalUserDesc"); + print "
"; + print "
"; - if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') - { - /* - * Affiche formulaire d'ajout d'un compte depuis LDAP - * si on est en synchro LDAP vers Dolibarr - */ + if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') + { + /* + * Affiche formulaire d'ajout d'un compte depuis LDAP + * si on est en synchro LDAP vers Dolibarr + */ - $ldap = new Ldap(); - $result = $ldap->connect_bind(); - if ($result >= 0) - { - $required_fields=array($conf->global->LDAP_KEY_USERS, - $conf->global->LDAP_FIELD_FULLNAME, - $conf->global->LDAP_FIELD_NAME, - $conf->global->LDAP_FIELD_FIRSTNAME, - $conf->global->LDAP_FIELD_LOGIN, - $conf->global->LDAP_FIELD_LOGIN_SAMBA); + $ldap = new Ldap(); + $result = $ldap->connect_bind(); + if ($result >= 0) + { + $required_fields=array($conf->global->LDAP_KEY_USERS, + $conf->global->LDAP_FIELD_FULLNAME, + $conf->global->LDAP_FIELD_NAME, + $conf->global->LDAP_FIELD_FIRSTNAME, + $conf->global->LDAP_FIELD_LOGIN, + $conf->global->LDAP_FIELD_LOGIN_SAMBA); - // Remove from required_fields all entries not configured in LDAP (empty) and duplicated - $required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement"))); + // Remove from required_fields all entries not configured in LDAP (empty) and duplicated + $required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement"))); - // Get from LDAP database an array of results - $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1); - if (is_array($ldapusers)) - { - $liste=array(); - foreach ($ldapusers as $key => $ldapuser) - { - // Define the label string for this user - $label=''; - foreach ($required_fields as $value) - { - if ($value) - { - $label.=$value."=".$ldapuser[$value]." "; - } - } - $liste[$key] = $label; - } + // Get from LDAP database an array of results + $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1); + if (is_array($ldapusers)) + { + $liste=array(); + foreach ($ldapusers as $key => $ldapuser) + { + // Define the label string for this user + $label=''; + foreach ($required_fields as $value) + { + if ($value) + { + $label.=$value."=".$ldapuser[$value]." "; + } + } + $liste[$key] = $label; + } - } - else - { - $message='
'.$ldap->error.'
'; - } - } - else - { - $message='
'.$ldap->error.'
'; - } - } + } + else + { + $message='
'.$ldap->error.'
'; + } + } + else + { + $message='
'.$ldap->error.'
'; + } + } - dol_htmloutput_errors($message); + dol_htmloutput_errors($message); - if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') - { - // Si la liste des users est rempli, on affiche la liste deroulante - if (is_array($liste)) - { - print "\n\n\n"; + if ($conf->ldap->enabled && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') + { + // Si la liste des users est rempli, on affiche la liste deroulante + if (is_array($liste)) + { + print "\n\n\n"; - print '
'; - print ''; - print ''; - print ''; - print '
'; - print $langs->trans("LDAPUsers"); - print ''; - print ''; - print $html->selectarray('users', $liste, '', 1); - print ''; - print ''; - print '
'; - print '
'; + print '
'; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("LDAPUsers"); + print ''; + print ''; + print $html->selectarray('users', $liste, '', 1); + print ''; + print ''; + print '
'; + print '
'; - print "\n\n\n"; - print '
'; - } - } + print "\n\n\n"; + print '
'; + } + } - print '
'; - print ''; - print ''; - if ($ldap_sid) print ''; - print ''; + print ''; + print ''; + print ''; + if ($ldap_sid) print ''; + print ''; - print ''; + print '
'; - print ''; + print ''; - // Nom - print ''; - print ''; + // Nom + print ''; + print ''; - // Prenom - print ''; - print ''; + // Prenom + print ''; + print ''; - // Login - print ''; - print ''; + // Login + print ''; + print ''; $generated_password=''; - if (! $ldap_sid) - { - include_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php'); - $generated_password=getRandomPassword(''); - } - $password=$generated_password; + if (! $ldap_sid) + { + include_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php'); + $generated_password=getRandomPassword(''); + } + $password=$generated_password; - // Mot de passe - print ''; - print ''; + // Mot de passe + print ''; + print ''; - // Administrateur - if ($user->admin) - { - print ''; - print ''; + print '\n"; - } + } + $checked=($_POST["superadmin"]?' checked':''); + $disabled=($_POST["superadmin"]?'':' disabled'); + print ' '.$langs->trans("SuperAdministrator"); + } + print "\n"; + } - // Type - print ''; - print ''; + // Type + print ''; + print ''; - // Tel - print ''; - print ''; + // Tel + print ''; + print ''; - // Tel portable - print ''; - print ''; + // Tel portable + print ''; + print ''; - // Fax - print ''; - print ''; + // Fax + print ''; + print ''; - // EMail + // EMail print ''; - print ''; + print ''; - // Note - print '\n"; + // Signature + print ''; + print ''; - // Autres caracteristiques issus des autres modules + // Note + print '\n"; - // Module Webcalendar - if ($conf->webcalendar->enabled) - { - print "".''; - print ''; - } + // Autres caracteristiques issus des autres modules - // Module Phenix - if ($conf->phenix->enabled) - { - print "".''; - print ''; - print "".''; - print ''; - } + // Module Webcalendar + if ($conf->webcalendar->enabled) + { + print "".''; + print ''; + } - print "".''; - print "
'.$langs->trans("Lastname").''; - if ($ldap_nom) - { - print ''; - print $ldap_nom; - } - else - { - print ''; - } - print '
'.$langs->trans("Lastname").''; + if ($ldap_nom) + { + print ''; + print $ldap_nom; + } + else + { + print ''; + } + print '
'.$langs->trans("Firstname").''; - if ($ldap_prenom) - { - print ''; - print $ldap_prenom; - } - else - { - print ''; - } - print '
'.$langs->trans("Firstname").''; + if ($ldap_prenom) + { + print ''; + print $ldap_prenom; + } + else + { + print ''; + } + print '
'.$langs->trans("Login").''; - if ($ldap_login) - { - print ''; - print $ldap_login; - } - elseif ($ldap_loginsmb) - { - print ''; - print $ldap_loginsmb; - } - else - { - print ''; - } - print '
'.$langs->trans("Login").''; + if ($ldap_login) + { + print ''; + print $ldap_login; + } + elseif ($ldap_loginsmb) + { + print ''; + print $ldap_loginsmb; + } + else + { + print ''; + } + print '
'.$langs->trans("Password").''; - if ($ldap_sid) - { - print 'Mot de passe du domaine'; - } - else - { - if ($ldap_pass) - { - print ''; - print preg_replace('/./i','*',$ldap_pass); - } - else - { - // We do not use a field password but a field text to show new password to use. - print ''; - } - } - print '
'.$langs->trans("Password").''; + if ($ldap_sid) + { + print 'Mot de passe du domaine'; + } + else + { + if ($ldap_pass) + { + print ''; + print preg_replace('/./i','*',$ldap_pass); + } + else + { + // We do not use a field password but a field text to show new password to use. + print ''; + } + } + print '
'.$langs->trans("Administrator").''; - print $form->selectyesno('admin',$_POST["admin"],1); + // Administrateur + if ($user->admin) + { + print '
'.$langs->trans("Administrator").''; + print $form->selectyesno('admin',$_POST["admin"],1); - if (! empty($conf->multicompany->enabled) && ! $user->entity) - { - if ($conf->use_javascript_ajax) - { - print ''; - } - $checked=($_POST["superadmin"]?' checked':''); - $disabled=($_POST["superadmin"]?'':' disabled'); - print ' '.$langs->trans("SuperAdministrator"); - } - print "
'.$langs->trans("Type").''; - print $html->textwithpicto($langs->trans("Internal"),$langs->trans("InternalExternalDesc")); - print '
'.$langs->trans("Type").''; + print $html->textwithpicto($langs->trans("Internal"),$langs->trans("InternalExternalDesc")); + print '
'.$langs->trans("PhonePro").''; - if ($ldap_phone) - { - print ''; - print $ldap_phone; - } - else - { - print ''; - } - print '
'.$langs->trans("PhonePro").''; + if ($ldap_phone) + { + print ''; + print $ldap_phone; + } + else + { + print ''; + } + print '
'.$langs->trans("PhoneMobile").''; - if ($ldap_mobile) - { - print ''; - print $ldap_mobile; - } - else - { - print ''; - } - print '
'.$langs->trans("PhoneMobile").''; + if ($ldap_mobile) + { + print ''; + print $ldap_mobile; + } + else + { + print ''; + } + print '
'.$langs->trans("Fax").''; - if ($ldap_fax) - { - print ''; - print $ldap_fax; - } - else - { - print ''; - } - print '
'.$langs->trans("Fax").''; + if ($ldap_fax) + { + print ''; + print $ldap_fax; + } + else + { + print ''; + } + print '
global->USER_MAIL_REQUIRED?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; - if ($ldap_mail) - { - print ''; - print $ldap_mail; - } - else - { - print ''; - } - print '
'; + if ($ldap_mail) + { + print ''; + print $ldap_mail; + } + else + { + print ''; + } + print '
'; - print $langs->trans("Note"); - print ''; - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_USER) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('note','','',180,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print ''; - } - print "
'.$langs->trans("Signature").''; + print ''; + print '
'; + print $langs->trans("Note"); + print ''; + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_USER) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('note','','',180,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print ''; + } + print "
'.$langs->trans("LoginWebcal").'
'.$langs->trans("LoginPenix").'
'.$langs->trans("PassPenix").'
'.$langs->trans("LoginWebcal").'
\n"; - print "
"; + // Module Phenix + if ($conf->phenix->enabled) + { + print "".''.$langs->trans("LoginPenix").''; + print ''; + print "".''.$langs->trans("PassPenix").''; + print ''; + } + + print "".''; + print "\n"; + print ""; } else { - /* ************************************************************************** */ - /* */ - /* Visu et edition */ - /* */ - /* ************************************************************************** */ + /* ************************************************************************** */ + /* */ + /* Visu et edition */ + /* */ + /* ************************************************************************** */ - if ($_GET["id"]) - { - $fuser = new User($db); - $fuser->fetch($_GET["id"]); + if ($_GET["id"]) + { + $fuser = new User($db); + $fuser->fetch($_GET["id"]); - // Connexion ldap - // pour recuperer passDoNotExpire et userChangePassNextLogon - if ($conf->ldap->enabled && $fuser->ldap_sid) - { - $ldap = new Ldap(); - $result=$ldap->connect_bind(); - if ($result > 0) - { - $userSearchFilter = '('.$conf->global->LDAP_FILTER_CONNECTION.'('.$this->getUserIdentifier().'='.$fuser->login.'))'; - $entries = $ldap->fetch($fuser->login,$userSearchFilter); - if (! $entries) - { - $message .= $ldap->error; - } + // Connexion ldap + // pour recuperer passDoNotExpire et userChangePassNextLogon + if ($conf->ldap->enabled && $fuser->ldap_sid) + { + $ldap = new Ldap(); + $result=$ldap->connect_bind(); + if ($result > 0) + { + $userSearchFilter = '('.$conf->global->LDAP_FILTER_CONNECTION.'('.$this->getUserIdentifier().'='.$fuser->login.'))'; + $entries = $ldap->fetch($fuser->login,$userSearchFilter); + if (! $entries) + { + $message .= $ldap->error; + } - $passDoNotExpire = 0; - $userChangePassNextLogon = 0; - $userDisabled = 0; - $statutUACF = ''; + $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"; - } + //On verifie les options du compte + if (sizeof($ldap->uacf) > 0) + { + foreach ($ldap->uacf as $key => $statut) + { + if ($key == 65536) + { + $passDoNotExpire = 1; + $statutUACF = $statut; + } + } + } + else + { + $userDisabled = 1; + $statutUACF = "ACCOUNTDISABLE"; + } - if ($ldap->pwdlastset == 0) - { - $userChangePassNextLogon = 1; - } - } - } + if ($ldap->pwdlastset == 0) + { + $userChangePassNextLogon = 1; + } + } + } - /* - * Affichage onglets - */ - $head = user_prepare_head($fuser); + /* + * Affichage onglets + */ + $head = user_prepare_head($fuser); - $title = $langs->trans("User"); - dol_fiche_head($head, 'user', $title, 0, 'user'); + $title = $langs->trans("User"); + dol_fiche_head($head, 'user', $title, 0, 'user'); - /* - * Confirmation reinitialisation mot de passe - */ - if ($action == 'password') - { - $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$fuser->login),"confirm_password", '', 0, 1); - if ($ret == 'html') print '
'; - } + /* + * Confirmation reinitialisation mot de passe + */ + if ($action == 'password') + { + $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$fuser->login),"confirm_password", '', 0, 1); + if ($ret == 'html') print '
'; + } - /* - * Confirmation envoi mot de passe - */ - if ($action == 'passwordsend') - { - $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$fuser->login),"confirm_passwordsend", '', 0, 1); - if ($ret == 'html') print '
'; - } + /* + * Confirmation envoi mot de passe + */ + if ($action == 'passwordsend') + { + $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$fuser->login),"confirm_passwordsend", '', 0, 1); + if ($ret == 'html') print '
'; + } - /* - * Confirmation desactivation - */ - if ($action == 'disable') - { - $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable", '', 0, 1); - if ($ret == 'html') print '
'; - } + /* + * Confirmation desactivation + */ + if ($action == 'disable') + { + $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable", '', 0, 1); + if ($ret == 'html') print '
'; + } - /* - * Confirmation activation - */ - if ($action == 'enable') - { - $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$fuser->login),"confirm_enable", '', 0, 1); - if ($ret == 'html') print '
'; - } + /* + * Confirmation activation + */ + if ($action == 'enable') + { + $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$fuser->login),"confirm_enable", '', 0, 1); + if ($ret == 'html') print '
'; + } - /* - * Confirmation suppression - */ - if ($action == 'delete') - { - $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete", '', 0, 1); - if ($ret == 'html') print '
'; - } + /* + * Confirmation suppression + */ + if ($action == 'delete') + { + $ret=$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete", '', 0, 1); + if ($ret == 'html') print '
'; + } - dol_htmloutput_mesg($message); + dol_htmloutput_mesg($message); - /* - * Fiche en mode visu - */ - if ($_GET["action"] != 'edit') - { - print ''; + /* + * Fiche en mode visu + */ + if ($_GET["action"] != 'edit') + { + print '
'; - // Ref - print ''; - print ''; - print ''."\n"; + // Ref + print ''; + print ''; + print ''."\n"; - $rowspan=13; + $rowspan=14; if ($conf->societe->enabled) $rowspan++; if ($conf->adherent->enabled) $rowspan++; if ($conf->webcalendar->enabled) $rowspan++; if ($conf->phenix->enabled) $rowspan+=2; - // Lastname - print ''; - print ''; + // Lastname + print ''; + print ''; // Photo print ''."\n"; - // Firstname - print ''; - print ''; + // Firstname + print ''; + print ''; print ''."\n"; - // Login - print ''; - if ($fuser->ldap_sid && $fuser->statut==0) - { - print ''; - } - else - { - print ''; - } - print ''."\n"; - - // Password - print ''; - if ($fuser->ldap_sid) - { - if ($passDoNotExpire) - { - print ''; - } - else if($userChangePassNextLogon) - { - print ''; - } - else if($userDisabled) - { - print ''; - } - else - { - print ''; - } - } - else - { - print '"; - } + // Login + print ''; + if ($fuser->ldap_sid && $fuser->statut==0) + { + print ''; + } + else + { + print ''; + } print ''."\n"; - // Administrator - print ''; + if ($fuser->ldap_sid) + { + if ($passDoNotExpire) + { + print ''; + } + else if($userChangePassNextLogon) + { + print ''; + } + else if($userDisabled) + { + print ''; + } + else + { + print ''; + } + } + else + { + print '"; + } + print ''."\n"; + + // Administrator + print ''."\n"; - // Type - print ''."\n"; - // Tel pro - print ''; - print ''; + // Tel pro + print ''; + print ''; print ''."\n"; - // Tel mobile - print ''; - print ''; + // Tel mobile + print ''; + print ''; print ''."\n"; - // Fax - print ''; - print ''; + // Fax + print ''; + print ''; print ''."\n"; - // EMail - print ''; - print ''; - print "\n"; + // EMail + print ''; + print ''; + print "\n"; - // Statut - print ''; - print ''; + // Signature + print ''; + print ''; + print "\n"; + + // Statut + print ''; + print ''; print ''."\n"; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print "\n"; - print ''; - print ''; - print "\n"; + print ''; + print ''; + print "\n"; - if (preg_match('/myopenid/',$conf->authmode)) - { - print ''; - print ''; - print "\n"; - } - // Autres caracteristiques issus des autres modules + if (preg_match('/myopenid/',$conf->authmode)) + { + print ''; + print ''; + print "\n"; + } + // Autres caracteristiques issus des autres modules - // Module Webcalendar - if ($conf->webcalendar->enabled) - { - $langs->load("other"); - print ''; - print ''; + // Module Webcalendar + if ($conf->webcalendar->enabled) + { + $langs->load("other"); + print ''; + print ''; print ''."\n"; - } + } - // Module Phenix - if ($conf->phenix->enabled) - { - $langs->load("other"); - print ''; - print ''; - print "\n"; - print ''; - print ''; + // Module Phenix + if ($conf->phenix->enabled) + { + $langs->load("other"); + print ''; + print ''; + print "\n"; + print ''; + print ''; print ''."\n"; - } + } - // Company / Contact - if ($conf->societe->enabled) - { - print ''; - print ''; + // Company / Contact + if ($conf->societe->enabled) + { + print ''; + print ''; print ''."\n"; - } + } - // Module Adherent - if ($conf->adherent->enabled) - { - $langs->load("members"); - print ''; - print ''; + // Module Adherent + if ($conf->adherent->enabled) + { + $langs->load("members"); + print ''; + print ''; print ''."\n"; - } + } - print "
'.$langs->trans("Ref").''; - print $html->showrefnav($fuser,'id','',$user->rights->user->user->lire || $user->admin); - print '
'.$langs->trans("Ref").''; + print $html->showrefnav($fuser,'id','',$user->rights->user->user->lire || $user->admin); + print '
'.$langs->trans("Lastname").''.$fuser->nom.'
'.$langs->trans("Lastname").''.$fuser->nom.''; @@ -927,404 +935,409 @@ else print '
'.$langs->trans("Firstname").''.$fuser->prenom.'
'.$langs->trans("Firstname").''.$fuser->prenom.'
'.$langs->trans("Login").''.$langs->trans("LoginAccountDisableInDolibarr").''.$fuser->login.'
'.$langs->trans("Password").''.$langs->trans("LdapUacf_".$statutUACF).''.$langs->trans("UserMustChangePassNextLogon",$ldap->domainFQDN).''.$langs->trans("LdapUacf_".$statutUACF,$ldap->domainFQDN).''.$langs->trans("DomainPassword").''; - if ($fuser->pass) print preg_replace('/./i','*',$fuser->pass); - else - { - if ($user->admin) print $langs->trans("Crypted").': '.$fuser->pass_indatabase_crypted; - else print $langs->trans("Hidden"); - } - print "
'.$langs->trans("Login").''.$langs->trans("LoginAccountDisableInDolibarr").''.$fuser->login.'
'.$langs->trans("Administrator").''; - if (! empty($conf->multicompany->enabled) && $fuser->admin && ! $fuser->entity) - { - print $html->textwithpicto(yn($fuser->admin),$langs->trans("SuperAdministratorDesc"),1,"superadmin"); - } - else if ($fuser->admin) - { - print $html->textwithpicto(yn($fuser->admin),$langs->trans("AdministratorDesc"),1,"admin"); - } - else - { - print yn($fuser->admin); - } + // Password + print '
'.$langs->trans("Password").''.$langs->trans("LdapUacf_".$statutUACF).''.$langs->trans("UserMustChangePassNextLogon",$ldap->domainFQDN).''.$langs->trans("LdapUacf_".$statutUACF,$ldap->domainFQDN).''.$langs->trans("DomainPassword").''; + if ($fuser->pass) print preg_replace('/./i','*',$fuser->pass); + else + { + if ($user->admin) print $langs->trans("Crypted").': '.$fuser->pass_indatabase_crypted; + else print $langs->trans("Hidden"); + } + print "
'.$langs->trans("Administrator").''; + if (! empty($conf->multicompany->enabled) && $fuser->admin && ! $fuser->entity) + { + print $html->textwithpicto(yn($fuser->admin),$langs->trans("SuperAdministratorDesc"),1,"superadmin"); + } + else if ($fuser->admin) + { + print $html->textwithpicto(yn($fuser->admin),$langs->trans("AdministratorDesc"),1,"admin"); + } + else + { + print yn($fuser->admin); + } print '
'.$langs->trans("Type").''; - if ($fuser->societe_id) - { - print $html->textwithpicto($langs->trans("External"),$langs->trans("InternalExternalDesc")); - } - else if ($fuser->ldap_sid) - { - print $langs->trans("DomainUser",$ldap->domainFQDN); - } - else - { - print $html->textwithpicto($langs->trans("Internal"),$langs->trans("InternalExternalDesc")); - } + // Type + print '
'.$langs->trans("Type").''; + if ($fuser->societe_id) + { + print $html->textwithpicto($langs->trans("External"),$langs->trans("InternalExternalDesc")); + } + else if ($fuser->ldap_sid) + { + print $langs->trans("DomainUser",$ldap->domainFQDN); + } + else + { + print $html->textwithpicto($langs->trans("Internal"),$langs->trans("InternalExternalDesc")); + } print '
'.$langs->trans("PhonePro").''.dol_print_phone($fuser->office_phone,'',0,0,1).'
'.$langs->trans("PhonePro").''.dol_print_phone($fuser->office_phone,'',0,0,1).'
'.$langs->trans("PhoneMobile").''.dol_print_phone($fuser->user_mobile,'',0,0,1).'
'.$langs->trans("PhoneMobile").''.dol_print_phone($fuser->user_mobile,'',0,0,1).'
'.$langs->trans("Fax").''.dol_print_phone($fuser->office_fax,'',0,0,1).'
'.$langs->trans("Fax").''.dol_print_phone($fuser->office_fax,'',0,0,1).'
'.$langs->trans("EMail").''.dol_print_email($fuser->email,0,0,1).'
'.$langs->trans("EMail").''.dol_print_email($fuser->email,0,0,1).'
'.$langs->trans("Status").''; - print $fuser->getLibStatut(4); - print '
'.$langs->trans('Signature').''.$fuser->signature.'
'.$langs->trans("Status").''; + print $fuser->getLibStatut(4); + print '
'.$langs->trans("LastConnexion").''.dol_print_date($fuser->datelastlogin,"dayhour").'
'.$langs->trans("LastConnexion").''.dol_print_date($fuser->datelastlogin,"dayhour").'
'.$langs->trans("PreviousConnexion").''.dol_print_date($fuser->datepreviouslogin,"dayhour").'
'.$langs->trans("PreviousConnexion").''.dol_print_date($fuser->datepreviouslogin,"dayhour").'
'.$langs->trans("url_openid").''.$fuser->openid.'
'.$langs->trans("url_openid").''.$fuser->openid.'
'.$langs->trans("LoginWebcal").''.$fuser->webcal_login.' 
'.$langs->trans("LoginWebcal").''.$fuser->webcal_login.' 
'.$langs->trans("LoginPhenix").''.$fuser->phenix_login.' 
'.$langs->trans("PassPhenix").''.preg_replace('/./i','*',$fuser->phenix_pass_crypted).' 
'.$langs->trans("LoginPhenix").''.$fuser->phenix_login.' 
'.$langs->trans("PassPhenix").''.preg_replace('/./i','*',$fuser->phenix_pass_crypted).' 
'.$langs->trans("LinkToCompanyContact").''; - 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 '
'; - print ''.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; - } - print '
'.$langs->trans("LinkToCompanyContact").''; + 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 '
'; + print ''.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; + } + print '
'.$langs->trans("LinkedToDolibarrMember").''; - if ($fuser->fk_member) - { - $adh=new Adherent($db); - $adh->fetch($fuser->fk_member); - $adh->ref=$adh->getFullname($langs); // Force to show login instead of id - print $adh->getNomUrl(1); - } - else - { - print $langs->trans("UserNotLinkedToMember"); - } - print '
'.$langs->trans("LinkedToDolibarrMember").''; + if ($fuser->fk_member) + { + $adh=new Adherent($db); + $adh->fetch($fuser->fk_member); + $adh->ref=$adh->getFullname($langs); // Force to show login instead of id + print $adh->getNomUrl(1); + } + else + { + print $langs->trans("UserNotLinkedToMember"); + } + print '
\n"; + print "\n"; - print "\n"; + print "\n"; - /* - * Barre d'actions - */ + /* + * Barre d'actions + */ - print '
'; + print '
'; - if ($caneditfield && - (empty($conf->multicompany->enabled) || (($fuser->entity == $conf->entity) || $fuser->entity == $user->entity)) ) - { - if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) - { - print ''.$langs->trans("Modify").''; - } - else - { - print ''.$langs->trans("Modify").''; - } - } - elseif ($caneditpassword && ! $fuser->ldap_sid && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) ) - { - print ''.$langs->trans("EditPassword").''; - } + if ($caneditfield && + (empty($conf->multicompany->enabled) || (($fuser->entity == $conf->entity) || $fuser->entity == $user->entity)) ) + { + if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) + { + print ''.$langs->trans("Modify").''; + } + else + { + print ''.$langs->trans("Modify").''; + } + } + elseif ($caneditpassword && ! $fuser->ldap_sid && + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) ) + { + print ''.$langs->trans("EditPassword").''; + } - // Si on a un gestionnaire de generation de mot de passe actif - if ($conf->global->USER_PASSWORD_GENERATED != 'none') - { - if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity))) - { - print ''.$langs->trans("ReinitPassword").''; - } + // Si on a un gestionnaire de generation de mot de passe actif + if ($conf->global->USER_PASSWORD_GENERATED != 'none') + { + if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity))) + { + print ''.$langs->trans("ReinitPassword").''; + } - if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) ) - { - if ($fuser->email) print ''.$langs->trans("SendNewPassword").''; - else print ''.$langs->trans("SendNewPassword").''; - } - } + if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) ) + { + if ($fuser->email) print ''.$langs->trans("SendNewPassword").''; + else print ''.$langs->trans("SendNewPassword").''; + } + } - // Activer - if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 0 && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) ) - { - print ''.$langs->trans("Reactivate").''; - } - // Desactiver - if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 1 && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) ) - { - print ''.$langs->trans("DisableUser").''; - } - // Delete - if ($user->id <> $_GET["id"] && $candisableuser && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) ) - { - print ''.$langs->trans("DeleteUser").''; - } + // Activer + if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 0 && + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) ) + { + print ''.$langs->trans("Reactivate").''; + } + // Desactiver + if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 1 && + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) ) + { + print ''.$langs->trans("DisableUser").''; + } + // Delete + if ($user->id <> $_GET["id"] && $candisableuser && + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity)) ) + { + print ''.$langs->trans("DeleteUser").''; + } - print "
\n"; - print "
\n"; + print "
\n"; + print "
\n"; - /* - * Liste des groupes dans lequel est l'utilisateur - */ + /* + * Liste des groupes dans lequel est l'utilisateur + */ - if ($canreadgroup) - { - print_fiche_titre($langs->trans("ListOfGroupsForUser"),'',''); + if ($canreadgroup) + { + print_fiche_titre($langs->trans("ListOfGroupsForUser"),'',''); - // On selectionne les groupes auquel fait parti le user - $exclude = array(); + // On selectionne les groupes auquel fait parti le user + $exclude = array(); - $usergroup=new UserGroup($db); - $groupslist = $usergroup->listGroupsForUser($fuser->id); + $usergroup=new UserGroup($db); + $groupslist = $usergroup->listGroupsForUser($fuser->id); - if (! empty($groupslist)) - { - foreach($groupslist as $groupforuser) - { - $exclude[]=$groupforuser->id; - } - } + if (! empty($groupslist)) + { + foreach($groupslist as $groupforuser) + { + $exclude[]=$groupforuser->id; + } + } - if ($caneditgroup) - { - $form = new Form($db); - print '
'."\n"; - print ''; - print ''; - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print '
'.$langs->trans("GroupsToAdd").''; - print $form->select_dolgroups('','group',1,$exclude); - print '   '; - print ''; - print '
'."\n"; + if ($caneditgroup) + { + $form = new Form($db); + print '
'."\n"; + print ''; + print ''; + print ''; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print '
'.$langs->trans("GroupsToAdd").''; + print $form->select_dolgroups('','group',1,$exclude); + print '   '; + print ''; + print '
'."\n"; - print '
'; - } + print '
'; + } - /* - * Groupes affectes - */ - print ''; - print ''; - print ''; - print "\n"; + /* + * Groupes affectes + */ + print '
'.$langs->trans("Groups").' 
'; + print ''; + print ''; + print "\n"; - if (! empty($groupslist)) - { - $var=true; + if (! empty($groupslist)) + { + $var=true; - foreach($groupslist as $group) - { - $var=!$var; + foreach($groupslist as $group) + { + $var=!$var; - print ""; - print ''; - print '"; + print ''; + print '\n"; - } - } - else - { - print ''; - } + if ($caneditgroup) + { + print ''; + print img_delete($langs->trans("RemoveFromGroup")); + } + else + { + print " "; + } + print "\n"; + } + } + else + { + print ''; + } - print "
'.$langs->trans("Groups").' 
'; - if ($caneditgroup) - { - print ''.img_object($langs->trans("ShowGroup"),"group").' '.$group->nom.''; - } - else - { - print img_object($langs->trans("ShowGroup"),"group").' '.$group->nom; - } - print ''; + print "
'; + if ($caneditgroup) + { + print ''.img_object($langs->trans("ShowGroup"),"group").' '.$group->nom.''; + } + else + { + print img_object($langs->trans("ShowGroup"),"group").' '.$group->nom; + } + print ''; - if ($caneditgroup) - { - print ''; - print img_delete($langs->trans("RemoveFromGroup")); - } - else - { - print " "; - } - print "
'.$langs->trans("None").'
'.$langs->trans("None").'
"; - print "
"; - } - } + print ""; + print "
"; + } + } - /* - * Fiche en mode edition - */ + /* + * Fiche en mode edition + */ - if ($_GET["action"] == 'edit' && ($canedituser || ($user->id == $fuser->id))) - { + if ($_GET["action"] == 'edit' && ($canedituser || ($user->id == $fuser->id))) + { - print '
'; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; - $rowspan=11; + $rowspan=12; if ($conf->societe->enabled) $rowspan++; if ($conf->adherent->enabled) $rowspan++; if ($conf->webcalendar->enabled) $rowspan++; if ($conf->phenix->enabled) $rowspan+=2; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - // Lastname - print ""; - print ''; - print ''; + // Lastname + print ""; + print ''; + print ''; // Photo print '
'.$langs->trans("Ref").''; - print $fuser->id; - print '
'.$langs->trans("Ref").''; + print $fuser->id; + print '
'.$langs->trans("Lastname").''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->nom; - } - print '
'.$langs->trans("Lastname").''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->nom; + } + print ''; print $html->showphoto('userphoto',$fuser); @@ -1338,84 +1351,84 @@ else print '
'; } print ''; - print ''; + print ''; - // Firstname - print "".''.$langs->trans("Firstname").''; - print ''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->prenom; - } - print ''; + // Firstname + print "".''.$langs->trans("Firstname").''; + print ''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->prenom; + } + print ''; - // Login - print "".''.$langs->trans("Login").''; - print ''; - if ($user->admin && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->login; - } - print ''; - print ''; + // Login + print "".''.$langs->trans("Login").''; + print ''; + if ($user->admin && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->login; + } + print ''; + print ''; - // Pass - print ''.$langs->trans("Password").''; - print ''; - if ($fuser->ldap_sid) - { - $text=$langs->trans("DomainPassword"); - } - else if ($caneditpassword) - { - $text=''; - if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http') - { - $text=$html->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning'); - } - } - else - { - $text=preg_replace('/./i','*',$fuser->pass); - } - print $text; - print "\n"; + // Pass + print ''.$langs->trans("Password").''; + print ''; + if ($fuser->ldap_sid) + { + $text=$langs->trans("DomainPassword"); + } + else if ($caneditpassword) + { + $text=''; + if ($dolibarr_main_authentication && $dolibarr_main_authentication == 'http') + { + $text=$html->textwithpicto($text,$langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless",$dolibarr_main_authentication),1,'warning'); + } + } + else + { + $text=preg_replace('/./i','*',$fuser->pass); + } + print $text; + print "\n"; - // Administrator - print "".''.$langs->trans("Administrator").''; - if ($fuser->societe_id > 0) - { - print ''; - print ''.yn($fuser->admin); - print ' ('.$langs->trans("ExternalUser").')'; - print ''; - } - else - { - print ''; - $nbSuperAdmin = $user->getNbOfUsers('superadmin'); - if ($user->admin - && ($user->id != $fuser->id) // Don't downgrade ourself - && ($fuser->entity > 0 || $nbSuperAdmin > 1) // Don't downgrade a superadmin if alone - ) - { - print $form->selectyesno('admin',$fuser->admin,1); + // Administrator + print "".''.$langs->trans("Administrator").''; + if ($fuser->societe_id > 0) + { + print ''; + print ''.yn($fuser->admin); + print ' ('.$langs->trans("ExternalUser").')'; + print ''; + } + else + { + print ''; + $nbSuperAdmin = $user->getNbOfUsers('superadmin'); + if ($user->admin + && ($user->id != $fuser->id) // Don't downgrade ourself + && ($fuser->entity > 0 || $nbSuperAdmin > 1) // Don't downgrade a superadmin if alone + ) + { + print $form->selectyesno('admin',$fuser->admin,1); - if (! empty($conf->multicompany->enabled) && ! $user->entity) - { - if ($conf->use_javascript_ajax) - { - print ''; - } + } - $checked=(($fuser->admin && ! $fuser->entity) ? ' checked' : ''); - print ' '.$langs->trans("SuperAdministrator"); - } - } - else - { - $yn = yn($fuser->admin); - print ''; - if (! empty($conf->multicompany->enabled) && ! $fuser->entity) print $html->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning'); - else print $yn; - } - print ''; - } + $checked=(($fuser->admin && ! $fuser->entity) ? ' checked' : ''); + print ' '.$langs->trans("SuperAdministrator"); + } + } + else + { + $yn = yn($fuser->admin); + print ''; + if (! empty($conf->multicompany->enabled) && ! $fuser->entity) print $html->textwithpicto($yn,$langs->trans("DontDowngradeSuperAdmin"),1,'warning'); + else print $yn; + } + print ''; + } - // Type - print ''.$langs->trans("Type").''; - print ''; - if ($fuser->societe_id) - { - print $langs->trans("External"); - } - else if ($fuser->ldap_sid) - { - print $langs->trans("DomainUser"); - } - else - { - print $langs->trans("Internal"); - } - print ''; + // Type + print ''.$langs->trans("Type").''; + print ''; + if ($fuser->societe_id) + { + print $langs->trans("External"); + } + else if ($fuser->ldap_sid) + { + print $langs->trans("DomainUser"); + } + else + { + print $langs->trans("Internal"); + } + print ''; - // Tel pro - print "".''.$langs->trans("PhonePro").''; - print ''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->office_phone; - } - print ''; + // Tel pro + print "".''.$langs->trans("PhonePro").''; + print ''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->office_phone; + } + print ''; - // Tel mobile - print "".''.$langs->trans("PhoneMobile").''; - print ''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->user_mobile; - } - print ''; + // Tel mobile + print "".''.$langs->trans("PhoneMobile").''; + print ''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->user_mobile; + } + print ''; - // Fax - print "".''.$langs->trans("Fax").''; - print ''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->office_fax; - } - print ''; + // Fax + print "".''.$langs->trans("Fax").''; + print ''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->office_fax; + } + print ''; - // EMail - print "".'global->USER_MAIL_REQUIRED?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; - print ''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->email; - } - print ''; + // EMail + print "".'global->USER_MAIL_REQUIRED?' class="fieldrequired"':'').'>'.$langs->trans("EMail").''; + print ''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->email; + } + print ''; - // openid - if (preg_match('/myopenid/',$conf->authmode)) - { - print "".''.$langs->trans("url_openid").''; - print ''; - if ($caneditfield && !$fuser->ldap_sid) - { - print ''; - } - else - { - print ''; - print $fuser->openid; - } - print ''; - } + // Signature + print "".''.$langs->trans("Signature").''; + print ''; + print ''; + print ''; - // Statut - print ''.$langs->trans("Status").''; - print ''; - print $fuser->getLibStatut(4); - print ''; + // openid + if (preg_match('/myopenid/',$conf->authmode)) + { + print "".''.$langs->trans("url_openid").''; + print ''; + if ($caneditfield && !$fuser->ldap_sid) + { + print ''; + } + else + { + print ''; + print $fuser->openid; + } + print ''; + } - // Autres caracteristiques issus des autres modules + // Statut + print ''.$langs->trans("Status").''; + print ''; + print $fuser->getLibStatut(4); + print ''; - // Module Webcalendar - if ($conf->webcalendar->enabled) - { - $langs->load("other"); - print "".''.$langs->trans("LoginWebcal").''; - print ''; - if ($caneditfield) print ''; - else print $fuser->webcal_login; - print ''; - } + // Autres caracteristiques issus des autres modules - // Module Phenix - if ($conf->phenix->enabled) - { - $langs->load("other"); - print "".''.$langs->trans("LoginPhenix").''; - print ''; - if ($caneditfield) print ''; - else print $fuser->phenix_login; - print ''; - print "".''.$langs->trans("PassPhenix").''; - print ''; - if ($caneditfield) print ''; - else print preg_replace('/./i','*',$fuser->phenix_pass_crypted); - print ''; - } + // Module Webcalendar + if ($conf->webcalendar->enabled) + { + $langs->load("other"); + print "".''.$langs->trans("LoginWebcal").''; + print ''; + if ($caneditfield) print ''; + else print $fuser->webcal_login; + print ''; + } - // Company / Contact - if ($conf->societe->enabled) - { - print ''.$langs->trans("LinkToCompanyContact").''; - print ''; - 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 ' / '.'
'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; - } - } - else - { - print $langs->trans("ThisUserIsNot"); - } - print ''; - print "\n"; - } + // Module Phenix + if ($conf->phenix->enabled) + { + $langs->load("other"); + print "".''.$langs->trans("LoginPhenix").''; + print ''; + if ($caneditfield) print ''; + else print $fuser->phenix_login; + print ''; + print "".''.$langs->trans("PassPhenix").''; + print ''; + if ($caneditfield) print ''; + else print preg_replace('/./i','*',$fuser->phenix_pass_crypted); + print ''; + } - // Module Adherent - if ($conf->adherent->enabled) - { - $langs->load("members"); - print ''.$langs->trans("LinkedToDolibarrMember").''; - print ''; - 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 ''; - print "\n"; - } + // Company / Contact + if ($conf->societe->enabled) + { + print ''.$langs->trans("LinkToCompanyContact").''; + print ''; + 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 ' / '.''.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; + } + } + else + { + print $langs->trans("ThisUserIsNot"); + } + print ''; + print "\n"; + } + + // Module Adherent + if ($conf->adherent->enabled) + { + $langs->load("members"); + print ''.$langs->trans("LinkedToDolibarrMember").''; + print ''; + 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 ''; + print "\n"; + } print ''; print '
'; - print ''; - print '   '; - print ''; - print '
'; + print ''; + print '   '; + print ''; + print ''; - print '
'; + print ''; - print ''; - } + print ''; + } - $ldap->close; - } + $ldap->close; + } } $db->close(); function dolValidElement($element) { - return (trim($element) != ''); + return (trim($element) != ''); } -llxFooter('$Date$ - $Revision$'); +llxFooter('$Date: 2011/06/29 10:23:33 $ - $Revision: 1.273 $'); ?>