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/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(); diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index 4cf1e0b7d89..ea481c64661 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -189,7 +189,7 @@ if (! empty($conf->banque->enabled)) else { print ''; - print $langs->trans("WarningModuleNotActive",$langs->transnoentities("Module85Name")).' '.img_warning("",""); + print $langs->trans("WarningModuleNotActive",$langs->transnoentities("Module85Name")); print ''; } print "\n"; 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/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/admin/dict.php b/htdocs/admin/dict.php index 56f4f6140bb..d5fe7846714 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 @@ -734,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"); } @@ -848,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"); } 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/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/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/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..31c9e36d898 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')); @@ -123,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); @@ -172,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); @@ -196,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 @@ -373,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); @@ -609,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); } } @@ -816,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']); @@ -937,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']); @@ -983,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) { @@ -1072,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')); @@ -1094,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')); @@ -1628,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) @@ -1640,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); } } @@ -1801,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); /* @@ -1845,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/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..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; @@ -880,8 +879,7 @@ class Commande extends CommonOrder */ function createFromProposal($object) { - global $conf,$user,$langs; - global $hookmanager; + global $conf,$user,$langs,$hookmanager; $error=0; @@ -945,11 +943,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..ccaadefe2ee 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')); @@ -107,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); @@ -174,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); @@ -204,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'); @@ -506,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); } } } @@ -745,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']); @@ -872,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']); @@ -931,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); } } } @@ -970,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); } } } @@ -1023,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; @@ -1043,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; @@ -1072,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) { @@ -1493,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)) @@ -2702,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; @@ -2812,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/conf.class.php b/htdocs/core/class/conf.class.php index 75414d8f109..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[]=$loghandlerinstance; + if (empty($conf->loghandlers[$handler])) $this->loghandlers[$handler]=$loghandlerinstance; } } } 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/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a804948bf1d..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.= ''; - foreach ($this->cache_currencies as $code_iso => $currency) + foreach ($langs->cache_currencies as $code_iso => $currency) { if ($selected && $selected == $code_iso) { 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/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 8e43669b2e8..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)) { @@ -590,18 +589,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/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 diff --git a/htdocs/core/js/lib_head.js b/htdocs/core/js/lib_head.js index 0a0547bf6f3..ba2df7195f8 100644 --- a/htdocs/core/js/lib_head.js +++ b/htdocs/core/js/lib_head.js @@ -771,7 +771,11 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton, */ (function( $ ) { $.widget( "ui.combobox", { + options: { + minLengthToAutocomplete: 0, + }, _create: function() { + var savMinLengthToAutocomplete = this.options.minLengthToAutocomplete; var self = this, select = this.element.hide(), selected = select.children( ":selected" ), @@ -781,7 +785,7 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton, .val( value ) .autocomplete({ delay: 0, - minLength: 0, + minLength: this.options.minLengthToAutocomplete, source: function( request, response ) { var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); response( select.children( "option" ).map(function() { @@ -854,7 +858,9 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton, } // pass empty string as value to search for, displaying all results + input.autocomplete({ minLength: 0 }); input.autocomplete( "search", "" ); + input.autocomplete({ minLength: savMinLengthToAutocomplete }); input.focus(); }); }, diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 8662830a3c4..4f7beb5356b 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -303,11 +303,12 @@ function ajax_dialog($title,$message,$w=350,$h=150) * @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return string Return html string to convert a select field into a combo */ -function ajax_combobox($htmlname, $event=array()) +function ajax_combobox($htmlname, $event=array(), $minLengthToAutocomplete=0) { $msg = ', or - * 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 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/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/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 9e8565402d2..ad9af68a6b9 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'); @@ -227,10 +228,9 @@ 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 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'); + } + + if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler]=$loghandlerinstance; + } + return 1; } diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index 6bbc8320830..e7ac32687cf 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -55,10 +55,10 @@ insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_M insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_SIZE_LISTE_LIMIT','25','chaine','Longueur maximum des listes',0,0); insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_SHOW_WORKBOARD','1','yesno','Affichage tableau de bord de travail Dolibarr',0,0); -insert into llx_const (name, value, type, note, visible) values ('MAIN_MENU_STANDARD','eldy_backoffice.php','chaine','Module de gestion de la barre de menu pour utilisateurs internes',0); -insert into llx_const (name, value, type, note, visible) values ('MAIN_MENUFRONT_STANDARD','eldy_frontoffice.php','chaine','Module de gestion de la barre de menu pour utilisateurs externes',0); -insert into llx_const (name, value, type, note, visible) values ('MAIN_MENU_SMARTPHONE','eldy_backoffice.php','chaine','Module de gestion de la barre de menu smartphone pour utilisateurs internes',0); -insert into llx_const (name, value, type, note, visible) values ('MAIN_MENUFRONT_SMARTPHONE','eldy_frontoffice.php','chaine','Module de gestion de la barre de menu smartphone pour utilisateurs externes',0); +insert into llx_const (name, value, type, note, visible) values ('MAIN_MENU_STANDARD','eldy_menu.php','chaine','Menu manager for internal users',0); +insert into llx_const (name, value, type, note, visible) values ('MAIN_MENUFRONT_STANDARD','eldy_menu.php','chaine','Menu manager for external users',0); +insert into llx_const (name, value, type, note, visible) values ('MAIN_MENU_SMARTPHONE','eldy_menu.php','chaine','Menu manager for internal users using smartphones',0); +insert into llx_const (name, value, type, note, visible) values ('MAIN_MENUFRONT_SMARTPHONE','eldy_menu.php','chaine','Menu manager for external users using smartphones',0); -- 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..0a5a4a94642 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,13 @@ 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'; + +ALTER TABLE llx_user add COLUMN fk_user integer; + diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index bc4d75f0869..3974096085f 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -50,6 +50,7 @@ create table llx_user fk_societe integer, fk_socpeople integer, fk_member integer, + fk_user integer, -- Hierarchic parent note text DEFAULT NULL, datelastlogin datetime, datepreviouslogin datetime, 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..f7081340f8a 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 @@ -677,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')) { @@ -778,21 +768,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 +791,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); @@ -836,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); @@ -849,7 +837,7 @@ if (! function_exists("llxHeader")) { left_menu('', $help_url, '', '', 1, $title); } - + // main area main_area($title); } @@ -1196,12 +1184,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=''; @@ -1337,6 +1320,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'].')'; @@ -1355,7 +1339,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a && $_SESSION["dol_authmode"] != 'http') { $logouttext .='trans('Logout'), 'logout.png', 'class="login"'); $logouttext .=''; @@ -1427,11 +1411,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..41bfa6d3a91 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..db147ffde86 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; @@ -565,55 +565,54 @@ 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++; + } } } - + // Si le fournisseur est classe on l'ajoute $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); + // 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 @@ -984,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); @@ -1064,8 +1064,7 @@ 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); + // 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 @@ -2505,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)) @@ -2554,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); 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..c1dd0c4c09d 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')); @@ -202,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) @@ -227,7 +225,7 @@ if (empty($reshook)) $action = ($action=='add'?'create':'edit'); } } - + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) { @@ -238,7 +236,7 @@ if (empty($reshook)) } } } - + if (! $error) { if ($action == 'add') @@ -397,22 +395,22 @@ 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)) { @@ -869,13 +867,13 @@ else if ($idprof!='-') { if (($j % 2) == 0) print '
'; - + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; if(empty($conf->global->$idprof_mandatory)) print ''; @@ -947,7 +945,7 @@ else // Capital print ''; - // 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") { @@ -970,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 ''; - + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; if(empty($conf->global->$idprof_mandatory)) print ''; @@ -1395,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 ''; } - + if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && $object->fournisseur==1) { print ''; print ''; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 52472297eb2..5b018a768ed 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..e274c9bf1a0 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -72,7 +72,9 @@ $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; $feature2='user'; if ($user->id == $id) { $feature2=''; $canreaduser=1; } // A user can always read its own card -$result = restrictedArea($user, 'user', $id, '&user', $feature2); +if (!$canreaduser) { + $result = restrictedArea($user, 'user', $id, '&user', $feature2); +} if ($user->id <> $id && ! $canreaduser) accessforbidden(); $langs->load("users"); @@ -84,8 +86,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')); 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,
".$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); @@ -1686,7 +1684,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G print ''; - $objectsrc->printOriginLinesList($hookmanager); + $objectsrc->printOriginLinesList(); print '
'; } @@ -2168,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 @@ -2182,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); } } @@ -2356,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 @@ -2399,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/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..4295e1f6fa9 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')); @@ -119,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); @@ -193,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) { @@ -396,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 @@ -473,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); } } } @@ -1186,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']); @@ -1316,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']); @@ -1362,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; @@ -1384,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; @@ -1616,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); @@ -2188,7 +2186,7 @@ if ($action == 'create') print ''; - $objectsrc->printOriginLinesList($hookmanager); + $objectsrc->printOriginLinesList(); print '
'; } @@ -3056,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 @@ -3068,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); } } @@ -3319,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; /* @@ -3384,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 cf7b89be7aa..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; @@ -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/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/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..9578bf54c98 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); @@ -211,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); @@ -1284,7 +1282,7 @@ else if ($user->rights->contrat->creer && ($object->statut >= 0)) { $dateSelector=1; - + print '
'; print ''; // Array with (n*2)+1 lines @@ -1300,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 8b6002c29c5..5c9b8d93122 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2463,21 +2463,16 @@ 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,$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 @@ -2547,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 @@ -2568,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 @@ -2590,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) @@ -2629,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').'
'.$idprof.''; else print ''.$idprof.''; - + $key='idprof'.$i; print $formcompany->get_input_id_prof($i,'idprof'.$i,$object->$key,$object->country_code); print '
'.$langs->trans('Capital').' '.$langs->trans("Currency".$conf->currency).'
'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; @@ -1319,13 +1317,13 @@ else if ($idprof!='-') { if (($j % 2) == 0) print '
'.$idprof.''; else print ''.$idprof.''; - + $key='idprof'.$i; print $formcompany->get_input_id_prof($i,'idprof'.$i,$object->$key,$object->country_code); print '
'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; @@ -1718,7 +1716,7 @@ else print yn($object->localtax2_assuj); print '
'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; @@ -1881,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 '