Change signature of all call executHooks.

Now they accept all the following signature:
executeHooks('method',$parameters,$object,$action)
This commit is contained in:
Laurent Destailleur 2011-08-10 22:47:33 +00:00
parent 6a24698fda
commit acea604e54
20 changed files with 166 additions and 122 deletions

View File

@ -24,7 +24,7 @@
* \file htdocs/adherents/class/adherent.class.php
* \ingroup member
* \brief File of class to manage members of a foundation
* \version $Id: adherent.class.php,v 1.48 2011/08/10 10:55:38 hregis Exp $
* \version $Id: adherent.class.php,v 1.49 2011/08/10 22:47:33 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
@ -425,7 +425,8 @@ class Adherent extends CommonObject
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
$hookmanager->callHooks(array('member_extrafields'));
$reshook=$hookmanager->executeHooks('insertExtraFields',$action,$this,$socid); // Note that $action and $object may have been modified by some hooks
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
$result=$this->insertExtraFields();

View File

@ -22,7 +22,7 @@
* \file htdocs/adherents/fiche.php
* \ingroup member
* \brief Page of member
* \version $Id: fiche.php,v 1.240 2011/08/10 00:50:19 eldy Exp $
* \version $Id: fiche.php,v 1.241 2011/08/10 22:47:35 eldy Exp $
*/
require("../main.inc.php");
@ -90,7 +90,8 @@ $hookmanager->callHooks(array('member_extrafields'));
* Actions
*/
$reshook=$hookmanager->executeHooks('doActions',$action,$object,$socid); // Note that $action and $object may have been modified by some hooks
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($_POST['action'] == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
@ -773,7 +774,8 @@ if ($action == 'create')
print "</td></tr>\n";
// Other attributes
$reshook=$hookmanager->executeHooks('showInputFields',$action,$object); // Note that $action and $object may have been modified by hook
$parameters=array();
$reshook=$hookmanager->executeHooks('showInputFields',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
foreach($extrafields->attribute_label as $key=>$label)
@ -990,7 +992,8 @@ if ($action == 'edit')
print "</td></tr>\n";
// Other attributes
$reshook=$hookmanager->executeHooks('showInputFields',$action,$object); // Note that $action and $object may have been modified by hook
$parameters=array();
$reshook=$hookmanager->executeHooks('showInputFields',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
foreach($extrafields->attribute_label as $key=>$label)
@ -1302,7 +1305,8 @@ if ($rowid && $action != 'edit')
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$object->getLibStatut(4).'</td></tr>';
// Other attributes
$reshook=$hookmanager->executeHooks('showOutputField',$action,$object,$socid); // Note that $action and $object may have been modified by hook
$parameters=array();
$reshook=$hookmanager->executeHooks('showOutputField',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
foreach($extrafields->attribute_label as $key=>$label)
@ -1522,5 +1526,5 @@ if ($rowid && $action != 'edit')
$db->close();
llxFooter('$Date: 2011/08/10 00:50:19 $ - $Revision: 1.240 $');
llxFooter('$Date: 2011/08/10 22:47:35 $ - $Revision: 1.241 $');
?>

View File

@ -26,7 +26,7 @@
* \file htdocs/comm/propal.php
* \ingroup propale
* \brief Page of commercial proposals card and list
* \version $Id: propal.php,v 1.619 2011/08/10 19:55:22 hregis Exp $
* \version $Id: propal.php,v 1.620 2011/08/10 22:47:35 eldy Exp $
*/
require("../main.inc.php");
@ -90,7 +90,8 @@ $hookmanager->callHooks(array('propalcard'));
/* Actions */
/******************************************************************************/
$reshook=$hookmanager->executeHooks('doActions',$action,$object,$socid); // Note that $action and $object may have been modified by some hooks
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes')
@ -1071,8 +1072,12 @@ if ($id > 0 || ! empty($ref))
$formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1);
}
if (! $formconfirm) $formconfirm=$hookmanager->executeHooks('formconfirm',$action,$object,$lineid); // Note that $action and $object may have been modified by hook
if (! $formconfirm)
{
$parameters=array('lineid'=>$lineid);
$formconfirm=$hookmanager->executeHooks('formconfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
}
// Print form confirm
print $formconfirm;
@ -1469,7 +1474,8 @@ if ($id > 0 || ! empty($ref))
$object->formAddPredefinedProduct(0,$mysoc,$soc,$hookmanager);
}
$reshook=$hookmanager->executeHooks('formAddObject',$action,$object); // Note that $action and $object may have been modified by hook
$parameters=array();
$reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
}
}
@ -1926,6 +1932,6 @@ else
}
$db->close();
llxFooter('$Date: 2011/08/10 19:55:22 $ - $Revision: 1.619 $');
llxFooter('$Date: 2011/08/10 22:47:35 $ - $Revision: 1.620 $');
?>

