diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 9724465864b..58f96b7faf1 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -50,13 +50,17 @@ if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) if (! $error) { + // Define if we have to generate thumbs or not + $generatethumbs = 1; + if (GETPOST('section_dir')) $generatethumbs=0; + if (! empty($upload_dirold) && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha')); + $result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs); } elseif (! empty($upload_dir)) { - $result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha')); + $result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs); } } } @@ -69,7 +73,7 @@ elseif (GETPOST('linkit','none') && ! empty($conf->global->MAIN_UPLOAD_DOC)) if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') { $link = 'http://' . $link; } - dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link); + dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link, '', 0); } } @@ -211,13 +215,20 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha')) $result = dol_move($srcpath, $destpath); if ($result) { - if ($object->id) - { - $object->addThumbs($destpath); - } + // Define if we have to generate thumbs or not + $generatethumbs = 1; + if (GETPOST('section_dir')) $generatethumbs=0; - // TODO Add revert function of addThumbs to remove for old name - //$object->delThumbs($srcpath); + if ($generatethumbs) + { + if ($object->id) + { + $object->addThumbs($destpath); + } + + // TODO Add revert function of addThumbs to remove thumbs with old name + //$object->delThumbs($srcpath); + } setEventMessages($langs->trans("FileRenamed"), null); } diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index a55df4a1038..fc01474a072 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -72,12 +72,12 @@ $fullpathselecteddir=''; if ($modulepart == 'ecm') { $fullpathselecteddir=$conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : ''); - $fullpathopeneddir=$conf->ecm->dir_output.'/'.($openeddir != '/' ? $openeddir : ''); + $fullpathpreopened=$conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : ''); } if ($modulepart == 'medias') { $fullpathselecteddir=$dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : ''); - $fullpathopeneddir=$dolibarr_main_data_root.'/medias/'.($openeddir != '/' ? $openeddir : ''); + $fullpathpreopened=$dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : ''); } @@ -132,161 +132,9 @@ foreach($sqltree as $keycursor => $val) if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { + treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened); -/** - * treeOutputForAbsoluteDir - * - * @param array $sqltree Sqltree - * @param string $selecteddir Selected dir - * @param string $fullpathselecteddir Full path of selected dir - * @param string $modulepart Modulepart - * @param string $websitekey Website key - * @param int $pageid Page id - * @return void - */ -function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid) -{ - global $db, $langs, $form; - - $ecmdirstatic = new EcmDirectory($db); - $userstatic = new User($db); - - if (file_exists($fullpathselecteddir)) - { - $files = @scandir($fullpathselecteddir); - - if ($files) - { - natcasesort($files); - if (count($files) > 2) /* The 2 accounts for . and .. */ - { - echo '\n"; - - } - } - else print "PermissionDenied"; - } -} - - treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid); - + // TODO Find a solution to not output this code for each leaf we open // Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php) // Because the content is reloaded by ajax call, we must also reenable some jquery hooks print "\n\n"; @@ -472,3 +320,175 @@ if (empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_ECM_DISABLE // Close db if mode is not noajax if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close(); + + + +/** + * treeOutputForAbsoluteDir + * + * @param array $sqltree Sqltree + * @param string $selecteddir Selected dir + * @param string $fullpathselecteddir Full path of selected dir + * @param string $modulepart Modulepart + * @param string $websitekey Website key + * @param int $pageid Page id + * @param string $preopened Current open dir + * @param string $fullpathpreopened Full path of current open dir + * @param int $depth Depth + * @return void + */ +function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth=0) +{ + global $conf, $db, $langs, $form; + global $dolibarr_main_data_root; + + $ecmdirstatic = new EcmDirectory($db); + $userstatic = new User($db); + + if (file_exists($fullpathselecteddir)) + { + $files = @scandir($fullpathselecteddir); + + if ($files) + { + natcasesort($files); + if (count($files) > 2) /* The 2 accounts for . and .. */ + { + echo '\n"; + + } + } + else print "PermissionDenied"; + } +} + diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index d47b846ba02..e4c5b9a84b5 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1139,7 +1139,6 @@ class FormFile //var_dump($sortfield.' - '.$sortorder); if ($sortfield && $sortorder) // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name) { - //var_dump($sortfield); $filearray=dol_sort_array($filearray, $sortfield, $sortorder); } } @@ -1258,12 +1257,9 @@ class FormFile if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1'; $fulllink=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:''); - //if (! empty($object->ref)) $fulllink.='&hashn='.$object->ref; // Hash of file path - //elseif (! empty($object->label)) $fulllink.='&hashc='.$object->label; // Hash of file content print img_picto($langs->trans("FileSharedViaALink"),'object_globe.png').' '; print ''; - //print ' '.$langs->trans("Download").''; // No target here } else { @@ -1299,17 +1295,12 @@ class FormFile if ($permtoeditline) { - print ''.img_edit('default',0,'class="paddingrightonly"').''; + $paramsectiondir=(in_array($modulepart, array('medias','ecm'))?'§ion_dir='.urlencode($relativepath):''); + print ''.img_edit('default',0,'class="paddingrightonly"').''; } } if ($permonobject) { - /* - if ($file['level1name'] <> $object->id) - $filepath=$file['level1name'].'/'.$file['name']; - else - $filepath=$file['name']; - */ $useajax=1; if (! empty($conf->dol_use_jmobile)) $useajax=0; if (empty($conf->use_javascript_ajax)) $useajax=0; diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index adc594e780f..5ee19aa25a8 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -28,7 +28,7 @@ if (empty($conf) || ! is_object($conf)) ?> - + global->MAIN_UPLOAD_DOC)) if (! $error) { - $res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', '', '', 0); + $generatethumbs = 0; + $res = dol_add_file_process($upload_dir, 0, 1, 'userfile', '', null, '', $generatethumbs); if ($res > 0) { $result=$ecmdir->changeNbOfFiles('+'); diff --git a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php index c47ca3e40ba..5fe466803fb 100644 --- a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php +++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2012 Regis Houssin + * Copyright (C) 2018 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by