From c962b894951c1d534bd009ae20f9920daa2810c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Mar 2018 20:46:55 +0100 Subject: [PATCH] NEW hook getnomurltooltip is replaced with hook getNomUrl more powerfull --- htdocs/comm/action/class/actioncomm.class.php | 15 ++++++++- htdocs/contact/class/contact.class.php | 17 ++++++++-- htdocs/product/class/product.class.php | 16 ++++++++- htdocs/projet/class/project.class.php | 33 +++++++++++++------ htdocs/societe/class/societe.class.php | 21 +++++++++--- htdocs/user/class/user.class.php | 15 ++++++++- htdocs/user/class/usergroup.class.php | 15 ++++++++- 7 files changed, 111 insertions(+), 21 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index af829969789..685ee6526d3 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1273,7 +1273,7 @@ class ActionComm extends CommonObject $linkclose.=' title="'.dol_escape_htmltag($tooltip, 1).'"'; $linkclose.=' class="'.$classname.' classfortooltip"'; - if (! is_object($hookmanager)) + /*if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager=new HookManager($this->db); @@ -1282,6 +1282,7 @@ class ActionComm extends CommonObject $parameters=array('id'=>$this->id); $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose); + */ } else $linkclose.=' class="'.$classname.'"'; @@ -1327,6 +1328,18 @@ class ActionComm extends CommonObject $result.=$libelleshort; $result.=$linkend; + global $action; + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('actiondao')); + $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 + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + return $result; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 432515fbf1f..6c841c267b8 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1124,7 +1124,7 @@ class Contact extends CommonObject } $linkclose.='>'; - if (! is_object($hookmanager)) + /*if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager=new HookManager($this->db); @@ -1132,7 +1132,7 @@ class Contact extends CommonObject $hookmanager->initHooks(array('contactdao')); $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; + if ($reshook > 0) $linkclose = $hookmanager->resPrint;*/ $linkstart.=$linkclose; $linkend=''; @@ -1143,12 +1143,23 @@ class Contact extends CommonObject $linkend=''; } - $result.=$linkstart; if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1); if ($withpicto != 2) $result.=($maxlen?dol_trunc($this->getFullName($langs),$maxlen):$this->getFullName($langs)); $result.=$linkend; + global $action; + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('contactdao')); + $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 + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + return $result; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 633d85e854b..f4722b9158e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3575,7 +3575,7 @@ class Product extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; $linkclose.= ' class="classfortooltip"'; - if (! is_object($hookmanager)) + /*if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager=new HookManager($this->db); @@ -3584,6 +3584,7 @@ class Product extends CommonObject $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; + */ } if ($option == 'supplier' || $option == 'category') { @@ -3615,6 +3616,19 @@ class Product extends CommonObject } $result.= $newref; $result.= $linkend; + + global $action; + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('productdao')); + $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 + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + return $result; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index bc78d285945..28afacba39f 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1021,17 +1021,18 @@ class Project extends CommonObject $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; - if (! is_object($hookmanager)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + /*if (! is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('projectdao')); + $parameters=array('id'=>$this->id); + // Note that $action and $object may have been modified by some hooks + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); + if ($reshook > 0) + $linkclose = $hookmanager->resPrint; + */ } - $hookmanager->initHooks(array('projectdao')); - $parameters=array('id'=>$this->id); - // Note that $action and $object may have been modified by some hooks - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); - if ($reshook > 0) - $linkclose = $hookmanager->resPrint; - } $picto = 'projectpub'; if (! $this->public) $picto = 'project'; @@ -1046,6 +1047,18 @@ class Project extends CommonObject $result .= $linkend; if ($withpicto != 2) $result.=(($addlabel && $this->title) ? $sep . dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); + global $action; + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('projectdao')); + $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 + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + return $result; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 72bd3b58426..515a2208947 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2095,7 +2095,7 @@ class Societe extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip refurl"'; - if (! is_object($hookmanager)) + /*if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager=new HookManager($this->db); @@ -2104,6 +2104,7 @@ class Societe extends CommonObject $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; + */ } $linkstart.=$linkclose.'>'; $linkend=''; @@ -2120,6 +2121,18 @@ class Societe extends CommonObject if ($withpicto != 2) $result.=($maxlen?dol_trunc($name,$maxlen):$name); $result.=$linkend; + global $action; + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('societedao')); + $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 + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + return $result; } @@ -2886,19 +2899,19 @@ class Societe extends CommonObject if (!is_numeric($chaine)) return -1; if (dol_strlen($chaine) != 14) return -1; - + // on prend chaque chiffre un par un // si son index (position dans la chaîne en commence à 0 au premier caractère) est pair // on double sa valeur et si cette dernière est supérieure à 9, on lui retranche 9 // on ajoute cette valeur à la somme totale - + for ($index = 0; $index < 14; $index ++) { $number = (int) $chaine[$index]; if (($index % 2) == 0) { if (($number *= 2) > 9) $number -= 9; } $sum += $number; } - + // le numéro est valide si la somme des chiffres est multiple de 10 if (($sum % 10) != 0) return -1; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 049275fc5b4..f3c8f03329f 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2201,7 +2201,7 @@ class User extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; } - if (! is_object($hookmanager)) + /*if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager=new HookManager($this->db); @@ -2210,6 +2210,7 @@ class User extends CommonObject $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; + */ $linkstart.=$linkclose.'>'; $linkend=''; @@ -2238,6 +2239,18 @@ class User extends CommonObject $result.=$companylink; + global $action; + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('userdao')); + $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 + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + return $result; } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 5104d813a05..f322d59a960 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -836,7 +836,7 @@ class UserGroup extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; } - if (! is_object($hookmanager)) + /*if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager=new HookManager($this->db); @@ -845,6 +845,7 @@ class UserGroup extends CommonObject $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; + */ $linkstart = ''; @@ -855,6 +856,18 @@ class UserGroup extends CommonObject if ($withpicto != 2) $result.= $this->name; $result .= $linkend; + global $action; + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('groupdao')); + $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 + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + return $result; }