View File

@ -29,7 +29,7 @@
* \author Rodolphe Qiedeville
* \author Eric Seigne
* \author Laurent Destailleur
* \version $Id: propal.class.php,v 1.112 2011/08/10 19:55:22 hregis Exp $
* \version $Id: propal.class.php,v 1.113 2011/08/10 22:47:35 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
@ -903,7 +903,8 @@ class Propal extends CommonObject
// Hook of thirdparty module
if (is_object($hookmanager))
{
$reshook=$hookmanager->executeHooks('createfrom','',$objFrom,$result,$object->element); // Note that $action and $object may have been modified by some hooks
$parameters=array('objFrom'=>$objFrom);
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}

View File

@ -24,7 +24,7 @@
* \file htdocs/commande/class/commande.class.php
* \ingroup commande
* \brief Fichier des classes de commandes
* \version $Id: commande.class.php,v 1.122 2011/08/10 19:55:22 hregis Exp $
* \version $Id: commande.class.php,v 1.123 2011/08/10 22:47:33 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
@ -825,7 +825,8 @@ class Commande extends CommonObject
// Hook of thirdparty module
if (is_object($hookmanager))
{
$reshook=$hookmanager->executeHooks('createfrom','',$objFrom,$result,$object->element); // Note that $action and $object may have been modified by some hooks
$parameters=array('objFrom'=>$objFrom);
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}
@ -916,7 +917,7 @@ class Commande extends CommonObject
// Hook of thirdparty module
if (is_object($hookmanager))
{
$reshook=$hookmanager->executeHooks('createfrom','',$object,$ret,$this->element); // Note that $action and $object may have been modified by some hooks
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}

View File

@ -25,7 +25,7 @@
* \file htdocs/commande/fiche.php
* \ingroup commande
* \brief Page to show customer order
* \version $Id: fiche.php,v 1.532 2011/08/10 19:55:22 hregis Exp $
* \version $Id: fiche.php,v 1.533 2011/08/10 22:47:34 eldy Exp $
*/
require("../main.inc.php");
@ -74,7 +74,8 @@ $hookmanager->callHooks(array('ordercard'));
/* Actions */
/******************************************************************************/
$reshook=$hookmanager->executeHooks('doActions',$action,$object,$socid); // Note that $action and $object may have been modified by some hooks
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes')
@ -294,7 +295,8 @@ if ($action == 'add' && $user->rights->commande->creer)
}
// Hooks
$reshook=$hookmanager->executeHooks('createfrom',$action,$srcobject,$object_id,$object->element); // Note that $action and $object may have been modified by hook
$parameters=array('objFrom'=>$srcobject);
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) $error++;
}
else
@ -1497,8 +1499,12 @@ else
// Paiement incomplet. On demande si motif = escompte ou autre
$formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1);
}
if (! $formconfirm) $formconfirm=$hookmanager->executeHooks('formconfirm',$action,$object,$lineid); // Note that $action and $object may have been modified by hook
if (! $formconfirm)
{
$parameters=array('lineid'=>$lienid);
$formconfirm=$hookmanager->executeHooks('formconfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
}
// Print form confirm
print $formconfirm;
@ -1837,8 +1843,9 @@ else
$var=!$var;
$object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager);
}
$reshook=$hookmanager->executeHooks('formAddObject',$action,$object); // Note that $action and $object may have been modified by hook
$parameters=array();
$reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
}
}
print '</table>';
@ -2063,5 +2070,5 @@ else
$db->close();
llxFooter('$Date: 2011/08/10 19:55:22 $ - $Revision: 1.532 $');
llxFooter('$Date: 2011/08/10 22:47:34 $ - $Revision: 1.533 $');
?>

