Browse Source

New: hookmanager class is used frequently and is a factory object, so we
can move it during init of environment and use it globally.

Laurent Destailleur 12 years ago
parent
commit
56e11e52fa
52 changed files with 27 additions and 183 deletions
  1. 1 3
      htdocs/adherents/class/adherent.class.php
  2. 2 2
      htdocs/adherents/class/adherent_type.class.php
  3. 0 2
      htdocs/adherents/fiche.php
  4. 0 2
      htdocs/adherents/type.php
  5. 0 2
      htdocs/admin/dict.php
  6. 0 2
      htdocs/categories/categorie.php
  7. 3 7
      htdocs/comm/action/class/actioncomm.class.php
  8. 0 2
      htdocs/comm/action/fiche.php
  9. 0 2
      htdocs/comm/addpropal.php
  10. 0 2
      htdocs/comm/list.php
  11. 0 2
      htdocs/comm/mailing/fiche.php
  12. 0 2
      htdocs/comm/propal.php
  13. 0 2
      htdocs/comm/propal/list.php
  14. 0 2
      htdocs/comm/prospect/list.php
  15. 1 7
      htdocs/commande/class/commande.class.php
  16. 0 2
      htdocs/commande/fiche.php
  17. 0 2
      htdocs/compta/deplacement/fiche.php
  18. 0 2
      htdocs/compta/dons/fiche.php
  19. 0 2
      htdocs/compta/facture.php
  20. 1 3
      htdocs/compta/facture/class/facture.class.php
  21. 0 2
      htdocs/compta/facture/list.php
  22. 0 2
      htdocs/compta/tva/fiche.php
  23. 1 3
      htdocs/contact/class/contact.class.php
  24. 0 2
      htdocs/contact/fiche.php
  25. 0 2
      htdocs/contrat/fiche.php
  26. 2 6
      htdocs/core/class/commonobject.class.php
  27. 2 10
      htdocs/core/class/html.formfile.class.php
  28. 1 10
      htdocs/core/class/html.formmail.class.php
  29. 2 25
      htdocs/core/lib/files.lib.php
  30. 0 5
      htdocs/core/lib/security2.lib.php
  31. 0 2
      htdocs/expedition/fiche.php
  32. 0 2
      htdocs/fichinter/fiche.php
  33. 0 2
      htdocs/fourn/commande/fiche.php
  34. 0 2
      htdocs/fourn/facture/fiche.php
  35. 0 2
      htdocs/fourn/liste.php
  36. 0 2
      htdocs/index.php
  37. 1 13
      htdocs/main.inc.php
  38. 7 3
      htdocs/master.inc.php
  39. 1 3
      htdocs/product/class/product.class.php
  40. 0 2
      htdocs/product/fiche.php
  41. 0 2
      htdocs/product/fournisseurs.php
  42. 0 2
      htdocs/projet/fiche.php
  43. 0 2
      htdocs/projet/tasks.php
  44. 0 2
      htdocs/projet/tasks/task.php
  45. 0 2
      htdocs/public/demo/index.php
  46. 0 2
      htdocs/societe/agenda.php
  47. 1 5
      htdocs/societe/class/societe.class.php
  48. 0 2
      htdocs/societe/info.php
  49. 0 2
      htdocs/societe/soc.php
  50. 1 3
      htdocs/user/class/user.class.php
  51. 0 2
      htdocs/user/fiche.php
  52. 0 5
      htdocs/user/passwordforgotten.php

+ 1 - 3
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='';

+ 2 - 2
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

+ 0 - 2
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'));
 
 

