dolibarr 25.0.0-alpha
ajaxdirpreview.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2010 Pierre Morin <pierre.morin@auguria.net>
7 * Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
8 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
10 * Copyright (C) 2025 Joachim Kueter <git-jk@bloxera.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
33if (!defined('NOTOKENRENEWAL')) {
34 define('NOTOKENRENEWAL', 1); // Disables token renewal
35}
36if (!defined('NOREQUIREMENU')) {
37 define('NOREQUIREMENU', '1');
38}
39if (!defined('NOREQUIREHTML')) {
40 define('NOREQUIREHTML', '1');
41}
42if (!defined('NOREQUIREAJAX')) {
43 define('NOREQUIREAJAX', '1');
44}
45
60'
61@phan-var-force ?string $mode
62';
63
64if (!isset($mode) || $mode != 'noajax') { // For ajax call
65 require_once '../../main.inc.php';
66 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
67 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
68 require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
69
70 $action = GETPOST('action', 'aZ09');
71 $file = urldecode(GETPOST('file', 'alpha'));
72 $section = GETPOST("section", 'alpha');
73 $module = GETPOST("module", 'alpha');
74 $urlsource = GETPOST("urlsource", 'alpha');
75 $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
76 $search_doc_date_start = '';
77 $search_doc_date_end = '';
78 if (GETPOSTISSET('search_doc_date_start') || GETPOSTISSET('search_doc_date_startday') || GETPOSTISSET('search_doc_date_startmonth') || GETPOSTISSET('search_doc_date_startyear')) {
79 $search_doc_date_start = GETPOSTDATE('search_doc_date_start');
80 }
81 if (GETPOSTISSET('search_doc_date_end') || GETPOSTISSET('search_doc_date_endday') || GETPOSTISSET('search_doc_date_endmonth') || GETPOSTISSET('search_doc_date_endyear')) {
82 $search_doc_date_end = GETPOSTDATE('search_doc_date_end', 'end');
83 }
84
85 $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
86 $sortfield = GETPOST("sortfield", 'aZ09comma');
87 $sortorder = GETPOST("sortorder", 'aZ09comma');
88 $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
89 $showonrightsize = '';
90
91 if (empty($page) || $page == -1) {
92 $page = 0;
93 } // If $page is not defined, or '' or -1
94 $offset = $limit * $page;
95 $pageprev = $page - 1;
96 $pagenext = $page + 1;
97 if (!$sortorder) {
98 $sortorder = "ASC";
99 }
100 if (!$sortfield) {
101 $sortfield = "name";
102 }
103
104 $rootdirfordoc = $conf->ecm->dir_output;
105
106 $upload_dir = dirname(str_replace("../", "/", $rootdirfordoc.'/'.$file));
107
108 $ecmdir = new EcmDirectory($db);
109 if ($section > 0) {
110 $result = $ecmdir->fetch((int) $section);
111 //if (!($result > 0)) {
112 //dol_print_error($db,$ecmdir->error);
113 //exit;
114 //}
115 }
116} else {
117 // When no an ajax call (include from other file)
127 '
128 @phan-var-force int $section
129 @phan-var-force string $action
130 @phan-var-force string $module
131 @phan-var-force string $showonrightsize
132 @phan-var-force string $sortfield
133 @phan-var-force string $sortorder
134 ';
135
136 $rootdirfordoc = $conf->ecm->dir_output;
137
138 $ecmdir = new EcmDirectory($db);
139 $relativepath = '';
140 if ($section > 0) {
141 $result = $ecmdir->fetch($section);
142 if (!($result > 0)) {
143 dol_print_error($db, $ecmdir->error);
144 exit;
145 }
146
147 $relativepath = $ecmdir->getRelativePath(); // Example 'mydir/'
148 } elseif (GETPOST('section_dir')) {
149 $relativepath = GETPOST('section_dir');
150 }
151 //var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath);
152
153 $upload_dir = $rootdirfordoc.'/'.$relativepath;
154}
155
156if (empty($url)) { // autoset $url but it is better to have it defined before into filemanager.tpl.php (not possible when in auto tree)
157 if (!empty($module) && $module == 'medias' && !GETPOST('website')) {
158 $url = DOL_URL_ROOT.'/ecm/index_medias.php';
159 } elseif (GETPOSTISSET('website')) {
160 $url = DOL_URL_ROOT.'/website/index.php';
161 } else {
162 $url = DOL_URL_ROOT.'/ecm/index.php';
163 }
164}
165
166// Load translation files required by the page
167$langs->loadLangs(array("ecm", "companies", "other"));
168
169if (empty($modulepart)) {
170 $modulepart = $module;
171}
172
173// Security check
174if ($user->socid > 0) {
175 $socid = $user->socid;
176}
177// We forbid directory traversal as well as pipes in file names.
178if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) {
179 dol_syslog("Refused to deliver file ".$upload_dir);
180 // Do no show plain path in shown error message
181 dol_print_error(null, $langs->trans("ErrorFileNameInvalid", $upload_dir));
182 exit;
183}
184// Check permissions
185if ($modulepart == 'ecm') {
186 if (!$user->hasRight('ecm', 'read')) {
188 }
189} elseif ($modulepart == 'medias' || $modulepart == 'website') {
190 // Always allowed
191} else {
193}
194
195
196/*
197 * Action
198 */
199
200// None
201
202
203
204/*
205 * View
206 */
207
208if (!isset($mode) || $mode != 'noajax') {
209 // Add directives to fix IE bug
210 header('Cache-Control: Public, must-revalidate');
211 header('Pragma: public');
212
213 top_httphead();
214}
215
216$type = 'directory';
217
218// This test if file exists should be useless. We keep it to find bug more easily
219if (!dol_is_dir($upload_dir)) {
220 //dol_mkdir($upload_dir);
221 /*$langs->load("install");
222 dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir));
223 exit;*/
224}
225
226print '<!-- ajaxdirpreview mode='.$mode.' type='.$type.' module='.$module.' modulepart='.$modulepart.'-->'."\n";
227//print '<!-- Page called with mode='.dol_escape_htmltag(isset($mode)?$mode:'').' type='.dol_escape_htmltag($type).' module='.dol_escape_htmltag($module).' url='.dol_escape_htmltag($url).' '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
228
229$param = ($sortfield ? '&sortfield='.urlencode($sortfield) : '').($sortorder ? '&sortorder='.urlencode($sortorder) : '');
230if (!empty($websitekey)) {
231 $param .= '&website='.urlencode($websitekey);
232}
233if (!empty($pageid)) {
234 $param .= '&pageid='.((int) $pageid);
235}
236
237
238// Dir scan
239if ($type == 'directory') {
240 $formfile = new FormFile($db);
241
242 $maxlengthname = 40;
243 $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$');
244 $sorting = (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC);
245
246 // Right area. If module is defined here, we are in automatic ecm.
247 $automodules = array(
248 'company',
249 'invoice',
250 'invoice_supplier',
251 'propal',
252 'supplier_proposal',
253 'order',
254 'order_supplier',
255 'contract',
256 'product',
257 'tax',
258 'tax-vat',
259 'salaries',
260 'project',
261 'project_task',
262 'fichinter',
263 'user',
264 'expensereport',
265 'holiday',
266 'recruitment-recruitmentcandidature',
267 'banque',
268 'bank-statement',
269 'chequereceipt',
270 'mrp-mo'
271 );
272
273 $parameters = array('modulepart' => $module);
274 $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters);
275 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
276 if (is_array($hookmanager->resArray['module'])) {
277 $automodules = array_merge($automodules, $hookmanager->resArray['module']);
278 } else {
279 $automodules[] = $hookmanager->resArray['module'];
280 }
281 }
282
283 // TODO change for multicompany sharing
284 if ($module == 'company') {
285 $upload_dir = $conf->societe->dir_output;
286 $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts.
287 } elseif ($module == 'invoice') {
288 $upload_dir = $conf->invoice->dir_output;
289 } elseif ($module == 'invoice_supplier') {
290 $upload_dir = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
291 } elseif ($module == 'propal') {
292 $upload_dir = $conf->propal->dir_output;
293 } elseif ($module == 'supplier_proposal') {
294 $upload_dir = $conf->supplier_proposal->dir_output;
295 } elseif ($module == 'order') {
296 $upload_dir = $conf->order->dir_output;
297 } elseif ($module == 'order_supplier') {
298 $upload_dir = $conf->fournisseur->commande->dir_output;
299 } elseif ($module == 'contract') {
300 $upload_dir = $conf->contract->dir_output;
301 } elseif ($module == 'product') {
302 $upload_dir = $conf->product->dir_output;
303 } elseif ($module == 'tax') {
304 $upload_dir = $conf->tax->dir_output;
305 $excludefiles[] = '^vat$'; // The subdir 'vat' contains files of vats.
306 } elseif ($module == 'tax-vat') {
307 $upload_dir = $conf->tax->dir_output.'/vat';
308 } elseif ($module == 'salaries') {
309 $upload_dir = $conf->salaries->dir_output;
310 } elseif ($module == 'project') {
311 $upload_dir = $conf->project->dir_output;
312 } elseif ($module == 'project_task') {
313 $upload_dir = $conf->project->dir_output;
314 } elseif ($module == 'fichinter') {
315 $upload_dir = $conf->ficheinter->dir_output;
316 } elseif ($module == 'user') {
317 $upload_dir = $conf->user->dir_output;
318 } elseif ($module == 'expensereport') {
319 $upload_dir = $conf->expensereport->dir_output;
320 } elseif ($module == 'holiday') {
321 $upload_dir = $conf->holiday->dir_output;
322 } elseif ($module == 'recruitment-recruitmentcandidature') {
323 $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature';
324 } elseif ($module == 'banque') {
325 $upload_dir = $conf->bank->dir_output;
326 } elseif ($module == 'bank-statement') {
327 $upload_dir = $conf->bank->dir_output.'/*/statement';
328 } elseif ($module == 'chequereceipt') {
329 $upload_dir = $conf->bank->dir_output.'/checkdeposits';
330 } elseif ($module == 'mrp-mo') {
331 $upload_dir = $conf->mrp->dir_output;
332 } else {
333 $parameters = array('modulepart' => $module);
334 $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters);
335 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
336 $upload_dir = $hookmanager->resArray['directory'];
337 }
338 }
339
340 // Automatic list
341 if (in_array($module, $automodules)) {
342 $param .= '&module='.urlencode($module);
343 if (isset($search_doc_ref) && $search_doc_ref != '') {
344 $param .= '&search_doc_ref='.urlencode($search_doc_ref);
345 }
346 if (!empty($search_doc_date_start)) {
347 $param .= '&search_doc_date_startday='.dol_print_date($search_doc_date_start, '%d');
348 $param .= '&search_doc_date_startmonth='.dol_print_date($search_doc_date_start, '%m');
349 $param .= '&search_doc_date_startyear='.dol_print_date($search_doc_date_start, '%Y');
350 }
351 if (!empty($search_doc_date_end)) {
352 $param .= '&search_doc_date_endday='.dol_print_date($search_doc_date_end, '%d');
353 $param .= '&search_doc_date_endmonth='.dol_print_date($search_doc_date_end, '%m');
354 $param .= '&search_doc_date_endyear='.dol_print_date($search_doc_date_end, '%Y');
355 }
356
357 $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound")));
358
359 $filter = preg_quote((string) $search_doc_ref, '/');
360 $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1);
361 if (!empty($search_doc_date_start) || !empty($search_doc_date_end)) {
362 foreach ($filearray as $key => $file) {
363 $filedate = empty($file['date']) ? 0 : (int) $file['date'];
364 if ((!empty($search_doc_date_start) && $filedate < $search_doc_date_start)
365 || (!empty($search_doc_date_end) && $filedate > $search_doc_date_end)
366 ) {
367 unset($filearray[$key]);
368 }
369 }
370 }
371 //var_dump($filearray);
372
373 // To allow external users,we must restrict $filearray to entries the user is a thirdparty.
374 // This can be done by filtering on entries found into llx_ecm
375 if ($user->socid > 0) {
376 $filearrayallowedtoexternal = array(); // 'fullpath' => array(...)
377
378 // Search files in ECM with select filepath.filename where src_object_type = $module and src_object_type EXISTS in (select rowid from $objecttablename WERE fk_soc = '.$user->socid.' and entity in getEntity($objecttbalename)
379 // TODO
380
381 // Now clean $filearray to keep only record also found into $filearrayallowedtoexternal.
382 foreach ($filearray as $key => $val) {
383 if (!in_array($upload_dir.'/'.$val['relativename'], $filearrayallowedtoexternal)) {
384 unset($filearray[$key]);
385 }
386 }
387 }
388
389 $perm = $user->hasRight('ecm', 'upload');
390
391 // Print list of files
392 $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1);
393 } else {
394 // Manual list
395 if ($module == 'medias') {
396 /*
397 $_POST is array like
398 'token' => string '062380e11b7dcd009d07318b57b71750' (length=32)
399 'action' => string 'file_manager' (length=12)
400 'website' => string 'template' (length=8)
401 'pageid' => string '124' (length=3)
402 'section_dir' => string 'mydir/' (length=3)
403 'section_id' => string '0' (length=1)
404 'max_file_size' => string '2097152' (length=7)
405 'sendit' => string 'Envoyer fichier' (length=15)
406 */
407 $relativepath = GETPOST('file', 'alpha') ? GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha');
408 if ($relativepath && $relativepath != '/') {
409 $relativepath .= '/';
410 }
411 $upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
412 if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) {
413 $param .= '&file_manager=1';
414 if (!preg_match('/website=/', $param) && GETPOST('website', 'alpha')) {
415 $param .= '&website='.urlencode(GETPOST('website', 'alpha'));
416 }
417 if (!preg_match('/pageid=/', $param)) {
418 $param .= '&pageid='.GETPOSTINT('pageid');
419 }
420 //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
421 }
422 } else {
423 $relativepath = $ecmdir->getRelativePath();
424 $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
425 }
426
427 // If $section defined with value 0
428 if (($section === '0' || empty($section)) && ($module != 'medias')) {
429 $filearray = array();
430 } else {
431 $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1);
432 }
433
434 if ($section) {
435 $param .= '&section='.urlencode($section);
436 if (isset($search_doc_ref) && $search_doc_ref != '') {
437 $param .= '&search_doc_ref='.urlencode($search_doc_ref);
438 }
439
440 $textifempty = $langs->trans('NoFileFound');
441 } elseif ($section === '0') {
442 if ($module == 'ecm') {
443 $textifempty = '<br><div class="center"><span class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</span></div><br>';
444 } else {
445 $textifempty = $langs->trans('NoFileFound');
446 }
447 } else {
448 $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection"));
449 }
450
451 $useinecm = 0;
452 if ($module == 'medias') {
453 $useinecm = 6;
454 $modulepart = 'medias';
455 $perm = $user->hasRight("website", "write");
456 $title = 'none';
457 } elseif ($module == 'ecm') { // DMS/ECM -> manual structure
458 if ($user->hasRight("ecm", "read")) {
459 // Buttons: Preview
460 $useinecm = 2;
461 }
462
463 if ($user->hasRight("ecm", "upload")) {
464 // Buttons: Preview + Delete
465 $useinecm = 4;
466 }
467
468 if ($user->hasRight("ecm", "setup")) {
469 // Buttons: Preview + Delete + Edit
470 $useinecm = 5;
471 }
472
473 $perm = $user->hasRight("ecm", "upload");
474 $modulepart = 'ecm';
475 $title = ''; // Use default
476 } else {
477 $useinecm = 5;
478 $modulepart = 'ecm';
479 $perm = $user->hasRight("ecm", "upload");
480 $title = ''; // Use default
481 }
482
483 // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
484 // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
485 //var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm(permtoeditline)=".$perm." relativepath=".$relativepath." upload_dir=".$upload_dir." param=".$param." url=".$url);
486
487 $formfile->list_of_documents($filearray, null, $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm, $upload_dir, $sortfield, $sortorder);
488 }
489}
490
491
492
493// Bottom of page
494$useajax = 1;
495if (!empty($conf->dol_use_jmobile)) {
496 $useajax = 0;
497}
498if (empty($conf->use_javascript_ajax)) {
499 $useajax = 0;
500}
501if (getDolGlobalString('MAIN_ECM_DISABLE_JS')) {
502 $useajax = 0;
503}
504
505//$param.=($param?'?':'').(preg_replace('/^&/','',$param));
506
507if ($useajax || $action == 'deletefile') {
508 $urlfile = '';
509 if ($action == 'deletefile') {
510 $urlfile = GETPOST('urlfile', 'alpha');
511 }
512
513 if (empty($section_dir)) {
514 $section_dir = GETPOST("file", "alpha");
515 }
516 $section_id = $section;
517
518 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
519
520 $form = new Form($db);
521 $formquestion = array();
522 $formquestion['urlfile'] = array('type' => 'hidden', 'value' => $urlfile, 'name' => 'urlfile'); // We must always put field, even if empty because it is filled by javascript later
523 $formquestion['section'] = array('type' => 'hidden', 'value' => $section, 'name' => 'section'); // We must always put field, even if empty because it is filled by javascript later
524 $formquestion['section_id'] = array('type' => 'hidden', 'value' => $section_id, 'name' => 'section_id'); // We must always put field, even if empty because it is filled by javascript later
525 $formquestion['section_dir'] = array('type' => 'hidden', 'value' => $section_dir, 'name' => 'section_dir'); // We must always put field, even if empty because it is filled by javascript later
526 $formquestion['sortfield'] = array('type' => 'hidden', 'value' => $sortfield, 'name' => 'sortfield'); // We must always put field, even if empty because it is filled by javascript later
527 $formquestion['sortorder'] = array('type' => 'hidden', 'value' => $sortorder, 'name' => 'sortorder'); // We must always put field, even if empty because it is filled by javascript later
528 if (!empty($action) && $action == 'file_manager') {
529 $formquestion['file_manager'] = array('type' => 'hidden', 'value' => 1, 'name' => 'file_manager');
530 }
531 if (!empty($websitekey)) {
532 $formquestion['website'] = array('type' => 'hidden', 'value' => $websitekey, 'name' => 'website');
533 }
534 if (!empty($pageid) && $pageid > 0) {
535 $formquestion['pageid'] = array('type' => 'hidden', 'value' => $pageid, 'name' => 'pageid');
536 }
537
538 print $form->formconfirm($url, $langs->trans("DeleteFile"), $langs->trans("ConfirmDeleteFile"), 'confirm_deletefile', $formquestion, "no", ($useajax ? 'deletefile' : 0));
539}
540
541if ($useajax) {
542 print '<!-- ajaxdirpreview.php: js to manage preview of doc -->'."\n";
543 print '<script nonce="'.getNonce().'" type="text/javascript">';
544
545 // Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
546 // Because the content is reloaded by ajax call, we must also redefine/reenable some jquery hooks.
547
548 // Handler to manage document_preview on click on a .documentpreview css class.
549 if ($conf->browser->layout != 'phone') {
550 print "\n/* JS CODE TO ENABLE document_preview */\n";
551 print '
552 jQuery(document).ready(function () {
553 jQuery(".documentpreview").click(function () {
554 console.log("We click on preview for element with href="+$(this).attr(\'href\')+" mime="+$(this).attr(\'mime\'));
555 var titledocpreview = $(this).attr(\'data-title\');
556 if (titledocpreview == undefined || titledocpreview == "") {
557 titledocpreview = \''.dol_escape_js($langs->transnoentities("Preview")).'\'
558 }
559 document_preview($(this).attr(\'href\'), $(this).attr(\'mime\'), titledocpreview);
560 return false;
561 });
562 });
563 ' . "\n";
564 }
565
566 // Enable jquery handlers button to delete files
567 print 'jQuery(document).ready(function() {'."\n";
568 print ' jQuery(".deletefilelink").click(function(e) { '."\n";
569 print ' console.log("We click on button with class deletefilelink, param='.$param.', we set urlfile to "+jQuery(this).attr("rel"));'."\n";
570 print ' jQuery("#urlfile").val(jQuery(this).attr("rel"));'."\n";
571 //print ' jQuery("#section_dir").val(\'aaa\');'."\n";
572 print ' jQuery("#dialog-confirm-deletefile").dialog("open");'."\n";
573 print ' return false;'."\n";
574 print ' });'."\n";
575 print '});'."\n";
576 print '</script>'."\n";
577}
578
579// Close db if mode is not noajax
580if ((!isset($mode) || $mode != 'noajax') && is_object($db)) {
581 $db->close();
582}
Class to manage ECM directories.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
document_preview(file, type, title)
Function to show a document preview popup.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:65
dol_is_dir($folder)
Test if filename is a directory.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.