View File

@ -25,7 +25,7 @@
* \file htdocs/compta/facture.php
* \ingroup facture
* \brief Page to create/see an invoice
* \version $Id: facture.php,v 1.853 2011/08/10 19:55:21 hregis Exp $
* \version $Id: facture.php,v 1.854 2011/08/10 22:47:34 eldy Exp $
*/
require('../main.inc.php');
@ -84,7 +84,8 @@ $hookmanager->callHooks(array('invoicecard'));
/* Actions */
/******************************************************************************/
$reshook=$hookmanager->executeHooks('doActions',$action,$object,$socid); // Note that $action and $object may have been modified by some hooks
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes')
@ -781,7 +782,8 @@ if ($action == 'add' && $user->rights->facture->creer)
}
// Hooks
$reshook=$hookmanager->executeHooks('createfrom',$action,$srcobject,$id,$object->element); // Note that $action and $object may have been modified by hook
$parameters=array('srcobject'=>$srcobject);
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) $error++;
}
else
@ -2032,8 +2034,12 @@ else
// Paiement incomplet. On demande si motif = escompte ou autre
$formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id,$langs->trans('CloneInvoice'),$langs->trans('ConfirmCloneInvoice',$object->ref),'confirm_clone',$formquestion,'yes',1);
}
if (! $formconfirm) $formconfirm=$hookmanager->executeHooks('formconfirm',$action,$object,$lineid); // Note that $action and $object may have been modified by hook
if (! $formconfirm)
{
$parameters=array('lineid'=>$lineid);
$formconfirm=$hookmanager->executeHooks('formconfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
}
// Print form confirm
print $formconfirm;
@ -2568,8 +2574,9 @@ else
$var=!$var;
$object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager);
}
$reshook=$hookmanager->executeHooks('formAddObject',$action,$object); // Note that $action and $object may have been modified by hook
$parameters=array();
$reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
}
print "</table>\n";
@ -3178,5 +3185,5 @@ else
$db->close();
llxFooter('$Date: 2011/08/10 19:55:21 $ - $Revision: 1.853 $');
llxFooter('$Date: 2011/08/10 22:47:34 $ - $Revision: 1.854 $');
?>

View File

