From 03d6903248e748881f316a52769aa532cbf8f817 Mon Sep 17 00:00:00 2001 From: simnandez Date: Thu, 24 Jan 2013 12:53:42 +0100 Subject: [PATCH 01/32] Fix: [ bug #698 ] Bad calculation of totals of associated documents --- htdocs/comm/propal/tpl/linkedobjectblock.tpl.php | 4 +++- htdocs/commande/tpl/linkedobjectblock.tpl.php | 4 +++- htdocs/compta/facture/tpl/linkedobjectblock.tpl.php | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 4337611066e..e9ad176a86d 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,6 +38,7 @@ print_titre($langs->trans('RelatedCommercialProposals')); +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +39,7 @@ print_titre($langs->trans('RelatedOrders')); +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +39,7 @@ else print_titre($langs->trans("RelatedBill")); Date: Thu, 24 Jan 2013 17:29:11 +0100 Subject: [PATCH 02/32] New: add hook getFormMail --- htdocs/core/class/html.formmail.class.php | 835 +++++++++++----------- 1 file changed, 429 insertions(+), 406 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 3d15fdbeeee..c221cc33c07 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -217,422 +217,445 @@ class FormMail function get_form($addfileaction='addfile',$removefileaction='removefile') { global $conf, $langs, $user; + global $hookmanager; $langs->load("other"); $langs->load("mails"); - $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($this->db); - - $out.= "\n\n"; - if ($this->withform) + if (! is_object($hookmanager)) { - $out.= '
'."\n"; - $out.= ''; + if (! class_exists('HookManager')) { + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array + require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } } - foreach ($this->param as $key=>$value) + $hookmanager->initHooks(array('formmail')); + + $parameters=array( + 'addfileaction' => $addfileaction, + 'removefileaction'=> $removefileaction + ); + $reshook=$hookmanager->executeHooks('getFormMail', $parameters, $this); + + if (!empty($reshook)) { - $out.= ''."\n"; + return $hookmanager->resPrint; } - $out.= ''."\n"; - - // Substitution array - if (! empty($this->withsubstit)) + else { - $out.= '\n"; + $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($this->db); + + $out.= "\n\n"; + if ($this->withform) + { + $out.= ''."\n"; + $out.= ''; + } + foreach ($this->param as $key=>$value) + { + $out.= ''."\n"; + } + $out.= '
'; - $help=""; - foreach($this->substit as $key => $val) - { - $help.=$key.' -> '.$langs->trans($val).'
'; - } - $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); - $out.= "
'."\n"; + + // Substitution array + if (! empty($this->withsubstit)) + { + $out.= '\n"; + } + + // From + if (! empty($this->withfrom)) + { + if (! empty($this->withfromreadonly)) + { + $out.= ''; + $out.= ''; + $out.= '\n"; + $out.= "\n"; + } + else + { + $out.= "\n"; + } + } + + // Replyto + if (! empty($this->withreplyto)) + { + if ($this->withreplytoreadonly) + { + $out.= ''; + $out.= ''; + $out.= "\n"; + } + } + + // Errorsto + if (! empty($this->witherrorsto)) + { + //if (! $this->errorstomail) $this->errorstomail=$this->frommail; + $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); + if ($this->witherrorstoreadonly) + { + $out.= ''; + $out.= '\n"; + } + else + { + $out.= '\n"; + } + } + + // To + if (! empty($this->withto) || is_array($this->withto)) + { + $out.= '\n"; + } + + // CC + if (! empty($this->withtocc) || is_array($this->withtocc)) + { + $out.= '\n"; + } + + // CCC + if (! empty($this->withtoccc) || is_array($this->withtoccc)) + { + $out.= '\n"; + } + + // Ask delivery receipt + if (! empty($this->withdeliveryreceipt)) + { + $out.= '\n"; + } + + // Topic + if (! empty($this->withtopic)) + { + $this->withtopic=make_substitutions($this->withtopic,$this->substit); + + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + // Attached files + if (! empty($this->withfile)) + { + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + // Message + if (! empty($this->withbody)) + { + $defaultmessage=""; + + // TODO A partir du type, proposer liste de messages dans table llx_models + if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } + elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } + elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } + elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } + elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } + + // Complete substitution array + if (! empty($conf->paypal->enabled) && ! empty($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=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + if ($this->param["models"]=='facture_send') + { + $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + } + + $defaultmessage=make_substitutions($defaultmessage,$this->substit); + if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; + $defaultmessage=str_replace('\n',"\n",$defaultmessage); + + $out.= ''; + $out.= ''; + $out.= '\n"; + } + + if (! empty($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.= "
'.$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("MailErrorsTo").''; + $out.= $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 (! empty($this->withtofree)) + { + $out.= 'withto) :"").'" />'; + } + if (! empty($this->withto) && is_array($this->withto)) + { + if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); + } + if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + if ($this->withtofree) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); + } + } + $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 (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); + } + if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtoccsocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); + } + } + $out.= "
'; + $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if (! empty($this->withtocccreadonly)) + { + $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; + } + else + { + $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); + } + if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); + } + } + //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); + $out.= "
'.$langs->trans("DeliveryReceipt").''; + + if (! empty($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("MailFile").''; + // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript + $out.= ''."\n"; + $out.= ''."\n"; + if (count($listofpaths)) + { + foreach($listofpaths as $key => $val) + { + $out.= '
'; + $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; + if (! $this->withfilereadonly) + { + $out.= ' '; + //$out.= ' '.img_delete($langs->trans("Delete").''; + } + $out.= '
'; + } + } + else + { + $out.= $langs->trans("NoAttachedFiles").'
'; + } + if ($this->withfile == 2) // Can add other files + { + $out.= ''; + $out.= ' '; + $out.= ''; + } + $out.= "
'.$langs->trans("MailText").''; + if ($this->withbodyreadonly) + { + $out.= nl2br($defaultmessage); + $out.= ''; + } + else + { + if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; + + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$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 (! empty($this->withform)) $out.= '
'."\n"; + $out.= "\n"; + + return $out; } - - // From - if (! empty($this->withfrom)) - { - if (! empty($this->withfromreadonly)) - { - $out.= ''; - $out.= ''; - $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.= "\n"; - $out.= "\n"; - } - else - { - $out.= "".$langs->trans("MailFrom").""; - $out.= $langs->trans("Name").':'; - $out.= '    '; - $out.= $langs->trans("EMail").':<>'; - $out.= "\n"; - } - } - - // Replyto - if (! empty($this->withreplyto)) - { - if ($this->withreplytoreadonly) - { - $out.= ''; - $out.= ''; - $out.= "".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); - $out.= "\n"; - } - } - - // Errorsto - if (! empty($this->witherrorsto)) - { - //if (! $this->errorstomail) $this->errorstomail=$this->frommail; - $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); - if ($this->witherrorstoreadonly) - { - $out.= ''; - $out.= ''.$langs->trans("MailErrorsTo").''; - $out.= $errorstomail; - $out.= "\n"; - } - else - { - $out.= ''.$langs->trans("MailErrorsTo").''; - $out.= ''; - $out.= "\n"; - } - } - - // To - if (! empty($this->withto) || is_array($this->withto)) - { - $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 (! empty($this->withtofree)) - { - $out.= 'withto) :"").'" />'; - } - if (! empty($this->withto) && is_array($this->withto)) - { - if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); - } - if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - if ($this->withtofree) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); - } - } - $out.= "\n"; - } - - // CC - if (! empty($this->withtocc) || is_array($this->withtocc)) - { - $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 (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); - } - if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtoccsocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); - } - } - $out.= "\n"; - } - - // CCC - if (! empty($this->withtoccc) || is_array($this->withtoccc)) - { - $out.= ''; - $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if (! empty($this->withtocccreadonly)) - { - $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; - } - else - { - $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); - } - if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); - } - } - //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); - $out.= "\n"; - } - - // Ask delivery receipt - if (! empty($this->withdeliveryreceipt)) - { - $out.= ''.$langs->trans("DeliveryReceipt").''; - - if (! empty($this->withdeliveryreceiptreadonly)) - { - $out.= yn($this->withdeliveryreceipt); - } - else - { - $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); - } - - $out.= "\n"; - } - - // Topic - if (! empty($this->withtopic)) - { - $this->withtopic=make_substitutions($this->withtopic,$this->substit); - - $out.= ''; - $out.= ''.$langs->trans("MailTopic").''; - $out.= ''; - if ($this->withtopicreadonly) - { - $out.= $this->withtopic; - $out.= ''; - } - else - { - $out.= 'withtopic) .'" />'; - } - $out.= "\n"; - } - - // Attached files - if (! empty($this->withfile)) - { - $out.= ''; - $out.= ''.$langs->trans("MailFile").''; - $out.= ''; - // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out.= ''."\n"; - $out.= ''."\n"; - if (count($listofpaths)) - { - foreach($listofpaths as $key => $val) - { - $out.= '
'; - $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; - if (! $this->withfilereadonly) - { - $out.= ' '; - //$out.= ' '.img_delete($langs->trans("Delete").''; - } - $out.= '
'; - } - } - else - { - $out.= $langs->trans("NoAttachedFiles").'
'; - } - if ($this->withfile == 2) // Can add other files - { - $out.= ''; - $out.= ' '; - $out.= ''; - } - $out.= "\n"; - } - - // Message - if (! empty($this->withbody)) - { - $defaultmessage=""; - - // TODO A partir du type, proposer liste de messages dans table llx_models - if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } - elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } - elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } - elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } - elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } - elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } - - // Complete substitution array - if (! empty($conf->paypal->enabled) && ! empty($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=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - if ($this->param["models"]=='facture_send') - { - $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$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 (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); - $out.= $doleditor->Create(1); - } - $out.= "\n"; - } - - if (! empty($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 (! empty($this->withform)) $out.= ''."\n"; - $out.= "\n"; - - return $out; } } From 7facbf7aa275694cd52b12ccc2eb5df8a1f65e55 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 24 Jan 2013 17:54:51 +0100 Subject: [PATCH 03/32] Multicompany restriction for transverse mode not used anymore. RestrictedArea is enough --- htdocs/user/fiche.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index bc0caf8d469..222ab62b846 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -67,12 +67,6 @@ if ($id) || (($user->id != $id) && $user->rights->user->user->password)); } -//Multicompany in mode transversal -if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode) -{ - accessforbidden(); -} - // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; From 70b21172f9090635b953fb17cccfc426b2fe9a71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Jan 2013 11:05:44 +0100 Subject: [PATCH 04/32] Qual: Removed not used and deprecated property --- htdocs/core/menus/smartphone/smartphone_backoffice.php | 2 -- htdocs/core/menus/smartphone/smartphone_frontoffice.php | 1 - htdocs/core/menus/standard/auguria_backoffice.php | 1 - htdocs/core/menus/standard/auguria_frontoffice.php | 1 - htdocs/core/menus/standard/eldy_backoffice.php | 1 - htdocs/core/menus/standard/eldy_frontoffice.php | 1 - htdocs/core/menus/standard/empty.php | 1 - 7 files changed, 8 deletions(-) diff --git a/htdocs/core/menus/smartphone/smartphone_backoffice.php b/htdocs/core/menus/smartphone/smartphone_backoffice.php index a909cce6826..e0144c6913f 100755 --- a/htdocs/core/menus/smartphone/smartphone_backoffice.php +++ b/htdocs/core/menus/smartphone/smartphone_backoffice.php @@ -28,8 +28,6 @@ class MenuSmart { var $db; - var $require_left=array("smartphone_backoffice"); // Si doit etre en phase avec un gestionnaire de menu particulier - var $hideifnotallowed=0; // Put 0 for back office menu, 1 for front office menu var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/smartphone/smartphone_frontoffice.php b/htdocs/core/menus/smartphone/smartphone_frontoffice.php index 4c17eca4447..9120537fa5b 100755 --- a/htdocs/core/menus/smartphone/smartphone_frontoffice.php +++ b/htdocs/core/menus/smartphone/smartphone_frontoffice.php @@ -28,7 +28,6 @@ class MenuSmart { - var $require_left=array("smartphone_frontoffice"); // Si doit etre en phase avec un gestionnaire de menu particulier var $hideifnotallowed=1; // Put 0 for back office menu, 1 for front office menu var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/standard/auguria_backoffice.php b/htdocs/core/menus/standard/auguria_backoffice.php index 3c05a0f6170..a22c40ed315 100644 --- a/htdocs/core/menus/standard/auguria_backoffice.php +++ b/htdocs/core/menus/standard/auguria_backoffice.php @@ -34,7 +34,6 @@ class MenuManager { var $db; - var $require_left=array("auguria_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier var $type_user=0; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/standard/auguria_frontoffice.php b/htdocs/core/menus/standard/auguria_frontoffice.php index 151abfbe9cc..cb8299feee3 100644 --- a/htdocs/core/menus/standard/auguria_frontoffice.php +++ b/htdocs/core/menus/standard/auguria_frontoffice.php @@ -34,7 +34,6 @@ class MenuManager { var $db; - var $require_left=array("auguria_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier var $type_user=1; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/standard/eldy_backoffice.php b/htdocs/core/menus/standard/eldy_backoffice.php index ab00caccb3a..638fd45664d 100644 --- a/htdocs/core/menus/standard/eldy_backoffice.php +++ b/htdocs/core/menus/standard/eldy_backoffice.php @@ -33,7 +33,6 @@ class MenuManager { var $db; - var $require_left=array("eldy_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier var $type_user=0; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/standard/eldy_frontoffice.php b/htdocs/core/menus/standard/eldy_frontoffice.php index 5ec673afe68..2221e0ec9f0 100644 --- a/htdocs/core/menus/standard/eldy_frontoffice.php +++ b/htdocs/core/menus/standard/eldy_frontoffice.php @@ -33,7 +33,6 @@ class MenuManager { var $db; - var $require_left=array("eldy_frontoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier var $type_user=1; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index da3eab44025..705dc2cf293 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -26,7 +26,6 @@ class MenuManager { var $db; - var $require_left=array("empty"); // If this top menu handler must be used with a particular left menu handler var $type_user=0; // Put 0 for internal users, 1 for external users var $atarget=""; // To store arget to use in menu links From e3be718a571627add1c1c6153d10a78cd4d87625 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 25 Jan 2013 12:37:03 +0100 Subject: [PATCH 05/32] Fix: wrong object name --- htdocs/fourn/facture/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 99e1bf5da0a..936fbd08572 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -2078,7 +2078,7 @@ else $formmail->frommail = $user->email; $formmail->withfrom=1; $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"]; - $formmail->withtosocid=$soc->id; + $formmail->withtosocid=$societe->id; $formmail->withtocc=1; $formmail->withtoccsocid=0; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; From 2aa548560b7c9b1390c206801cc883dcdf7a30a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Jan 2013 16:52:23 +0100 Subject: [PATCH 06/32] doc: Update exemples --- dev/skeletons/modMyModule.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 4d7bf0df4ae..355964273f2 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -106,7 +106,7 @@ class modMyModule extends DolibarrModules // Constants // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), - // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) // ); $this->const = array(); From c2d334624b1b8bb26d7ef0a49b10292a9e9f3f46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Jan 2013 17:44:23 +0100 Subject: [PATCH 07/32] Qual: Simplify system for menu manager. Only one file, one class per manager. --- ChangeLog | 5 +- htdocs/admin/menus.php | 4 - htdocs/core/class/html.formadmin.class.php | 8 +- .../smartphone/smartphone_backoffice.php | 60 --------------- ...ne_frontoffice.php => smartphone_menu.php} | 38 ++++++---- .../menus/standard/auguria_backoffice.php | 74 ------------------- ...guria_frontoffice.php => auguria_menu.php} | 35 ++++----- .../core/menus/standard/eldy_frontoffice.php | 33 +++++---- .../{eldy_backoffice.php => eldy_menu.php} | 38 ++++++---- .../install/mysql/migration/3.3.0-3.4.0.sql | 8 ++ htdocs/langs/en_US/main.lang | 1 + htdocs/langs/fr_FR/main.lang | 1 + htdocs/main.inc.php | 19 +++-- 13 files changed, 111 insertions(+), 213 deletions(-) delete mode 100755 htdocs/core/menus/smartphone/smartphone_backoffice.php rename htdocs/core/menus/smartphone/{smartphone_frontoffice.php => smartphone_menu.php} (57%) delete mode 100644 htdocs/core/menus/standard/auguria_backoffice.php rename htdocs/core/menus/standard/{auguria_frontoffice.php => auguria_menu.php} (63%) rename htdocs/core/menus/standard/{eldy_backoffice.php => eldy_menu.php} (63%) diff --git a/ChangeLog b/ChangeLog index 46f482aeab9..8775d808037 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,9 +4,12 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.4 compared to 3.3 ***** For users: -- New: Some performance enhancements +- New: Some performance enhancements. +- New: Can attach files onto trip and expenses modules. For developers: +- System of menu managers has been rewritten to reduce code to do same things. +- An external module can force its theme. For translators: diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 23eade151a1..e40af9b75dc 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -77,10 +77,6 @@ if ($action == 'update' && empty($_POST["cancel"])) // Define list of menu handlers to initialize $listofmenuhandler=array(); - $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_STANDARD"])]=1; - $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_STANDARD"])]=1; - if (isset($_POST["MAIN_MENU_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_SMARTPHONE"])]=1; - if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1; // Initialize menu handlers foreach ($listofmenuhandler as $key => $val) diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index c60f1a81504..ccd3e038f74 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -121,7 +121,7 @@ class FormAdmin global $langs,$conf; // Clean parameters - if ($selected == 'eldy.php') $selected='eldy_backoffice.php'; // For compatibility + // Check parameters if (! is_array($dirmenuarray)) return -1; @@ -143,7 +143,11 @@ class FormAdmin if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index') { if (preg_match('/lib\.php$/i',$file)) continue; // We exclude library files - $filelib=preg_replace('/\.php$/i','',$file); + if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files + if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files + if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files + + $filelib=preg_replace('/\.php$/i','',$file); $prefix=''; // 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other if (preg_match('/^eldy/i',$file)) $prefix='0'; diff --git a/htdocs/core/menus/smartphone/smartphone_backoffice.php b/htdocs/core/menus/smartphone/smartphone_backoffice.php deleted file mode 100755 index e0144c6913f..00000000000 --- a/htdocs/core/menus/smartphone/smartphone_backoffice.php +++ /dev/null @@ -1,60 +0,0 @@ - - * Copyright (C) 2007-2010 Regis Houssin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/core/menus/smartphone/smartphone_backoffice.php - * \brief Gestionnaire nomme smartphone du menu smartphone - */ - - -/** - * Class to manage smartphone menu smartphone (for internal users) - */ -class MenuSmart -{ - var $db; - var $atarget=""; // Valeur du target a utiliser dans les liens - - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - - /** - * Show menu - * - * @param string $limitmenuto To limit menu to a top or left menu value - * @return void - */ - function showmenu($limitmenuto) - { - require_once DOL_DOCUMENT_ROOT.'/core/menus/smartphone/smartphone.lib.php'; - - print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$limitmenuto); - } - -} - -?> \ No newline at end of file diff --git a/htdocs/core/menus/smartphone/smartphone_frontoffice.php b/htdocs/core/menus/smartphone/smartphone_menu.php similarity index 57% rename from htdocs/core/menus/smartphone/smartphone_frontoffice.php rename to htdocs/core/menus/smartphone/smartphone_menu.php index 9120537fa5b..e95bdc1df09 100755 --- a/htdocs/core/menus/smartphone/smartphone_frontoffice.php +++ b/htdocs/core/menus/smartphone/smartphone_menu.php @@ -17,45 +17,57 @@ */ /** - * \file htdocs/core/menus/smartphone/smartphone_frontoffice.php - * \brief Gestionnaire nomme smartphone du menu smartphone + * \file htdocs/core/menus/smartphone/smartphone_menu.php + * \brief Menu smartphone manager */ /** - * Class to manage smartphone menu smartphone (for external users) + * Class to manage smartphone menu smartphone */ class MenuSmart { var $hideifnotallowed=1; // Put 0 for back office menu, 1 for front office menu var $atarget=""; // Valeur du target a utiliser dans les liens - + var $name="smartphone"; + /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler + * @param int $type_user Type of user */ - function __construct($db) + function __construct($db, $type_user) { $this->db=$db; } /** - * Show menu + * Show menu * - * @param string $limitmenuto To limit menu to a top or left menu value - * @return void + * @param string $mode 'top' or 'left' + * @return int Number of menu entries shown */ - function showmenu($limitmenuto) + function showmenu($mode) { - require_once DOL_DOCUMENT_ROOT.'/core/menus/smartphone/smartphone.lib.php'; + global $conf; + + require_once DOL_DOCUMENT_ROOT.'/core/menus/smartphone/smartphone.lib.php'; - print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$limitmenuto); + if ($this->type_user == 1) + { + $conf->global->MAIN_SEARCHFORM_SOCIETE=0; + $conf->global->MAIN_SEARCHFORM_CONTACT=0; + } + + print_smartphone_menu($this->db,$this->atarget,$this->hideifnotallowed,$mode); + + return 1; } } -?> +?> \ No newline at end of file diff --git a/htdocs/core/menus/standard/auguria_backoffice.php b/htdocs/core/menus/standard/auguria_backoffice.php deleted file mode 100644 index a22c40ed315..00000000000 --- a/htdocs/core/menus/standard/auguria_backoffice.php +++ /dev/null @@ -1,74 +0,0 @@ - - * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2008-2013 Laurent Destailleur - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/core/menus/standard/auguria_backoffice.php - * \brief Gestionnaire nomme Auguria du menu du haut - * - * \remarks La construction d'un gestionnaire pour le menu du haut est simple: - * \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut - * \remarks doivent etre affichees par ... - * \remarks ou si menu selectionne ... - */ - - -/** - * Classe permettant la gestion du menu du haut Auguria - */ -class MenuManager -{ - var $db; - var $type_user=0; // Put 0 for internal users, 1 for external users - var $atarget=""; // Valeur du target a utiliser dans les liens - - var $menu_array; - var $menu_array_after; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - - /** - * Show menu - * - * @param string $mode 'top' or 'left' - * @return int Number of menu entries shown - */ - function showmenu($mode) - { - require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; - - $res='ErrorBadParameterForMode'; - if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user); - if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after); - - return $res; - } - -} - -?> diff --git a/htdocs/core/menus/standard/auguria_frontoffice.php b/htdocs/core/menus/standard/auguria_menu.php similarity index 63% rename from htdocs/core/menus/standard/auguria_frontoffice.php rename to htdocs/core/menus/standard/auguria_menu.php index cb8299feee3..251a205290e 100644 --- a/htdocs/core/menus/standard/auguria_frontoffice.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -18,25 +18,21 @@ */ /** - * \file htdocs/core/menus/standard/auguria_frontoffice.php - * \brief Gestionnaire nomme Auguria du menu du haut - * - * \remarks La construction d'un gestionnaire pour le menu du haut est simple: - * \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut - * \remarks doivent etre affichees par ... - * \remarks ou si menu selectionne ... + * \file htdocs/core/menus/standard/auguria_menu.php + * \brief Menu auguria manager */ /** - * Classe permettant la gestion du menu du haut Auguria + * Class to manage menu Auguria */ class MenuManager { var $db; - var $type_user=1; // Put 0 for internal users, 1 for external users - var $atarget=""; // Valeur du target a utiliser dans les liens - + var $type_user; // Put 0 for internal users, 1 for external users + var $atarget=""; // Valeur du target a utiliser dans les liens + var $name="auguria"; + var $menu_array; var $menu_array_after; @@ -44,11 +40,13 @@ class MenuManager /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler + * @param int $type_user Type of user */ - function __construct($db) + function __construct($db, $type_user) { - $this->db=$db; + $this->type_user=$type_user; + $this->db=$db; } @@ -64,9 +62,12 @@ class MenuManager require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; - $conf->global->MAIN_SEARCHFORM_SOCIETE=0; - $conf->global->MAIN_SEARCHFORM_CONTACT=0; - + if ($this->type_user == 1) + { + $conf->global->MAIN_SEARCHFORM_SOCIETE=0; + $conf->global->MAIN_SEARCHFORM_CONTACT=0; + } + $res='ErrorBadParameterForMode'; if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user); if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after); diff --git a/htdocs/core/menus/standard/eldy_frontoffice.php b/htdocs/core/menus/standard/eldy_frontoffice.php index 2221e0ec9f0..2d6d11f28dc 100644 --- a/htdocs/core/menus/standard/eldy_frontoffice.php +++ b/htdocs/core/menus/standard/eldy_frontoffice.php @@ -17,25 +17,21 @@ */ /** - * \file htdocs/core/menus/standard/eldy_frontoffice.php - * \brief Gestionnaire nomme eldy du menu du haut - * - * \remarks La construction d'un gestionnaire pour le menu du haut est simple: - * \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut - * \remarks doivent etre affichees par ... - * \remarks ou si menu selectionne ... + * \file htdocs/core/menus/standard/eldy_menu.php + * \brief Menu eldy manager */ /** - * Class to manage menu Eldy (for external users) + * Class to manage menu Eldy */ class MenuManager { var $db; - var $type_user=1; // Put 0 for internal users, 1 for external users + var $type_user; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens - + var $name="eldy"; + var $menu_array; var $menu_array_after; @@ -43,10 +39,12 @@ class MenuManager /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler + * @param int $type_user Type of user */ - function __construct($db) + function __construct($db, $type_user) { + $this->type_user=$type_user; $this->db=$db; } @@ -54,8 +52,8 @@ class MenuManager /** * Show menu * - * @param string $mode 'top' or 'left' - * @return int Number of menu entries shown + * @param string $mode 'top' or 'left' + * @return int Number of menu entries shown */ function showmenu($mode) { @@ -63,8 +61,11 @@ class MenuManager require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; - $conf->global->MAIN_SEARCHFORM_SOCIETE=0; - $conf->global->MAIN_SEARCHFORM_CONTACT=0; + if ($this->type_user == 1) + { + $conf->global->MAIN_SEARCHFORM_SOCIETE=0; + $conf->global->MAIN_SEARCHFORM_CONTACT=0; + } $res='ErrorBadParameterForMode'; if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user); diff --git a/htdocs/core/menus/standard/eldy_backoffice.php b/htdocs/core/menus/standard/eldy_menu.php similarity index 63% rename from htdocs/core/menus/standard/eldy_backoffice.php rename to htdocs/core/menus/standard/eldy_menu.php index 638fd45664d..2d6d11f28dc 100644 --- a/htdocs/core/menus/standard/eldy_backoffice.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -1,6 +1,6 @@ - * Copyright (C) 2007-2010 Regis Houssin + * Copyright (C) 2007-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,25 +17,21 @@ */ /** - * \file htdocs/core/menus/standard/eldy_backoffice.php - * \brief Gestionnaire nomme eldy du menu du haut - * - * \remarks La construction d'un gestionnaire pour le menu du haut est simple: - * \remarks Toutes les entrees de menu a faire apparaitre dans la barre du haut - * \remarks doivent etre affichees par ... - * \remarks ou si menu selectionne ... + * \file htdocs/core/menus/standard/eldy_menu.php + * \brief Menu eldy manager */ /** - * Classe to manage menu Eldy + * Class to manage menu Eldy */ class MenuManager { var $db; - var $type_user=0; // Put 0 for internal users, 1 for external users + var $type_user; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens - + var $name="eldy"; + var $menu_array; var $menu_array_after; @@ -43,10 +39,12 @@ class MenuManager /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler + * @param int $type_user Type of user */ - function __construct($db) + function __construct($db, $type_user) { + $this->type_user=$type_user; $this->db=$db; } @@ -54,17 +52,25 @@ class MenuManager /** * Show menu * - * @param string $mode 'top' or 'left' - * @return int Number of menu entries shown + * @param string $mode 'top' or 'left' + * @return int Number of menu entries shown */ function showmenu($mode) { + global $conf; + require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; + if ($this->type_user == 1) + { + $conf->global->MAIN_SEARCHFORM_SOCIETE=0; + $conf->global->MAIN_SEARCHFORM_CONTACT=0; + } + $res='ErrorBadParameterForMode'; if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user); if ($mode == 'left') $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after); - + return $res; } diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index 4827eafb60b..fd779495e3e 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -23,3 +23,11 @@ create table llx_adherent_type_extrafields import_key varchar(14) -- import key ) ENGINE=innodb; ALTER TABLE llx_adherent_type_extrafields ADD INDEX idx_adherent_type_extrafields (fk_object); + +UPDATE llx_const set value='eldy_menu.php' where value='eldy_backoffice.php'; +UPDATE llx_const set value='eldy_menu.php' where value='eldy_frontoffice.php'; +UPDATE llx_const set value='auguria_menu.php' where value='auguria_backoffice.php'; +UPDATE llx_const set value='auguria_menu.php' where value='auguria_frontoffice.php'; +UPDATE llx_const set value='smartphone_menu.php' where value='smartphone_backoffice.php'; +UPDATE llx_const set value='smartphone_menu.php' where value='smartphone_frontoffice.php'; + diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c8430c95cac..bb10a493384 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -565,6 +565,7 @@ ThisLimitIsDefinedInSetup=Dolibarr limit (Menu home-setup-security): %s Kb, PHP NoFileFound=No documents saved in this directory CurrentUserLanguage=Current language CurrentTheme=Current theme +CurrentMenuManager=current men manager DisabledModules=Disabled modules For=For ForCustomer=For customer diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 80e4493ff84..52c7b339ffe 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -568,6 +568,7 @@ ThisLimitIsDefinedInSetup=Limite Dolibarr (Menu accueil-configuration-sécurité NoFileFound=Pas de documents stockés dans cette rubrique CurrentUserLanguage=Langue utilisateur actuelle CurrentTheme=Thème courant +CurrentMenuManager=Gestionnaire de menu courant DisabledModules=Modules désactivés For=Pour ForCustomer=Pour le client diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d464083167b..58f1ac48d02 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -778,21 +778,18 @@ if (! empty($conf->multicompany->enabled) && GETPOST('action') == 'switchentity' // Init menu manager if (empty($user->societe_id)) // If internal user or not defined { - $conf->standard_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED); - $conf->smart_menu=(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED); + $conf->standard_menu=(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?(empty($conf->global->MAIN_MENU_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENU_STANDARD):$conf->global->MAIN_MENU_STANDARD_FORCED); + $conf->smart_menu=(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?(empty($conf->global->MAIN_MENU_SMARTPHONE)?'smartphone_menu.php':$conf->global->MAIN_MENU_SMARTPHONE):$conf->global->MAIN_MENU_SMARTPHONE_FORCED); } else // If external user { - $conf->standard_menu=(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED); - $conf->smart_menu=(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED); + $conf->standard_menu=(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?(empty($conf->global->MAIN_MENUFRONT_STANDARD)?'eldy_menu.php':$conf->global->MAIN_MENUFRONT_STANDARD):$conf->global->MAIN_MENUFRONT_STANDARD_FORCED); + $conf->smart_menu=(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE)?'smartphone_menu.php':$conf->global->MAIN_MENUFRONT_SMARTPHONE):$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED); } -// For backward compatibility -if (empty($conf->standard_menu)) $conf->standard_menu ='eldy_backoffice.php'; -elseif ($conf->standard_menu == 'eldy.php') $conf->standard_menu='eldy_backoffice.php'; // Load the menu manager (only if not already done) $file_menu=empty($conf->browser->phone)?$conf->standard_menu:$conf->smart_menu; -if (GETPOST('menu')) $file_menu=GETPOST('menu'); // menu=eldy_backoffice.php +if (GETPOST('menu')) $file_menu=GETPOST('menu'); // example: menu=eldy_menu.php if (! class_exists('MenuManager')) { $menufound=0; @@ -804,11 +801,12 @@ if (! class_exists('MenuManager')) } if (! $menufound) // If failed to include, we try with standard { - $file_menu='eldy_backoffice.php'; + dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING); + $file_menu='eldy_menu.php'; include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu; } } -$menumanager = new MenuManager($db); +$menumanager = new MenuManager($db, empty($user->societe_id)?0:1); @@ -1337,6 +1335,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $loginhtmltext.='
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin,"dayhour"); $loginhtmltext.='
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"]; $loginhtmltext.='
'.$langs->trans("CurrentTheme").': '.$conf->theme; + $loginhtmltext.='
'.$langs->trans("CurrentMenuManager").': '.$menumanager->name; $s=picto_from_langcode($langs->getDefaultLang()); $loginhtmltext.='
'.$langs->trans("CurrentUserLanguage").': '.($s?$s.' ':'').$langs->getDefaultLang(); $loginhtmltext.='
'.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version?' '.$conf->browser->version:'').' ('.$_SERVER['HTTP_USER_AGENT'].')'; From 56e11e52faeb70c42c2ff42aae0ef00a7416abda Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Jan 2013 19:12:54 +0100 Subject: [PATCH 08/32] New: hookmanager class is used frequently and is a factory object, so we can move it during init of environment and use it globally. --- htdocs/adherents/class/adherent.class.php | 4 +-- .../adherents/class/adherent_type.class.php | 4 +-- htdocs/adherents/fiche.php | 2 -- htdocs/adherents/type.php | 2 -- htdocs/admin/dict.php | 2 -- htdocs/categories/categorie.php | 2 -- htdocs/comm/action/class/actioncomm.class.php | 10 +++---- htdocs/comm/action/fiche.php | 2 -- htdocs/comm/addpropal.php | 2 -- htdocs/comm/list.php | 2 -- htdocs/comm/mailing/fiche.php | 2 -- htdocs/comm/propal.php | 2 -- htdocs/comm/propal/list.php | 2 -- htdocs/comm/prospect/list.php | 2 -- htdocs/commande/class/commande.class.php | 8 +----- htdocs/commande/fiche.php | 2 -- htdocs/compta/deplacement/fiche.php | 2 -- htdocs/compta/dons/fiche.php | 2 -- htdocs/compta/facture.php | 2 -- htdocs/compta/facture/class/facture.class.php | 4 +-- htdocs/compta/facture/list.php | 2 -- htdocs/compta/tva/fiche.php | 2 -- htdocs/contact/class/contact.class.php | 4 +-- htdocs/contact/fiche.php | 2 -- htdocs/contrat/fiche.php | 2 -- htdocs/core/class/commonobject.class.php | 8 ++---- htdocs/core/class/html.formfile.class.php | 12 ++------- htdocs/core/class/html.formmail.class.php | 11 +------- htdocs/core/lib/files.lib.php | 27 ++----------------- htdocs/core/lib/security2.lib.php | 5 ---- htdocs/expedition/fiche.php | 2 -- htdocs/fichinter/fiche.php | 2 -- htdocs/fourn/commande/fiche.php | 2 -- htdocs/fourn/facture/fiche.php | 2 -- htdocs/fourn/liste.php | 2 -- htdocs/index.php | 2 -- htdocs/main.inc.php | 14 +--------- htdocs/master.inc.php | 10 ++++--- htdocs/product/class/product.class.php | 4 +-- htdocs/product/fiche.php | 2 -- htdocs/product/fournisseurs.php | 2 -- htdocs/projet/fiche.php | 2 -- htdocs/projet/tasks.php | 2 -- htdocs/projet/tasks/task.php | 2 -- htdocs/public/demo/index.php | 2 -- htdocs/societe/agenda.php | 2 -- htdocs/societe/class/societe.class.php | 6 +---- htdocs/societe/info.php | 2 -- htdocs/societe/soc.php | 2 -- htdocs/user/class/user.class.php | 4 +-- htdocs/user/fiche.php | 2 -- htdocs/user/passwordforgotten.php | 5 ---- 52 files changed, 27 insertions(+), 183 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 61edd3bee05..0eea1c6f5d7 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -394,7 +394,7 @@ class Adherent extends CommonObject */ function update($user,$notrigger=0,$nosyncuser=0,$nosyncuserpass=0,$nosyncthirdparty=0,$action='update') { - global $conf, $langs; + global $conf, $langs, $hookmanager; $nbrowsaffected=0; $error=0; @@ -462,8 +462,6 @@ class Adherent extends CommonObject $nbrowsaffected+=$this->db->affected_rows($resql); // Actions on extra fields (by external module) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('memberdao')); $parameters=array('id'=>$this->id); $action=''; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index ead494783aa..d829c5a84f9 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -98,6 +98,8 @@ class AdherentType extends CommonObject */ function update($user) { + global $hookmanager; + $this->libelle=trim($this->libelle); $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type "; @@ -114,8 +116,6 @@ class AdherentType extends CommonObject if ($result) { // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('membertypedao')); $parameters=array('membertype'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 02e0af3a768..f84990b94e5 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -107,8 +107,6 @@ if ($rowid) } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('membercard')); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 592695130b3..369f925bc7e 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -67,8 +67,6 @@ if (GETPOST('button_removefilter')) // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('membertypecard')); /* diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 56f4f6140bb..b5c49355672 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -64,8 +64,6 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('admin')); // This page is a generic page to edit dictionnaries diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index fb4ba30a269..d3a06304e46 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -86,8 +86,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('categorycard')); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 5e7a77c6ca2..43278dbaaa2 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -106,8 +106,8 @@ class ActionComm extends CommonObject */ function add($user,$notrigger=0) { - global $langs,$conf; - + global $langs,$conf,$hookmanager; + $error=0; $now=dol_now(); @@ -210,8 +210,6 @@ class ActionComm extends CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm","id"); // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('actioncommdao')); $parameters=array('actcomm'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -430,7 +428,7 @@ class ActionComm extends CommonObject */ function update($user,$notrigger=0) { - global $langs,$conf; + global $langs,$conf,$hookmanager; $error=0; @@ -482,8 +480,6 @@ class ActionComm extends CommonObject { // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('actioncommdao')); $parameters=array('actcomm'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 60233a20650..782d7444429 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -66,8 +66,6 @@ $extrafields = new ExtraFields($db); //var_dump($_POST); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('actioncard')); diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index b2d5285d849..8c5a07df0c3 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -46,8 +46,6 @@ $origin=GETPOST('origin','alpha'); $originid=GETPOST('originid','int'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('propalcard')); /* diff --git a/htdocs/comm/list.php b/htdocs/comm/list.php index 496b9217059..fd7ea79f345 100755 --- a/htdocs/comm/list.php +++ b/htdocs/comm/list.php @@ -58,8 +58,6 @@ $search_categ = GETPOST("search_categ",'int'); $catid = GETPOST("catid",'int'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('customerlist')); diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 680790ff04e..310a48eb935 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -47,8 +47,6 @@ $result=$object->fetch($id); $extrafields = new ExtraFields($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('mailingcard')); // Tableau des substitutions possibles diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index f1850014a48..08a03ff8866 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -99,8 +99,6 @@ else } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('propalcard')); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 95e549c0b1d..b2f1f8dcc44 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -77,8 +77,6 @@ $result = restrictedArea($user, $module, $objectid, $dbtable); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('propalcard')); diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index a093f73c57b..69aaab9e68e 100755 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -148,8 +148,6 @@ $sts = array(-1,0,1,2,3); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('prospectlist')); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 481b51400a5..28d56fcf3a2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -880,8 +880,7 @@ class Commande extends CommonOrder */ function createFromProposal($object) { - global $conf,$user,$langs; - global $hookmanager; + global $conf,$user,$langs,$hookmanager; $error=0; @@ -945,11 +944,6 @@ class Commande extends CommonOrder if ($ret > 0) { // Actions hooked (by external module) - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('orderdao')); $parameters=array('objFrom'=>$object); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index e3fd1029326..b6e7b821495 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -84,8 +84,6 @@ if ($id > 0 || ! empty($ref)) } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('ordercard')); diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index d13880f7559..1e20d91c350 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -49,8 +49,6 @@ $mesg = ''; $object = new Deplacement($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('tripsandexpensescard')); diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php index 51550f41ebd..6ba13a19631 100644 --- a/htdocs/compta/dons/fiche.php +++ b/htdocs/compta/dons/fiche.php @@ -50,8 +50,6 @@ $donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOS $result = restrictedArea($user, 'don', $id); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('doncard')); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 34b501f73c9..f15762b97bf 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -95,8 +95,6 @@ if ($id > 0 || ! empty($ref)) } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('invoicecard')); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index cf7b89be7aa..1637524cfce 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -637,7 +637,7 @@ class Facture extends CommonInvoice */ function createFromOrder($object) { - global $conf,$user,$langs; + global $conf,$user,$langs,$hookmanager; $error=0; @@ -701,8 +701,6 @@ class Facture extends CommonInvoice if ($ret > 0) { // Actions hooked (by external module) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('invoicedao')); $parameters=array('objFrom'=>$object); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 12d653e5b26..796bf769698 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -97,8 +97,6 @@ $usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MA $object=new Facture($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('invoicecard')); $now=dol_now(); diff --git a/htdocs/compta/tva/fiche.php b/htdocs/compta/tva/fiche.php index 45dc91263ad..c8139c5575f 100644 --- a/htdocs/compta/tva/fiche.php +++ b/htdocs/compta/tva/fiche.php @@ -41,8 +41,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('taxvatcard')); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index c1eb6426c7b..14c8630e1e5 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -210,7 +210,7 @@ class Contact extends CommonObject */ function update($id, $user=0, $notrigger=0, $action='update') { - global $conf, $langs; + global $conf, $langs, $hookmanager; $error=0; @@ -266,8 +266,6 @@ class Contact extends CommonObject unset($this->state); // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('contactdao')); $parameters=array('socid'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 0233c367b07..9097584bfb5 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -65,8 +65,6 @@ if (! empty($canvas)) $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', '', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('contactcard')); diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 50c30e4be2b..d3a7f48c24b 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -59,8 +59,6 @@ $result=restrictedArea($user,'contrat',$id); $usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:0); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('contractcard')); $object = new Contrat($db); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8b6002c29c5..344507971bb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2468,16 +2468,12 @@ abstract class CommonObject */ function showLinkedObjectBlock($hookmanager=false) { - global $conf,$langs,$bc; + global $conf,$langs,$hookmanager; + global $bc; $this->fetchObjectLinked(); // Bypass the default method - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('commonobject')); $parameters=array(); $reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 8e43669b2e8..83818285265 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -590,18 +590,10 @@ class FormFile */ function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='') { - global $user, $conf, $langs; - global $bc, $hookmanager; + global $user, $conf, $langs, $hookmanager; + global $bc; global $sortfield, $sortorder, $maxheightmini; - if (! is_object($hookmanager)) - { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } - } $hookmanager->initHooks(array('formfile')); $parameters=array( diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index c221cc33c07..f499bcb6b68 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -216,20 +216,11 @@ class FormMail */ function get_form($addfileaction='addfile',$removefileaction='removefile') { - global $conf, $langs, $user; - global $hookmanager; + global $conf, $langs, $user, $hookmanager; $langs->load("other"); $langs->load("mails"); - if (! is_object($hookmanager)) - { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } - } $hookmanager->initHooks(array('formmail')); $parameters=array( diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index c257b00e56d..b480184808f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -65,15 +65,8 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil $path=preg_replace('/([\\/]+)$/i','',$path); $newpath=dol_osencode($path); - if (! $nohook) { - if (! is_object($hookmanager)) - { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); - } - } + if (! $nohook) + { $hookmanager->initHooks(array('fileslib')); $parameters=array( @@ -653,14 +646,6 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable return -2; } - if (! is_object($hookmanager)) - { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - } - $hookmanager=new HookManager($db); - } $hookmanager->initHooks(array('fileslib')); $parameters=array('filename' => $file_name, 'varfiles' => $varfiles, 'allowoverwrite' => $allowoverwrite); @@ -722,14 +707,6 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n if (empty($nohook)) { - if (! is_object($hookmanager)) - { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); - } - } $hookmanager->initHooks(array('fileslib')); $parameters=array( diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index b7196ba228f..6aa41576c01 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -131,11 +131,6 @@ function dol_loginfunction($langs,$conf,$mysoc) global $smartphone,$hookmanager; // Instantiate hooks of thirdparty module only if not already define - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); - } $hookmanager->initHooks(array('mainloginpage')); $langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang')); diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 7e9a24be0f9..1d34aea5d0c 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -59,8 +59,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user, $origin, $origin_id); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('expeditioncard')); $action = GETPOST('action','alpha'); diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 755b68b5af1..86230754ef3 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -60,8 +60,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('interventioncard')); $object = new Fichinter($db); diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index bbe46c9a21a..ed5c7483c64 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -70,8 +70,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'commande_fournisseur', $id,''); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('ordersuppliercard')); $object = new CommandeFournisseur($db); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 241c17b7cef..abec49e0e89 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -61,8 +61,6 @@ if (! empty($user->societe_id)) $socid=$user->societe_id; $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('invoicesuppliercard')); $object=new FactureFournisseur($db); diff --git a/htdocs/fourn/liste.php b/htdocs/fourn/liste.php index 3c50b16cb4f..13361f10eb2 100644 --- a/htdocs/fourn/liste.php +++ b/htdocs/fourn/liste.php @@ -57,8 +57,6 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="nom"; // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('supplierlist')); /* diff --git a/htdocs/index.php b/htdocs/index.php index ba3cbf1b05f..8119e3a83be 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -34,8 +34,6 @@ $_GET['mainmenu']=GETPOST('mainmenu', 'alpha')?GETPOST('mainmenu', 'alpha'):'hom $action=GETPOST('action'); -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('index')); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 58f1ac48d02..ec82c9e7e41 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -603,8 +603,6 @@ if (! defined('NOLOGIN')) // Hooks on successfull login $action=''; - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); $hookmanager->initHooks(array('login')); $parameters=array('dol_authmode'=>$dol_authmode); $reshook=$hookmanager->executeHooks('afterLogin',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks @@ -1194,12 +1192,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a global $dolibarr_main_authentication; global $hookmanager,$menumanager; - // Instantiate hooks of thirdparty module only if not already define - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); - } + // Instantiate hooks of thirdparty module $hookmanager->initHooks(array('toprightmenu')); $toprightmenu=''; @@ -1426,11 +1419,6 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me $bookmarks=''; // Instantiate hooks of thirdparty module - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); - } $hookmanager->initHooks(array('searchform','leftblock')); if (empty($_SESSION['dol_hide_leftmenu'])) diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 6d6ce8680b8..b023f7110b0 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -186,9 +186,7 @@ if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) } } -/* - * Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr. - */ +// Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr. if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC')) { require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; @@ -207,6 +205,12 @@ if (! defined('NOREQUIRETRAN')) $langs->setDefaultLang((! empty($conf->global->MAIN_LANG_DEFAULT)?$conf->global->MAIN_LANG_DEFAULT:'')); } + +// Create the global $hookmanager object +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager=new HookManager($db); + + if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR'); // We force feature to help debug diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a9c0439b220..8f91e30b257 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -418,7 +418,7 @@ class Product extends CommonObject */ function update($id, $user, $notrigger=false, $action='update') { - global $langs, $conf; + global $langs, $conf, $hookmanager; $error=0; @@ -500,8 +500,6 @@ class Product extends CommonObject } // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('productdao')); $parameters=array('id'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 74aa705eeab..1ccc7e2c8b3 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -78,8 +78,6 @@ $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype,$objcanvas); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('productcard')); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index b8b30184af9..43929c96b0c 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -59,8 +59,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service&fournisseur',$fieldvalue,'product&product','','',$fieldtype); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('pricesuppliercard')); diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index f5870301860..fc518e29d27 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -50,8 +50,6 @@ if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $id); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('projectcard')); $object = new Project($db); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 934bf9b238e..55055d0f467 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -55,8 +55,6 @@ if ($user->societe_id > 0) $socid = $user->societe_id; $result = restrictedArea($user, 'projet', $id); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('projecttaskcard')); $progress=GETPOST('progress', 'int'); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index def739e31f1..94034e9b541 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -42,8 +42,6 @@ if ($user->societe_id > 0) $socid = $user->societe_id; if (! $user->rights->projet->lire) accessforbidden(); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('projecttaskcard')); $object = new Task($db); diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index b8a240b44b6..40c499d5469 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -38,8 +38,6 @@ global $dolibarr_main_demo; if (empty($dolibarr_main_demo)) accessforbidden('Parameter dolibarr_main_demo must be defined in conf file with value "default login,default pass" to enable the demo entry page',1,1,1); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('demo')); $demoprofiles=array( diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 9e373a97158..bc9b11b3149 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -38,8 +38,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe', $socid, '&societe'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('agendathirdparty')); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 6ea29526c00..95c16965fb5 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -380,7 +380,7 @@ class Societe extends CommonObject */ function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1) { - global $langs,$conf; + global $langs,$conf,$hookmanager; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $error=0; @@ -612,8 +612,6 @@ class Societe extends CommonObject $this->AddFournisseurInCategory($this->fournisseur_categorie); // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('thirdpartydao')); $parameters=array('socid'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -1064,8 +1062,6 @@ class Societe extends CommonObject if (! $error) { // Additionnal action by hooks - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('thirdpartydao')); $parameters=array(); $action='delete'; $reshook=$hookmanager->executeHooks('deleteThirdparty',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/societe/info.php b/htdocs/societe/info.php index 82eab7da454..8f0d0836ed4 100644 --- a/htdocs/societe/info.php +++ b/htdocs/societe/info.php @@ -38,8 +38,6 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe', $socid, '&societe'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('infothirdparty')); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index d2f816cd1ca..9a9900df23e 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -70,8 +70,6 @@ if (! empty($canvas)) $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('thirdpartycard')); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index daf7b7ade4c..678be6bf873 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1079,7 +1079,7 @@ class User extends CommonObject */ function update($user,$notrigger=0,$nosyncmember=0,$nosyncmemberpass=0) { - global $conf, $langs; + global $conf, $langs, $hookmanager; $nbrowsaffected=0; $error=0; @@ -1218,8 +1218,6 @@ class User extends CommonObject } // Actions on extra fields (by external module or standard code) - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); $hookmanager->initHooks(array('userdao')); $parameters=array('socid'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 7ce2640710a..4d79b687c60 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -84,8 +84,6 @@ $object = new User($db); $extrafields = new ExtraFields($db); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); $hookmanager->initHooks(array('usercard')); diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index a3bbcea980a..61ac2f373fc 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -52,11 +52,6 @@ $passwordmd5 = GETPOST('passwordmd5'); $conf->entity = (GETPOST('entity') ? GETPOST('entity') : 1); // Instantiate hooks of thirdparty module only if not already define -if (! is_object($hookmanager)) -{ - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); -} $hookmanager->initHooks(array('passwordforgottenpage')); From 64cac3194ccbc2d594e2fc4e7be479eb1e6d6589 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 Jan 2013 19:19:41 +0100 Subject: [PATCH 09/32] Fix: Use translation of NPR --- htdocs/admin/dict.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index b5c49355672..d5fe7846714 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -732,7 +732,7 @@ if ($id) if (in_array('region_id',$fieldlist)) { print ' '; continue; } // For region page, we do not show the country input $valuetoshow=$langs->trans("Country"); } - if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; $align="center"; } + if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; } if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); } if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } @@ -846,7 +846,7 @@ if ($id) if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*"; } if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; } if ($fieldlist[$field]=='pays') { $valuetoshow=$langs->trans("Country"); } - if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; $align="center"; } + if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; } if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } if ($fieldlist[$field]=='fdm') { $valuetoshow=$langs->trans("AtEndOfMonth"); } if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } From fcee35c65dd590a05763e5d6185ce1735589a8a0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 26 Jan 2013 10:35:30 +0100 Subject: [PATCH 10/32] Fix: $hookmanager is a global object --- htdocs/comm/propal.php | 32 +++---- htdocs/comm/propal/class/propal.class.php | 5 +- htdocs/commande/class/commande.class.php | 5 +- htdocs/commande/fiche.php | 38 ++++---- htdocs/compta/facture.php | 32 +++---- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/compta/paiement/fiche.php | 2 +- htdocs/compta/payment_sc/fiche.php | 2 +- htdocs/contrat/fiche.php | 18 ++-- htdocs/core/class/commonobject.class.php | 33 +++---- htdocs/core/class/html.formfile.class.php | 11 +-- htdocs/core/lib/pdf.lib.php | 92 +++++++++++-------- .../doc/doc_generic_order_odt.modules.php | 5 +- .../commande/doc/pdf_einstein.modules.php | 34 ++++--- .../modules/commande/modules_commande.php | 7 +- htdocs/core/modules/dons/modules_don.php | 2 +- .../doc/pdf_expedition_merou.modules.php | 7 +- .../doc/pdf_expedition_rouget.modules.php | 7 +- .../doc/doc_generic_invoice_odt.modules.php | 5 +- .../modules/facture/doc/pdf_crabe.modules.php | 32 +++---- .../core/modules/facture/modules_facture.php | 5 +- .../fichinter/doc/pdf_soleil.modules.php | 5 +- .../modules/fichinter/modules_fichinter.php | 5 +- .../core/modules/project/modules_project.php | 7 +- .../doc/doc_generic_proposal_odt.modules.php | 10 +- .../modules/propale/doc/pdf_azur.modules.php | 37 +++----- .../core/modules/propale/modules_propale.php | 5 +- .../societe/doc/doc_generic_odt.modules.php | 10 +- .../modules_facturefournisseur.php | 5 +- .../pdf/pdf_canelle.modules.php | 21 ++--- .../modules_commandefournisseur.php | 5 +- .../pdf/pdf_muscadet.modules.php | 21 ++--- htdocs/expedition/fiche.php | 2 +- htdocs/fichinter/fiche.php | 2 +- .../class/fournisseur.commande.class.php | 5 +- htdocs/fourn/commande/fiche.php | 18 ++-- htdocs/fourn/facture/fiche.php | 10 +- htdocs/societe/class/societe.class.php | 15 +-- htdocs/societe/soc.php | 30 +++--- 39 files changed, 272 insertions(+), 317 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 08a03ff8866..31c9e36d898 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -121,7 +121,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') { if ($object->id > 0) { - $result=$object->createFromClone($socid, $hookmanager); + $result=$object->createFromClone($socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -170,7 +170,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -194,7 +194,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->pr $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -371,7 +371,7 @@ else if ($action == 'add' && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); @@ -607,7 +607,7 @@ if ($action == 'modif' && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } @@ -814,7 +814,7 @@ else if ($action == "addline" && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -935,7 +935,7 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -981,7 +981,7 @@ else if ($action == 'builddoc' && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - $result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { @@ -1070,7 +1070,7 @@ else if ($action == 'up' && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); @@ -1092,7 +1092,7 @@ else if ($action == 'down' && $user->rights->propal->creer) $outputlangs->setDefaultLang($newlang); } $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); @@ -1626,7 +1626,7 @@ print ''; // Show object lines $result = $object->getLinesArray(); if (! empty($object->lines)) - $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,0,$hookmanager); + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid); // Form to add new line if ($object->statut == 0 && $user->rights->propal->creer) @@ -1638,18 +1638,18 @@ if ($object->statut == 0 && $user->rights->propal->creer) if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services - $object->formAddObjectLine(0,$mysoc,$soc,$hookmanager); + $object->formAddObjectLine(0,$mysoc,$soc); } else { // Add free products/services - $object->formAddFreeProduct(0,$mysoc,$soc,$hookmanager); + $object->formAddFreeProduct(0,$mysoc,$soc); // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $var=!$var; - $object->formAddPredefinedProduct(0,$mysoc,$soc,$hookmanager); + $object->formAddPredefinedProduct(0,$mysoc,$soc); } } @@ -1799,7 +1799,7 @@ if ($action != 'presend') $var=true; - $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'',0,'',$soc->default_lang,$hookmanager); + $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'',0,'',$soc->default_lang); /* @@ -1843,7 +1843,7 @@ if ($action == 'presend') $outputlangs->setDefaultLang($newlang); } - $result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 8e3e4748f05..90ba3f93690 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -867,12 +867,11 @@ class Propal extends CommonObject * Load an object from its id and create a new one in database * * @param int $socid Id of thirdparty - * @param HookManager $hookmanager Hook manager instance * @return int New id of clone */ - function createFromClone($socid=0,$hookmanager=false) + function createFromClone($socid=0) { - global $user,$langs,$conf; + global $user,$langs,$conf,$hookmanager; $error=0; $now=dol_now(); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 28d56fcf3a2..335757c59d6 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -794,12 +794,11 @@ class Commande extends CommonOrder * Load an object from its id and create a new one in database * * @param int $socid Id of thirdparty - * @param HookManager $hookmanager Hook manager instance * @return int New id of clone */ - function createFromClone($socid=0,$hookmanager=false) + function createFromClone($socid=0) { - global $conf,$user,$langs; + global $conf,$user,$langs,$hookmanager; $error=0; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index b6e7b821495..ccaadefe2ee 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -105,7 +105,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande-> { if ($object->id > 0) { - $result=$object->createFromClone($socid, $hookmanager); + $result=$object->createFromClone($socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -172,7 +172,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -202,7 +202,7 @@ else if ($action == 'add' && $user->rights->commande->creer) $action='create'; $error++; } - + if ($socid<1) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors'); @@ -504,7 +504,7 @@ else if ($action == 'setconditions' && $user->rights->commande->creer) } $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -743,7 +743,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) } $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -870,7 +870,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' } $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -929,7 +929,7 @@ else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->co $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -968,7 +968,7 @@ else if ($action == 'confirm_modif' && $user->rights->commande->creer) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($object->id); // Reload to get new records - commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -1021,7 +1021,7 @@ else if ($action == 'up' && $user->rights->commande->creer) $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); exit; @@ -1041,7 +1041,7 @@ else if ($action == 'down' && $user->rights->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid')); exit; @@ -1070,7 +1070,7 @@ else if ($action == 'builddoc') // In get or post $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { @@ -1491,7 +1491,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G print "'; - + // Ligne info remises tiers print ''; if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) @@ -2698,12 +2693,11 @@ abstract class CommonObject * @param string $seller Object of seller third party * @param string $buyer Object of buyer third party * @param string $selected Object line selected - * @param HookManager $hookmanager Hook manager * @return void */ - function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$hookmanager=false) + function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0) { - global $conf,$langs,$user; + global $conf,$langs,$user,$hookmanager; global $form,$bc,$bcdd; $element=$this->element; @@ -2808,12 +2802,11 @@ abstract class CommonObject * If lines are into a template, title must also be into a template * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * - * @param HookManager $hookmanager Hook manager * @return void */ - function printOriginLinesList($hookmanager=false) + function printOriginLinesList() { - global $langs; + global $langs, $hookmanager; print ''; print ''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 83818285265..525b163d994 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -161,13 +161,12 @@ class FormFile * @param string $title Title to show on top of form * @param string $buttonlabel Label on submit button * @param string $codelang Default language code to use on lang combo box if multilang is enabled - * @param HookManager $hookmanager Object hookmanager with instance of external modules hook classes * @return int <0 if KO, number of shown files if OK */ - function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$hookmanager=false) + function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='') { $this->numoffiles=0; - print $this->showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed,$modelselected,$allowgenifempty,$forcenomultilang,$iconPDF,$maxfilenamelength,$noform,$param,$title,$buttonlabel,$codelang,$hookmanager); + print $this->showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed,$modelselected,$allowgenifempty,$forcenomultilang,$iconPDF,$maxfilenamelength,$noform,$param,$title,$buttonlabel,$codelang); return $this->numoffiles; } @@ -191,15 +190,15 @@ class FormFile * @param string $title Title to show on top of form * @param string $buttonlabel Label on submit button * @param string $codelang Default language code to use on lang combo box if multilang is enabled - * @param HookManager $hookmanager Object hookmanager with instance of external modules hook classes * @return string Output string with HTML array of documents (might be empty string) */ - function showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$hookmanager=false) + function showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='') { // filedir = conf->...dir_ouput."/".get_exdir(id) include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - global $langs,$bc,$conf; + global $langs,$conf,$hookmanager; + global $bc; // For backward compatibility if (! empty($iconPDF)) { diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 481e1751ef0..e07c660fddc 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -792,12 +792,11 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass * @param float $h Cell minimum height. The cell extends automatically if needed. * @param int $align Align * @param string $default_font_size Font size - * @param HookManager $hookmanager Hook manager object * @return void */ -function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size,$hookmanager=false) +function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size) { - $linkedobjects = pdf_getLinkedObjects($object,$outputlangs,$hookmanager); + $linkedobjects = pdf_getLinkedObjects($object,$outputlangs); if (! empty($linkedobjects)) { foreach($linkedobjects as $linkedobject) @@ -833,12 +832,11 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$al * @param int $hideref Hide reference * @param int $hidedesc Hide description * @param int $issupplierline Is it a line for a supplier object ? - * @param HookManager $hookmanager Instance of HookManager * @return void */ -function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref=0,$hidedesc=0,$issupplierline=0,$hookmanager=false) +function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hideref=0,$hidedesc=0,$issupplierline=0) { - global $db, $conf, $langs; + global $db, $conf, $langs, $hookmanager; if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) { @@ -1002,9 +1000,11 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0) { - if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + global $hookmanager; + + if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1024,12 +1024,13 @@ function pdf_getlinenum($object,$i,$outputlangs,$hidedetails=0,$hookmanager=fals * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0) { - if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + global $hookmanager; + + if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1048,12 +1049,13 @@ function pdf_getlineref($object,$i,$outputlangs,$hidedetails=0,$hookmanager=fals * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0) { - if (! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + global $hookmanager; + + if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1072,12 +1074,13 @@ function pdf_getlineref_supplier($object,$i,$outputlangs,$hidedetails=0,$hookman * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0) { - if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + global $hookmanager; + + if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1098,12 +1101,11 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0,$hookmanager= * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0) { - global $conf; + global $conf, $hookmanager; $sign=1; if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; @@ -1133,7 +1135,9 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanage */ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0) { - if (! empty($object->hooks) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) + global $hookmanager; + + if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1155,11 +1159,12 @@ function pdf_getlineupwithtax($object,$i,$outputlangs,$hidedetails=0) * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + if ($object->lines[$i]->special_code != 3) { if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) @@ -1184,11 +1189,12 @@ function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0,$hookmanager=fals * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + if ($object->lines[$i]->special_code != 3) { if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) @@ -1213,11 +1219,12 @@ function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0,$hookmanage * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + if ($object->lines[$i]->special_code != 3) { if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) @@ -1242,11 +1249,12 @@ function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0,$hookmana * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + if ($object->lines[$i]->special_code != 3) { if (is_object($hookmanager) && (( $object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) @@ -1271,11 +1279,12 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0,$hookm * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; if ($object->lines[$i]->special_code != 3) @@ -1302,12 +1311,11 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0,$hookma * @param int $i Current line number * @param Translate $outputlangs Object langs for output * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanager=false) +function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0) { - global $conf; + global $conf, $hookmanager; $sign=1; if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; @@ -1344,13 +1352,15 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0,$hookman */ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0) { + global $hookmanager; + if ($object->lines[$i]->special_code == 3) { return $outputlangs->transnoentities("Option"); } else { - if (! empty($object->hooks) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) + if (is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1373,11 +1383,12 @@ function pdf_getlinetotalwithtax($object,$i,$outputlangs,$hidedetails=0) * @param Object $object Object * @param string $type Type * @param Translate $outputlangs Object langs for output - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false) +function pdf_getTotalQty($object,$type,$outputlangs) { + global $hookmanager; + $total=0; $nblignes=count($object->lines); @@ -1390,7 +1401,7 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false) { $total += $object->lines[$i]->qty; } - else if ($type==9 && ! empty($object->hooks) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) ) + else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) { $special_code = $object->lines[$i]->special_code; if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); @@ -1415,11 +1426,12 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false) * * @param object $object Object * @param Translate $outputlangs Object lang for output - * @param HookManager $hookmanager Hook manager instance * @return void */ -function pdf_getLinkedObjects($object,$outputlangs,$hookmanager=false) +function pdf_getLinkedObjects($object,$outputlangs) { + global $hookmanager; + $linkedobjects=array(); $object->fetchObjectLinked(); diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index aa156eaf412..0ad0ecc0e7e 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -238,12 +238,11 @@ class doc_generic_order_odt extends ModelePDFCommandes * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1 if OK, <=0 if KO */ - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf,$mysoc,$hookmanager; if (empty($srctemplatepath)) { diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index a9b1e89ece9..cff6d9b099f 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -133,12 +133,11 @@ class pdf_einstein extends ModelePDFCommandes * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc,$db; + global $user,$langs,$conf,$mysoc,$db,$hookmanager; if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO @@ -230,7 +229,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -284,7 +283,7 @@ class pdf_einstein extends ModelePDFCommandes $showpricebeforepagebreak=1; $pdf->startTransaction(); - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -292,7 +291,7 @@ class pdf_einstein extends ModelePDFCommandes $pageposafter=$pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); $posyafter=$pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text { @@ -300,7 +299,7 @@ class pdf_einstein extends ModelePDFCommandes { $pdf->AddPage('','',true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($pagenb+1); } } @@ -331,18 +330,18 @@ class pdf_einstein extends ModelePDFCommandes // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } // Unit price before discount - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0); // Quantity - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager); + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); // Enough for 6 chars @@ -350,12 +349,12 @@ class pdf_einstein extends ModelePDFCommandes if ($object->lines[$i]->remise_percent) { $pdf->SetXY($this->posxdiscount-2, $curY); - $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager); + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); } // Total HT line - $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); @@ -426,7 +425,7 @@ class pdf_einstein extends ModelePDFCommandes $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) { @@ -443,7 +442,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } } @@ -1041,12 +1040,11 @@ class pdf_einstein extends ModelePDFCommandes * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs; + global $conf,$langs,$hookmanager; $outputlangs->load("main"); $outputlangs->load("bills"); @@ -1125,7 +1123,7 @@ class pdf_einstein extends ModelePDFCommandes $posy+=2; // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); if ($showaddress) { diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index 8ebd473876d..aa52d55bad3 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -157,12 +157,11 @@ abstract class ModeleNumRefCommandes * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$user,$langs; + global $conf,$user,$langs,$hookmanager; $langs->load("orders"); $error=0; @@ -223,7 +222,7 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0 // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index 24816e4141a..ff05e6d8262 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -222,7 +222,7 @@ function don_create($db, $id, $message, $modele, $outputlangs) // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object,$outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object,$outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php index 42598a2094d..c2f8da7c0e2 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php @@ -78,12 +78,11 @@ class pdf_expedition_merou extends ModelePdfExpedition * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$conf,$langs,$mysoc; + global $user,$conf,$langs,$mysoc,$hookmanager; $object->fetch_thirdparty(); @@ -183,7 +182,7 @@ class pdf_expedition_merou extends ModelePdfExpedition // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 3); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php index e3113689726..b458a5a3a42 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php @@ -81,12 +81,11 @@ class pdf_expedition_rouget extends ModelePdfExpedition * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$conf,$langs; + global $user,$conf,$langs,$hookmanager; $object->fetch_thirdparty(); @@ -170,7 +169,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 35cb6851886..dcf8436636d 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -250,12 +250,11 @@ class doc_generic_invoice_odt extends ModelePDFFactures * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1 if OK, <=0 if KO */ - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf,$mysoc,$hookmanager; if (empty($srctemplatepath)) { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index e12a4984104..bfa48ceed37 100755 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -134,12 +134,11 @@ class pdf_crabe extends ModelePDFFactures * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc,$db; + global $user,$langs,$conf,$mysoc,$db,$hookmanager; if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO @@ -232,7 +231,7 @@ class pdf_crabe extends ModelePDFFactures if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -285,7 +284,7 @@ class pdf_crabe extends ModelePDFFactures $showpricebeforepagebreak=1; $pdf->startTransaction(); - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -293,7 +292,7 @@ class pdf_crabe extends ModelePDFFactures $pageposafter=$pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); $posyafter=$pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; @@ -303,7 +302,7 @@ class pdf_crabe extends ModelePDFFactures { $pdf->AddPage('','',true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($pagenb+1); } } @@ -334,18 +333,18 @@ class pdf_crabe extends ModelePDFFactures // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } // Unit price before discount - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0); // Quantity - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager); + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); // Enough for 6 chars @@ -353,12 +352,12 @@ class pdf_crabe extends ModelePDFFactures if ($object->lines[$i]->remise_percent) { $pdf->SetXY($this->posxdiscount-2, $curY); - $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager); + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); } // Total HT line - $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); @@ -428,7 +427,7 @@ class pdf_crabe extends ModelePDFFactures $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) { @@ -445,7 +444,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } } @@ -1194,10 +1193,9 @@ class pdf_crabe extends ModelePDFFactures * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; @@ -1331,7 +1329,7 @@ class pdf_crabe extends ModelePDFFactures $posy+=1; // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); if ($showaddress) { diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index 42462c9b246..865d1f578bd 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -152,10 +152,9 @@ abstract class ModeleNumRefFactures * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int <0 if KO, >0 if OK */ -function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf,$user,$langs; @@ -224,7 +223,7 @@ function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 953466ec88a..d40dfb3c8f3 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -101,10 +101,9 @@ class pdf_soleil extends ModelePDFFicheinter * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { global $user,$langs,$conf,$mysoc; @@ -174,7 +173,7 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index 545a6979491..cb0336f2bd2 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -151,10 +151,9 @@ abstract class ModeleNumRefFicheinter * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf,$langs,$user; $langs->load("ficheinter"); @@ -216,7 +215,7 @@ function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $ // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/project/modules_project.php b/htdocs/core/modules/project/modules_project.php index fc0260a0be2..6aae57c34d5 100644 --- a/htdocs/core/modules/project/modules_project.php +++ b/htdocs/core/modules/project/modules_project.php @@ -110,7 +110,7 @@ abstract class ModeleNumRefProjects /** * Renvoi prochaine valeur attribuee - * + * * @param Societe $objsoc Object third party * @param Project $project Object project * @return string Valeur @@ -149,10 +149,9 @@ abstract class ModeleNumRefProjects * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function project_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function project_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf,$langs; $langs->load("projects"); @@ -214,7 +213,7 @@ function project_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 812fb81a859..be0ac3f7d3f 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -237,12 +237,11 @@ class doc_generic_proposal_odt extends ModelePDFPropales * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1 if OK, <=0 if KO */ - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf,$mysoc,$hookmanager; if (empty($srctemplatepath)) { @@ -485,11 +484,6 @@ class doc_generic_proposal_odt extends ModelePDFPropales } // Add odtgeneration hook - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('odtgeneration')); $parameters=array('odfHandler'=>$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); global $action; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 3a76d61f7f3..43f2bab3940 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -132,12 +132,11 @@ class pdf_azur extends ModelePDFPropales * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc,$db; + global $user,$langs,$conf,$mysoc,$db,$hookmanager; if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO @@ -229,7 +228,7 @@ class pdf_azur extends ModelePDFPropales $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -282,7 +281,7 @@ class pdf_azur extends ModelePDFPropales $showpricebeforepagebreak=1; $pdf->startTransaction(); - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -290,7 +289,7 @@ class pdf_azur extends ModelePDFPropales $pageposafter=$pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); $posyafter=$pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text @@ -299,7 +298,7 @@ class pdf_azur extends ModelePDFPropales { $pdf->AddPage('','',true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($pagenb+1); } } @@ -330,18 +329,18 @@ class pdf_azur extends ModelePDFPropales // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } // Unit price before discount - $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0); // Quantity - $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager); + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); // Enough for 6 chars @@ -349,12 +348,12 @@ class pdf_azur extends ModelePDFPropales if ($object->lines[$i]->remise_percent) { $pdf->SetXY($this->posxdiscount-2, $curY); - $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager); + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); } // Total HT line - $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); @@ -423,7 +422,7 @@ class pdf_azur extends ModelePDFPropales $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) { @@ -440,7 +439,7 @@ class pdf_azur extends ModelePDFPropales $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } } @@ -480,11 +479,6 @@ class pdf_azur extends ModelePDFPropales $pdf->Output($file,'F'); //Add pdfgeneration hook - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('pdfgeneration')); $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); global $action; @@ -1088,10 +1082,9 @@ class pdf_azur extends ModelePDFPropales * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; @@ -1186,7 +1179,7 @@ class pdf_azur extends ModelePDFPropales $posy+=2; // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); if ($showaddress) { diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php index d26193d2a1b..b5a25954df9 100644 --- a/htdocs/core/modules/propale/modules_propale.php +++ b/htdocs/core/modules/propale/modules_propale.php @@ -153,10 +153,9 @@ abstract class ModeleNumRefPropales * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf,$user,$langs; $langs->load("propale"); @@ -219,7 +218,7 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index cc5c08f7431..0146ebfc253 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -161,12 +161,11 @@ class doc_generic_odt extends ModeleThirdPartyDoc * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1 if OK, <=0 if KO */ - function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf,$mysoc,$hookmanager; if (empty($srctemplatepath)) { @@ -298,11 +297,6 @@ class doc_generic_odt extends ModeleThirdPartyDoc } // Add odtgeneration hook - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('odtgeneration')); $parameters=array('odfHandler'=>$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); global $action; diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php index d29abaa08a0..5d409dd6c67 100755 --- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php @@ -65,10 +65,9 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf, $user, $langs; @@ -137,7 +136,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hided // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 0813162020d..46b2e893996 100755 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -129,12 +129,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) + function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf,$mysoc,$hookmanager; if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO @@ -227,7 +226,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -276,7 +275,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Description of product line $curX = $this->posxdesc-1; - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); @@ -294,7 +293,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } @@ -414,11 +413,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->Output($file,'F'); // Add pdfgeneration hook - if (!is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('pdfgeneration')); $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); global $action; @@ -824,10 +818,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -907,7 +900,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetTextColor(0,0,60); // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); if ($showaddress) { diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php index e66b22a4f83..6b9fd315f18 100644 --- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php @@ -147,10 +147,9 @@ abstract class ModeleNumRefSuppliersOrders * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param HookManager $hookmanager Hook manager instance * @return int 0 if KO, 1 if OK */ -function supplier_order_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false) +function supplier_order_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { global $conf, $user, $langs; $langs->load("suppliers"); @@ -218,7 +217,7 @@ function supplier_order_pdf_create($db, $object, $modele, $outputlangs, $hidedet // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0) + if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) { $outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 3074e73d19a..6805bb3fddb 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -138,12 +138,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @param object $hookmanager Hookmanager object * @return int 1=OK, 0=KO */ - function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) + function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) { - global $user,$langs,$conf; + global $user,$langs,$conf,$hookmanager; if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO @@ -239,7 +238,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -288,7 +287,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Description of product line $curX = $this->posxdesc-1; - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1,$hookmanager); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1); $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); @@ -306,7 +305,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } @@ -433,11 +432,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Add pdfgeneration hook - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } $hookmanager->initHooks(array('pdfgeneration')); $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); global $action; @@ -917,10 +911,9 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output - * @param object $hookmanager Hookmanager object * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager) + function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -1005,7 +998,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetTextColor(0,0,60); // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); if ($showaddress) { diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 1d34aea5d0c..90850fce683 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -1422,7 +1422,7 @@ else $outputlangs->setDefaultLang($newlang); } - $result=expedition_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=expedition_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 86230754ef3..11e1eabd782 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -1466,7 +1466,7 @@ else if ($id > 0 || ! empty($ref)) $outputlangs->setDefaultLang($newlang); } - $result=fichinter_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=fichinter_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 3e7c5600582..28eae474799 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1029,12 +1029,11 @@ class CommandeFournisseur extends CommonOrder /** * Load an object from its id and create a new one in database * - * @param HookManager $hookmanager Hook manager instance * @return int New id of clone */ - function createFromClone($hookmanager=false) + function createFromClone() { - global $conf,$user,$langs; + global $conf,$user,$langs,$hookmanager; $error=0; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index ed5c7483c64..ee802c3dc0f 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -308,7 +308,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) } $ret=$object->fetch($object->id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); unset($_POST['type']); @@ -367,7 +367,7 @@ else if ($action == 'updateligne' && $user->rights->fournisseur->commande->creer if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($object->id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -392,7 +392,7 @@ else if ($action == 'confirm_deleteproductline' && $confirm == 'yes' && $user->r if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($object->id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -423,7 +423,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fourn if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($object->id); // Reload to get new records - supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -522,7 +522,7 @@ else if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->fourn { if ($object->id > 0) { - $result=$object->createFromClone($hookmanager); + $result=$object->createFromClone(); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -592,7 +592,7 @@ else if ($action == 'up' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#'.$_GET['rowid'])); exit; } @@ -606,7 +606,7 @@ else if ($action == 'down' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#'.$_GET['rowid'])); exit; } @@ -628,7 +628,7 @@ else if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) / $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang(GETPOST('lang_id')); } - $result=supplier_order_pdf_create($db, $object,$object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=supplier_order_pdf_create($db, $object,$object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); @@ -1797,7 +1797,7 @@ if (! empty($object->id)) $outputlangs->setDefaultLang($newlang); } - $result=supplier_order_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=supplier_order_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index abec49e0e89..fd6ffc2efe2 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -562,7 +562,7 @@ elseif ($action == 'addline') $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); unset($_POST['qty']); unset($_POST['type']); @@ -613,7 +613,7 @@ elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); $action=''; } @@ -839,7 +839,7 @@ elseif ($action == 'builddoc') $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - $result=supplier_invoice_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=supplier_invoice_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); @@ -1221,7 +1221,7 @@ if ($action == 'create') print '
".$langs->trans("DefaultContact").''; $form->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist); print '
'.$langs->trans('Discounts').''; if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); @@ -1684,7 +1684,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G print ''; - $objectsrc->printOriginLinesList($hookmanager); + $objectsrc->printOriginLinesList(); print '
'; } @@ -2166,7 +2166,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G // Show object lines if (! empty($object->lines)) - $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1); /* * Form to add new line @@ -2180,18 +2180,18 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services - $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager); + $object->formAddObjectLine(1,$mysoc,$soc); } else { // Add free products/services - $object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); + $object->formAddFreeProduct(1,$mysoc,$soc); // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $var=!$var; - $object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager); + $object->formAddPredefinedProduct(1,$mysoc,$soc); } } @@ -2354,7 +2354,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $genallowed=$user->rights->commande->creer; $delallowed=$user->rights->commande->supprimer; - $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$hookmanager); + $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); /* * Linked object block @@ -2397,7 +2397,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $outputlangs->setDefaultLang($newlang); } - $result=commande_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=commande_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index f15762b97bf..4295e1f6fa9 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -117,7 +117,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->c { if ($object->fetch($id) > 0) { - $result=$object->createFromClone($socid, $hookmanager); + $result=$object->createFromClone($socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); @@ -191,7 +191,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights-> if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } if ($result >= 0) { @@ -394,7 +394,7 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } else @@ -471,7 +471,7 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { $ret=$object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } } } @@ -1184,7 +1184,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- } $ret=$object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -1314,7 +1314,7 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa } $ret=$object->fetch($id); // Reload to get new records - facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } unset($_POST['qty']); @@ -1360,7 +1360,7 @@ else if ($action == 'up' && $user->rights->facture->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']); exit; @@ -1382,7 +1382,7 @@ else if ($action == 'down' && $user->rights->facture->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.'#'.$_GET['rowid']); exit; @@ -1614,7 +1614,7 @@ else if ($action == 'builddoc') // En get ou en post $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); @@ -2186,7 +2186,7 @@ if ($action == 'create') print ''; - $objectsrc->printOriginLinesList($hookmanager); + $objectsrc->printOriginLinesList(); print '
'; } @@ -3054,7 +3054,7 @@ else if ($id > 0 || ! empty($ref)) // Show object lines if (! empty($object->lines)) - $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1); /* * Form to add new line @@ -3066,18 +3066,18 @@ else if ($id > 0 || ! empty($ref)) if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services - $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager); + $object->formAddObjectLine(1,$mysoc,$soc); } else { // Add free products/services - $object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); + $object->formAddFreeProduct(1,$mysoc,$soc); // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $var=!$var; - $object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager); + $object->formAddPredefinedProduct(1,$mysoc,$soc); } } @@ -3317,7 +3317,7 @@ else if ($id > 0 || ! empty($ref)) $delallowed=$user->rights->facture->supprimer; print '
'; - print $formfile->showdocuments('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$hookmanager); + print $formfile->showdocuments('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); $somethingshown=$formfile->numoffiles; /* @@ -3382,7 +3382,7 @@ else if ($id > 0 || ! empty($ref)) $outputlangs->setDefaultLang($newlang); } - $result=facture_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=facture_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1637524cfce..b96fd57916d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -541,7 +541,7 @@ class Facture extends CommonInvoice * @param HookManager $hookmanager Hook manager instance * @return int New id of clone */ - function createFromClone($socid=0,$hookmanager=false) + function createFromClone($socid=0) { global $conf,$user,$langs; diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index a3eaa76d463..50ce36d4e9c 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -112,7 +112,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture-> $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs); } header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); diff --git a/htdocs/compta/payment_sc/fiche.php b/htdocs/compta/payment_sc/fiche.php index 0bf129c567b..c8d710e2831 100644 --- a/htdocs/compta/payment_sc/fiche.php +++ b/htdocs/compta/payment_sc/fiche.php @@ -94,7 +94,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs, $hookmanager); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) facture_pdf_create($db, $fac, $fac->modelpdf, $outputlangs); } header('Location: fiche.php?id='.$paiement->id); diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index d3a7f48c24b..9578bf54c98 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -209,7 +209,7 @@ else if ($action == 'addline' && $user->rights->contrat->creer) setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")),'errors'); $error++; } - + if (! $error) { $ret=$object->fetch($id); @@ -1282,7 +1282,7 @@ else if ($user->rights->contrat->creer && ($object->statut >= 0)) { $dateSelector=1; - + print '
'; print ''; // Array with (n*2)+1 lines @@ -1298,28 +1298,28 @@ else if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services - $object->formAddObjectLine($dateSelector,$mysoc,$object->thirdparty,$hookmanager); + $object->formAddObjectLine($dateSelector,$mysoc,$object->thirdparty); } else { // Add free products/services - $object->formAddFreeProduct($dateSelector,$mysoc,$object->thirdparty,$hookmanager); - + $object->formAddFreeProduct($dateSelector,$mysoc,$object->thirdparty); + // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $var=!$var; - $object->formAddPredefinedProduct($dateSelector,$mysoc,$object->thirdparty,$hookmanager); + $object->formAddPredefinedProduct($dateSelector,$mysoc,$object->thirdparty); } } - + $parameters=array(); $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } - + // Restore correct setup $conf->product->enabled = $savproductenabled; - + print ''; print '
'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 344507971bb..5c9b8d93122 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2463,10 +2463,9 @@ abstract class CommonObject * TODO Move this into html.class.php * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * - * @param HookManager $hookmanager Hook manager instance * @return void */ - function showLinkedObjectBlock($hookmanager=false) + function showLinkedObjectBlock() { global $conf,$langs,$hookmanager; global $bc; @@ -2543,13 +2542,12 @@ abstract class CommonObject * @param int $dateSelector 1=Show also date range input fields * @param Societe $seller Object thirdparty who sell * @param Societe $buyer Object thirdparty who buy - * @param HookManager $hookmanager Hook manager instance * @return void * @deprecated */ - function formAddPredefinedProduct($dateSelector,$seller,$buyer,$hookmanager=false) + function formAddPredefinedProduct($dateSelector,$seller,$buyer) { - global $conf,$langs,$object; + global $conf,$langs,$object,$hookmanager; global $form,$bcnd,$var; // Use global variables + $dateSelector + $seller and $buyer @@ -2564,13 +2562,12 @@ abstract class CommonObject * @param int $dateSelector 1=Show also date range input fields * @param Societe $seller Object thirdparty who sell * @param Societe $buyer Object thirdparty who buy - * @param HookManager $hookmanager Hook manager instance * @return void * @deprecated */ - function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false) + function formAddFreeProduct($dateSelector,$seller,$buyer) { - global $conf,$langs,$object; + global $conf,$langs,$object,$hookmanager; global $form,$bcnd,$var; // Use global variables + $dateSelector + $seller and $buyer @@ -2586,12 +2583,11 @@ abstract class CommonObject * @param int $dateSelector 1=Show also date range input fields * @param Societe $seller Object thirdparty who sell * @param Societe $buyer Object thirdparty who buy - * @param HookManager $hookmanager Hook manager instance * @return void */ - function formAddObjectLine($dateSelector,$seller,$buyer,$hookmanager=false) + function formAddObjectLine($dateSelector,$seller,$buyer) { - global $conf,$user,$langs,$object; + global $conf,$user,$langs,$object,$hookmanager; global $form,$bcnd,$var; // Output template part (modules that overwrite templates must declare this into descriptor) @@ -2625,12 +2621,11 @@ abstract class CommonObject * @param string $buyer Object of buyer third party * @param string $selected Object line selected * @param int $dateSelector 1=Show also date range input fields - * @param HookManager $hookmanager Hookmanager * @return void */ - function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0, $hookmanager=false) + function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { - global $conf,$langs; + global $conf,$langs,$hookmanager; print '
'.$langs->trans('Ref').'
'; - $objectsrc->printOriginLinesList($hookmanager); + $objectsrc->printOriginLinesList(); print '
'; } @@ -2054,7 +2054,7 @@ else $outputlangs->setDefaultLang($newlang); } - $result=supplier_invoice_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + $result=supplier_invoice_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 95c16965fb5..7cdc137d9f1 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -578,12 +578,12 @@ class Societe extends CommonObject if (! $nosyncmember && ! empty($conf->adherent->enabled)) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - + dol_syslog(get_class($this)."::update update linked member"); - + $lmember=new Adherent($this->db); $result=$lmember->fetch(0, 0, $this->id); - + if ($result > 0) { $lmember->firstname=$this->firstname; @@ -604,14 +604,15 @@ class Societe extends CommonObject { $this->error=$lmember->error; $error++; - } + } } } - + // Si le fournisseur est classe on l'ajoute $this->AddFournisseurInCategory($this->fournisseur_categorie); // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! $hookmanager->initHooks(array('thirdpartydao')); $parameters=array('socid'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -982,7 +983,8 @@ class Societe extends CommonObject */ function delete($id) { - global $user,$langs,$conf; + global $user, $langs, $conf, $hookmanager; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_syslog(get_class($this)."::delete", LOG_DEBUG); @@ -1062,6 +1064,7 @@ class Societe extends CommonObject if (! $error) { // Additionnal action by hooks + // FIXME on a déjà un trigger, pourquoi rajouter un hook !! $hookmanager->initHooks(array('thirdpartydao')); $parameters=array(); $action='delete'; $reshook=$hookmanager->executeHooks('deleteThirdparty',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 9a9900df23e..e8cff6c4016 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -200,7 +200,7 @@ if (empty($reshook)) $error++; $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled"); $action = ($action=='add'?'create':'edit'); } - + // We set country_id, country_code and country for the selected country $object->country_id=GETPOST('country_id')?GETPOST('country_id'):$mysoc->country_id; if ($object->country_id) @@ -225,7 +225,7 @@ if (empty($reshook)) $action = ($action=='add'?'create':'edit'); } } - + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) { @@ -236,7 +236,7 @@ if (empty($reshook)) } } } - + if (! $error) { if ($action == 'add') @@ -395,11 +395,11 @@ if (empty($reshook)) } // Gestion du logo de la société - + // Update linked member if (! $error && $object->fk_soc > 0) { - + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); @@ -410,7 +410,7 @@ if (empty($reshook)) dol_syslog(get_class($this)."::delete erreur -1 ".$this->error, LOG_ERR); } } - + if (! $error && ! count($errors)) { @@ -867,13 +867,13 @@ else if ($idprof!='-') { if (($j % 2) == 0) print ''; - + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; if(empty($conf->global->$idprof_mandatory)) print ''.$idprof.''; else print ''.$idprof.''; - + $key='idprof'.$i; print $formcompany->get_input_id_prof($i,'idprof'.$i,$object->$key,$object->country_code); print ''; @@ -945,7 +945,7 @@ else // Capital print ''.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->currency).''; - // Local Taxes + // Local Taxes //TODO: Place into a function to control showing by country or study better option if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") { @@ -968,7 +968,7 @@ else print $form->selectyesno('localtax2assuj_value',0,1); print ''; } - + if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || GETPOST("type")=='') ) { print ''.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; @@ -1317,13 +1317,13 @@ else if ($idprof!='-') { if (($j % 2) == 0) print ''; - + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; if(empty($conf->global->$idprof_mandatory)) print ''.$idprof.''; else print ''.$idprof.''; - + $key='idprof'.$i; print $formcompany->get_input_id_prof($i,'idprof'.$i,$object->$key,$object->country_code); print ''; @@ -1393,7 +1393,7 @@ else print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); print ''; } - + if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && $object->fournisseur==1) { print ''.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; @@ -1716,7 +1716,7 @@ else print yn($object->localtax2_assuj); print ''; } - + if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && $object->fournisseur==1) { print ''.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; @@ -1879,7 +1879,7 @@ else $var=true; - $somethingshown=$formfile->show_documents('company',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang,$hookmanager); + $somethingshown=$formfile->show_documents('company',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang); print ''; print ''; From 647cbb08fbaa8113f56c8caf67eba338d653ebcb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 26 Jan 2013 10:38:11 +0100 Subject: [PATCH 11/32] Fix: wrong EOL --- htdocs/categories/class/categorie.class.php | 70 ++++++++++----------- htdocs/core/class/hookmanager.class.php | 2 +- htdocs/core/lib/trip.lib.php | 10 +-- htdocs/master.inc.php | 4 +- htdocs/societe/class/societe.class.php | 66 +++++++++---------- htdocs/societe/soc.php | 28 ++++----- 6 files changed, 90 insertions(+), 90 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 802e8e3ff11..c2c249f5e41 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -543,39 +543,39 @@ class Categorie return ($n[0] > 0); } - - /** - * Load this->motherof that is array(id_son=>id_parent, ...) - * - * @return int <0 if KO, >0 if OK - */ - private function load_motherof() - { - global $conf; - - $this->motherof=array(); - + + /** + * Load this->motherof that is array(id_son=>id_parent, ...) + * + * @return int <0 if KO, >0 if OK + */ + private function load_motherof() + { + global $conf; + + $this->motherof=array(); + // Load array[child]=parent - $sql = "SELECT fk_parent as id_parent, rowid as id_son"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE fk_parent != 0"; - $sql.= " AND entity = ".$conf->entity; - - dol_syslog(get_class($this)."::load_motherof sql=".$sql); - $resql = $this->db->query($sql); - if ($resql) - { - while ($obj= $this->db->fetch_object($resql)) - { - $this->motherof[$obj->id_son]=$obj->id_parent; - } - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } + $sql = "SELECT fk_parent as id_parent, rowid as id_son"; + $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE fk_parent != 0"; + $sql.= " AND entity = ".$conf->entity; + + dol_syslog(get_class($this)."::load_motherof sql=".$sql); + $resql = $this->db->query($sql); + if ($resql) + { + while ($obj= $this->db->fetch_object($resql)) + { + $this->motherof[$obj->id_son]=$obj->id_parent; + } + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } } /** @@ -596,8 +596,8 @@ class Categorie { $this->cats = array(); - // Init this->motherof that is array(id_son=>id_parent, ...) - $this->load_motherof(); + // Init this->motherof that is array(id_son=>id_parent, ...) + $this->load_motherof(); // Init $this->cats array $sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.fk_parent"; // Distinct reduce pb with old tables with duplicates @@ -695,7 +695,7 @@ class Categorie $i++; $cursor_categ=$this->motherof[$cursor_categ]; } //print 'Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].'
'."\n"; - + // We count number of _ to have level $this->cats[$id_categ]['level']=dol_strlen(preg_replace('/[^_]/i','',$this->cats[$id_categ]['fullpath'])); diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 0c31a7569fa..cca22038746 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -179,7 +179,7 @@ class HookManager if (! is_array($result) && ! is_numeric($result)) $this->resPrint.=$result; } - //print "method=".$method." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." result=".$result." resaction=".$resaction; + //print "method=".$method." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." result=".$result." resaction=".$resaction; } } } diff --git a/htdocs/core/lib/trip.lib.php b/htdocs/core/lib/trip.lib.php index 309bcf33224..60794497554 100644 --- a/htdocs/core/lib/trip.lib.php +++ b/htdocs/core/lib/trip.lib.php @@ -50,11 +50,11 @@ function trip_prepare_head($object) $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id; - $head[$h][1] = $langs->trans("Info"); - $head[$h][2] = 'info'; - $h++; - + $head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + complete_head_from_modules($conf,$langs,$object,$head,$h,'trip','remove'); return $head; diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index b023f7110b0..41bfa6d3a91 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -207,8 +207,8 @@ if (! defined('NOREQUIRETRAN')) // Create the global $hookmanager object -include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$hookmanager=new HookManager($db); +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager=new HookManager($db); if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR'); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7cdc137d9f1..269f428a61a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -565,45 +565,45 @@ class Societe extends CommonObject $resql=$this->db->query($sql); if ($resql) { - unset($this->country_code); // We clean this because it may have been changed after an update of country_id - unset($this->country); - unset($this->state_code); - unset($this->state); - - $nbrowsaffected+=$this->db->affected_rows($resql); + unset($this->country_code); // We clean this because it may have been changed after an update of country_id + unset($this->country); + unset($this->state_code); + unset($this->state); + + $nbrowsaffected+=$this->db->affected_rows($resql); if (! $error && $nbrowsaffected) { // Update information on linked member if it is an update if (! $nosyncmember && ! empty($conf->adherent->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - - dol_syslog(get_class($this)."::update update linked member"); - - $lmember=new Adherent($this->db); - $result=$lmember->fetch(0, 0, $this->id); - - if ($result > 0) - { - $lmember->firstname=$this->firstname; - $lmember->lastname=$this->lastname; - $lmember->address=$this->address; - $lmember->email=$this->email; - $lmember->phone=$this->phone; - - $result=$lmember->update($user,0,1,1); // Use nosync to 1 to avoid cyclic updates - if ($result < 0) - { - $this->error=$lmember->error; - dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR); - $error++; - } - } - else if ($result < 0) - { - $this->error=$lmember->error; - $error++; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + + dol_syslog(get_class($this)."::update update linked member"); + + $lmember=new Adherent($this->db); + $result=$lmember->fetch(0, 0, $this->id); + + if ($result > 0) + { + $lmember->firstname=$this->firstname; + $lmember->lastname=$this->lastname; + $lmember->address=$this->address; + $lmember->email=$this->email; + $lmember->phone=$this->phone; + + $result=$lmember->update($user,0,1,1); // Use nosync to 1 to avoid cyclic updates + if ($result < 0) + { + $this->error=$lmember->error; + dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR); + $error++; + } + } + else if ($result < 0) + { + $this->error=$lmember->error; + $error++; } } } diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index e8cff6c4016..c1dd0c4c09d 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -395,21 +395,21 @@ if (empty($reshook)) } // Gestion du logo de la société - - // Update linked member - if (! $error && $object->fk_soc > 0) + + // Update linked member + if (! $error && $object->fk_soc > 0) { - - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; - dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); - if (! $this->db->query($sql)) - { - $error++; - $this->error .= $this->db->lasterror(); - dol_syslog(get_class($this)."::delete erreur -1 ".$this->error, LOG_ERR); - } - } + + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; + $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; + dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG); + if (! $this->db->query($sql)) + { + $error++; + $this->error .= $this->db->lasterror(); + dol_syslog(get_class($this)."::delete erreur -1 ".$this->error, LOG_ERR); + } + } if (! $error && ! count($errors)) { From 20023880983ece133a0ba84cff1ec5d3368027fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Jan 2013 13:40:31 +0100 Subject: [PATCH 12/32] Revert "New: add hook getFormMail" This reverts commit c7325324839e1796400eb3246873af922d964434. --- htdocs/core/class/html.formmail.class.php | 835 +++++++++++----------- 1 file changed, 406 insertions(+), 429 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index c221cc33c07..3d15fdbeeee 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -217,445 +217,422 @@ class FormMail function get_form($addfileaction='addfile',$removefileaction='removefile') { global $conf, $langs, $user; - global $hookmanager; $langs->load("other"); $langs->load("mails"); - if (! is_object($hookmanager)) + $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($this->db); + + $out.= "\n\n"; + if ($this->withform) { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } + $out.= '
'."\n"; + $out.= ''; } - $hookmanager->initHooks(array('formmail')); - - $parameters=array( - 'addfileaction' => $addfileaction, - 'removefileaction'=> $removefileaction - ); - $reshook=$hookmanager->executeHooks('getFormMail', $parameters, $this); - - if (!empty($reshook)) + foreach ($this->param as $key=>$value) { - return $hookmanager->resPrint; + $out.= ''."\n"; } - else + $out.= ''."\n"; + + // Substitution array + if (! empty($this->withsubstit)) { - $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($this->db); - - $out.= "\n\n"; - if ($this->withform) - { - $out.= ''."\n"; - $out.= ''; - } - foreach ($this->param as $key=>$value) - { - $out.= ''."\n"; - } - $out.= '
'."\n"; - - // Substitution array - if (! empty($this->withsubstit)) - { - $out.= '\n"; - } - - // From - if (! empty($this->withfrom)) - { - if (! empty($this->withfromreadonly)) - { - $out.= ''; - $out.= ''; - $out.= '\n"; - $out.= "\n"; - } - else - { - $out.= "\n"; - } - } - - // Replyto - if (! empty($this->withreplyto)) - { - if ($this->withreplytoreadonly) - { - $out.= ''; - $out.= ''; - $out.= "\n"; - } - } - - // Errorsto - if (! empty($this->witherrorsto)) - { - //if (! $this->errorstomail) $this->errorstomail=$this->frommail; - $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); - if ($this->witherrorstoreadonly) - { - $out.= ''; - $out.= '\n"; - } - else - { - $out.= '\n"; - } - } - - // To - if (! empty($this->withto) || is_array($this->withto)) - { - $out.= '\n"; - } - - // CC - if (! empty($this->withtocc) || is_array($this->withtocc)) - { - $out.= '\n"; - } - - // CCC - if (! empty($this->withtoccc) || is_array($this->withtoccc)) - { - $out.= '\n"; - } - - // Ask delivery receipt - if (! empty($this->withdeliveryreceipt)) - { - $out.= '\n"; - } - - // Topic - if (! empty($this->withtopic)) - { - $this->withtopic=make_substitutions($this->withtopic,$this->substit); - - $out.= ''; - $out.= ''; - $out.= '\n"; - } - - // Attached files - if (! empty($this->withfile)) - { - $out.= ''; - $out.= ''; - $out.= '\n"; - } - - // Message - if (! empty($this->withbody)) - { - $defaultmessage=""; - - // TODO A partir du type, proposer liste de messages dans table llx_models - if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } - elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } - elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } - elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } - elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } - elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } - - // Complete substitution array - if (! empty($conf->paypal->enabled) && ! empty($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=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - if ($this->param["models"]=='facture_send') - { - $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); - $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); - } - } - - $defaultmessage=make_substitutions($defaultmessage,$this->substit); - if (isset($_POST["message"])) $defaultmessage=$_POST["message"]; - $defaultmessage=str_replace('\n',"\n",$defaultmessage); - - $out.= ''; - $out.= ''; - $out.= '\n"; - } - - if (! empty($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.= "
'.$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("MailErrorsTo").''; - $out.= $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 (! empty($this->withtofree)) - { - $out.= 'withto) :"").'" />'; - } - if (! empty($this->withto) && is_array($this->withto)) - { - if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); - } - if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - if ($this->withtofree) $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); - } - } - $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 (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); - } - if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtoccsocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); - } - } - $out.= "
'; - $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if (! empty($this->withtocccreadonly)) - { - $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; - } - else - { - $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; - if (! empty($this->withto) && is_array($this->withto)) - { - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); - } - if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. - { - $liste=array(); - $soc=new Societe($this->db); - $soc->fetch($this->withtosocid); - foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) - { - $liste[$key]=$value; - } - $out.= " ".$langs->trans("or")." "; - $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); - } - } - //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); - $out.= "
'.$langs->trans("DeliveryReceipt").''; - - if (! empty($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("MailFile").''; - // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out.= ''."\n"; - $out.= ''."\n"; - if (count($listofpaths)) - { - foreach($listofpaths as $key => $val) - { - $out.= '
'; - $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; - if (! $this->withfilereadonly) - { - $out.= ' '; - //$out.= ' '.img_delete($langs->trans("Delete").''; - } - $out.= '
'; - } - } - else - { - $out.= $langs->trans("NoAttachedFiles").'
'; - } - if ($this->withfile == 2) // Can add other files - { - $out.= ''; - $out.= ' '; - $out.= ''; - } - $out.= "
'.$langs->trans("MailText").''; - if ($this->withbodyreadonly) - { - $out.= nl2br($defaultmessage); - $out.= ''; - } - else - { - if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$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 (! empty($this->withform)) $out.= '
'."\n"; - $out.= "\n"; - - return $out; + $out.= ''; + $help=""; + foreach($this->substit as $key => $val) + { + $help.=$key.' -> '.$langs->trans($val).'
'; + } + $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"),$help); + $out.= "\n"; } + + // From + if (! empty($this->withfrom)) + { + if (! empty($this->withfromreadonly)) + { + $out.= ''; + $out.= ''; + $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.= "\n"; + $out.= "\n"; + } + else + { + $out.= "".$langs->trans("MailFrom").""; + $out.= $langs->trans("Name").':'; + $out.= '    '; + $out.= $langs->trans("EMail").':<>'; + $out.= "\n"; + } + } + + // Replyto + if (! empty($this->withreplyto)) + { + if ($this->withreplytoreadonly) + { + $out.= ''; + $out.= ''; + $out.= "".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail?(" <".$this->replytomail.">"):""); + $out.= "\n"; + } + } + + // Errorsto + if (! empty($this->witherrorsto)) + { + //if (! $this->errorstomail) $this->errorstomail=$this->frommail; + $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); + if ($this->witherrorstoreadonly) + { + $out.= ''; + $out.= ''.$langs->trans("MailErrorsTo").''; + $out.= $errorstomail; + $out.= "\n"; + } + else + { + $out.= ''.$langs->trans("MailErrorsTo").''; + $out.= ''; + $out.= "\n"; + } + } + + // To + if (! empty($this->withto) || is_array($this->withto)) + { + $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 (! empty($this->withtofree)) + { + $out.= 'withto) :"").'" />'; + } + if (! empty($this->withto) && is_array($this->withto)) + { + if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); + } + if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + if ($this->withtofree) $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); + } + } + $out.= "\n"; + } + + // CC + if (! empty($this->withtocc) || is_array($this->withtocc)) + { + $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 (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $this->withto, GETPOST("receivercc"), 1); + } + if (! empty($this->withtoccsocid) && $this->withtoccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtoccsocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receivercc", $liste, GETPOST("receivercc"), 1); + } + } + $out.= "\n"; + } + + // CCC + if (! empty($this->withtoccc) || is_array($this->withtoccc)) + { + $out.= ''; + $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out.= ''; + if (! empty($this->withtocccreadonly)) + { + $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; + } + else + { + $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />'; + if (! empty($this->withto) && is_array($this->withto)) + { + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $this->withto, GETPOST("receiverccc"), 1); + } + if (! empty($this->withtocccsocid) && $this->withtocccsocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. + { + $liste=array(); + $soc=new Societe($this->db); + $soc->fetch($this->withtosocid); + foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value) + { + $liste[$key]=$value; + } + $out.= " ".$langs->trans("or")." "; + $out.= $form->selectarray("receiverccc", $liste, GETPOST("receiverccc"), 1); + } + } + //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); + $out.= "\n"; + } + + // Ask delivery receipt + if (! empty($this->withdeliveryreceipt)) + { + $out.= ''.$langs->trans("DeliveryReceipt").''; + + if (! empty($this->withdeliveryreceiptreadonly)) + { + $out.= yn($this->withdeliveryreceipt); + } + else + { + $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:0), 1); + } + + $out.= "\n"; + } + + // Topic + if (! empty($this->withtopic)) + { + $this->withtopic=make_substitutions($this->withtopic,$this->substit); + + $out.= ''; + $out.= ''.$langs->trans("MailTopic").''; + $out.= ''; + if ($this->withtopicreadonly) + { + $out.= $this->withtopic; + $out.= ''; + } + else + { + $out.= 'withtopic) .'" />'; + } + $out.= "\n"; + } + + // Attached files + if (! empty($this->withfile)) + { + $out.= ''; + $out.= ''.$langs->trans("MailFile").''; + $out.= ''; + // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript + $out.= ''."\n"; + $out.= ''."\n"; + if (count($listofpaths)) + { + foreach($listofpaths as $key => $val) + { + $out.= '
'; + $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; + if (! $this->withfilereadonly) + { + $out.= ' '; + //$out.= ' '.img_delete($langs->trans("Delete").''; + } + $out.= '
'; + } + } + else + { + $out.= $langs->trans("NoAttachedFiles").'
'; + } + if ($this->withfile == 2) // Can add other files + { + $out.= ''; + $out.= ' '; + $out.= ''; + } + $out.= "\n"; + } + + // Message + if (! empty($this->withbody)) + { + $defaultmessage=""; + + // TODO A partir du type, proposer liste de messages dans table llx_models + if ($this->param["models"]=='facture_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoice"); } + elseif ($this->param["models"]=='facture_relance') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + elseif ($this->param["models"]=='propal_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($this->param["models"]=='order_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendOrder"); } + elseif ($this->param["models"]=='order_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + elseif ($this->param["models"]=='invoice_supplier_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + elseif ($this->param["models"]=='shipping_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendShipping"); } + elseif ($this->param["models"]=='fichinter_send') { $defaultmessage=$langs->transnoentities("PredefinedMailContentSendFichInter"); } + elseif (! is_numeric($this->withbody)) { $defaultmessage=$this->withbody; } + + // Complete substitution array + if (! empty($conf->paypal->enabled) && ! empty($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=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url); + } + if ($this->param["models"]=='facture_send') + { + $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__FACREF__']); + $this->substit['__PERSONALIZED__']=$langs->transnoentitiesnoconv("PredefinedMailContentLink",$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 (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; + + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72); + $out.= $doleditor->Create(1); + } + $out.= "\n"; + } + + if (! empty($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 (! empty($this->withform)) $out.= ''."\n"; + $out.= "\n"; + + return $out; } } From dde873899974f9fb473f10b93ede74587dbc08fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 11:30:28 +0100 Subject: [PATCH 13/32] Qual: Add a protection to detect bad usage of getStaticMember --- htdocs/core/lib/functions.lib.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3a17c270544..fa0a1c22619 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -51,15 +51,18 @@ function getStaticMember($class, $member) $classObj = new ReflectionClass($class); $result = null; + $found=0; foreach($classObj->getStaticProperties() as $prop => $value) { - if($prop == $member) + if ($prop == $member) { $result = $value; + $found++; break; } } + if (! $found) dol_print_error('','Try to get a static member "'.$member.'" in class "'.$class.'" that does not exists or is not static.'); return $result; } @@ -2122,7 +2125,7 @@ function dol_print_error($db='',$error='') $out.="
\n"; $out.="".$langs->trans("RequestedUrl").": ".$_SERVER["REQUEST_URI"]."
\n";; $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:'')."
\n";; - $out.="".$langs->trans("MenuManager").": ".$conf->standard_menu."
\n"; + $out.="".$langs->trans("MenuManager").": ".(isset($conf->standard_menu)?$conf->standard_menu:'')."
\n"; $out.="
\n"; $syslog.="url=".$_SERVER["REQUEST_URI"]; $syslog.=", query_string=".$_SERVER["QUERY_STRING"]; From 1b8634588f1ec7ca32b155732e0543fbfd68767c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 11:31:44 +0100 Subject: [PATCH 14/32] Fix: Missing property --- htdocs/core/db/pgsql.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 695ab573fc4..ecb17b8a9f0 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -41,7 +41,9 @@ class DoliDBPgsql //! Database label static $label='PostgreSQL'; // Label of manager //! Charset - var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value + var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value + //! Collate used to force collate when creating database + var $forcecollate=''; // Can't be static as it may be forced with a dynamic value //! Version min database static $versionmin=array(8,4,0); // Version min database From eeba48f9b094fde9e93ae9739f5b108b0ad04afc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 11:43:49 +0100 Subject: [PATCH 15/32] Fix: Log not reported Fix: charset not correctly forced --- htdocs/install/etape1.php | 11 +++++++---- htdocs/install/inc.php | 22 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 32717e18b80..009d953e73d 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -255,8 +255,10 @@ if (! $error && $db->connected) { if (! empty($_POST["db_create_database"])) // If we create database, we force default value { - $defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); - $defaultDBSortingCollation=getStaticMember(get_class($db),'forcecollate'); + //$defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); + //$defaultDBSortingCollation=getStaticMember(get_class($db),'forcecollate'); + $defaultCharacterSet=$db->forcecharset; + $defaultDBSortingCollation=$db->forcecollate; } else // If already created, we take current value { @@ -268,6 +270,7 @@ if (! $error && $db->connected) print ''; $db_character_set=$defaultCharacterSet; $db_collation=$defaultDBSortingCollation; + dolibarr_install_syslog("db_character_set=".$db_character_set." db_collation=".$db_collation); } @@ -559,8 +562,8 @@ if (! $error && $db->connected && $action == "set") // If database creation is asked, we create it if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on")) { - dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name, LOG_DEBUG); - $newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); + dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name." ".$dolibarr_main_db_character_set." ".$dolibarr_main_db_collation." ".$dolibarr_main_db_user, LOG_DEBUG); + $newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); //print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit; if ($newdb->connected) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 9e8565402d2..866bb471d78 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -200,6 +200,7 @@ if (constant('DOL_DATA_ROOT') && file_exists($lockfile)) // Force usage of log file for install and upgrades $conf->syslog->enabled=1; $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG'); +if (! defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS','["mod_syslog_file"]'); if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined { if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log'); @@ -314,7 +315,26 @@ function conf($dolibarr_main_document_root) //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1); - + // We init log handler for install + $handlers = array('mod_syslog_file'); + foreach ($handlers as $handler) + { + $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php'; + if (!file_exists($file)) + { + throw new Exception('Missing log handler file '.$handler.'.php'); + } + + require_once $file; + $loghandlerinstance = new $handler(); + if (!$loghandlerinstance instanceof LogHandlerInterface) + { + throw new Exception('Log handler does not extend LogHandlerInterface'); + } + + $conf->loghandlers[]=$loghandlerinstance; + } + return 1; } From abd8aea06b97f8eb3839c00fb5370da5b41a032d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 11:56:45 +0100 Subject: [PATCH 16/32] Fix: Log not reported Fix: charset not correctly forced Conflicts: htdocs/install/inc.php --- htdocs/install/etape1.php | 11 +++++++---- htdocs/install/inc.php | 23 +++++++++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 32717e18b80..009d953e73d 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -255,8 +255,10 @@ if (! $error && $db->connected) { if (! empty($_POST["db_create_database"])) // If we create database, we force default value { - $defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); - $defaultDBSortingCollation=getStaticMember(get_class($db),'forcecollate'); + //$defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); + //$defaultDBSortingCollation=getStaticMember(get_class($db),'forcecollate'); + $defaultCharacterSet=$db->forcecharset; + $defaultDBSortingCollation=$db->forcecollate; } else // If already created, we take current value { @@ -268,6 +270,7 @@ if (! $error && $db->connected) print ''; $db_character_set=$defaultCharacterSet; $db_collation=$defaultDBSortingCollation; + dolibarr_install_syslog("db_character_set=".$db_character_set." db_collation=".$db_collation); } @@ -559,8 +562,8 @@ if (! $error && $db->connected && $action == "set") // If database creation is asked, we create it if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on")) { - dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name, LOG_DEBUG); - $newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); + dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name." ".$dolibarr_main_db_character_set." ".$dolibarr_main_db_collation." ".$dolibarr_main_db_user, LOG_DEBUG); + $newdb=getDoliDBInstance($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port); //print 'eee'.$conf->db->type." ".$conf->db->host." ".$userroot." ".$passroot." ".$conf->db->port." ".$newdb->connected." ".$newdb->forcecharset;exit; if ($newdb->connected) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 354ad1e8cbe..f078f7a1802 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -200,6 +200,7 @@ if (constant('DOL_DATA_ROOT') && file_exists($lockfile)) // Force usage of log file for install and upgrades $conf->syslog->enabled=1; $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG'); +if (! defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS','["mod_syslog_file"]'); if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined { if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log'); @@ -230,7 +231,6 @@ foreach ($handlers as $handler) $conf->loghandlers[]=$loghandlerinstance; } - // Removed magic_quotes if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP 5.4 { @@ -314,7 +314,26 @@ function conf($dolibarr_main_document_root) //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; } if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1); - + // We init log handler for install + $handlers = array('mod_syslog_file'); + foreach ($handlers as $handler) + { + $file = DOL_DOCUMENT_ROOT.'/core/modules/syslog/'.$handler.'.php'; + if (!file_exists($file)) + { + throw new Exception('Missing log handler file '.$handler.'.php'); + } + + require_once $file; + $loghandlerinstance = new $handler(); + if (!$loghandlerinstance instanceof LogHandlerInterface) + { + throw new Exception('Log handler does not extend LogHandlerInterface'); + } + + $conf->loghandlers[]=$loghandlerinstance; + } + return 1; } From b98151db9463ed9145748c81e522ac5392bdd30c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 12:22:12 +0100 Subject: [PATCH 17/32] Fix: A log handler can be loaded twice. --- htdocs/core/class/conf.class.php | 2 +- htdocs/install/etape5.php | 4 ++++ htdocs/install/inc.php | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 75414d8f109..500d215ef44 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -454,7 +454,7 @@ class Conf throw new Exception('Log handler does not extend LogHandlerInterface'); } - $this->loghandlers[]=$loghandlerinstance; + $this->loghandlers[$handler]=$loghandlerinstance; } } } diff --git a/htdocs/install/etape5.php b/htdocs/install/etape5.php index 4f7803c9786..1fb4f45e80f 100644 --- a/htdocs/install/etape5.php +++ b/htdocs/install/etape5.php @@ -142,6 +142,10 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); + // Create the global $hookmanager object + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($db); + $ok = 0; // If first install diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 866bb471d78..18648ab8680 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -228,7 +228,7 @@ foreach ($handlers as $handler) throw new Exception('Log handler does not extend LogHandlerInterface'); } - $conf->loghandlers[]=$loghandlerinstance; + if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler]=$loghandlerinstance; } @@ -331,8 +331,8 @@ function conf($dolibarr_main_document_root) { throw new Exception('Log handler does not extend LogHandlerInterface'); } - - $conf->loghandlers[]=$loghandlerinstance; + + if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler]=$loghandlerinstance; } return 1; From db38c9baac84145c09068443e0eae35d72dfd3f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 12:35:29 +0100 Subject: [PATCH 18/32] Fix: loghandler loaded twice --- htdocs/core/class/conf.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 500d215ef44..685dfa93b9a 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -454,7 +454,7 @@ class Conf throw new Exception('Log handler does not extend LogHandlerInterface'); } - $this->loghandlers[$handler]=$loghandlerinstance; + if (empty($conf->loghandlers[$handler])) $this->loghandlers[$handler]=$loghandlerinstance; } } } From a8ccc0ab0b0cd3b3ec716f96b74ceef5db9ec2a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 12:36:15 +0100 Subject: [PATCH 19/32] Fix: loghandler loaded twice. --- htdocs/core/class/conf.class.php | 2 +- htdocs/install/inc.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 2d9fb472407..e456effe66e 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -466,7 +466,7 @@ class Conf throw new Exception('Log handler does not extend LogHandlerInterface'); } - $this->loghandlers[]=$loghandlerinstance; + if (empty($conf->loghandlers[$handler])) $this->loghandlers[$handler]=$loghandlerinstance; } } } diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index f078f7a1802..12c58371b29 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -228,7 +228,7 @@ foreach ($handlers as $handler) throw new Exception('Log handler does not extend LogHandlerInterface'); } - $conf->loghandlers[]=$loghandlerinstance; + if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler]=$loghandlerinstance; } // Removed magic_quotes @@ -331,7 +331,7 @@ function conf($dolibarr_main_document_root) throw new Exception('Log handler does not extend LogHandlerInterface'); } - $conf->loghandlers[]=$loghandlerinstance; + if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler]=$loghandlerinstance; } return 1; From ac3ccade985387beca8e7f7c1b2cf6bb9d71a79a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 13:11:12 +0100 Subject: [PATCH 20/32] Fix: number of chars to low to show value. --- htdocs/core/modules/syslog/mod_syslog_file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index b00fa11945a..b0e1bd550b4 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -138,7 +138,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface LOG_DEBUG => 'DEBUG' ); - $message = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".sprintf("%-5s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident>0?str_pad('',$this->ident,' '):'').$content['message']; + $message = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".sprintf("%-7s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident>0?str_pad('',$this->ident,' '):'').$content['message']; fwrite($filefd, $message."\n"); fclose($filefd); From c42a0c5b035d40a74a804fcf6c757f9107984e61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 14:40:15 +0100 Subject: [PATCH 21/32] Fix: removed warning --- htdocs/admin/company.php | 6 ++--- htdocs/core/menus/standard/eldy.lib.php | 16 +++++------ htdocs/main.inc.php | 2 +- htdocs/societe/class/societe.class.php | 35 +++++++++++++------------ 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index bc61dad4aed..28336d2966a 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -646,13 +646,13 @@ else print ''; $var=!$var; - print ''.$langs->trans("CompanyAddress").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_ADRESSE) . ''; + print ''.$langs->trans("CompanyAddress").'' . nl2br(empty($conf->global->MAIN_INFO_SOCIETE_ADRESSE)?'':$conf->global->MAIN_INFO_SOCIETE_ADRESSE) . ''; $var=!$var; - print ''.$langs->trans("CompanyZip").'' . $conf->global->MAIN_INFO_SOCIETE_CP . ''; + print ''.$langs->trans("CompanyZip").'' . (empty($conf->global->MAIN_INFO_SOCIETE_CP)?'':$conf->global->MAIN_INFO_SOCIETE_CP) . ''; $var=!$var; - print ''.$langs->trans("CompanyTown").'' . $conf->global->MAIN_INFO_SOCIETE_VILLE . ''; + print ''.$langs->trans("CompanyTown").'' . (empty($conf->global->MAIN_INFO_SOCIETE_VILLE)?'':$conf->global->MAIN_INFO_SOCIETE_VILLE) . ''; $var=!$var; print ''.$langs->trans("CompanyCountry").''; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 67b6b816ea9..c837de7c9fb 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -68,7 +68,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Third parties - $tmpentry=array('enabled'=>($conf->societe->enabled || $conf->fournisseur->enabled), 'perms'=>($user->rights->societe->lire || $user->rights->fournisseur->lire), 'module'=>'societe|fournisseur'); + $tmpentry=array('enabled'=>(! empty($conf->societe->enabled) || ! empty($conf->fournisseur->enabled)), 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), 'module'=>'societe|fournisseur'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { @@ -110,7 +110,7 @@ function print_eldy_menu($db,$atarget,$type_user) } // Products-Services - $tmpentry=array('enabled'=>($conf->product->enabled || $conf->service->enabled), 'perms'=>($user->rights->produit->lire || $user->rights->service->lire), 'module'=>'product|service'); + $tmpentry=array('enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)), 'module'=>'product|service'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { @@ -160,7 +160,7 @@ function print_eldy_menu($db,$atarget,$type_user) if (! empty($conf->fournisseur->enabled)) $menuqualified++; if (! empty($conf->contrat->enabled)) $menuqualified++; if (! empty($conf->ficheinter->enabled)) $menuqualified++; - $tmpentry=array('enabled'=>$menuqualified, 'perms'=>($user->rights->societe->lire || $user->rights->societe->contact->lire), 'module'=>'propal|commande|fournisseur|contrat|ficheinter'); + $tmpentry=array('enabled'=>$menuqualified, 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), 'module'=>'propal|commande|fournisseur|contrat|ficheinter'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { @@ -201,7 +201,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Financial $tmpentry=array('enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->don->enabled) || ! empty($conf->tax->enabled)), - 'perms'=>($user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->facture->lire || $user->rights->deplacement->lire || $user->rights->don->lire || $user->rights->tax->charges->lire), + 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->plancompte->lire) || ! empty($user->rights->facture->lire) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire)), 'module'=>'comptabilite|accounting|facture|deplacement|don|tax'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -243,7 +243,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Bank $tmpentry=array('enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)), - 'perms'=>($user->rights->banque->lire || $user->rights->prelevement->lire), + 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)), 'module'=>'banque|prelevement'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -286,7 +286,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Projects $tmpentry=array('enabled'=>(! empty($conf->projet->enabled)), - 'perms'=>($user->rights->projet->lire), + 'perms'=>(! empty($user->rights->projet->lire)), 'module'=>'projet'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -328,7 +328,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Tools $tmpentry=array('enabled'=>(! empty($conf->mailing->enabled) || ! empty($conf->export->enabled) || ! empty($conf->import->enabled)), - 'perms'=>($user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run), + 'perms'=>(! empty($user->rights->mailing->lire) || ! empty($user->rights->export->lire) || ! empty($user->rights->import->run)), 'module'=>'mailing|export|import'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -400,7 +400,7 @@ function print_eldy_menu($db,$atarget,$type_user) // Members $tmpentry=array('enabled'=>(! empty($conf->adherent->enabled)), - 'perms'=>($user->rights->adherent->lire), + 'perms'=>(! empty($user->rights->adherent->lire)), 'module'=>'adherent'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ec82c9e7e41..2695a2fd3d0 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1347,7 +1347,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a && $_SESSION["dol_authmode"] != 'http') { $logouttext .='trans('Logout'), 'logout.png', 'class="login"'); $logouttext .=''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 269f428a61a..db147ffde86 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2504,17 +2504,18 @@ class Societe extends CommonObject global $langs; $this->id=0; - $this->name=(! empty($conf->global->MAIN_INFO_SOCIETE_NOM))?$conf->global->MAIN_INFO_SOCIETE_NOM:''; - $this->nom=$this->name; // deprecated - $this->address=(! empty($conf->global->MAIN_INFO_SOCIETE_ADRESSE))?$conf->global->MAIN_INFO_SOCIETE_ADRESSE:''; - $this->adresse=$this->address; // deprecated - $this->zip=(! empty($conf->global->MAIN_INFO_SOCIETE_CP))?$conf->global->MAIN_INFO_SOCIETE_CP:''; - $this->cp=$this->zip; // deprecated - $this->town=(! empty($conf->global->MAIN_INFO_SOCIETE_VILLE))?$conf->global->MAIN_INFO_SOCIETE_VILLE:''; - $this->ville=$this->town; // deprecated - $this->state_id=$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT; + $this->name=empty($conf->global->MAIN_INFO_SOCIETE_NOM)?'':$conf->global->MAIN_INFO_SOCIETE_NOM; + $this->address=empty($conf->global->MAIN_INFO_SOCIETE_ADRESSE)?'':$conf->global->MAIN_INFO_SOCIETE_ADRESSE; + $this->zip=empty($conf->global->MAIN_INFO_SOCIETE_CP)?'':$conf->global->MAIN_INFO_SOCIETE_CP; + $this->town=empty($conf->global->MAIN_INFO_SOCIETE_VILLE)?'':$conf->global->MAIN_INFO_SOCIETE_VILLE; + $this->state_id=empty($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT)?'':$conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT; $this->note=empty($conf->global->MAIN_INFO_SOCIETE_NOTE)?'':$conf->global->MAIN_INFO_SOCIETE_NOTE; - + + $this->nom=$this->name; // deprecated + $this->adresse=$this->address; // deprecated + $this->cp=$this->zip; // deprecated + $this->ville=$this->town; // deprecated + // We define country_id, country_code and country $country_id=$country_code=$country_label=''; if (! empty($conf->global->MAIN_INFO_SOCIETE_PAYS)) @@ -2553,13 +2554,13 @@ class Societe extends CommonObject $this->idprof4=empty($conf->global->MAIN_INFO_RCS)?'':$conf->global->MAIN_INFO_RCS; $this->idprof5=empty($conf->global->MAIN_INFO_PROFID5)?'':$conf->global->MAIN_INFO_PROFID5; $this->idprof6=empty($conf->global->MAIN_INFO_PROFID6)?'':$conf->global->MAIN_INFO_PROFID6; - $this->tva_intra=(! empty($conf->global->MAIN_INFO_TVAINTRA))?$conf->global->MAIN_INFO_TVAINTRA:''; // VAT number, not necessarly INTRA. - $this->capital=(! empty($conf->global->MAIN_INFO_CAPITAL))?$conf->global->MAIN_INFO_CAPITAL:''; - $this->forme_juridique_code=$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE; - $this->email=(! empty($conf->global->MAIN_INFO_SOCIETE_MAIL))?$conf->global->MAIN_INFO_SOCIETE_MAIL:''; - $this->logo=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO))?$conf->global->MAIN_INFO_SOCIETE_LOGO:''; - $this->logo_small=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL))?$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL:''; - $this->logo_mini=(! empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI))?$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI:''; + $this->tva_intra=empty($conf->global->MAIN_INFO_TVAINTRA)?'':$conf->global->MAIN_INFO_TVAINTRA; // VAT number, not necessarly INTRA. + $this->capital=empty($conf->global->MAIN_INFO_CAPITAL)?'':$conf->global->MAIN_INFO_CAPITAL; + $this->forme_juridique_code=empty($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE)?'':$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE; + $this->email=empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?'':$conf->global->MAIN_INFO_SOCIETE_MAIL; + $this->logo=empty($conf->global->MAIN_INFO_SOCIETE_LOGO)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO; + $this->logo_small=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL; + $this->logo_mini=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; // Define if company use vat or not (Do not use conf->global->FACTURE_TVAOPTION anymore) $this->tva_assuj=((isset($conf->global->FACTURE_TVAOPTION) && $conf->global->FACTURE_TVAOPTION=='franchise')?0:1); From 0743049dc4276c7eb67afaf3aa24d3ffab8cd457 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2013 14:57:37 +0100 Subject: [PATCH 22/32] Fix: get list of currencies --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a804948bf1d..e71a0f6eafe 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3005,14 +3005,14 @@ class Form { global $conf,$langs,$user; - $langs->load_cache_currencies(); + $langs->load_cache_currencies(''); $out=''; if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilite $out.= ' blocks. - * - * @access public - * - * @param string $buffer The source text to be filtered. - * - * @return string The filtered text. - * - */ - - public static function filter($buffer) - { - // Pull out the script blocks - preg_match_all("!]+>.*?!is", $buffer, $match); - $script_blocks = $match[0]; - $buffer = preg_replace( - "!]+>.*?!is", - '@@@SAVANT:TRIM:SCRIPT@@@', - $buffer - ); - - // Pull out the pre blocks - preg_match_all("!]*>.*?!is", $buffer, $match); - $pre_blocks = $match[0]; - $buffer = preg_replace( - "!]*>.*?!is", - '@@@SAVANT:TRIM:PRE@@@', - $buffer - ); - - // Pull out the textarea blocks - preg_match_all("!]+>.*?!is", $buffer, $match); - $textarea_blocks = $match[0]; - $buffer = preg_replace( - "!]+>.*?!is", - '@@@SAVANT:TRIM:TEXTAREA@@@', - $buffer - ); - - // remove all leading spaces, tabs and carriage returns NOT - // preceeded by a php close tag. - $buffer = trim(preg_replace('/((?)\n)[\s]+/m', '\1', $buffer)); - - // replace script blocks - Savant3_Filter_trimwhitespace::replace( - "@@@SAVANT:TRIM:SCRIPT@@@", - $script_blocks, - $buffer - ); - - // replace pre blocks - Savant3_Filter_trimwhitespace::replace( - "@@@SAVANT:TRIM:PRE@@@", - $pre_blocks, - $buffer - ); - - // replace textarea blocks - Savant3_Filter_trimwhitespace::replace( - "@@@SAVANT:TRIM:TEXTAREA@@@", - $textarea_blocks, - $buffer - ); - - return $buffer; - } - - - /** - * - * Does a simple search-and-replace on the source text. - * - * @access protected - * - * @param string $search The string to search for. - * - * @param string $replace Replace with this text. - * - * @param string &$buffer The source text. - * - * @return string The text after search-and-replace. - * - */ - - protected static function replace($search, $replace, &$buffer) - { - $len = strlen($search); - $pos = 0; - $count = count($replace); - - for ($i = 0; $i < $count; $i++) { - // does the search-string exist in the buffer? - $pos = strpos($buffer, $search, $pos); - if ($pos !== false) { - // replace the search-string - $buffer = substr_replace($buffer, $replace[$i], $pos, $len); - } else { - break; - } - } - } -} -?> \ No newline at end of file diff --git a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_ahref.php b/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_ahref.php deleted file mode 100644 index 6d6bb319bb3..00000000000 --- a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_ahref.php +++ /dev/null @@ -1,109 +0,0 @@ -... tag. -* -* @package Savant3 -* -* @author Paul M. Jones -* -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* -* @version $Id: Savant3_Plugin_ahref.php,v 1.4 2005/08/09 12:56:14 pmjones Exp $ -* -*/ - -/** -* -* Generates an ... tag. -* -* @package Savant3 -* -* @author Paul M. Jones -* -*/ - -class Savant3_Plugin_ahref extends Savant3_Plugin { - - /** - * - * Generate an HTML ... tag. - * - * @access public - * - * @param string|array $href A string URL for the resulting tag. May - * also be an array with any combination of the keys 'scheme', - * 'host', 'path', 'query', and 'fragment' (c.f. PHP's native - * parse_url() function). - * - * @param string $text The displayed text of the link. - * - * @param string|array $attr Any extra attributes for the tag. - * - * @return string The ... tag. - * - */ - - public function ahref($href, $text, $attr = null) - { - $html = ' $val) { - $key = htmlspecialchars($key); - $val = htmlspecialchars($val); - $html .= " $key=\"$val\""; - } - } elseif (! is_null($attr)) { - // from scalar - $html .= htmlspecialchars(" $attr"); - } - - // set the link text, close the tag, and return - $html .= '>' . $text . ''; - return $html; - } -} -?> \ No newline at end of file diff --git a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_date.php b/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_date.php deleted file mode 100644 index c35db4ca7b6..00000000000 --- a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_date.php +++ /dev/null @@ -1,123 +0,0 @@ - -* -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* -* @version $Id: Savant3_Plugin_date.php,v 1.3 2005/03/07 14:40:16 pmjones Exp $ -* -*/ - -/** -* -* Plugin to generate a formatted date using strftime() conventions. -* -* @package Savant3 -* -* @author Paul M. Jones -* -*/ - -class Savant3_Plugin_date extends Savant3_Plugin { - - /** - * - * The default strftime() format string. - * - * @access public - * - * @var array - * - */ - - public $default = '%c'; - - - /** - * - * Custom strftime() format strings to use for dates. - * - * You can preset the format strings via Savant3::setPluginConf(). - * - * - * $conf = array( - * 'custom' => array( - * 'mydate' => '%Y-%m-%d', - * 'mytime' => '%R' - * ) - * ); - * - * $Savant->setPluginConf('date', $conf); - * - * - * ... and in your template, to use a preset custom string by name: - * - * - * echo $this->date($value, 'mydate'); - * - * - * @access public - * - * @var array - * - */ - - public $custom = array( - 'date' => '%Y-%m-%d', - 'time' => '%H:%M:%S' - ); - - - /** - * - * Outputs a formatted date using strftime() conventions. - * - * @access public - * - * @param string $datestring Any date-time string suitable for - * strtotime(). - * - * @param string $format The strftime() formatting string, or a named - * custom string key from $this->custom. - * - * @return string The formatted date string. - * - */ - - function date($datestring, $format = null) - { - settype($format, 'string'); - - if (is_null($format)) { - $format = $this->default; - } - - // does the format string have a % sign in it? - if (strpos($format, '%') === false) { - // no, look for a custom format string - if (! empty($this->custom[$format])) { - // found a custom format string - $format = $this->custom[$format]; - } else { - // did not find the custom format, revert to default - $format = $this->default; - } - } - - // convert the date string to the specified format - if (trim($datestring != '')) { - return strftime($format, strtotime($datestring)); - } else { - // no datestring, return VOID - return; - } - } - -} -?> \ No newline at end of file diff --git a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_htmlAttribs.php b/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_htmlAttribs.php deleted file mode 100644 index 09257f77cf7..00000000000 --- a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_htmlAttribs.php +++ /dev/null @@ -1,63 +0,0 @@ - -* -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* -* @version $Id: Savant3_Plugin_htmlAttribs.php,v 1.3 2005/09/12 17:49:27 pmjones Exp $ -* -*/ - -/** -* -* Plugin to convert an associative array to a string of tag attributes. -* -* @package Savant3 -* -* @author Paul M. Jones -* -*/ - -class Savant3_Plugin_htmlAttribs extends Savant3_Plugin { - - /** - * - * Converts an associative array to a string of tag attributes. - * - * @access public - * - * @param array $attribs From this array, each key-value pair is - * converted to an attribute name and value. - * - * @return string The XHTML for the attributes. - * - */ - - public function htmlAttribs($attribs) - { - $xhtml = ''; - foreach ((array) $attribs as $key => $val) { - - if ($val === null) { - continue; - } - - if (is_array($val)) { - $val = implode(' ', $val); - } - - $key = htmlspecialchars($key); - $val = htmlspecialchars($val); - - $xhtml .= " $key=\"$val\""; - } - return $xhtml; - } -} -?> \ No newline at end of file diff --git a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_image.php b/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_image.php deleted file mode 100644 index 4b316e7537c..00000000000 --- a/htdocs/includes/savant/Savant3/resources/Savant3_Plugin_image.php +++ /dev/null @@ -1,199 +0,0 @@ - tag. -* -* @package Savant3 -* -* @author Paul M. Jones -* -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* -* @version $Id: Savant3_Plugin_image.php,v 1.7 2005/08/12 14:34:09 pmjones Exp $ -* -*/ - -/** -* -* Plugin to generate an tag. -* -* Support for alpha transparency of PNG files in Microsoft IE added by -* Edward Ritter; thanks, Edward. -* -* @package Savant3 -* -* @author Paul M. Jones -* -*/ - -class Savant3_Plugin_image extends Savant3_Plugin { - - - /** - * - * The document root. - * - * @access public - * - * @var string - * - */ - - protected $documentRoot = null; - - - /** - * - * The base directory for images within the document root. - * - * @access public - * - * @var string - * - */ - - protected $imageDir = null; - - - /** - * - * Outputs an tag. - * - * Microsoft IE alpha PNG support added by Edward Ritter. - * - * @access public - * - * @param string $file The path to the image on the local file system - * relative to $this->imageDir. - * - * @param string $alt Alternative descriptive text for the image; - * defaults to the filename of the image. - * - * @param int $border The border width for the image; defaults to zero. - * - * @param int $width The displayed image width in pixels; defaults to - * the width of the image. - * - * @param int $height The displayed image height in pixels; defaults to - * the height of the image. - * - * @return string An tag. - * - */ - - public function image($file, $alt = null, $height = null, $width = null, - $attr = null) - { - // is the document root set? - if (is_null($this->documentRoot) && isset($_SERVER['DOCUMENT_ROOT'])) { - // no, so set it - $this->documentRoot = $_SERVER['DOCUMENT_ROOT']; - } - - // make sure there's a DIRECTORY_SEPARATOR between the docroot - // and the image dir - if (substr($this->documentRoot, -1) != DIRECTORY_SEPARATOR && - substr($this->imageDir, 0, 1) != DIRECTORY_SEPARATOR) { - $this->documentRoot .= DIRECTORY_SEPARATOR; - } - - // make sure there's a separator between the imageDir and the - // file name - if (substr($this->imageDir, -1) != DIRECTORY_SEPARATOR && - substr($file, 0, 1) != DIRECTORY_SEPARATOR) { - $this->imageDir .= DIRECTORY_SEPARATOR; - } - - // the image file type code (PNG = 3) - $type = null; - - // get the file information - $info = false; - - if (strpos($file, '://') === false) { - // no "://" in the file, so it's local - $file = $this->imageDir . $file; - $tmp = $this->documentRoot . $file; - $info = @getimagesize($tmp); - } else { - // don't attempt to get file info from streams, it takes - // way too long. - $info = false; - } - - // did we find the file info? - if (is_array($info)) { - - // capture type info regardless - $type = $info[2]; - - // capture size info where both not specified - if (is_null($width) && is_null($height)) { - $width = $info[0]; - $height = $info[1]; - } - } - - // clean up - unset($info); - - // is the file a PNG? if so, check user agent, we will need to - // make special allowances for Microsoft IE. - if (stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && $type === 3) { - - // support alpha transparency for PNG files in MSIE - $html = 'Savant->htmlAttribs($attr); - - // done - $html .= '>'; - - } else { - - // not IE, so build a normal image tag. - $html = 'Savant->htmlAttribs($attr); - - // done - $html .= ' />'; - - } - - // done! - return $html; - } -} - -?> \ No newline at end of file From a177853299e92f3eac71cced8ce0bd3e46767e82 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 28 Jan 2013 20:30:33 +0100 Subject: [PATCH 27/32] =?UTF-8?q?Fix:=20la=20b=C3=A9tise=20n'a=20pas=20de?= =?UTF-8?q?=20limite=20!=20restons=20archa=C3=AFque.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/main.inc.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2695a2fd3d0..f7081340f8a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -675,14 +675,6 @@ if (! defined('NOREQUIRETRAN')) } } -// Use php template engine -if (! empty($conf->global->MAIN_USE_TEMPLATE_ENGINE) && ! defined('NOTEMPLATEENGINE')) -{ - require_once DOL_DOCUMENT_ROOT.'/includes/savant/Savant3.php'; - - $tpl = new Savant3(); -} - // Case forcing style from url if (GETPOST('theme')) { @@ -832,7 +824,7 @@ if (! function_exists("llxHeader")) function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='') { global $conf; - + // html header top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); @@ -845,7 +837,7 @@ if (! function_exists("llxHeader")) { left_menu('', $help_url, '', '', 1, $title); } - + // main area main_area($title); } From ed92e91cc0a8e04a39ac9cea139d1495733898af Mon Sep 17 00:00:00 2001 From: jfefe Date: Tue, 29 Jan 2013 03:59:23 +0100 Subject: [PATCH 28/32] Fix : wrong value for contact_id when call getUser webservice method (contact_id is variable name in user.class) --- htdocs/webservices/server_user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index 82f8afbd8bf..226f061ba68 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -327,7 +327,7 @@ function getUser($authentication,$id,$ref='',$ref_ext='') 'datec' => dol_print_date($user->datec,'dayhourrfc'), 'datem' => dol_print_date($user->datem,'dayhourrfc'), 'fk_thirdparty' => $user->societe_id, -'fk_socpeople' => $user->fk_socpeople, +'fk_socpeople' => $user->contact_id, 'fk_member' => $user->fk_member, 'webcal_login' => $user->webcal_login, 'phenix_login' => $user->phenix_login, From 180fb2c91a66a4cf3b9f901be827fefa55be576f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Jan 2013 15:22:07 +0100 Subject: [PATCH 29/32] Fix: Option COMPANY_USE_SEARCH_TO_SELECT was not working for third party selection when autocomplete is on. --- htdocs/core/class/html.form.class.php | 17 +++++++++++++++-- htdocs/core/js/lib_head.js | 8 +++++++- htdocs/core/lib/ajax.lib.php | 3 ++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e71a0f6eafe..f31cb0f741e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -688,8 +688,21 @@ class Form if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && ! $forcecombo) { //$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); - - $out.= ajax_combobox($htmlname, $event); + $out.= ajax_combobox($htmlname, $event, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); + /* + if ($selected && empty($selected_input_value)) + { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $product = new Product($this->db); + $product->fetch($selected); + $selected_input_value=$product->ref; + } + // mode=1 means customers products + $ajaxoptions=array(); + $urloption='htmlname='.$htmlname.'&outjson=1&filter='.urlencode($filter).'&showtype='.$showtype; + $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); + $out.=''; + */ } $out.= '