mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 09:38:23 +01:00
Clean code
This commit is contained in:
@@ -144,7 +144,7 @@ class HookManager
|
||||
*/
|
||||
public function executeHooks($method, $parameters = array(), &$object = '', &$action = '')
|
||||
{
|
||||
if (!is_array($this->hooks) || empty($this->hooks)) return '';
|
||||
if (!is_array($this->hooks) || empty($this->hooks)) return 0; // No hook available, do nothing.
|
||||
|
||||
$parameters['context'] = join(':', $this->contextarray);
|
||||
//dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']);
|
||||
@@ -225,14 +225,14 @@ class HookManager
|
||||
|
||||
// Loop on each hook to qualify modules that have declared context
|
||||
$modulealreadyexecuted = array();
|
||||
$resaction = 0; $error = 0; $result = '';
|
||||
$resaction = 0; $error = 0;
|
||||
foreach ($this->hooks as $context => $modules) // $this->hooks is an array with context as key and value is an array of modules that handle this context
|
||||
{
|
||||
if (!empty($modules))
|
||||
{
|
||||
foreach ($modules as $module => $actionclassinstance)
|
||||
{
|
||||
//print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."<br>\n";
|
||||
//print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."<br>\n";
|
||||
|
||||
// test to avoid running twice a hook, when a module implements several active contexts
|
||||
if (in_array($module, $modulealreadyexecuted)) continue;
|
||||
@@ -290,7 +290,7 @@ class HookManager
|
||||
}
|
||||
}
|
||||
|
||||
//print "After hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."<br>\n";
|
||||
//print "After hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."<br>\n";
|
||||
|
||||
unset($actionclassinstance->results);
|
||||
unset($actionclassinstance->resprints);
|
||||
|
||||
@@ -1155,6 +1155,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0,
|
||||
return false;
|
||||
}
|
||||
|
||||
$reshook = 0;
|
||||
if (empty($nohook))
|
||||
{
|
||||
$hookmanager->initHooks(array('fileslib'));
|
||||
@@ -1174,17 +1175,13 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0,
|
||||
if ($reshook < 0) return false;
|
||||
return true;
|
||||
} else {
|
||||
//print "x".$file." ".$disableglob;exit;
|
||||
dol_syslog("reshook=".$reshook);
|
||||
$file_osencoded = dol_osencode($file); // New filename encoded in OS filesystem encoding charset
|
||||
if (empty($disableglob) && !empty($file_osencoded))
|
||||
{
|
||||
$ok = true;
|
||||
$globencoded = str_replace('[', '\[', $file_osencoded);
|
||||
$globencoded = str_replace(']', '\]', $globencoded);
|
||||
dol_syslog("globencoded=".$globencoded);
|
||||
$listofdir = glob($globencoded);
|
||||
dol_syslog("listofdir=".join(', ', $listofdir));
|
||||
if (!empty($listofdir) && is_array($listofdir))
|
||||
{
|
||||
foreach ($listofdir as $filename)
|
||||
|
||||
Reference in New Issue
Block a user