30if (!defined(
'NOTOKENRENEWAL')) {
31 define(
'NOTOKENRENEWAL', 1);
33if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36if (!defined(
'NOREQUIREHTML')) {
37 define(
'NOREQUIREHTML',
'1');
39if (!defined(
'NOREQUIREAJAX')) {
40 define(
'NOREQUIREAJAX',
'1');
58@phan-var-force int $section
59@phan-var-force string $module
60@phan-var-force ?string $mode
63if (!isset($mode) || $mode !=
'noajax') {
64 $res = @include
'../../main.inc.php';
65 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
66 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
67 include_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
68 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
69 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
71 $openeddir =
GETPOST(
'openeddir');
72 $modulepart =
GETPOST(
'modulepart');
75 $preopened =
GETPOST(
'preopened');
77 if ($selecteddir !=
'/') {
78 $selecteddir = preg_replace(
'/\/$/',
'', $selecteddir);
83 $openeddir =
GETPOST(
'openeddir');
84 $modulepart =
GETPOST(
'modulepart');
87 $preopened =
GETPOST(
'preopened');
89 if ($selecteddir !=
'/') {
90 $selecteddir = preg_replace(
'/\/$/',
'', $selecteddir);
93 $url = DOL_URL_ROOT.
'/ecm/index.php';
97$websitekey =
GETPOST(
'websitekey',
'alpha');
99$original_file =
GETPOST(
"file");
105$fullpathselecteddir =
'<none>';
106$fullpathpreopened =
'';
107if ($modulepart ==
'ecm') {
108 $fullpathselecteddir =
$conf->ecm->dir_output.
'/'.($selecteddir !=
'/' ? $selecteddir :
'');
109 $fullpathpreopened =
$conf->ecm->dir_output.
'/'.($preopened !=
'/' ? $preopened :
'');
110} elseif ($modulepart ==
'medias' || $modulepart ==
'website') {
111 $fullpathselecteddir = $dolibarr_main_data_root.
'/medias/'.($selecteddir !=
'/' ? $selecteddir :
'');
112 $fullpathpreopened = $dolibarr_main_data_root.
'/medias/'.($preopened !=
'/' ? $preopened :
'');
118if (preg_match(
'/\.\./', $fullpathselecteddir) || preg_match(
'/[<>|]/', $fullpathselecteddir)) {
119 dol_syslog(
"Refused to deliver file ".$original_file);
121 dol_print_error(
null, $langs->trans(
"ErrorFileNameInvalid", $original_file));
125if (empty($modulepart)) {
126 $modulepart = $module;
130if ($modulepart ==
'ecm') {
131 if (!$user->hasRight(
'ecm',
'read')) {
134} elseif ($modulepart ==
'medias' || $modulepart ==
'website') {
152if (!isset($mode) || $mode !=
'noajax') {
162if (empty($sqltree)) {
163 $sqltree = $ecmdirstatic->get_full_arbo(0);
167$current_ecmdir_id = -1;
168foreach ($sqltree as $keycursor => $val) {
170 if ($val[
'fullrelativename'] == $selecteddir) {
171 $current_ecmdir_id = $keycursor;
177 treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened);
182 print
"\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n";
183 print
'<script nonce="'.getNonce().
'" type="text/javascript">
184 jQuery(document).ready(function () {
185 jQuery(".classfortooltip").tooltip({
186 show: { collision: "flipfit", effect:\'toggle\', delay:50 },
187 hide: { delay: 50 }, /* If I enable effect:\'toggle\' here, a bug appears: the tooltip is shown when collapsing a new dir if it was shown before */
188 tooltipClass: "mytooltip",
189 content: function () {
190 return $(this).prop(\'title\'); /* To force to get title as is */
204 print
'<ul class="ecmjqft">';
207 if (empty($sqltree)) {
208 $sqltree = $ecmdirstatic->get_full_arbo(0);
216 $fullpathselected =
'';
217 foreach ($sqltree as $key => $val) {
219 if ($val[
'id'] == $section) {
220 $fullpathselected = $val[
'fullpath'];
227 $expandedsectionarray = array();
228 if (isset($_SESSION[
'dol_ecmexpandedsectionarray'])) {
229 $expandedsectionarray = explode(
',', $_SESSION[
'dol_ecmexpandedsectionarray']);
232 if ($section &&
GETPOST(
'sectionexpand') ==
'true') {
234 $pathtosection = explode(
'_', $fullpathselected);
235 foreach ($pathtosection as $idcursor) {
236 if ($idcursor && !in_array($idcursor, $expandedsectionarray)) {
237 $expandedsectionarray[] = $idcursor;
240 $_SESSION[
'dol_ecmexpandedsectionarray'] = implode(
',', $expandedsectionarray);
242 if ($section &&
GETPOST(
'sectionexpand') ==
'false') {
244 $oldexpandedsectionarray = $expandedsectionarray;
245 $expandedsectionarray = array();
247 foreach ($oldexpandedsectionarray as $sectioncursor) {
251 $_SESSION[
'dol_ecmexpandedsectionarray'] = implode(
',', $expandedsectionarray);
257 foreach ($sqltree as $key => $val) {
258 $ecmdirstatic->id = $val[
'id'];
259 $ecmdirstatic->ref = $val[
'label'];
262 if (preg_match(
'/refresh/i', $action)) {
263 $result = $ecmdirstatic->fetch($val[
'id']);
264 $ecmdirstatic->ref = $ecmdirstatic->label;
266 $result = $ecmdirstatic->refreshcachenboffile(0);
267 $val[
'cachenbofdoc'] = $result;
276 if (in_array($val[
'id_mere'], $expandedsectionarray)) {
278 } elseif ($val[
'id'] != $section && $val[
'id_mere'] == $ecmdirstatic->motherof[$section]) {
281 } elseif (preg_match(
'/'.$val[
'fullpath'].
'_/i', $fullpathselected.
'_')) {
284 } elseif ($val[
'level'] < 2) {
290 if (in_array($val[
'id'], $expandedsectionarray)) {
291 $option =
'indexexpanded';
293 $option =
'indexnotexpanded';
297 print
'<li class="directory collapsed">';
301 while ($cpt < $sqltree[$key][
'level']) {
302 print
' ';
307 $nbofsubdir = $resarray[1];
308 $nboffilesinsubdir = $resarray[2];
311 print $ecmdirstatic->getNomUrl(0, $option, 32,
'class="fmdirlia jqft ecmjqft"');
313 print
'<div class="ecmjqft">';
316 print
'<table class="nobordernopadding"><tr>';
318 print
'<!-- nb of docs -->';
320 print $val[
'cachenbofdoc'];
323 print
'<!-- nb in subdir -->';
324 print
'<td class="left">';
325 if ($nbofsubdir && $nboffilesinsubdir) {
326 print
'<span style="color: #AAAAAA">+'.$nboffilesinsubdir.
'</span> ';
331 print
'<!-- info -->';
332 print
'<td class="center">';
333 $userstatic->id = $val[
'fk_user_c'];
334 $userstatic->lastname = $val[
'login_c'];
335 $userstatic->status = $val[
'statut_c'];
336 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
337 $htmltooltip =
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionManual").
'<br>';
338 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$userstatic->getNomUrl(1,
'', 0, 1).
'<br>';
339 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationDate").
'</b>: '.
dol_print_date($val[
'date_c'],
"dayhour").
'<br>';
340 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'description'].
'<br>';
341 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInDir").
'</b>: '.$val[
'cachenbofdoc'].
'<br>';
343 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInSubDir").
'</b>: '.$nboffilesinsubdir;
345 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfSubDir").
'</b>: '.$nbofsubdir.
'<br>';
347 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
350 print
'</tr></table>';
357 $oldvallevel = $val[
'level'];
362 if ($nbofentries == 0) {
363 print
'<li class="directory collapsed">';
364 print
'<div class="ecmjqft">';
365 print $langs->trans(
"ECMNoDirectoryYet");
375if ((!isset($mode) || $mode !=
'noajax') && is_object(
$db)) {
395function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth = 0)
397 global
$conf,
$db, $langs, $form, $user;
398 global $dolibarr_main_data_root;
403 if (file_exists($fullpathselecteddir)) {
404 $files = @scandir($fullpathselecteddir);
406 if (!empty($files)) {
408 if (count($files) > 2) {
409 echo
'<ul class="ecmjqft" style="display: none;">'.
"\n";
413 foreach ($files as $file) {
415 if (in_array($file, array(
'temp',
'.',
'..'))) {
421 if ($user->socid > 0) {
426 $nboffilesinsubdir = 0;
431 foreach ($sqltree as $key => $tmpval) {
433 if ($tmpval[
'fullrelativename'] == (($selecteddir !=
'/' ? $selecteddir.
'/' :
'').$file)) {
438 if (isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] < 0) {
439 $result = $ecmdirstatic->fetch($val[
'id']);
440 $ecmdirstatic->ref = $ecmdirstatic->label;
442 $result = $ecmdirstatic->refreshcachenboffile(0);
443 $val[
'cachenbofdoc'] = $result;
447 $nbofsubdir = $resarray[1];
448 $nboffilesinsubdir = $resarray[2];
454 if ((!empty($val[
'fullrelativename']) && $val[
'id'] >= 0) ||
dol_is_dir($fullpathselecteddir.(preg_match(
'/\/$/', $fullpathselecteddir) ?
'' :
'/').$file)) {
455 if (empty($val[
'fullrelativename'])) {
456 $val[
'fullrelativename'] = (($selecteddir && $selecteddir !=
'/') ? $selecteddir.
'/' :
'').$file;
458 $val[
'label'] = $file;
459 $val[
'description'] =
'';
460 $nboffilesinsubdir = $langs->trans(
"Unknown");
463 $collapsedorexpanded =
'collapsed';
464 if (preg_match(
'/^'.preg_quote($val[
'fullrelativename'].
'/',
'/').
'/', $preopened)) {
465 $collapsedorexpanded =
'expanded';
470 print
'<li class="directory '.$collapsedorexpanded.
' lidirecm">';
473 print
'<a class="fmdirlia jqft ecmjqft" href="';
475 print
"\" rel=\"".dol_escape_htmltag($val[
'fullrelativename'].
'/').
"\" id=\"fmdirlia_id_".$val[
'id'].
"\"";
476 print
" onClick=\"loadandshowpreview('".dol_escape_js($val[
'fullrelativename']).
"',".$val[
'id'].
")";
482 print
'<div class="ecmjqft">';
484 print
'<table class="nobordernopadding"><tr>';
491 print
'<!-- nb of docs -->';
492 print
'<td class="right">';
493 print (isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] >= 0) ? $val[
'cachenbofdoc'] :
' ';
496 print
'<!-- nb of subdirs -->';
497 print
'<td class="left">';
498 if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) {
499 print
'<span class="opacitymedium">+'.$nboffilesinsubdir.
'</span> ';
504 print
'<!-- edit link -->';
505 print
'<td class="right" width="18"><a class="editfielda" href="';
506 print DOL_URL_ROOT.
'/ecm/dir_card.php?module='.urlencode($modulepart).
'§ion='.$val[
'id'].
'&relativedir='.urlencode($val[
'fullrelativename']);
507 print
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.$websitekey.
'&pageid='.$pageid);
508 print
'">'.img_edit($langs->trans(
"Edit").
' - '.$langs->trans(
"View"), 0,
'class="valignmiddle opacitymedium"').
'</a></td>';
515 if ($modulepart ==
'ecm') {
516 print
'<!-- info -->';
517 print
'<td class="right" width="18">';
518 $userstatic->id = isset($val[
'fk_user_c']) ? $val[
'fk_user_c'] : 0;
519 $userstatic->lastname = isset($val[
'login_c']) ? $val[
'login_c'] : 0;
520 $userstatic->status = isset($val[
'statut_c']) ? $val[
'statut_c'] : 0;
521 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
522 $htmltooltip =
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionManual").
'<br>';
523 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$userstatic->getNomUrl(1,
'', 0, 1).
'<br>';
524 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationDate").
'</b>: '.(isset($val[
'date_c']) ?
dol_print_date($val[
'date_c'],
"dayhour") : $langs->trans(
"NeedRefresh")).
'<br>';
525 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'description'].
'<br>';
526 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInDir").
'</b>: '.((isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] >= 0) ? $val[
'cachenbofdoc'] : $langs->trans(
"NeedRefresh")).
'<br>';
527 if ($nboffilesinsubdir > 0) {
528 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInSubDir").
'</b>: '.$nboffilesinsubdir;
530 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfSubDir").
'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans(
"NeedRefresh")).
'<br>';
532 print $form->textwithpicto(
'', $htmltooltip, 1,
"info");
536 print
"</tr></table>\n";
540 if (preg_match(
'/^'.preg_quote($val[
'fullrelativename'].
'/',
'/').
'/', $preopened)) {
542 $newselecteddir = $val[
'fullrelativename'];
543 $newfullpathselecteddir =
'';
544 if ($modulepart ==
'ecm') {
545 $newfullpathselecteddir =
$conf->ecm->dir_output.
'/'.($val[
'fullrelativename'] !=
'/' ? $val[
'fullrelativename'] :
'');
546 } elseif ($modulepart ==
'medias') {
547 $newfullpathselecteddir = $dolibarr_main_data_root.
'/medias/'.($val[
'fullrelativename'] !=
'/' ? $val[
'fullrelativename'] :
'');
550 if ($newfullpathselecteddir) {
551 treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1);
559 if ($user->socid > 0 && empty($nboflinesshown)) {
561 print
'<li>Not directory allowed to external users.<br>ACL for external users not yet implemented.</li>';
567 print
"PermissionDenied";
foreach($sqltree as $keycursor=> $val) if(!empty( $conf->use_javascript_ajax) &&!getDolGlobalString( 'MAIN_ECM_DISABLE_JS')) if(empty($conf->use_javascript_ajax)||getDolGlobalString('MAIN_ECM_DISABLE_JS')) if((!isset( $mode)||$mode !='noajax') &&is_object( $db)) treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth=0)
treeOutputForAbsoluteDir
Class to manage ECM directories.
Class to manage Dolibarr users.
dol_is_dir($folder)
Test if filename is a directory.
jsUnEscape($source)
Same function than javascript unescape() function but in PHP.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
tree_showpad(&$fulltree, $key, $silent=0)
Show indent and picto of a tree line.