Clean code. $hookmanager must be global and never be erased
This commit is contained in:
parent
8c4056f38f
commit
2ab510d746
@ -1319,15 +1319,17 @@ class ActionComm extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function getActions($socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0)
|
public function getActions($socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs, $hookmanager;
|
||||||
|
|
||||||
$resarray = array();
|
$resarray = array();
|
||||||
|
|
||||||
dol_syslog(get_class()."::getActions", LOG_DEBUG);
|
dol_syslog(get_class()."::getActions", LOG_DEBUG);
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
|
|
||||||
$hookmanager = new HookManager($this->db);
|
|
||||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||||
|
if (!is_object($hookmanager)) {
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
|
$hookmanager = new HookManager($db);
|
||||||
|
}
|
||||||
$hookmanager->initHooks(array('agendadao'));
|
$hookmanager->initHooks(array('agendadao'));
|
||||||
|
|
||||||
$sql = "SELECT a.id";
|
$sql = "SELECT a.id";
|
||||||
|
|||||||
@ -641,7 +641,7 @@ class CMailFile
|
|||||||
*/
|
*/
|
||||||
public function sendfile()
|
public function sendfile()
|
||||||
{
|
{
|
||||||
global $conf, $db, $langs;
|
global $conf, $db, $langs, $hookmanager;
|
||||||
|
|
||||||
$errorlevel = error_reporting();
|
$errorlevel = error_reporting();
|
||||||
//error_reporting($errorlevel ^ E_WARNING); // Desactive warnings
|
//error_reporting($errorlevel ^ E_WARNING); // Desactive warnings
|
||||||
@ -649,8 +649,10 @@ class CMailFile
|
|||||||
$res = false;
|
$res = false;
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
|
if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
if (!is_object($hookmanager)) {
|
||||||
$hookmanager = new HookManager($db);
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
|
$hookmanager = new HookManager($db);
|
||||||
|
}
|
||||||
$hookmanager->initHooks(array('mail'));
|
$hookmanager->initHooks(array('mail'));
|
||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
|
|||||||
@ -210,7 +210,8 @@ function getEntity($element, $shared = 1, $currentobject = null)
|
|||||||
{
|
{
|
||||||
global $conf, $mc, $hookmanager, $object, $action, $db;
|
global $conf, $mc, $hookmanager, $object, $action, $db;
|
||||||
|
|
||||||
if (! is_object($hookmanager)) {
|
if (!is_object($hookmanager)) {
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1114,6 +1114,7 @@ function httponly_accessforbidden($message = 1, $http_response_code = 403, $stri
|
|||||||
function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null)
|
function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null)
|
||||||
{
|
{
|
||||||
global $conf, $db, $user, $langs, $hookmanager;
|
global $conf, $db, $user, $langs, $hookmanager;
|
||||||
|
global $action, $object;
|
||||||
|
|
||||||
if (!is_object($langs)) {
|
if (!is_object($langs)) {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
|
||||||
@ -1139,12 +1140,13 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
if (empty($showonlymessage)) {
|
if (empty($showonlymessage)) {
|
||||||
global $action, $object;
|
|
||||||
if (empty($hookmanager)) {
|
if (empty($hookmanager)) {
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||||
$hookmanager->initHooks(array('main'));
|
$hookmanager->initHooks(array('main'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$parameters = array('message'=>$message, 'params'=>$params);
|
$parameters = array('message'=>$message, 'params'=>$params);
|
||||||
$reshook = $hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
|
|||||||
@ -122,6 +122,7 @@ if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) {
|
|||||||
$contentsecuritypolicy = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSPRO');
|
$contentsecuritypolicy = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSPRO');
|
||||||
|
|
||||||
if (!is_object($hookmanager)) {
|
if (!is_object($hookmanager)) {
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
}
|
}
|
||||||
$hookmanager->initHooks(array("main"));
|
$hookmanager->initHooks(array("main"));
|
||||||
@ -154,6 +155,7 @@ if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) {
|
|||||||
$contentsecuritypolicy = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP');
|
$contentsecuritypolicy = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP');
|
||||||
|
|
||||||
if (!is_object($hookmanager)) {
|
if (!is_object($hookmanager)) {
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
}
|
}
|
||||||
$hookmanager->initHooks(array("main"));
|
$hookmanager->initHooks(array("main"));
|
||||||
|
|||||||
@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
|
||||||
|
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
|
|
||||||
$socid = GETPOST('socid', 'int');
|
$socid = GETPOST('socid', 'int');
|
||||||
|
|
||||||
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
|
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
|
||||||
|
|||||||
@ -54,6 +54,7 @@ if (isModEnabled('holiday')) {
|
|||||||
|
|
||||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
|
|
||||||
$hookmanager->initHooks('hrmindex');
|
$hookmanager->initHooks('hrmindex');
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
|
|||||||
@ -1622,6 +1622,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr
|
|||||||
//print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">'."\n";
|
//print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">'."\n";
|
||||||
if (empty($disablehead)) {
|
if (empty($disablehead)) {
|
||||||
if (!is_object($hookmanager)) {
|
if (!is_object($hookmanager)) {
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
}
|
}
|
||||||
$hookmanager->initHooks(array("main"));
|
$hookmanager->initHooks(array("main"));
|
||||||
|
|||||||
@ -37,6 +37,11 @@ if ($search_project_user == $user->id) {
|
|||||||
$mine = 1;
|
$mine = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hookmanager = new HookManager($db);
|
||||||
|
|
||||||
|
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
|
||||||
|
$hookmanager->initHooks(array('activityindex'));
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = 0;
|
$socid = 0;
|
||||||
if ($user->socid > 0) {
|
if ($user->socid > 0) {
|
||||||
@ -47,11 +52,6 @@ if (!$user->rights->projet->lire) {
|
|||||||
accessforbidden();
|
accessforbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
$hookmanager = new HookManager($db);
|
|
||||||
|
|
||||||
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
|
|
||||||
$hookmanager->initHooks(array('activityindex'));
|
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
|
|
||||||
|
|||||||
@ -66,8 +66,8 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||||
|
|
||||||
// Hook to be used by external payment modules (ie Payzen, ...)
|
// Hook to be used by external payment modules (ie Payzen, ...)
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
$hookmanager->initHooks(array('newpayment'));
|
$hookmanager->initHooks(array('newpayment'));
|
||||||
|
|
||||||
|
|||||||
@ -58,9 +58,10 @@ if (isModEnabled('paypal')) {
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook to be used by external payment modules (ie Payzen, ...)
|
// Hook to be used by external payment modules (ie Payzen, ...)
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
|
|
||||||
$hookmanager->initHooks(array('newpayment'));
|
$hookmanager->initHooks(array('newpayment'));
|
||||||
|
|
||||||
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal"));
|
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal"));
|
||||||
|
|||||||
@ -50,9 +50,10 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||||
|
|
||||||
// Hook to be used by external payment modules (ie Payzen, ...)
|
// Hook to be used by external payment modules (ie Payzen, ...)
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
|
|
||||||
$hookmanager->initHooks(array('newpayment'));
|
$hookmanager->initHooks(array('newpayment'));
|
||||||
|
|
||||||
// Load translation files
|
// Load translation files
|
||||||
|
|||||||
@ -51,9 +51,10 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
|
||||||
|
|
||||||
// Hook to be used by external payment modules (ie Payzen, ...)
|
// Hook to be used by external payment modules (ie Payzen, ...)
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
|
|
||||||
$hookmanager->initHooks(array('newpayment'));
|
$hookmanager->initHooks(array('newpayment'));
|
||||||
|
|
||||||
// For encryption
|
// For encryption
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user