diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 72b49af418e..64d35cf004b 100755 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -128,10 +128,10 @@ class HookManager $parameters['context']=join(':',$this->contextarray); dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); - // Define type of hook ('output', 'returnvalue' or 'addreplace') + // Define type of hook ('output', 'returnvalue' or 'addreplace'). 'addreplace' should be type for all hooks. 'output' and 'returnvalue' are deprecated. $hooktype='output'; if (preg_match('/^pdf_/',$method)) $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are returnvalue hooks. When there is 2 hooks of this type, only last one win. - if (in_array($method,array('doActions','formObjectOptions','pdf_writelinedesc','paymentsupplierinvoices'))) $hooktype='addreplace'; + if (in_array($method,array('doActions','formObjectOptions','moveUploadedFile','pdf_writelinedesc','paymentsupplierinvoices'))) $hooktype='addreplace'; // Loop on each hook to qualify modules that declared context $modulealreadyexecuted=array(); @@ -166,8 +166,11 @@ class HookManager if ($action=='update') $action='edit'; } } + + if (is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results); + if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints; } - // Generic hooks that return a string (printSearchForm, printLeftBlock, printTopRightMenu, formAddObjectLine, formBuilddocOptions, ...) + // Generic hooks that return a string or array (printSearchForm, printLeftBlock, printTopRightMenu, formAddObjectLine, formBuilddocOptions, ...) else { // TODO. this should be done into the method of hook by returning nothing diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index d847bd2df71..53726f39460 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -647,13 +647,13 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable return -2; } - $hookmanager->initHooks(array('fileslib')); + $reshook=$hookmanager->initHooks(array('fileslib')); $parameters=array('dest_file' => $dest_file, 'src_file' => $src_file, 'file_name' => $file_name, 'varfiles' => $varfiles, 'allowoverwrite' => $allowoverwrite); - $hookmanager->executeHooks('moveUploadedFile', $parameters, $object); + $reshook=$hookmanager->executeHooks('moveUploadedFile', $parameters, $object); } - if (empty($hookmanager->resPrint)) + if (empty($reshook)) { // The file functions must be in OS filesystem encoding. $src_file_osencoded=dol_osencode($src_file); @@ -687,7 +687,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable } } else - return $hookmanager->resPrint; + return $reshook; } /**