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');
43if (!isset($mode) || $mode !=
'noajax') {
44 $res = @include
'../../main.inc.php';
45 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
46 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
47 include_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
48 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
49 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
51 $openeddir =
GETPOST(
'openeddir');
52 $modulepart =
GETPOST(
'modulepart');
55 $preopened =
GETPOST(
'preopened');
57 if ($selecteddir !=
'/') {
58 $selecteddir = preg_replace(
'/\/$/',
'', $selecteddir);
63 $openeddir =
GETPOST(
'openeddir');
64 $modulepart =
GETPOST(
'modulepart');
67 $preopened =
GETPOST(
'preopened');
69 if ($selecteddir !=
'/') {
70 $selecteddir = preg_replace(
'/\/$/',
'', $selecteddir);
73 $url = DOL_URL_ROOT.
'/ecm/index.php';
77$websitekey =
GETPOST(
'websitekey',
'alpha');
84$fullpathselecteddir =
'<none>';
85if ($modulepart ==
'ecm') {
86 $fullpathselecteddir = $conf->ecm->dir_output.
'/'.($selecteddir !=
'/' ? $selecteddir :
'');
87 $fullpathpreopened = $conf->ecm->dir_output.
'/'.($preopened !=
'/' ? $preopened :
'');
88} elseif ($modulepart ==
'medias' || $modulepart ==
'website') {
89 $fullpathselecteddir = $dolibarr_main_data_root.
'/medias/'.($selecteddir !=
'/' ? $selecteddir :
'');
90 $fullpathpreopened = $dolibarr_main_data_root.
'/medias/'.($preopened !=
'/' ? $preopened :
'');
96if (preg_match(
'/\.\./', $fullpathselecteddir) || preg_match(
'/[<>|]/', $fullpathselecteddir)) {
97 dol_syslog(
"Refused to deliver file ".$original_file);
103if (empty($modulepart)) {
104 $modulepart = $module;
108if ($modulepart ==
'ecm') {
109 if (!$user->hasRight(
'ecm',
'read')) {
112} elseif ($modulepart ==
'medias' || $modulepart ==
'website') {
130if (!isset($mode) || $mode !=
'noajax') {
135$userstatic =
new User($db);
136$form =
new Form($db);
140if (empty($sqltree)) {
141 $sqltree = $ecmdirstatic->get_full_arbo(0);
145$current_ecmdir_id = -1;
146foreach ($sqltree as $keycursor => $val) {
148 if ($val[
'fullrelativename'] == $selecteddir) {
149 $current_ecmdir_id = $keycursor;
153if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_ECM_DISABLE_JS')) {
155 treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened);
160 print
"\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n";
161 print
'<script nonce="'.getNonce().
'" type="text/javascript">
162 jQuery(document).ready(function () {
163 jQuery(".classfortooltip").tooltip({
164 show: { collision: "flipfit", effect:\'toggle\', delay:50 },
165 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 */
166 tooltipClass: "mytooltip",
167 content: function () {
168 return $(this).prop(\'title\'); /* To force to get title as is */
182 print
'<ul class="ecmjqft">';
185 if (empty($sqltree)) {
186 $sqltree = $ecmdirstatic->get_full_arbo(0);
194 $fullpathselected =
'';
195 foreach ($sqltree as $key => $val) {
197 if ($val[
'id'] == $section) {
198 $fullpathselected = $val[
'fullpath'];
205 $expandedsectionarray = array();
206 if (isset($_SESSION[
'dol_ecmexpandedsectionarray'])) {
207 $expandedsectionarray = explode(
',', $_SESSION[
'dol_ecmexpandedsectionarray']);
210 if ($section &&
GETPOST(
'sectionexpand') ==
'true') {
212 $pathtosection = explode(
'_', $fullpathselected);
213 foreach ($pathtosection as $idcursor) {
214 if ($idcursor && !in_array($idcursor, $expandedsectionarray)) {
215 $expandedsectionarray[] = $idcursor;
218 $_SESSION[
'dol_ecmexpandedsectionarray'] = implode(
',', $expandedsectionarray);
220 if ($section &&
GETPOST(
'sectionexpand') ==
'false') {
222 $oldexpandedsectionarray = $expandedsectionarray;
223 $expandedsectionarray = array();
225 foreach ($oldexpandedsectionarray as $sectioncursor) {
229 $_SESSION[
'dol_ecmexpandedsectionarray'] = implode(
',', $expandedsectionarray);
235 foreach ($sqltree as $key => $val) {
236 $ecmdirstatic->id = $val[
'id'];
237 $ecmdirstatic->ref = $val[
'label'];
240 if (preg_match(
'/refresh/i', $action)) {
241 $result = $ecmdirstatic->fetch($val[
'id']);
242 $ecmdirstatic->ref = $ecmdirstatic->label;
244 $result = $ecmdirstatic->refreshcachenboffile(0);
245 $val[
'cachenbofdoc'] = $result;
254 if (in_array($val[
'id_mere'], $expandedsectionarray)) {
256 } elseif ($val[
'id'] != $section && $val[
'id_mere'] == $ecmdirstatic->motherof[$section]) {
259 } elseif (preg_match(
'/'.$val[
'fullpath'].
'_/i', $fullpathselected.
'_')) {
262 } elseif ($val[
'level'] < 2) {
268 if (in_array($val[
'id'], $expandedsectionarray)) {
269 $option =
'indexexpanded';
271 $option =
'indexnotexpanded';
275 print
'<li class="directory collapsed">';
279 while ($cpt < $sqltree[$key][
'level']) {
280 print
' ';
285 $nbofsubdir = $resarray[1];
286 $nboffilesinsubdir = $resarray[2];
289 print $ecmdirstatic->getNomUrl(0, $option, 32,
'class="fmdirlia jqft ecmjqft"');
291 print
'<div class="ecmjqft">';
294 print
'<table class="nobordernopadding"><tr>';
296 print
'<!-- nb of docs -->';
298 print $val[
'cachenbofdoc'];
301 print
'<!-- nb in subdir -->';
302 print
'<td class="left">';
303 if ($nbofsubdir && $nboffilesinsubdir) {
304 print
'<span style="color: #AAAAAA">+'.$nboffilesinsubdir.
'</span> ';
309 print
'<!-- info -->';
310 print
'<td class="center">';
311 $userstatic->id = $val[
'fk_user_c'];
312 $userstatic->lastname = $val[
'login_c'];
313 $userstatic->status = $val[
'statut_c'];
314 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
315 $htmltooltip =
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionManual").
'<br>';
316 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$userstatic->getNomUrl(1,
'',
false, 1).
'<br>';
317 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationDate").
'</b>: '.
dol_print_date($val[
'date_c'],
"dayhour").
'<br>';
318 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'description'].
'<br>';
319 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInDir").
'</b>: '.$val[
'cachenbofdoc'].
'<br>';
321 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInSubDir").
'</b>: '.$nboffilesinsubdir;
323 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfSubDir").
'</b>: '.$nbofsubdir.
'<br>';
325 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
328 print
'</tr></table>';
335 $oldvallevel = $val[
'level'];
340 if ($nbofentries == 0) {
341 print
'<li class="directory collapsed">';
342 print
'<div class="ecmjqft">';
343 print $langs->trans(
"ECMNoDirectoryYet");
353if ((!isset($mode) || $mode !=
'noajax') && is_object($db)) {
373function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth = 0)
375 global $conf, $db, $langs, $form, $user;
376 global $dolibarr_main_data_root;
379 $userstatic =
new User($db);
381 if (file_exists($fullpathselecteddir)) {
382 $files = @scandir($fullpathselecteddir);
384 if (!empty($files)) {
386 if (count($files) > 2) {
387 echo
'<ul class="ecmjqft" style="display: none;">'.
"\n";
391 foreach ($files as $file) {
393 if (in_array($file, array(
'temp',
'.',
'..'))) {
399 if ($user->socid > 0) {
404 $nboffilesinsubdir = 0;
409 foreach ($sqltree as $key => $tmpval) {
411 if ($tmpval[
'fullrelativename'] == (($selecteddir !=
'/' ? $selecteddir.
'/' :
'').$file)) {
416 if (isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] < 0) {
417 $result = $ecmdirstatic->fetch($val[
'id']);
418 $ecmdirstatic->ref = $ecmdirstatic->label;
420 $result = $ecmdirstatic->refreshcachenboffile(0);
421 $val[
'cachenbofdoc'] = $result;
425 $nbofsubdir = $resarray[1];
426 $nboffilesinsubdir = $resarray[2];
432 if ((!empty($val[
'fullrelativename']) && $val[
'id'] >= 0) ||
dol_is_dir($fullpathselecteddir.(preg_match(
'/\/$/', $fullpathselecteddir) ?
'' :
'/').$file)) {
433 if (empty($val[
'fullrelativename'])) {
434 $val[
'fullrelativename'] = (($selecteddir && $selecteddir !=
'/') ? $selecteddir.
'/' :
'').$file;
436 $val[
'label'] = $file;
437 $val[
'description'] =
'';
438 $nboffilesinsubdir = $langs->trans(
"Unknown");
441 $collapsedorexpanded =
'collapsed';
442 if (preg_match(
'/^'.preg_quote($val[
'fullrelativename'].
'/',
'/').
'/', $preopened)) {
443 $collapsedorexpanded =
'expanded';
448 print
'<li class="directory '.$collapsedorexpanded.
' lidirecm">';
451 print
'<a class="fmdirlia jqft ecmjqft" href="';
453 print
"\" rel=\"".dol_escape_htmltag($val[
'fullrelativename'].
'/').
"\" id=\"fmdirlia_id_".$val[
'id'].
"\"";
454 print
" onClick=\"loadandshowpreview('".dol_escape_js($val[
'fullrelativename']).
"',".$val[
'id'].
")";
460 print
'<div class="ecmjqft">';
462 print
'<table class="nobordernopadding"><tr>';
469 print
'<!-- nb of docs -->';
470 print
'<td class="right">';
471 print (isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] >= 0) ? $val[
'cachenbofdoc'] :
' ';
474 print
'<!-- nb of subdirs -->';
475 print
'<td class="left">';
476 if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) {
477 print
'<span class="opacitymedium">+'.$nboffilesinsubdir.
'</span> ';
482 print
'<!-- edit link -->';
483 print
'<td class="right" width="18"><a class="editfielda" href="';
484 print DOL_URL_ROOT.
'/ecm/dir_card.php?module='.urlencode($modulepart).
'§ion='.$val[
'id'].
'&relativedir='.urlencode($val[
'fullrelativename']);
485 print
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.$websitekey.
'&pageid='.$pageid);
486 print
'">'.img_edit($langs->trans(
"Edit").
' - '.$langs->trans(
"View"), 0,
'class="valignmiddle opacitymedium"').
'</a></td>';
493 if ($modulepart ==
'ecm') {
494 print
'<!-- info -->';
495 print
'<td class="right" width="18">';
496 $userstatic->id = isset($val[
'fk_user_c']) ? $val[
'fk_user_c'] : 0;
497 $userstatic->lastname = isset($val[
'login_c']) ? $val[
'login_c'] : 0;
498 $userstatic->status = isset($val[
'statut_c']) ? $val[
'statut_c'] : 0;
499 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
500 $htmltooltip =
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionManual").
'<br>';
501 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$userstatic->getNomUrl(1,
'',
false, 1).
'<br>';
502 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationDate").
'</b>: '.(isset($val[
'date_c']) ?
dol_print_date($val[
'date_c'],
"dayhour") : $langs->trans(
"NeedRefresh")).
'<br>';
503 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'description'].
'<br>';
504 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInDir").
'</b>: '.((isset($val[
'cachenbofdoc']) && $val[
'cachenbofdoc'] >= 0) ? $val[
'cachenbofdoc'] : $langs->trans(
"NeedRefresh")).
'<br>';
505 if ($nboffilesinsubdir > 0) {
506 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfFilesInSubDir").
'</b>: '.$nboffilesinsubdir;
508 $htmltooltip .=
'<b>'.$langs->trans(
"ECMNbOfSubDir").
'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans(
"NeedRefresh")).
'<br>';
510 print $form->textwithpicto(
'', $htmltooltip, 1,
"info");
514 print
"</tr></table>\n";
518 if (preg_match(
'/^'.preg_quote($val[
'fullrelativename'].
'/',
'/').
'/', $preopened)) {
520 $newselecteddir = $val[
'fullrelativename'];
521 $newfullpathselecteddir =
'';
522 if ($modulepart ==
'ecm') {
523 $newfullpathselecteddir = $conf->ecm->dir_output.
'/'.($val[
'fullrelativename'] !=
'/' ? $val[
'fullrelativename'] :
'');
524 } elseif ($modulepart ==
'medias') {
525 $newfullpathselecteddir = $dolibarr_main_data_root.
'/medias/'.($val[
'fullrelativename'] !=
'/' ? $val[
'fullrelativename'] :
'');
528 if ($newfullpathselecteddir) {
529 treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1);
537 if ($user->socid > 0 && empty($nboflinesshown)) {
539 print
'<li>Not directory allowed to external users.<br>ACL for external users not yet implemented.</li>';
545 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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $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_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.