@ -27,7 +27,7 @@
* \file htdocs/compta/facture/class/facture.class.php
* \ingroup facture
* \brief Fichier de la classe des factures clients
* \version $Id: facture.class.php,v 1.125 2011/08/10 19:55:21 hregis Exp $
* \version $Id: facture.class.php,v 1.126 2011/08/10 22:47:33 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
@ -573,7 +573,8 @@ class Facture extends CommonObject
// Hook of thirdparty module
if (is_object($hookmanager))
{
$reshook=$hookmanager->executeHooks('createfrom','',$objFrom,$result,$object->element); // Note that $action and $object may have been modified by some hooks
$parameters=array('objFrom'=>$objFrom);
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}
@ -660,7 +661,8 @@ class Facture extends CommonObject
// Hook of thirdparty module
if (is_object($hookmanager))
{
$reshook=$hookmanager->executeHooks('createfrom','',$objFrom,$result,$object->element); // Note that $action and $object may have been modified by some hooks
$parameters=array('objFrom'=>$objFrom);
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}
@ -1634,7 +1636,7 @@ class Facture extends CommonObject
if (! $error)
{
$this->oldref = '';
// Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
@ -1651,7 +1653,7 @@ class Facture extends CommonObject
if (@rename($dirsource, $dirdest))
{
$this->oldref = $facref;
dol_syslog("Rename ok");
// Suppression ancien fichier PDF dans nouveau rep
dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'.*');
@ -1993,12 +1995,12 @@ class Facture extends CommonObject
// Update line into database
$this->line=new FactureLigne($this->db);
// Stock previous line records
$staticline=new FactureLigne($this->db);
$staticline->fetch($rowid);
$this->line->oldline = $staticline;
$this->line->rowid = $rowid;
$this->line->desc = $desc;
$this->line->qty = $qty;
@ -3245,7 +3247,7 @@ class FactureLigne
{
var $db;
var $error;
var $oldline;
//! From llx_facturedet

View File

@ -23,7 +23,7 @@
* \file htdocs/contact/fiche.php
* \ingroup societe
* \brief Card of a contact
* \version $Id: fiche.php,v 1.223 2011/08/10 19:55:22 hregis Exp $
* \version $Id: fiche.php,v 1.224 2011/08/10 22:47:34 eldy Exp $
*/
require("../main.inc.php");
@ -77,7 +77,8 @@ $hookmanager->callHooks(array('contactcard'));
* Actions
*/
$reshook=$hookmanager->executeHooks('doActions',$action,$object,$id); // Note that $action and $object may have been modified by some hooks
$parameters=array('id'=>$id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
// ---------- start deprecated. Use hook to hook actions.
@ -948,5 +949,5 @@ else
$db->close();
llxFooter('$Date: 2011/08/10 19:55:22 $ - $Revision: 1.223 $');
llxFooter('$Date: 2011/08/10 22:47:34 $ - $Revision: 1.224 $');
?>

View File

@ -21,7 +21,7 @@
* \file htdocs/core/class/commonobject.class.php
* \ingroup core
* \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...)
* \version $Id: commonobject.class.php,v 1.153 2011/08/10 17:40:46 hregis Exp $
* \version $Id: commonobject.class.php,v 1.154 2011/08/10 22:47:34 eldy Exp $
*/
@ -1703,7 +1703,7 @@ class CommonObject
if (empty($line->fk_parent_line))
{
$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected);
$reshook=$hookmanager->executeHooks('printObjectLine',$action,$this,'',$parameters); // Note that $action and $object may have been modified by some hooks
$reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
}
}
else

View File