+ 0 - 2
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'));
 
 /*

+ 0 - 2
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

+ 0 - 2
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'));
 
 

+ 3 - 7
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

+ 0 - 2
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'));
 
 

+ 0 - 2
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'));
 
 /*

+ 0 - 2
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'));
 
 

+ 0 - 2
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

+ 0 - 2
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'));
 
 

+ 0 - 2
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'));
 
 

+ 0 - 2
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'));
 
 

+ 1 - 7
htdocs/commande/class/commande.class.php

@@ -880,8 +880,7 @@ class Commande extends CommonOrder
      */
     function createFromProposal($object)
     {
-        global $conf,$user,$langs;
-        global $hookmanager;
+        global $conf,$user,$langs,$hookmanager;
 
         $error=0;
 
@@ -945,11 +944,6 @@ class Commande extends CommonOrder
             if ($ret > 0)
             {
                 // Actions hooked (by external module)
-                if (! is_object($hookmanager))
-                {
-                	include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-                	$hookmanager=new HookManager($this->db);
-                }
                 $hookmanager->initHooks(array('orderdao'));
 
                 $parameters=array('objFrom'=>$object);

+ 0 - 2
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'));
 
 

+ 0 - 2
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'));
 
 

+ 0 - 2
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'));
 
 

+ 0 - 2
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'));
 
 

+ 1 - 3
htdocs/compta/facture/class/facture.class.php

@@ -637,7 +637,7 @@ class Facture extends CommonInvoice
      */
     function createFromOrder($object)
     {
-        global $conf,$user,$langs;
+        global $conf,$user,$langs,$hookmanager;
 
         $error=0;
 
@@ -701,8 +701,6 @@ class Facture extends CommonInvoice
         if ($ret > 0)
         {
             // Actions hooked (by external module)
-            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-            $hookmanager=new HookManager($this->db);
             $hookmanager->initHooks(array('invoicedao'));
 
             $parameters=array('objFrom'=>$object);

+ 0 - 2
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();

+ 0 - 2
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'));
 
 

+ 1 - 3
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

+ 0 - 2
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'));
 
 

+ 0 - 2
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);

+ 2 - 6
htdocs/core/class/commonobject.class.php

@@ -2468,16 +2468,12 @@ abstract class CommonObject
      */
     function showLinkedObjectBlock($hookmanager=false)
     {
-        global $conf,$langs,$bc;
+        global $conf,$langs,$hookmanager;
+        global $bc;
 
         $this->fetchObjectLinked();
 
         // Bypass the default method
-        if (! is_object($hookmanager))
-        {
-        	include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-        	$hookmanager=new HookManager($this->db);
-        }
         $hookmanager->initHooks(array('commonobject'));
         $parameters=array();
         $reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action);    // Note that $action and $object may have been modified by hook

+ 2 - 10
htdocs/core/class/html.formfile.class.php

@@ -590,18 +590,10 @@ class FormFile
      */
 	function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='')
 	{
-		global $user, $conf, $langs;
-		global $bc, $hookmanager;
+		global $user, $conf, $langs, $hookmanager;
+		global $bc;
 		global $sortfield, $sortorder, $maxheightmini;
 
-		if (! is_object($hookmanager))
-		{
-			if (! class_exists('HookManager')) {
-				// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
-				require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-				$hookmanager=new HookManager($this->db);
-			}
-		}
 		$hookmanager->initHooks(array('formfile'));
 
 		$parameters=array(

+ 1 - 10
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(

+ 2 - 25
htdocs/core/lib/files.lib.php

@@ -65,15 +65,8 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
 	$path=preg_replace('/([\\/]+)$/i','',$path);
 	$newpath=dol_osencode($path);
 
-	if (! $nohook) {
-		if (! is_object($hookmanager))
-		{
-			if (! class_exists('HookManager')) {
-				// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
-				require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-				$hookmanager=new HookManager($db);
-			}
-		}
+	if (! $nohook) 
+	{
 		$hookmanager->initHooks(array('fileslib'));
 
 		$parameters=array(
@@ -653,14 +646,6 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
 			return -2;
 		}
 
-		if (! is_object($hookmanager))
-		{
-			if (! class_exists('HookManager')) {
-				// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
-				require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-			}
-			$hookmanager=new HookManager($db);
-		}
 		$hookmanager->initHooks(array('fileslib'));
 
 		$parameters=array('filename' => $file_name, 'varfiles' => $varfiles, 'allowoverwrite' => $allowoverwrite);
@@ -722,14 +707,6 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n
 
 	if (empty($nohook))
 	{
-		if (! is_object($hookmanager))
-		{
-			if (! class_exists('HookManager')) {
-				// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
-				require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-				$hookmanager=new HookManager($db);
-			}
-		}
 		$hookmanager->initHooks(array('fileslib'));
 
 		$parameters=array(

+ 0 - 5
htdocs/core/lib/security2.lib.php

@@ -131,11 +131,6 @@ function dol_loginfunction($langs,$conf,$mysoc)
 	global $smartphone,$hookmanager;
 
 	// Instantiate hooks of thirdparty module only if not already define
-	if (! is_object($hookmanager))
-	{
-		include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-		$hookmanager=new HookManager($db);
-	}
 	$hookmanager->initHooks(array('mainloginpage'));
 
 	$langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang'));

+ 0 - 2
htdocs/expedition/fiche.php

@@ -59,8 +59,6 @@ if ($user->societe_id) $socid=$user->societe_id;
 $result=restrictedArea($user, $origin, $origin_id);
 
 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
-include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-$hookmanager=new HookManager($db);
 $hookmanager->initHooks(array('expeditioncard'));
 
 $action		= GETPOST('action','alpha');

+ 0 - 2
htdocs/fichinter/fiche.php

@@ -60,8 +60,6 @@ if ($user->societe_id) $socid=$user->societe_id;
 $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
 
 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
-include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-$hookmanager=new HookManager($db);
 $hookmanager->initHooks(array('interventioncard'));
 
 $object = new Fichinter($db);

+ 0 - 2
htdocs/fourn/commande/fiche.php

@@ -70,8 +70,6 @@ if ($user->societe_id) $socid=$user->societe_id;
 $result = restrictedArea($user, 'commande_fournisseur', $id,'');
 
 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
-include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-$hookmanager=new HookManager($db);
 $hookmanager->initHooks(array('ordersuppliercard'));
 
 $object = new CommandeFournisseur($db);

+ 0 - 2
htdocs/fourn/facture/fiche.php

@@ -61,8 +61,6 @@ if (! empty($user->societe_id)) $socid=$user->societe_id;
 $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
 
 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
-include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-$hookmanager=new HookManager($db);
 $hookmanager->initHooks(array('invoicesuppliercard'));
 
 $object=new FactureFournisseur($db);

+ 0 - 2
htdocs/fourn/liste.php

@@ -57,8 +57,6 @@ if (! $sortorder) $sortorder="ASC";
 if (! $sortfield) $sortfield="nom";
 
 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
-include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-$hookmanager=new HookManager($db);
 $hookmanager->initHooks(array('supplierlist'));
 
 /*

+ 0 - 2
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'));
 
 

+ 1 - 13
htdocs/main.inc.php

@@ -603,8 +603,6 @@ if (! defined('NOLOGIN'))
 
         // Hooks on successfull login
         $action='';
-        include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-        $hookmanager=new HookManager($db);
         $hookmanager->initHooks(array('login'));
         $parameters=array('dol_authmode'=>$dol_authmode);
         $reshook=$hookmanager->executeHooks('afterLogin',$parameters,$user,$action);    // Note that $action and $object may have been modified by some hooks
@@ -1194,12 +1192,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
     global $dolibarr_main_authentication;
     global $hookmanager,$menumanager;
 
-    // Instantiate hooks of thirdparty module only if not already define
-    if (! is_object($hookmanager))
-    {
-    	include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-    	$hookmanager=new HookManager($db);
-    }
+    // Instantiate hooks of thirdparty module
     $hookmanager->initHooks(array('toprightmenu'));
 
     $toprightmenu='';
@@ -1426,11 +1419,6 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
     $bookmarks='';
 
     // Instantiate hooks of thirdparty module
-    if (! is_object($hookmanager))
-    {
-    	include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-    	$hookmanager=new HookManager($db);
-	}
     $hookmanager->initHooks(array('searchform','leftblock'));
 
     if (empty($_SESSION['dol_hide_leftmenu']))

+ 7 - 3
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

+ 1 - 3
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

+ 0 - 2
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'));
 
 

+ 0 - 2
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'));
 
 

+ 0 - 2
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);

+ 0 - 2
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');

+ 0 - 2
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);

+ 0 - 2
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(

+ 0 - 2
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'));
 
 

+ 1 - 5
htdocs/societe/class/societe.class.php

@@ -380,7 +380,7 @@ class Societe extends CommonObject
      */
     function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1)
     {
-        global $langs,$conf;
+        global $langs,$conf,$hookmanager;
         require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 
 		$error=0;
@@ -612,8 +612,6 @@ class Societe extends CommonObject
                 $this->AddFournisseurInCategory($this->fournisseur_categorie);
 
                 // Actions on extra fields (by external module or standard code)
-                include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-                $hookmanager=new HookManager($this->db);
                 $hookmanager->initHooks(array('thirdpartydao'));
                 $parameters=array('socid'=>$this->id);
                 $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
@@ -1064,8 +1062,6 @@ class Societe extends CommonObject
             if (! $error)
             {
             	// Additionnal action by hooks
-                include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-                $hookmanager=new HookManager($this->db);
                 $hookmanager->initHooks(array('thirdpartydao'));
                 $parameters=array(); $action='delete';
                 $reshook=$hookmanager->executeHooks('deleteThirdparty',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks

+ 0 - 2
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'));
 
 

+ 0 - 2
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'));
 
 

+ 1 - 3
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

+ 0 - 2
htdocs/user/fiche.php

@@ -84,8 +84,6 @@ $object = new User($db);
 $extrafields = new ExtraFields($db);
 
 // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
-include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-$hookmanager=new HookManager($db);
 $hookmanager->initHooks(array('usercard'));
 
 

+ 0 - 5
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'));