29if (!defined(
'NOTOKENRENEWAL')) {
30 define(
'NOTOKENRENEWAL', 1);
32if (!defined(
'NOREQUIREMENU')) {
33 define(
'NOREQUIREMENU',
'1');
35if (!defined(
'NOREQUIREHTML')) {
36 define(
'NOREQUIREHTML',
'1');
38if (!defined(
'NOREQUIREAJAX')) {
39 define(
'NOREQUIREAJAX',
'1');
42if (!isset($mode) || $mode !=
'noajax') {
43 $res = @include
'../../main.inc.php';
44 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
45 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
46 include_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
47 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
48 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
50 $openeddir =
GETPOST(
'openeddir');
51 $modulepart =
GETPOST(
'modulepart');
54 $preopened =
GETPOST(
'preopened');
56 if ($selecteddir !=
'/') {
57 $selecteddir = preg_replace(
'/\/$/',
'', $selecteddir);
62 $openeddir =
GETPOST(
'openeddir');
63 $modulepart =
GETPOST(
'modulepart');
66 $preopened =
GETPOST(
'preopened');
68 if ($selecteddir !=
'/') {
69 $selecteddir = preg_replace(
'/\/$/',
'', $selecteddir);
72 $url = DOL_URL_ROOT.
'/ecm/index.php';
76$websitekey =
GETPOST(
'websitekey',
'alpha');
77$pageid =
GETPOST(
'pageid',
'int');
83$fullpathselecteddir =
'<none>';
84if ($modulepart ==
'ecm') {
85 $fullpathselecteddir = $conf->ecm->dir_output.
'/'.($selecteddir !=
'/' ? $selecteddir :
'');
86 $fullpathpreopened = $conf->ecm->dir_output.
'/'.($preopened !=
'/' ? $preopened :
'');
87} elseif ($modulepart ==
'medias' || $modulepart ==
'website') {
88 $fullpathselecteddir = $dolibarr_main_data_root.
'/medias/'.($selecteddir !=
'/' ? $selecteddir :
'');
89 $fullpathpreopened = $dolibarr_main_data_root.
'/medias/'.($preopened !=
'/' ? $preopened :
'');
95if (preg_match(
'/\.\./', $fullpathselecteddir) || preg_match(
'/[<>|]/', $fullpathselecteddir)) {
96 dol_syslog(
"Refused to deliver file ".$original_file);
102if (empty($modulepart)) {
103 $modulepart = $module;
107if ($modulepart ==
'ecm') {
108 if (!$user->hasRight(
'ecm',
'read')) {
111} elseif ($modulepart ==
'medias' || $modulepart ==
'website') {
128if (!isset($mode) || $mode !=
'noajax') {
133$userstatic =
new User($db);
134$form =
new Form($db);
138if (empty($sqltree)) {
139 $sqltree = $ecmdirstatic->get_full_arbo(0);
143$current_ecmdir_id = -1;
144foreach ($sqltree as $keycursor => $val) {
146 if ($val[
'fullrelativename'] == $selecteddir) {
147 $current_ecmdir_id = $keycursor;
151if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
152 treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened);
157 print
"\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n";
158 print
'<script nonce="'.getNonce().
'" type="text/javascript">
159 jQuery(document).ready(function () {
160 jQuery(".classfortooltip").tooltip({
161 show: { collision: "flipfit", effect:\'toggle\', delay:50 },
162 hide: { delay: 50 }, /* If I enable effect:\'toggle\' here, a bug appears: the tooltip is shown when collpasing a new dir if it was shown before */
163 tooltipClass: "mytooltip",
164 content: function () {
165 return $(this).prop(\'title\'); /* To force to get title as is */
178if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS)) {
179 print
'<ul class="ecmjqft">';
182 if (empty($sqltree)) {
183 $sqltree = $ecmdirstatic->get_full_arbo(0);
191 $fullpathselected =
'';
192 foreach ($sqltree as $key => $val) {
194 if ($val[
'id'] == $section) {
195 $fullpathselected = $val[
'fullpath'];
202 $expandedsectionarray = array();
203 if (isset($_SESSION[
'dol_ecmexpandedsectionarray'])) {
204 $expandedsectionarray = explode(
',', $_SESSION[
'dol_ecmexpandedsectionarray']);
207 if ($section &&
GETPOST(
'sectionexpand') ==
'true') {
209 $pathtosection = explode(
'_', $fullpathselected);
210 foreach ($pathtosection as $idcursor) {
211 if ($idcursor && !in_array($idcursor, $expandedsectionarray)) {
212 $expandedsectionarray[] = $idcursor;
215 $_SESSION[
'dol_ecmexpandedsectionarray'] = join(
',', $expandedsectionarray);
217 if ($section &&
GETPOST(
'sectionexpand') ==
'false') {
219 $oldexpandedsectionarray = $expandedsectionarray;
220 $expandedsectionarray = array();
221 foreach ($oldexpandedsectionarray as $sectioncursor) {
225 $_SESSION[
'dol_ecmexpandedsectionarray'] = join(
',', $expandedsectionarray);
231 foreach ($sqltree as $key => $val) {
232 $ecmdirstatic->id = $val[
'id'];
233 $ecmdirstatic->ref = $val[
'label'];
236 if (preg_match(
'/refresh/i', $action)) {
237 $result = $ecmdirstatic->fetch($val[
'id']);
238 $ecmdirstatic->ref = $ecmdirstatic->label;
240 $result = $ecmdirstatic->refreshcachenboffile(0);
241 $val[
'cachenbofdoc'] = $result;
250 if (in_array($val[
'id_mere'], $expandedsectionarray)) {
252 } elseif ($val[
'id'] != $section && $val[
'id_mere'] == $ecmdirstatic->motherof[$section]) {
255 } elseif (preg_match(
'/'.$val[
'fullpath'].
'_/i', $fullpathselected.
'_')) {
258 } elseif ($val[
'level'] < 2) {
264 if (in_array($val[
'id'], $expandedsectionarray)) {
265 $option =
'indexexpanded';
267 $option =
'indexnotexpanded';
271 print
'<li class="directory collapsed">';
275 while ($cpt < $sqltree[$key][
'level']) {
276 print
' ';
281 $nbofsubdir = $resarray[1];
282 $nboffilesinsubdir = $resarray[2];
285 print $ecmdirstatic->getNomUrl(0, $option, 32,
'class="fmdirlia jqft ecmjqft"');
287 print
'<div class="ecmjqft">';
290 print
'<table class="nobordernopadding"><tr>';
292 print
'<!-- nb of docs -->';
294 print $val[
'cachenbofdoc'];
297 print
'<!-- nb in subdir -->';
298 print
'<td class="left">';
299 if ($nbofsubdir && $nboffilesinsubdir) {
300 print
'<span style="color: #AAAAAA">+'.$nboffilesinsubdir.
'</span> ';
305 print
'<!-- info -->';
306 print
'<td class="center">';
307 $userstatic->id = $val[
'fk_user_c'];
308 $userstatic->lastname = $val[
'login_c'];
309 $userstatic->statut = $val[
'statut_c'];
310 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
311 $htmltooltip =
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionManual").
'<br>';
312 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$userstatic->getNomUrl(1,
'',
false, 1).
'<br>';
313 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationDate").
'</b>: '.
dol_print_date($val[
'date_c'],
"dayhour").
'<br>';
314 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'description'].
'<br>';
315 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInDir").
'</b>: '.$val[
'cachenbofdoc'].
'<br>';
317 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInSubDir").
'</b>: '.$nboffilesinsubdir;
319 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfSubDir").
'</b>: '.$nbofsubdir.
'<br>';
321 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
324 print
'</tr></table>';
331 $oldvallevel = $val[
'level'];
336 if ($nbofentries == 0) {
337 print
'<li class="directory collapsed">';
338 print
'<div class="ecmjqft">';
339 print $langs->trans(
"ECMNoDirectoryYet");
349if ((!isset($mode) || $mode !=
'noajax') && is_object($db)) {
369function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth = 0)
371 global $conf, $db, $langs, $form;
372 global $dolibarr_main_data_root;
375 $userstatic =
new User($db);
377 if (file_exists($fullpathselecteddir)) {
378 $files = @scandir($fullpathselecteddir);
380 if (!empty($files)) {
382 if (count($files) > 2) {
383 echo
'<ul class="ecmjqft" style="display: none;">'.
"\n";
386 foreach ($files as $file) {
387 if ($file ==
'temp') {
392 $nboffilesinsubdir = 0;
397 foreach ($sqltree as $key => $tmpval) {
399 if ($tmpval[
'fullrelativename'] == (($selecteddir !=
'/' ? $selecteddir.
'/' :
'').$file)) {
404 if (isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] < 0) {
405 $result = $ecmdirstatic->fetch($val[
'id']);
406 $ecmdirstatic->ref = $ecmdirstatic->label;
408 $result = $ecmdirstatic->refreshcachenboffile(0);
409 $val[
'cachenbofdoc'] = $result;
413 $nbofsubdir = $resarray[1];
414 $nboffilesinsubdir = $resarray[2];
420 if ($file !=
'.' && $file !=
'..' && ((!empty($val[
'fullrelativename']) && $val[
'id'] >= 0) ||
dol_is_dir($fullpathselecteddir.(preg_match(
'/\/$/', $fullpathselecteddir) ?
'' :
'/').$file))) {
421 if (empty($val[
'fullrelativename'])) {
422 $val[
'fullrelativename'] = (($selecteddir && $selecteddir !=
'/') ? $selecteddir.
'/' :
'').$file;
424 $val[
'label'] = $file;
425 $val[
'description'] =
'';
426 $nboffilesinsubdir = $langs->trans(
"Unknown");
429 $collapsedorexpanded =
'collapsed';
430 if (preg_match(
'/^'.preg_quote($val[
'fullrelativename'].
'/',
'/').
'/', $preopened)) {
431 $collapsedorexpanded =
'expanded';
433 print
'<li class="directory '.$collapsedorexpanded.
' lidirecm">';
436 print
'<a class="fmdirlia jqft ecmjqft" href="';
438 print
"\" rel=\"".dol_escape_htmltag($val[
'fullrelativename'].
'/').
"\" id=\"fmdirlia_id_".$val[
'id'].
"\"";
439 print
" onClick=\"loadandshowpreview('".dol_escape_js($val[
'fullrelativename']).
"',".$val[
'id'].
")";
445 print
'<div class="ecmjqft">';
447 print
'<table class="nobordernopadding"><tr>';
454 print
'<!-- nb of docs -->';
455 print
'<td class="right">';
456 print (isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] >= 0) ? $val[
'cachenbofdoc'] :
' ';
459 print
'<!-- nb of subdirs -->';
460 print
'<td class="left">';
461 if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) {
462 print
'<span class="opacitymedium">+'.$nboffilesinsubdir.
'</span> ';
467 print
'<!-- edit link -->';
468 print
'<td class="right" width="18"><a class="editfielda" href="';
469 print DOL_URL_ROOT.
'/ecm/dir_card.php?module='.urlencode($modulepart).
'§ion='.$val[
'id'].
'&relativedir='.urlencode($val[
'fullrelativename']);
470 print
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.$websitekey.
'&pageid='.$pageid);
471 print
'">'.img_edit($langs->trans(
"Edit").
' - '.$langs->trans(
"View"), 0,
'class="valignmiddle opacitymedium"').
'</a></td>';
478 if ($modulepart ==
'ecm') {
479 print
'<!-- info -->';
480 print
'<td class="right" width="18">';
481 $userstatic->id = isset($val[
'fk_user_c']) ? $val[
'fk_user_c'] : 0;
482 $userstatic->lastname = isset($val[
'login_c']) ? $val[
'login_c'] : 0;
483 $userstatic->statut = isset($val[
'statut_c']) ? $val[
'statut_c'] : 0;
484 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
485 $htmltooltip =
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionManual").
'<br>';
486 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$userstatic->getNomUrl(1,
'',
false, 1).
'<br>';
487 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationDate").
'</b>: '.(isset($val[
'date_c']) ?
dol_print_date($val[
'date_c'],
"dayhour") : $langs->trans(
"NeedRefresh")).
'<br>';
488 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'description'].
'<br>';
489 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInDir").
'</b>: '.((isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] >= 0) ? $val[
'cachenbofdoc'] : $langs->trans(
"NeedRefresh")).
'<br>';
490 if ($nboffilesinsubdir > 0) {
491 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInSubDir").
'</b>: '.$nboffilesinsubdir;
493 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfSubDir").
'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans(
"NeedRefresh")).
'<br>';
495 print $form->textwithpicto(
'', $htmltooltip, 1,
"info");
499 print
"</tr></table>\n";
503 if (preg_match(
'/^'.preg_quote($val[
'fullrelativename'].
'/',
'/').
'/', $preopened)) {
505 $newselecteddir = $val[
'fullrelativename'];
506 $newfullpathselecteddir =
'';
507 if ($modulepart ==
'ecm') {
508 $newfullpathselecteddir = $conf->ecm->dir_output.
'/'.($val[
'fullrelativename'] !=
'/' ? $val[
'fullrelativename'] :
'');
509 } elseif ($modulepart ==
'medias') {
510 $newfullpathselecteddir = $dolibarr_main_data_root.
'/medias/'.($val[
'fullrelativename'] !=
'/' ? $val[
'fullrelativename'] :
'');
513 if ($newfullpathselecteddir) {
514 treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1);
525 print
"PermissionDenied";
foreach($sqltree as $keycursor=> $val) if(!empty( $conf->use_javascript_ajax) &&empty( $conf->global->MAIN_ECM_DISABLE_JS)) if(empty($conf->use_javascript_ajax)||!empty($conf->global->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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.