@ -21,7 +21,7 @@
* \file htdocs/core/class/hookmanager.class.php
* \ingroup core
* \brief File of class to manage hooks
* \version $Id: hookmanager.class.php,v 1.4 2011/08/10 19:35:25 eldy Exp $
* \version $Id: hookmanager.class.php,v 1.5 2011/08/10 22:47:34 eldy Exp $
*/
@ -53,7 +53,9 @@ class HookManager
/**
* Init array this->hooks with instantiated controler
* A hook is declared by a module by adding a constant MAIN_MODULE_MYMODULENAME_HOOKS
* with value nameofhookkey1:nameofhookkey2:...:nameofhookkeyn
* with value nameofhookkey1:nameofhookkey2:...:nameofhookkeyn.
* This add into conf->hooks_module an entries ('modulename'=>nameofhookkey)
* After this, this->hooks is defined
* @param arraytype Array list of hooked tab/features. For example: thirdpartytab, ...
* @return int Always 1
*/
@ -89,10 +91,10 @@ class HookManager
if ($resaction)
{
$controlclassname = 'Actions'.ucfirst($module);
$objModule = new $controlclassname($this->db);
$this->hooks[$i]['modules'][$objModule->module_number] = $objModule;
$actionInstance = new $controlclassname($this->db);
$this->hooks[$i]['modules'][$module] = $actionInstance;
}
// Include dataservice class (model)
// TODO storing dao is useless here. It's goal of controller to known which dao to manage
$daofile = 'dao_'.$module.'.class.php';
@ -100,8 +102,8 @@ class HookManager
if ($resdao)
{
// Instantiate dataservice class (model)
$modelclassname = 'Dao'.ucfirst($module);
$this->hooks[$i]['modules'][$objModule->module_number]->object = new $modelclassname($this->db);
$daoInstance = 'Dao'.ucfirst($module);
$this->hooks[$i]['modules'][$module]->object = new $daoInstance($this->db);
}
$i++;
@ -115,17 +117,17 @@ class HookManager
/**
* Execute hooks (if the were initialized) for the given method
* @param method Method name to hook ('doActions', 'printSearchForm', ...)
* @param action Action code ('create', 'edit', 'view', 'add', 'update', 'delete'...)
* @param parameters Array of parameters
* @param action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
* @param object Object to use hooks on
* @param id Id.
* @param string For doActions,showInputField,showOutputField: Return 0 if we want to keep doing standard actions, >0 if if want to stop standard actions, >0 means KO.
* For printSearchForm,printLeftBlock: Return HTML string.
* $this->error or this->errors are also defined with hooks errors.
*/
function executeHooks($method, $action='', &$object='', $id='', $parameters=false)
function executeHooks($method, $parameters=false, &$action='', &$object='')
{
global $var;
if (! is_array($this->hooks) || empty($this->hooks)) return '';
// Loop on each hook
@ -134,17 +136,17 @@ class HookManager
{
if (! empty($hook['modules']))
{
foreach($hook['modules'] as $module)
foreach($hook['modules'] as $module => $actioninstance)
{
$var=!$var;
// Hooks that return int
if ($method == 'doActions' && method_exists($module,$method))
if ($method == 'doActions' && method_exists($actioninstance,$method))
{
$restmp+=$module->doActions($object, $action, $id); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
if ($restmp < 0 || ! empty($module->error) || (! empty($module->errors) && sizeof($module->errors) > 0))
$restmp+=$actioninstance->doActions($parameters, $object, $action); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
if ($restmp < 0 || ! empty($actioninstance->error) || (! empty($actioninstance->errors) && sizeof($actioninstance->errors) > 0))
{
$this->error=$module->error; $this->errors=$module->errors;
$this->error=$actioninstance->error; $this->errors=$actioninstance->errors;
if ($action=='add') $action='create'; // TODO this change must be inside the doActions
if ($action=='update') $action='edit'; // TODO this change must be inside the doActions
}
@ -153,48 +155,37 @@ class HookManager
$resaction+=$restmp;
}
}
else if ($method == 'showInputFields' && method_exists($module,$method))
else if ($method == 'showInputFields' && method_exists($actioninstance,$method))
{
$restmp+=$module->showInputFields($object, $action, $id); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
if ($restmp < 0 || ! empty($module->error) || (! empty($module->errors) && sizeof($module->errors) > 0))
$restmp+=$actioninstance->showInputFields($parameters, $object, $action); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
if ($restmp < 0 || ! empty($actioninstance->error) || (! empty($actioninstance->errors) && sizeof($actioninstance->errors) > 0))
{
$this->error=$module->error; $this->errors=$module->errors;
$this->error=$actioninstance->error; $this->errors=$actioninstance->errors;
}
else
{
$resaction+=$restmp;
}
}
else if ($method == 'showOutputFields' && method_exists($module,$method))
else if ($method == 'showOutputFields' && method_exists($actioninstance,$method))
{
$restmp+=$module->showOutputFields($object, $id); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
if ($restmp < 0 || ! empty($module->error) || (! empty($module->errors) && sizeof($module->errors) > 0))
$restmp+=$actioninstance->showOutputFields($parameters, $object, $action); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
if ($restmp < 0 || ! empty($actioninstance->error) || (! empty($actioninstance->errors) && sizeof($actioninstance->errors) > 0))
{
$this->error=$module->error; $this->errors=$module->errors;
$this->error=$actioninstance->error; $this->errors=$actioninstance->errors;
}
else
{
$resaction+=$restmp;
}
}
// Hooks that return a string
else if ($method == 'printSearchForm' && method_exists($module,$method))
// Generic hooks that return a string (printSearchForm, printLeftBlock, formBuilddocOptions, ...)
else if (method_exists($actioninstance,$method))
{
$resprint.='<!-- Begin search form hook area -->'."\n";
$resprint.=$module->printSearchForm($object, $action, $id); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
$resprint.="\n".'<!-- End of search form hook area -->'."\n";
}
else if ($method == 'printLeftBlock' && method_exists($module,$method))
{
$resprint.='<!-- Begin left block hook area -->'."\n";
$resprint.=$module->printLeftBlock($object, $action, $id); // action can be changed by method (to go back to other action for example), socid can be changed/set by method (during creation for example)
$resprint.="\n".'<!-- End of left block hook area -->'."\n";
}
// Hook generic
else if (method_exists($module,$method))
{
if (is_array($parameters) && $parameters['special_code'] > 3 && $parameters['special_code'] != $module->module_number) continue;
$resprint.=$module->$method($object, $action, $id, $parameters, $this);
$resprint.='<!-- Begin hook '.$method.' -->'."\n";
if (is_array($parameters) && $parameters['special_code'] > 3 && $parameters['special_code'] != $module) continue;
$resprint.=$actioninstance->$method($parameters, $object, $action, $this);
$resprint.="\n".'<!-- End of hook '.$method.' -->'."\n";
}
}
}

View File

@ -21,7 +21,7 @@
* \file htdocs/core/class/html.formfile.class.php
* \ingroup core
* \brief File of class to offer components to list and upload files
* \version $Id: html.formfile.class.php,v 1.53 2011/08/10 19:55:22 hregis Exp $
* \version $Id: html.formfile.class.php,v 1.54 2011/08/10 22:47:34 eldy Exp $
*/
@ -451,7 +451,8 @@ class FormFile
$out.= '</tr>';
// Execute hooks
if (is_object($hookmanager)) $out.= $hookmanager->executeHooks('formBuilddocOptions');
$parameters=array('socid'=>$GLOBALS['socid'],'id'=>$GLOBAL['id']);
if (is_object($hookmanager)) $out.= $hookmanager->executeHooks('formBuilddocOptions',$parameters);
}
// Get list of files

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* $Id: freeproductline_create.tpl.php,v 1.17 2011/08/10 10:55:36 hregis Exp $
* $Id: freeproductline_create.tpl.php,v 1.18 2011/08/10 22:47:33 eldy Exp $
*
* Need to have following variables defined:
* $conf
@ -47,7 +47,11 @@
echo $html->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1);
if (($conf->product->enabled && $conf->service->enabled) || (empty($conf->product->enabled) && empty($conf->service->enabled))) echo '<br>';
if (is_object($hookmanager)) $hookmanager->executeHooks('formCreateProductOptions',$action,$object);
if (is_object($hookmanager))
{
$parameters=array();
$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
}
// Editor wysiwyg
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* $Id: freeproductline_edit.tpl.php,v 1.17 2011/08/10 10:55:34 hregis Exp $
* $Id: freeproductline_edit.tpl.php,v 1.18 2011/08/10 22:47:33 eldy Exp $
*
* Need to have following variables defined:
* $conf
@ -39,7 +39,11 @@
<a name="<?php echo $line->id; ?>"></a>
<?php
if (is_object($hookmanager)) $hookmanager->executeHooks('formEditProductOptions',$action,$this,$line->fk_parent_line);
if (is_object($hookmanager))
{
$parameters=array('fk_parent_line'=>$line->fk_parent_line);
$hookmanager->executeHooks('formEditProductOptions',$parameters,$object,$action);
}
// editeur wysiwyg
$nbrows=ROWS_2;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* $Id: predefinedproductline_create.tpl.php,v 1.15 2011/08/10 10:55:35 hregis Exp $
* $Id: predefinedproductline_create.tpl.php,v 1.16 2011/08/10 22:47:33 eldy Exp $
*
* Need to have following variables defined:
* $conf
@ -58,8 +58,12 @@
$html->select_produits('','idprod','',$conf->product->limit_size);
if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) echo '<br>';
if (is_object($hookmanager)) $hookmanager->executeHooks('formCreateProductOptions',$action,$object);
if (is_object($hookmanager))
{
$parameters=array();
$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
}
// Editor wysiwyg
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* $Id: predefinedproductline_edit.tpl.php,v 1.16 2011/08/10 10:55:34 hregis Exp $
* $Id: predefinedproductline_edit.tpl.php,v 1.17 2011/08/10 22:47:33 eldy Exp $
*
* Need to have following variables defined:
* $conf
@ -47,7 +47,10 @@
echo ' - '.nl2br($line->product_label);
echo '<br>';
if (is_object($hookmanager)) $hookmanager->executeHooks('formEditProductOptions',$action,$this,$line->fk_parent_line);
if (is_object($hookmanager))
{
$parameters=array('fk_parent_line'=>$line_fk_parent_line);
$hookmanager->executeHooks('formEditProductOptions',$parameters,$object,$action);
// editeur wysiwyg
$nbrows=ROWS_2;

View File

@ -24,7 +24,7 @@
* \file htdocs/lib/pdf.lib.php
* \brief Set of functions used for PDF generation
* \ingroup core
* \version $Id: pdf.lib.php,v 1.101 2011/08/10 17:40:46 hregis Exp $
* \version $Id: pdf.lib.php,v 1.102 2011/08/10 22:47:35 eldy Exp $
*/
@ -663,7 +663,7 @@ function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hide
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
$parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code);
$reshook=$hookmanager->executeHooks('pdf_writelinedesc','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
$reshook=$hookmanager->executeHooks('pdf_writelinedesc',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
}
else
{
@ -886,7 +886,7 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0,$hookmanager=
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
return $hookmanager->executeHooks('pdf_getlinevatrate','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
return $hookmanager->executeHooks('pdf_getlinevatrate',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
}
else
{
@ -911,7 +911,7 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0,$hookmanage
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
return $hookmanager->executeHooks('pdf_getlineupexcltax','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
return $hookmanager->executeHooks('pdf_getlineupexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
}
else
{
@ -938,7 +938,7 @@ function pdf_getlineqty($object,$i,$outputlangs,$hidedetails=0,$hookmanager=fals
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
return $hookmanager->executeHooks('pdf_getlineqty','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
return $hookmanager->executeHooks('pdf_getlineqty',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
}
else
{
@ -966,7 +966,7 @@ function pdf_getlineqty_asked($object,$i,$outputlangs,$hidedetails=0,$hookmanage
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
return $hookmanager->executeHooks('pdf_getlineqty_asked','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
return $hookmanager->executeHooks('pdf_getlineqty_asked',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
}
else
{
@ -994,7 +994,7 @@ function pdf_getlineqty_shipped($object,$i,$outputlangs,$hidedetails=0,$hookmana
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
return $hookmanager->executeHooks('pdf_getlineqty_shipped','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
return $hookmanager->executeHooks('pdf_getlineqty_shipped',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
}
else
{
@ -1022,7 +1022,7 @@ function pdf_getlineqty_keeptoship($object,$i,$outputlangs,$hidedetails=0,$hookm
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
return $hookmanager->executeHooks('pdf_getlineqty_keeptoship','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
return $hookmanager->executeHooks('pdf_getlineqty_keeptoship',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
}
else
{
@ -1052,7 +1052,7 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0,$hookma
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
return $hookmanager->executeHooks('pdf_getlineremisepercent','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
return $hookmanager->executeHooks('pdf_getlineremisepercent',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
}
else
{
@ -1084,7 +1084,7 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0,$hookman
$special_code = $object->lines[$i]->special_code;
if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
$parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code);
return $hookmanager->executeHooks('pdf_getlinetotalexcltax','',$object,'',$parameters); // Note that $action and $object may have been modified by some hooks
return $hookmanager->executeHooks('pdf_getlinetotalexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
}
else
{

View File

@ -25,7 +25,7 @@
* \file htdocs/main.inc.php
* \ingroup core
* \brief File that defines environment for Dolibarr pages only (variables not required by scripts)
* \version $Id: main.inc.php,v 1.758 2011/08/10 11:23:41 eldy Exp $
* \version $Id: main.inc.php,v 1.759 2011/08/10 22:47:36 eldy Exp $
*/
@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP
@ -1346,7 +1346,8 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
}
// Execute hook printSearchForm
$searchform.=$hookmanager->executeHooks('printSearchForm'); // Note that $action and $object may have been modified by some hooks
$parameters=array();
$searchform.=$hookmanager->executeHooks('printSearchForm',$parameters); // Note that $action and $object may have been modified by some hooks
// Define $bookmarks
if ($conf->bookmark->enabled && $user->rights->bookmark->lire)
@ -1457,7 +1458,8 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
print "\n";
// Execute hook printLeftBlock
$leftblock.=$hookmanager->executeHooks('printLeftBlock'); // Note that $action and $object may have been modified by some hooks
$parameters=array();
$leftblock.=$hookmanager->executeHooks('printLeftBlock',$parameters); // Note that $action and $object may have been modified by some hooks
print $leftblock;
if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print '</div> <!-- End left layout -->'."\n";

View File

@ -26,7 +26,7 @@
* \file htdocs/societe/class/societe.class.php
* \ingroup societe
* \brief File for third party class
* \version $Id: societe.class.php,v 1.95 2011/08/10 10:55:39 hregis Exp $
* \version $Id: societe.class.php,v 1.96 2011/08/10 22:47:35 eldy Exp $
*/
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
@ -537,7 +537,8 @@ class Societe extends CommonObject
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
$hookmanager->callHooks(array('thirdparty_extrafields'));
$reshook=$hookmanager->executeHooks('insertExtraFields',$action,$this,$socid); // Note that $action and $object may have been modified by some hooks
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
$result=$this->insertExtraFields($this);

View File

@ -25,7 +25,7 @@
* \file htdocs/societe/soc.php
* \ingroup societe
* \brief Third party card page
* \version $Id: soc.php,v 1.131 2011/08/10 19:34:44 eldy Exp $
* \version $Id: soc.php,v 1.132 2011/08/10 22:47:35 eldy Exp $
*/
require("../main.inc.php");
@ -87,7 +87,8 @@ $hookmanager->callHooks(array('thirdpartycard','thirdparty_extrafields'));
* Actions
*/
$reshook=$hookmanager->executeHooks('doActions',$action,$object,$socid); // Note that $action and $object may have been modified by some hooks
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
// ---------- start deprecated. Use hook to hook actions.
@ -999,7 +1000,8 @@ else
}
// Other attributes
$reshook=$hookmanager->executeHooks('showInputFields',$action,$object); // Note that $action and $object may have been modified by hook
$parameters=array();
$reshook=$hookmanager->executeHooks('showInputFields',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
foreach($extrafields->attribute_label as $key=>$label)
@ -1426,7 +1428,8 @@ else
}
// Other attributes
$reshook=$hookmanager->executeHooks('showInputFields',$action,$object); // Note that $action and $object may have been modified by hook
$parameters=array();
$reshook=$hookmanager->executeHooks('showInputFields',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
foreach($extrafields->attribute_label as $key=>$label)
@ -1766,7 +1769,8 @@ else
}
// Other attributes
$reshook=$hookmanager->executeHooks('showOutputFields',$action,$object,$socid); // Note that $action and $object may have been modified by hook
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('showOutputFields',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
foreach($extrafields->attribute_label as $key=>$label)
@ -1955,5 +1959,5 @@ else
$db->close();
llxFooter('$Date: 2011/08/10 19:34:44 $ - $Revision: 1.131 $');
llxFooter('$Date: 2011/08/10 22:47:35 $ - $Revision: 1.132 $');
?>