ajaxdirtree.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <?php
  2. /* Copyright (C) 2007-2018 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/core/ajax/ajaxdirtree.php
  20. * \ingroup ecm
  21. * \brief This script returns content of a directory for filetree
  22. */
  23. // This script is called with a POST method.
  24. // Directory to scan (full path) is inside POST['dir'] and encode by js escape() if ajax is used or encoded by urlencode if mode=noajax
  25. if (!defined('NOTOKENRENEWAL')) {
  26. define('NOTOKENRENEWAL', 1); // Disables token renewal
  27. }
  28. if (!defined('NOREQUIREMENU')) {
  29. define('NOREQUIREMENU', '1');
  30. }
  31. if (!defined('NOREQUIREHTML')) {
  32. define('NOREQUIREHTML', '1');
  33. }
  34. if (!defined('NOREQUIREAJAX')) {
  35. define('NOREQUIREAJAX', '1');
  36. }
  37. if (!isset($mode) || $mode != 'noajax') { // For ajax call
  38. $res = @include '../../main.inc.php';
  39. include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  40. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  41. include_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
  42. include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
  43. include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
  44. $openeddir = GETPOST('openeddir');
  45. $modulepart = GETPOST('modulepart');
  46. $selecteddir = jsUnEscape(GETPOST('dir')); // relative path. We must decode using same encoding function used by javascript: escape()
  47. $preopened = GETPOST('preopened');
  48. if ($selecteddir != '/') {
  49. $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/'
  50. }
  51. } else {
  52. // For no ajax call
  53. $openeddir = GETPOST('openeddir');
  54. $modulepart = GETPOST('modulepart');
  55. $selecteddir = GETPOST('dir');
  56. $preopened = GETPOST('preopened');
  57. if ($selecteddir != '/') {
  58. $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/'
  59. }
  60. if (empty($url)) {
  61. $url = DOL_URL_ROOT.'/ecm/index.php';
  62. }
  63. }
  64. $websitekey = GETPOST('websitekey', 'alpha');
  65. $pageid = GETPOST('pageid', 'int');
  66. // Load translation files required by the page
  67. $langs->load("ecm");
  68. // Define fullpathselecteddir.
  69. $fullpathselecteddir = '<none>';
  70. if ($modulepart == 'ecm') {
  71. $fullpathselecteddir = $conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
  72. $fullpathpreopened = $conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : '');
  73. } elseif ($modulepart == 'medias' || $modulepart == 'website') {
  74. $fullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
  75. $fullpathpreopened = $dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : '');
  76. }
  77. // Security:
  78. // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers.
  79. if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpathselecteddir)) {
  80. dol_syslog("Refused to deliver file ".$original_file);
  81. // Do no show plain path in shown error message
  82. dol_print_error(0, $langs->trans("ErrorFileNameInvalid", GETPOST("file")));
  83. exit;
  84. }
  85. if (empty($modulepart)) {
  86. $modulepart = $module;
  87. }
  88. // Check permissions
  89. if ($modulepart == 'ecm') {
  90. if (!$user->hasRight('ecm', 'read')) {
  91. accessforbidden();
  92. }
  93. } elseif ($modulepart == 'medias' || $modulepart == 'website') {
  94. // Always allowed
  95. } else {
  96. accessforbidden();
  97. }
  98. /*
  99. * Actions
  100. */
  101. // None
  102. /*
  103. * View
  104. */
  105. if (!isset($mode) || $mode != 'noajax') { // if ajax mode
  106. top_httphead();
  107. }
  108. //print '<!-- selecteddir (relative dir we click on) = '.$selecteddir.', openeddir = '.$openeddir.', modulepart='.$modulepart.', preopened='.$preopened.' -->'."\n";
  109. $userstatic = new User($db);
  110. $form = new Form($db);
  111. $ecmdirstatic = new EcmDirectory($db);
  112. // Load full manual tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir
  113. if (empty($sqltree)) {
  114. $sqltree = $ecmdirstatic->get_full_arbo(0);
  115. }
  116. // Try to find selected dir id into $sqltree and save it into $current_ecmdir_id
  117. $current_ecmdir_id = -1;
  118. foreach ($sqltree as $keycursor => $val) {
  119. //print $val['fullrelativename']." == ".$selecteddir;
  120. if ($val['fullrelativename'] == $selecteddir) {
  121. $current_ecmdir_id = $keycursor;
  122. }
  123. }
  124. if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
  125. treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened);
  126. // TODO Find a solution to not output this code for each leaf we open
  127. // Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
  128. // Because the content is reloaded by ajax call, we must also reenable some jquery hooks
  129. print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n";
  130. print '<script type="text/javascript">
  131. jQuery(document).ready(function () {
  132. jQuery(".classfortooltip").tooltip({
  133. show: { collision: "flipfit", effect:\'toggle\', delay:50 },
  134. 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 */
  135. tooltipClass: "mytooltip",
  136. content: function () {
  137. return $(this).prop(\'title\'); /* To force to get title as is */
  138. }
  139. });
  140. });
  141. </script>';
  142. // This ajax service is called only when a directory $selecteddir is opened but not when closed.
  143. //print '<script type="text/javascript">';
  144. //print "loadandshowpreview('".dol_escape_js($selecteddir)."');";
  145. //print '</script>';
  146. }
  147. if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS)) {
  148. print '<ul class="ecmjqft">';
  149. // Load full manual tree from database. We will use it to define nbofsubdir and nboffilesinsubdir
  150. if (empty($sqltree)) {
  151. $sqltree = $ecmdirstatic->get_full_arbo(0); // Slow
  152. }
  153. // ----- This section will show a tree from a fulltree array -----
  154. // $section must also be defined
  155. // ----------------------------------------------------------------
  156. // Define fullpathselected ( _x_y_z ) of $section parameter (!! not into ajaxdirtree)
  157. $fullpathselected = '';
  158. foreach ($sqltree as $key => $val) {
  159. //print $val['id']."-".$section."<br>";
  160. if ($val['id'] == $section) {
  161. $fullpathselected = $val['fullpath'];
  162. break;
  163. }
  164. }
  165. //print "fullpathselected=".$fullpathselected."<br>";
  166. // Update expandedsectionarray in session
  167. $expandedsectionarray = array();
  168. if (isset($_SESSION['dol_ecmexpandedsectionarray'])) {
  169. $expandedsectionarray = explode(',', $_SESSION['dol_ecmexpandedsectionarray']);
  170. }
  171. if ($section && GETPOST('sectionexpand') == 'true') {
  172. // We add all sections that are parent of opened section
  173. $pathtosection = explode('_', $fullpathselected);
  174. foreach ($pathtosection as $idcursor) {
  175. if ($idcursor && !in_array($idcursor, $expandedsectionarray)) { // Not already in array
  176. $expandedsectionarray[] = $idcursor;
  177. }
  178. }
  179. $_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray);
  180. }
  181. if ($section && GETPOST('sectionexpand') == 'false') {
  182. // We removed all expanded sections that are child of the closed section
  183. $oldexpandedsectionarray = $expandedsectionarray;
  184. $expandedsectionarray = array(); // Reset
  185. foreach ($oldexpandedsectionarray as $sectioncursor) {
  186. // TODO is_in_subtree(fulltree,sectionparent,sectionchild) does nox exists. Enable or remove this...
  187. //if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
  188. }
  189. $_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray);
  190. }
  191. //print $_SESSION['dol_ecmexpandedsectionarray'].'<br>';
  192. $nbofentries = 0;
  193. $oldvallevel = 0;
  194. foreach ($sqltree as $key => $val) {
  195. $ecmdirstatic->id = $val['id'];
  196. $ecmdirstatic->ref = $val['label'];
  197. // Refresh cache
  198. if (preg_match('/refresh/i', $action)) {
  199. $result = $ecmdirstatic->fetch($val['id']);
  200. $ecmdirstatic->ref = $ecmdirstatic->label;
  201. $result = $ecmdirstatic->refreshcachenboffile(0);
  202. $val['cachenbofdoc'] = $result;
  203. }
  204. //$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']);
  205. // Define showline
  206. $showline = 0;
  207. // If directory is son of expanded directory, we show line
  208. if (in_array($val['id_mere'], $expandedsectionarray)) {
  209. $showline = 4;
  210. } elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) {
  211. // If directory is brother of selected directory, we show line
  212. $showline = 3;
  213. } elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) {
  214. // If directory is parent of selected directory or is selected directory, we show line
  215. $showline = 2;
  216. } elseif ($val['level'] < 2) {
  217. // If we are level one we show line
  218. $showline = 1;
  219. }
  220. if ($showline) {
  221. if (in_array($val['id'], $expandedsectionarray)) {
  222. $option = 'indexexpanded';
  223. } else {
  224. $option = 'indexnotexpanded';
  225. }
  226. //print $option;
  227. print '<li class="directory collapsed">';
  228. // Show tree graph pictos
  229. $cpt = 1;
  230. while ($cpt < $sqltree[$key]['level']) {
  231. print ' &nbsp; &nbsp;';
  232. $cpt++;
  233. }
  234. $resarray = tree_showpad($sqltree, $key, 1);
  235. $a = $resarray[0];
  236. $nbofsubdir = $resarray[1];
  237. $nboffilesinsubdir = $resarray[2];
  238. // Show link
  239. print $ecmdirstatic->getNomUrl(0, $option, 32, 'class="fmdirlia jqft ecmjqft"');
  240. print '<div class="ecmjqft">';
  241. // Nb of docs
  242. print '<table class="nobordernopadding"><tr>';
  243. print '<!-- nb of docs -->';
  244. print '<td>';
  245. print $val['cachenbofdoc'];
  246. print '</td>';
  247. print '<!-- nb in subdir -->';
  248. print '<td class="left">';
  249. if ($nbofsubdir && $nboffilesinsubdir) {
  250. print '<span style="color: #AAAAAA">+'.$nboffilesinsubdir.'</span> ';
  251. }
  252. print '</td>';
  253. // Info
  254. print '<!-- info -->';
  255. print '<td class="center">';
  256. $userstatic->id = $val['fk_user_c'];
  257. $userstatic->lastname = $val['login_c'];
  258. $userstatic->statut = $val['statut_c'];
  259. $htmltooltip = '<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
  260. $htmltooltip = '<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
  261. $htmltooltip .= '<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
  262. $htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'], "dayhour").'<br>';
  263. $htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
  264. $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
  265. if ($nbofsubdir) {
  266. $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
  267. } else {
  268. $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
  269. }
  270. print $form->textwithpicto('', $htmltooltip, 1, 'info');
  271. print "</td>";
  272. print '</tr></table>';
  273. print '</div>';
  274. print "</li>\n";
  275. }
  276. $oldvallevel = $val['level'];
  277. $nbofentries++;
  278. }
  279. // If nothing to show
  280. if ($nbofentries == 0) {
  281. print '<li class="directory collapsed">';
  282. print '<div class="ecmjqft">';
  283. print $langs->trans("ECMNoDirectoryYet");
  284. print '</div>';
  285. print "</li>\n";
  286. }
  287. print '</ul>';
  288. }
  289. // Close db if mode is not noajax
  290. if ((!isset($mode) || $mode != 'noajax') && is_object($db)) {
  291. $db->close();
  292. }
  293. /**
  294. * treeOutputForAbsoluteDir
  295. *
  296. * @param array $sqltree Sqltree
  297. * @param string $selecteddir Selected dir
  298. * @param string $fullpathselecteddir Full path of selected dir
  299. * @param string $modulepart Modulepart
  300. * @param string $websitekey Website key
  301. * @param int $pageid Page id
  302. * @param string $preopened Current open dir
  303. * @param string $fullpathpreopened Full path of current open dir
  304. * @param int $depth Depth
  305. * @return void
  306. */
  307. function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth = 0)
  308. {
  309. global $conf, $db, $langs, $form;
  310. global $dolibarr_main_data_root;
  311. $ecmdirstatic = new EcmDirectory($db);
  312. $userstatic = new User($db);
  313. if (file_exists($fullpathselecteddir)) {
  314. $files = @scandir($fullpathselecteddir);
  315. if (!empty($files)) {
  316. natcasesort($files);
  317. if (count($files) > 2) { /* The 2 accounts for . and .. */
  318. echo '<ul class="ecmjqft" style="display: none;">'."\n";
  319. // All dirs
  320. foreach ($files as $file) { // $file can be '.', '..', or 'My dir' or 'My file'
  321. if ($file == 'temp') {
  322. continue;
  323. }
  324. $nbofsubdir = 0;
  325. $nboffilesinsubdir = 0;
  326. $val = array();
  327. // Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan
  328. foreach ($sqltree as $key => $tmpval) {
  329. //print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n";
  330. if ($tmpval['fullrelativename'] == (($selecteddir != '/' ? $selecteddir.'/' : '').$file)) { // We found equivalent record into database
  331. $val = $tmpval;
  332. $resarray = tree_showpad($sqltree, $key, 1);
  333. // Refresh cache for this subdir
  334. if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) { // Cache is not up to date, so we update it for this directory t
  335. $result = $ecmdirstatic->fetch($val['id']);
  336. $ecmdirstatic->ref = $ecmdirstatic->label;
  337. $result = $ecmdirstatic->refreshcachenboffile(0);
  338. $val['cachenbofdoc'] = $result;
  339. }
  340. $a = $resarray[0];
  341. $nbofsubdir = $resarray[1];
  342. $nboffilesinsubdir = $resarray[2];
  343. break;
  344. }
  345. }
  346. //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
  347. if ($file != '.' && $file != '..' && ((!empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir.(preg_match('/\/$/', $fullpathselecteddir) ? '' : '/').$file))) {
  348. if (empty($val['fullrelativename'])) { // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
  349. $val['fullrelativename'] = (($selecteddir && $selecteddir != '/') ? $selecteddir.'/' : '').$file;
  350. $val['id'] = 0;
  351. $val['label'] = $file;
  352. $val['description'] = '';
  353. $nboffilesinsubdir = $langs->trans("Unknown");
  354. }
  355. $collapsedorexpanded = 'collapsed';
  356. if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) {
  357. $collapsedorexpanded = 'expanded';
  358. }
  359. print '<li class="directory '.$collapsedorexpanded.' lidirecm">'; // collapsed is opposite if expanded
  360. //print '<div class="divfmdirlia inline-block">'; // Disabled, this break the javascrip component
  361. print '<a class="fmdirlia jqft ecmjqft" href="';
  362. print "#";
  363. print "\" rel=\"".dol_escape_htmltag($val['fullrelativename'].'/')."\" id=\"fmdirlia_id_".$val['id']."\"";
  364. print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")";
  365. print "\">";
  366. print dol_escape_htmltag($file);
  367. print '</a>';
  368. //print '</div>';
  369. print '<div class="ecmjqft">';
  370. print '<table class="nobordernopadding"><tr>';
  371. /*print '<td class="left">';
  372. print dol_escape_htmltag($file);
  373. print '</td>';*/
  374. // Nb of docs
  375. print '<!-- nb of docs -->';
  376. print '<td class="right">';
  377. print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : '&nbsp;';
  378. print '</td>';
  379. print '<!-- nb of subdirs -->';
  380. print '<td class="left">';
  381. if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) {
  382. print '<span class="opacitymedium">+'.$nboffilesinsubdir.'</span> ';
  383. }
  384. print '</td>';
  385. // Edit link
  386. print '<!-- edit link -->';
  387. print '<td class="right" width="18"><a class="editfielda" href="';
  388. print DOL_URL_ROOT.'/ecm/dir_card.php?module='.urlencode($modulepart).'&section='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']);
  389. print '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
  390. print '">'.img_edit($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle opacitymedium"').'</a></td>';
  391. // Add link
  392. //print '<td class="right"><a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
  393. //print '<td class="right" width="14">&nbsp;</td>';
  394. // Info
  395. if ($modulepart == 'ecm') {
  396. print '<!-- info -->';
  397. print '<td class="right" width="18">';
  398. $userstatic->id = isset($val['fk_user_c']) ? $val['fk_user_c'] : 0;
  399. $userstatic->lastname = isset($val['login_c']) ? $val['login_c'] : 0;
  400. $userstatic->statut = isset($val['statut_c']) ? $val['statut_c'] : 0;
  401. $htmltooltip = '<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
  402. $htmltooltip = '<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
  403. $htmltooltip .= '<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1, '', false, 1).'<br>';
  404. $htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c']) ?dol_print_date($val['date_c'], "dayhour") : $langs->trans("NeedRefresh")).'<br>';
  405. $htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
  406. $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : $langs->trans("NeedRefresh")).'<br>';
  407. if ($nboffilesinsubdir > 0) {
  408. $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
  409. } else {
  410. $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
  411. }
  412. print $form->textwithpicto('', $htmltooltip, 1, "info");
  413. print "</td>";
  414. }
  415. print "</tr></table>\n";
  416. print '</div>';
  417. //print 'selecteddir='.$selecteddir.' preopened='.$preopened.' $val[\'fullrelativename\']='.$val['fullrelativename']."<br>\n";
  418. if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) {
  419. //print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
  420. $newselecteddir = $val['fullrelativename'];
  421. $newfullpathselecteddir = '';
  422. if ($modulepart == 'ecm') {
  423. $newfullpathselecteddir = $conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
  424. } elseif ($modulepart == 'medias') {
  425. $newfullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
  426. }
  427. if ($newfullpathselecteddir) {
  428. treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1);
  429. }
  430. }
  431. print "</li>\n";
  432. }
  433. }
  434. echo "</ul>\n";
  435. }
  436. } else {
  437. print "PermissionDenied";
  438. }
  439. }
  440. }