New: hookmanager class is used frequently and is a factory object, so we

can move it during init of environment and use it globally.
This commit is contained in:
Laurent Destailleur 2013-01-25 19:12:54 +01:00
parent 1cc949777f
commit 56e11e52fa
52 changed files with 27 additions and 183 deletions

View File

@ -394,7 +394,7 @@ class Adherent extends CommonObject
*/ */
function update($user,$notrigger=0,$nosyncuser=0,$nosyncuserpass=0,$nosyncthirdparty=0,$action='update') function update($user,$notrigger=0,$nosyncuser=0,$nosyncuserpass=0,$nosyncthirdparty=0,$action='update')
{ {
global $conf, $langs; global $conf, $langs, $hookmanager;
$nbrowsaffected=0; $nbrowsaffected=0;
$error=0; $error=0;
@ -462,8 +462,6 @@ class Adherent extends CommonObject
$nbrowsaffected+=$this->db->affected_rows($resql); $nbrowsaffected+=$this->db->affected_rows($resql);
// Actions on extra fields (by external module) // 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')); $hookmanager->initHooks(array('memberdao'));
$parameters=array('id'=>$this->id); $parameters=array('id'=>$this->id);
$action=''; $action='';

View File

@ -98,6 +98,8 @@ class AdherentType extends CommonObject
*/ */
function update($user) function update($user)
{ {
global $hookmanager;
$this->libelle=trim($this->libelle); $this->libelle=trim($this->libelle);
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type "; $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
@ -114,8 +116,6 @@ class AdherentType extends CommonObject
if ($result) if ($result)
{ {
// Actions on extra fields (by external module or standard code) // 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')); $hookmanager->initHooks(array('membertypedao'));
$parameters=array('membertype'=>$this->id); $parameters=array('membertype'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

View File

@ -107,8 +107,6 @@ if ($rowid)
} }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('membercard'));

View File

@ -67,8 +67,6 @@ if (GETPOST('button_removefilter'))
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('membertypecard'));
/* /*

View File

@ -64,8 +64,6 @@ $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('admin'));
// This page is a generic page to edit dictionnaries // This page is a generic page to edit dictionnaries

View File

@ -86,8 +86,6 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid); $result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('categorycard'));

View File

@ -106,8 +106,8 @@ class ActionComm extends CommonObject
*/ */
function add($user,$notrigger=0) function add($user,$notrigger=0)
{ {
global $langs,$conf; global $langs,$conf,$hookmanager;
$error=0; $error=0;
$now=dol_now(); $now=dol_now();
@ -210,8 +210,6 @@ class ActionComm extends CommonObject
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm","id"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm","id");
// Actions on extra fields (by external module or standard code) // 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')); $hookmanager->initHooks(array('actioncommdao'));
$parameters=array('actcomm'=>$this->id); $parameters=array('actcomm'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $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) function update($user,$notrigger=0)
{ {
global $langs,$conf; global $langs,$conf,$hookmanager;
$error=0; $error=0;
@ -482,8 +480,6 @@ class ActionComm extends CommonObject
{ {
// Actions on extra fields (by external module or standard code) // 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')); $hookmanager->initHooks(array('actioncommdao'));
$parameters=array('actcomm'=>$this->id); $parameters=array('actcomm'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

View File

@ -66,8 +66,6 @@ $extrafields = new ExtraFields($db);
//var_dump($_POST); //var_dump($_POST);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('actioncard'));

View File

@ -46,8 +46,6 @@ $origin=GETPOST('origin','alpha');
$originid=GETPOST('originid','int'); $originid=GETPOST('originid','int');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('propalcard'));
/* /*

View File

@ -58,8 +58,6 @@ $search_categ = GETPOST("search_categ",'int');
$catid = GETPOST("catid",'int'); $catid = GETPOST("catid",'int');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('customerlist'));

View File

@ -47,8 +47,6 @@ $result=$object->fetch($id);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('mailingcard'));
// Tableau des substitutions possibles // Tableau des substitutions possibles

View File

@ -99,8 +99,6 @@ else
} }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('propalcard'));

View File

@ -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 // 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')); $hookmanager->initHooks(array('propalcard'));

View File

@ -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 // 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')); $hookmanager->initHooks(array('prospectlist'));

View File

@ -880,8 +880,7 @@ class Commande extends CommonOrder
*/ */
function createFromProposal($object) function createFromProposal($object)
{ {
global $conf,$user,$langs; global $conf,$user,$langs,$hookmanager;
global $hookmanager;
$error=0; $error=0;
@ -945,11 +944,6 @@ class Commande extends CommonOrder
if ($ret > 0) if ($ret > 0)
{ {
// Actions hooked (by external module) // 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')); $hookmanager->initHooks(array('orderdao'));
$parameters=array('objFrom'=>$object); $parameters=array('objFrom'=>$object);

View File

@ -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 // 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')); $hookmanager->initHooks(array('ordercard'));

View File

@ -49,8 +49,6 @@ $mesg = '';
$object = new Deplacement($db); $object = new Deplacement($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('tripsandexpensescard'));

View File

@ -50,8 +50,6 @@ $donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOS
$result = restrictedArea($user, 'don', $id); $result = restrictedArea($user, 'don', $id);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('doncard'));

View File

@ -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 // 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')); $hookmanager->initHooks(array('invoicecard'));

View File

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

View File

@ -97,8 +97,6 @@ $usehm=(! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MA
$object=new Facture($db); $object=new Facture($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('invoicecard'));
$now=dol_now(); $now=dol_now();

View File

@ -41,8 +41,6 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges'); $result = restrictedArea($user, 'tax', '', '', 'charges');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('taxvatcard'));

View File

@ -210,7 +210,7 @@ class Contact extends CommonObject
*/ */
function update($id, $user=0, $notrigger=0, $action='update') function update($id, $user=0, $notrigger=0, $action='update')
{ {
global $conf, $langs; global $conf, $langs, $hookmanager;
$error=0; $error=0;
@ -266,8 +266,6 @@ class Contact extends CommonObject
unset($this->state); unset($this->state);
// Actions on extra fields (by external module or standard code) // 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')); $hookmanager->initHooks(array('contactdao'));
$parameters=array('socid'=>$this->id); $parameters=array('socid'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

View File

@ -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 $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 // 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')); $hookmanager->initHooks(array('contactcard'));

View File

@ -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); $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 // 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')); $hookmanager->initHooks(array('contractcard'));
$object = new Contrat($db); $object = new Contrat($db);

View File

@ -2468,16 +2468,12 @@ abstract class CommonObject
*/ */
function showLinkedObjectBlock($hookmanager=false) function showLinkedObjectBlock($hookmanager=false)
{ {
global $conf,$langs,$bc; global $conf,$langs,$hookmanager;
global $bc;
$this->fetchObjectLinked(); $this->fetchObjectLinked();
// Bypass the default method // 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')); $hookmanager->initHooks(array('commonobject'));
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('showLinkedObjectBlock',$parameters,$this,$action); // Note that $action and $object may have been modified by hook

View File

@ -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='') 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 $user, $conf, $langs, $hookmanager;
global $bc, $hookmanager; global $bc;
global $sortfield, $sortorder, $maxheightmini; 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')); $hookmanager->initHooks(array('formfile'));
$parameters=array( $parameters=array(

View File

@ -216,20 +216,11 @@ class FormMail
*/ */
function get_form($addfileaction='addfile',$removefileaction='removefile') function get_form($addfileaction='addfile',$removefileaction='removefile')
{ {
global $conf, $langs, $user; global $conf, $langs, $user, $hookmanager;
global $hookmanager;
$langs->load("other"); $langs->load("other");
$langs->load("mails"); $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')); $hookmanager->initHooks(array('formmail'));
$parameters=array( $parameters=array(

View File

@ -65,15 +65,8 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
$path=preg_replace('/([\\/]+)$/i','',$path); $path=preg_replace('/([\\/]+)$/i','',$path);
$newpath=dol_osencode($path); $newpath=dol_osencode($path);
if (! $nohook) { 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);
}
}
$hookmanager->initHooks(array('fileslib')); $hookmanager->initHooks(array('fileslib'));
$parameters=array( $parameters=array(
@ -653,14 +646,6 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
return -2; 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')); $hookmanager->initHooks(array('fileslib'));
$parameters=array('filename' => $file_name, 'varfiles' => $varfiles, 'allowoverwrite' => $allowoverwrite); $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 (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')); $hookmanager->initHooks(array('fileslib'));
$parameters=array( $parameters=array(

View File

@ -131,11 +131,6 @@ function dol_loginfunction($langs,$conf,$mysoc)
global $smartphone,$hookmanager; global $smartphone,$hookmanager;
// Instantiate hooks of thirdparty module only if not already define // 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')); $hookmanager->initHooks(array('mainloginpage'));
$langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang')); $langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang'));

View File

@ -59,8 +59,6 @@ if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user, $origin, $origin_id); $result=restrictedArea($user, $origin, $origin_id);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('expeditioncard'));
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');

View File

@ -60,8 +60,6 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('interventioncard'));
$object = new Fichinter($db); $object = new Fichinter($db);

View File

@ -70,8 +70,6 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'commande_fournisseur', $id,''); $result = restrictedArea($user, 'commande_fournisseur', $id,'');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('ordersuppliercard'));
$object = new CommandeFournisseur($db); $object = new CommandeFournisseur($db);

View File

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

View File

@ -57,8 +57,6 @@ if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="nom"; if (! $sortfield) $sortfield="nom";
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('supplierlist'));
/* /*

View File

@ -34,8 +34,6 @@ $_GET['mainmenu']=GETPOST('mainmenu', 'alpha')?GETPOST('mainmenu', 'alpha'):'hom
$action=GETPOST('action'); $action=GETPOST('action');
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('index')); $hookmanager->initHooks(array('index'));

View File

@ -603,8 +603,6 @@ if (! defined('NOLOGIN'))
// Hooks on successfull login // Hooks on successfull login
$action=''; $action='';
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('login')); $hookmanager->initHooks(array('login'));
$parameters=array('dol_authmode'=>$dol_authmode); $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 $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 $dolibarr_main_authentication;
global $hookmanager,$menumanager; global $hookmanager,$menumanager;
// Instantiate hooks of thirdparty module only if not already define // 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('toprightmenu')); $hookmanager->initHooks(array('toprightmenu'));
$toprightmenu=''; $toprightmenu='';
@ -1426,11 +1419,6 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
$bookmarks=''; $bookmarks='';
// Instantiate hooks of thirdparty module // 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')); $hookmanager->initHooks(array('searchform','leftblock'));
if (empty($_SESSION['dol_hide_leftmenu'])) if (empty($_SESSION['dol_hide_leftmenu']))

View File

@ -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')) if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC'))
{ {
require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; 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:'')); $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'); if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR');
// We force feature to help debug // We force feature to help debug

View File

@ -418,7 +418,7 @@ class Product extends CommonObject
*/ */
function update($id, $user, $notrigger=false, $action='update') function update($id, $user, $notrigger=false, $action='update')
{ {
global $langs, $conf; global $langs, $conf, $hookmanager;
$error=0; $error=0;
@ -500,8 +500,6 @@ class Product extends CommonObject
} }
// Actions on extra fields (by external module or standard code) // 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')); $hookmanager->initHooks(array('productdao'));
$parameters=array('id'=>$this->id); $parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

View File

@ -78,8 +78,6 @@ $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype,$objcanvas); $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 // 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')); $hookmanager->initHooks(array('productcard'));

View File

@ -59,8 +59,6 @@ if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service&fournisseur',$fieldvalue,'product&product','','',$fieldtype); $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 // 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')); $hookmanager->initHooks(array('pricesuppliercard'));

View File

@ -50,8 +50,6 @@ if ($user->societe_id > 0) $socid=$user->societe_id;
$result = restrictedArea($user, 'projet', $id); $result = restrictedArea($user, 'projet', $id);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('projectcard'));
$object = new Project($db); $object = new Project($db);

View File

@ -55,8 +55,6 @@ if ($user->societe_id > 0) $socid = $user->societe_id;
$result = restrictedArea($user, 'projet', $id); $result = restrictedArea($user, 'projet', $id);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('projecttaskcard'));
$progress=GETPOST('progress', 'int'); $progress=GETPOST('progress', 'int');

View File

@ -42,8 +42,6 @@ if ($user->societe_id > 0) $socid = $user->societe_id;
if (! $user->rights->projet->lire) accessforbidden(); if (! $user->rights->projet->lire) accessforbidden();
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('projecttaskcard'));
$object = new Task($db); $object = new Task($db);

View File

@ -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); 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 // 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')); $hookmanager->initHooks(array('demo'));
$demoprofiles=array( $demoprofiles=array(

View File

@ -38,8 +38,6 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('agendathirdparty'));

View File

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

View File

@ -38,8 +38,6 @@ if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('infothirdparty'));

View File

@ -70,8 +70,6 @@ if (! empty($canvas))
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); $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 // 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')); $hookmanager->initHooks(array('thirdpartycard'));

View File

@ -1079,7 +1079,7 @@ class User extends CommonObject
*/ */
function update($user,$notrigger=0,$nosyncmember=0,$nosyncmemberpass=0) function update($user,$notrigger=0,$nosyncmember=0,$nosyncmemberpass=0)
{ {
global $conf, $langs; global $conf, $langs, $hookmanager;
$nbrowsaffected=0; $nbrowsaffected=0;
$error=0; $error=0;
@ -1218,8 +1218,6 @@ class User extends CommonObject
} }
// Actions on extra fields (by external module or standard code) // 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')); $hookmanager->initHooks(array('userdao'));
$parameters=array('socid'=>$this->id); $parameters=array('socid'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks

View File

@ -84,8 +84,6 @@ $object = new User($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // 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')); $hookmanager->initHooks(array('usercard'));

View File

@ -52,11 +52,6 @@ $passwordmd5 = GETPOST('passwordmd5');
$conf->entity = (GETPOST('entity') ? GETPOST('entity') : 1); $conf->entity = (GETPOST('entity') ? GETPOST('entity') : 1);
// Instantiate hooks of thirdparty module only if not already define // 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')); $hookmanager->initHooks(array('passwordforgottenpage'));