From 303b6d6e9e06889d22904fa45e31fa940b526d04 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Jun 2022 11:23:10 +0200 Subject: [PATCH] Fix object not defined --- .../class/emailcollector.class.php | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index f00ec802b39..ea8913bae23 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -504,7 +504,7 @@ class EmailCollector extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $conf, $langs, $hookmanager; + global $conf, $langs, $action, $hookmanager; if (!empty($conf->dol_no_mouse_hover)) { $notooltip = 1; // Force disable tooltips @@ -537,13 +537,6 @@ class EmailCollector extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* - $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -562,7 +555,6 @@ class EmailCollector extends CommonObject $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action, $hookmanager; $hookmanager->initHooks(array('emailcollectordao')); $parameters = array('id'=>$this->id, 'getnomurl'=>$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks @@ -965,6 +957,7 @@ class EmailCollector extends CommonObject public function doCollectOneCollector() { global $conf, $langs, $user; + global $hookmanager; //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; @@ -2009,11 +2002,16 @@ class EmailCollector extends CommonObject 'object' => 'Mo'), ); - global $hookmanager; + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } $hookmanager->initHooks(array('emailcolector')); $parameters = array('arrayobject' => $arrayobject); $reshook = $hookmanager->executeHooks('addmoduletoeamailcollectorjoinpiece', $parameters); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $arrayobject = $hookmanager->resArray; + if ($reshook > 0) { + $arrayobject = $hookmanager->resArray; + } $resultobj = array(); @@ -2365,8 +2363,6 @@ class EmailCollector extends CommonObject } elseif (substr($operation['type'], 0, 4) == 'hook') { // Create event specific on hook // this code action is hook..... for support this call - global $hookmanager; - if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); @@ -2391,9 +2387,9 @@ class EmailCollector extends CommonObject 'header'=>$header, 'attachments'=>$attachments, ); - $res = $hookmanager->executeHooks('doCollectOneCollector', $parameters, $this, $operation['type']); + $reshook = $hookmanager->executeHooks('doCollectOneCollector', $parameters, $this, $operation['type']); - if ($res < 0) { + if ($reshook < 0) { $errorforthisaction++; $this->error = $hookmanager->resPrint; }