Fix: possibility to disable hook
This commit is contained in:
parent
dc7100677a
commit
58ae3b9372
@ -47,25 +47,16 @@ function dol_basename($pathfile)
|
|||||||
* @param string $sortcriteria Sort criteria ("","fullname","name","date","size")
|
* @param string $sortcriteria Sort criteria ("","fullname","name","date","size")
|
||||||
* @param string $sortorder Sort order (SORT_ASC, SORT_DESC)
|
* @param string $sortorder Sort order (SORT_ASC, SORT_DESC)
|
||||||
* @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
|
* @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
|
||||||
|
* @param int $nohook Disable all hooks
|
||||||
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file')
|
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file')
|
||||||
*/
|
*/
|
||||||
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
|
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=false)
|
||||||
{
|
{
|
||||||
global $db, $hookmanager;
|
global $db, $hookmanager;
|
||||||
global $object;
|
global $object;
|
||||||
|
|
||||||
dol_syslog("files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".json_encode($excludefilter));
|
dol_syslog("files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".json_encode($excludefilter));
|
||||||
|
|
||||||
if (! is_object($hookmanager))
|
|
||||||
{
|
|
||||||
if (! class_exists('HookManager')) {
|
|
||||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
|
||||||
require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
|
||||||
$hookmanager=new HookManager($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$hookmanager->initHooks(array('fileslib'));
|
|
||||||
|
|
||||||
$loaddate=($mode==1||$mode==2)?true:false;
|
$loaddate=($mode==1||$mode==2)?true:false;
|
||||||
$loadsize=($mode==1||$mode==3)?true:false;
|
$loadsize=($mode==1||$mode==3)?true:false;
|
||||||
|
|
||||||
@ -73,23 +64,35 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
|||||||
$path=preg_replace('/([\\/]+)$/i','',$path);
|
$path=preg_replace('/([\\/]+)$/i','',$path);
|
||||||
$newpath=dol_osencode($path);
|
$newpath=dol_osencode($path);
|
||||||
|
|
||||||
$parameters=array(
|
if (! $nohook) {
|
||||||
'path' => $newpath,
|
if (! is_object($hookmanager))
|
||||||
'types'=> $types,
|
{
|
||||||
'recursive' => $recursive,
|
if (! class_exists('HookManager')) {
|
||||||
'filter' => $filter,
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
'excludefilter' => $excludefilter,
|
require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
'sortcriteria' => $sortcriteria,
|
$hookmanager=new HookManager($db);
|
||||||
'sortorder' => $sortorder,
|
}
|
||||||
'loaddate' => $loaddate,
|
}
|
||||||
'loadsize' => $loadsize
|
$hookmanager->initHooks(array('fileslib'));
|
||||||
);
|
|
||||||
$reshook=$hookmanager->executeHooks('getNodesList', $parameters, $object);
|
$parameters=array(
|
||||||
|
'path' => $newpath,
|
||||||
|
'types'=> $types,
|
||||||
|
'recursive' => $recursive,
|
||||||
|
'filter' => $filter,
|
||||||
|
'excludefilter' => $excludefilter,
|
||||||
|
'sortcriteria' => $sortcriteria,
|
||||||
|
'sortorder' => $sortorder,
|
||||||
|
'loaddate' => $loaddate,
|
||||||
|
'loadsize' => $loadsize
|
||||||
|
);
|
||||||
|
$reshook=$hookmanager->executeHooks('getNodesList', $parameters, $object);
|
||||||
|
}
|
||||||
|
|
||||||
// $reshook may contain returns stacked by other modules
|
// $reshook may contain returns stacked by other modules
|
||||||
// $reshook is always empty with an array for can not lose returns stacked with other modules
|
// $reshook is always empty with an array for can not lose returns stacked with other modules
|
||||||
// $hookmanager->resArray may contain array stacked by other modules
|
// $hookmanager->resArray may contain array stacked by other modules
|
||||||
if (! empty($hookmanager->resArray)) // forced to use $hookmanager->resArray even if $hookmanager->resArray['nodes'] is empty
|
if (! $nohook && ! empty($hookmanager->resArray)) // forced to use $hookmanager->resArray even if $hookmanager->resArray['nodes'] is empty
|
||||||
{
|
{
|
||||||
return $hookmanager->resArray['nodes'];
|
return $hookmanager->resArray['nodes'];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1230,7 +1230,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0)
|
|||||||
if (! $tmpdir) { unset($listofdir[$key]); continue; }
|
if (! $tmpdir) { unset($listofdir[$key]); continue; }
|
||||||
if (is_dir($tmpdir))
|
if (is_dir($tmpdir))
|
||||||
{
|
{
|
||||||
$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt');
|
$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt','','name',SORT_ASC,0,true); // Disable hook for the moment
|
||||||
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
|
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1817,7 +1817,7 @@ else
|
|||||||
|
|
||||||
$var=true;
|
$var=true;
|
||||||
|
|
||||||
$somethingshown=$formfile->show_documents('company',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang);
|
$somethingshown=$formfile->show_documents('company',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang,$hookmanager);
|
||||||
|
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td></td>';
|
print '<td></td>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user