dolibarr 19.0.3
ecmdirectory.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2008-2012 Regis Houssin <regis.houssin@inodbox.com>
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
29{
33 public $element = 'ecm_directories';
34
38 public $table_element = 'ecm_directories';
39
43 public $picto = 'folder-open';
44
48 public $id;
49
53 public $label;
54
58 public $fk_parent;
59
63 public $description;
64
68 public $cachenbofdoc = -1; // By default cache initialized with value 'not calculated'
69
73 public $date_c;
74
78 public $date_m;
79
83 public $fk_user_m;
84
88 public $fk_user_c;
89
93 public $ref;
94
98 public $cats = array();
99
103 public $motherof = array();
104
108 public $forbiddenchars = array('<', '>', ':', '/', '\\', '?', '*', '|', '"');
109
113 public $forbiddencharsdir = array('<', '>', ':', '?', '*', '|', '"');
114
118 public $full_arbo_loaded;
119
125 public function __construct($db)
126 {
127 $this->db = $db;
128 }
129
130
137 public function create($user)
138 {
139 global $conf, $langs;
140
141 $error = 0;
142 $now = dol_now();
143
144 // Clean parameters
145 $this->label = dol_sanitizeFileName(trim($this->label));
146 $this->description = trim($this->description);
147 $this->date_c = $now;
148 $this->fk_user_c = $user->id;
149 if ($this->fk_parent <= 0) {
150 $this->fk_parent = 0;
151 }
152
153
154 // Check if same directory does not exists with this name
155 $relativepath = $this->label;
156 if ($this->fk_parent > 0) {
157 $parent = new EcmDirectory($this->db);
158 $parent->fetch($this->fk_parent);
159 $relativepath = $parent->getRelativePath().$relativepath;
160 }
161 $relativepath = preg_replace('/([\/])+/i', '/', $relativepath); // Avoid duplicate / or \
162 //print $relativepath.'<br>';
163
164 $cat = new EcmDirectory($this->db);
165 $cate_arbo = $cat->get_full_arbo(1);
166 $pathfound = 0;
167 foreach ($cate_arbo as $key => $categ) {
168 $path = str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']);
169 //print $relativepath.' - '.$path.'<br>';
170 if ($path == $relativepath) {
171 $pathfound = 1;
172 break;
173 }
174 }
175
176 if ($pathfound) {
177 $this->error = "ErrorDirAlreadyExists";
178 dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING);
179 return -1;
180 } else {
181 $this->db->begin();
182
183 // Insert request
184 $sql = "INSERT INTO ".MAIN_DB_PREFIX."ecm_directories(";
185 $sql .= "label,";
186 $sql .= "entity,";
187 $sql .= "fk_parent,";
188 $sql .= "description,";
189 $sql .= "cachenbofdoc,";
190 $sql .= "date_c,";
191 $sql .= "fk_user_c";
192 $sql .= ") VALUES (";
193 $sql .= " '".$this->db->escape($this->label)."',";
194 $sql .= " '".$this->db->escape($conf->entity)."',";
195 $sql .= " ".($this->fk_parent > 0 ? ((int) $this->fk_parent) : "null").",";
196 $sql .= " '".$this->db->escape($this->description)."',";
197 $sql .= " ".((int) $this->cachenbofdoc).",";
198 $sql .= " '".$this->db->idate($this->date_c)."',";
199 $sql .= " ".($this->fk_user_c > 0 ? ((int) $this->fk_user_c) : "null");
200 $sql .= ")";
201
202 dol_syslog(get_class($this)."::create", LOG_DEBUG);
203 $resql = $this->db->query($sql);
204 if ($resql) {
205 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ecm_directories");
206
207 $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
208 $result = dol_mkdir($dir);
209 if ($result < 0) {
210 $error++;
211 $this->error = "ErrorFailedToCreateDir";
212 }
213
214 // Call trigger
215 $result = $this->call_trigger('MYECMDIR_CREATE', $user);
216 if ($result < 0) {
217 $error++;
218 }
219 // End call triggers
220
221 if (!$error) {
222 $this->db->commit();
223 return $this->id;
224 } else {
225 $this->db->rollback();
226 return -1;
227 }
228 } else {
229 $this->error = "Error ".$this->db->lasterror();
230 $this->db->rollback();
231 return -1;
232 }
233 }
234 }
235
243 public function update($user = null, $notrigger = 0)
244 {
245 global $conf, $langs;
246
247 $error = 0;
248
249 // Clean parameters
250 $this->label = trim($this->label);
251 $this->description = trim($this->description);
252 if ($this->fk_parent <= 0) {
253 $this->fk_parent = 0;
254 }
255
256 $this->db->begin();
257
258 // Update request
259 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
260 $sql .= " label = '".$this->db->escape($this->label)."',";
261 $sql .= " fk_parent = ".($this->fk_parent > 0 ? ((int) $this->fk_parent) : "null").",";
262 $sql .= " description = '".$this->db->escape($this->description)."'";
263 $sql .= " WHERE rowid = ".((int) $this->id);
264
265 dol_syslog(get_class($this)."::update", LOG_DEBUG);
266 $resql = $this->db->query($sql);
267 if (!$resql) {
268 $error++;
269 $this->error = "Error ".$this->db->lasterror();
270 }
271
272 if (!$error && !$notrigger) {
273 // Call trigger
274 $result = $this->call_trigger('MYECMDIR_MODIFY', $user);
275 if ($result < 0) {
276 $error++;
277 }
278 // End call triggers
279 }
280
281 if (!$error) {
282 $this->db->commit();
283 return 1;
284 } else {
285 $this->db->rollback();
286 return -1;
287 }
288 }
289
290
297 public function changeNbOfFiles($value)
298 {
299 // Update request
300 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
301 if (preg_match('/[0-9]+/', $value)) {
302 $sql .= " cachenbofdoc = ".(int) $value;
303 } else {
304 $sql .= " cachenbofdoc = cachenbofdoc ".$value." 1";
305 }
306 $sql .= " WHERE rowid = ".((int) $this->id);
307
308 dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG);
309 $resql = $this->db->query($sql);
310 if (!$resql) {
311 $this->error = "Error ".$this->db->lasterror();
312 return -1;
313 } else {
314 if (preg_match('/[0-9]+/', $value)) {
315 $this->cachenbofdoc = (int) $value;
316 } elseif ($value == '+') {
317 $this->cachenbofdoc++;
318 } elseif ($value == '-') {
319 $this->cachenbofdoc--;
320 }
321 }
322
323 return 1;
324 }
325
326
333 public function fetch($id)
334 {
335 $sql = "SELECT";
336 $sql .= " t.rowid,";
337 $sql .= " t.label,";
338 $sql .= " t.fk_parent,";
339 $sql .= " t.description,";
340 $sql .= " t.cachenbofdoc,";
341 $sql .= " t.fk_user_c,";
342 $sql .= " t.fk_user_m,";
343 $sql .= " t.date_c as date_c,";
344 $sql .= " t.tms as date_m";
345 $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
346 $sql .= " WHERE t.rowid = ".((int) $id);
347
348 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
349 $resql = $this->db->query($sql);
350 if ($resql) {
351 $obj = $this->db->fetch_object($resql);
352 if ($obj) {
353 $this->id = $obj->rowid;
354 $this->ref = $obj->rowid;
355
356 $this->label = $obj->label;
357 $this->fk_parent = $obj->fk_parent;
358 $this->description = $obj->description;
359 $this->cachenbofdoc = $obj->cachenbofdoc;
360 $this->fk_user_m = $obj->fk_user_m;
361 $this->fk_user_c = $obj->fk_user_c;
362 $this->date_c = $this->db->jdate($obj->date_c);
363 $this->date_m = $this->db->jdate($obj->date_m);
364 }
365
366 // Retrieve all extrafields for ecm_files
367 // fetch optionals attributes and labels
368 $this->fetch_optionals();
369
370 $this->db->free($resql);
371
372 return $obj ? 1 : 0;
373 } else {
374 $this->error = "Error ".$this->db->lasterror();
375 return -1;
376 }
377 }
378
379
388 public function delete($user, $mode = 'all', $deletedirrecursive = 0)
389 {
390 global $conf, $langs;
391 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
392
393 $error = 0;
394
395 if ($mode != 'databaseonly') {
396 $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3
397 }
398
399 dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath));
400
401 $this->db->begin();
402
403 $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
404 $sql .= " WHERE rowid=".((int) $this->id);
405
406 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
407 $resql = $this->db->query($sql);
408 if (!$resql) {
409 $this->db->rollback();
410 $this->error = "Error ".$this->db->lasterror();
411 return -2;
412 } else {
413 // Call trigger
414 $result = $this->call_trigger('MYECMDIR_DELETE', $user);
415 if ($result < 0) {
416 $this->db->rollback();
417 return -2;
418 }
419 // End call triggers
420 }
421
422 if ($mode != 'databaseonly') {
423 $file = $conf->ecm->dir_output."/".$relativepath;
424 if ($deletedirrecursive) {
425 $result = @dol_delete_dir_recursive($file, 0, 0);
426 } else {
427 $result = @dol_delete_dir($file, 0);
428 }
429 }
430
431 if ($result || !@is_dir(dol_osencode($file))) {
432 $this->db->commit();
433 } else {
434 $this->error = 'ErrorFailToDeleteDir';
435 dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
436 $this->db->rollback();
437 $error++;
438 }
439
440 if (!$error) {
441 return 1;
442 } else {
443 return -1;
444 }
445 }
446
447
455 public function initAsSpecimen()
456 {
457 $this->id = 0;
458
459 $this->label = 'MyDirectory';
460 $this->fk_parent = '0';
461 $this->description = 'This is a directory';
462 }
463
464
475 public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0)
476 {
477 global $langs, $hookmanager;
478
479 $result = '';
480 //$newref=str_replace('_',' ',$this->ref);
481 $newref = $this->ref;
482 $label = $langs->trans("ShowECMSection").': '.$newref;
483 $linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
484
485 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
486 if ($option == 'index') {
487 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
488 }
489 if ($option == 'indexexpanded') {
490 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
491 }
492 if ($option == 'indexnotexpanded') {
493 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
494 }
495 $linkend = '</a>';
496
497 //$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
498 $picto = 'dir';
499
500 $result .= $linkstart;
501 if ($withpicto) {
502 $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
503 }
504 if ($withpicto != 2) {
505 $result .= ($max ? dol_trunc($newref, $max, 'middle') : $newref);
506 }
507 $result .= $linkend;
508
509 global $action;
510 $hookmanager->initHooks(array($this->element . 'dao'));
511 $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
512 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
513 if ($reshook > 0) {
514 $result = $hookmanager->resPrint;
515 } else {
516 $result .= $hookmanager->resPrint;
517 }
518 return $result;
519 }
520
527 public function getRelativePath($force = 0)
528 {
529 $this->get_full_arbo($force);
530
531 $ret = '';
532 $idtosearch = $this->id;
533 $i = 0;
534 do {
535 // Get index cursor in this->cats for id_mere
536 $cursorindex = -1;
537 foreach ($this->cats as $key => $val) {
538 if ($this->cats[$key]['id'] == $idtosearch) {
539 $cursorindex = $key;
540 break;
541 }
542 }
543 //print "c=".$idtosearch."-".$cursorindex;
544
545 if ($cursorindex >= 0) {
546 // Path is label sanitized (no space and no special char) and concatenated
547 $ret = dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret;
548
549 $idtosearch = $this->cats[$cursorindex]['id_mere'];
550 $i++;
551 }
552 } while ($cursorindex >= 0 && !empty($idtosearch) && $i < 100); // i avoid infinite loop
553
554 return $ret;
555 }
556
557 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
563 public function load_motherof()
564 {
565 // phpcs:enable
566 global $conf;
567
568 $this->motherof = array();
569
570 // Load array[child]=parent
571 $sql = "SELECT fk_parent as id_parent, rowid as id_son";
572 $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories";
573 $sql .= " WHERE fk_parent != 0";
574 $sql .= " AND entity = ".$conf->entity;
575
576 dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
577 $resql = $this->db->query($sql);
578 if ($resql) {
579 // This assignment in condition is not a bug. It allows walking the results.
580 while ($obj = $this->db->fetch_object($resql)) {
581 $this->motherof[$obj->id_son] = $obj->id_parent;
582 }
583 return 1;
584 } else {
585 dol_print_error($this->db);
586 return -1;
587 }
588 }
589
590
597 public function getLibStatut($mode = 0)
598 {
599 return $this->LibStatut($this->status, $mode);
600 }
601
602 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
610 public static function LibStatut($status, $mode = 0)
611 {
612 // phpcs:enable
613 global $langs;
614 return '';
615 }
616
617
618 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
638 public function get_full_arbo($force = 0)
639 {
640 // phpcs:enable
641 global $conf;
642
643 if (empty($force) && !empty($this->full_arbo_loaded)) {
644 return $this->cats;
645 }
646
647 // Init this->motherof that is array(id_son=>id_parent, ...)
648 $this->load_motherof();
649
650 // Charge tableau des categories
651 $sql = "SELECT c.rowid as rowid, c.label as label,";
652 $sql .= " c.description as description, c.cachenbofdoc,";
653 $sql .= " c.fk_user_c,";
654 $sql .= " c.date_c,";
655 $sql .= " u.login as login_c,";
656 $sql .= " u.statut as statut_c,";
657 $sql .= " ca.rowid as rowid_fille";
658 $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c";
659 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca";
660 $sql .= " ON c.rowid = ca.fk_parent";
661 $sql .= " WHERE c.fk_user_c = u.rowid";
662 $sql .= " AND c.entity = ".$conf->entity;
663 $sql .= " ORDER BY c.label, c.rowid";
664
665 dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG);
666 $resql = $this->db->query($sql);
667 if ($resql) {
668 $this->cats = array();
669 $i = 0;
670 // This assignment in condition is not a bug. It allows walking the results.
671 while ($obj = $this->db->fetch_object($resql)) {
672 $this->cats[$obj->rowid]['id'] = $obj->rowid;
673 $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : '');
674 $this->cats[$obj->rowid]['label'] = $obj->label;
675 $this->cats[$obj->rowid]['description'] = $obj->description;
676 $this->cats[$obj->rowid]['cachenbofdoc'] = $obj->cachenbofdoc;
677 $this->cats[$obj->rowid]['date_c'] = $this->db->jdate($obj->date_c);
678 $this->cats[$obj->rowid]['fk_user_c'] = (int) $obj->fk_user_c;
679 $this->cats[$obj->rowid]['statut_c'] = (int) $obj->statut_c;
680 $this->cats[$obj->rowid]['login_c'] = $obj->login_c;
681
682 if (!empty($obj->rowid_fille)) {
683 if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) {
684 $newelempos = count($this->cats[$obj->rowid]['id_children']);
685 //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements<br>";
686 $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille;
687 } else {
688 //print "this->cats[".$obj->rowid."]['id_children'] n'est pas encore un tableau<br>";
689 $this->cats[$obj->rowid]['id_children'] = array($obj->rowid_fille);
690 }
691 }
692 $i++;
693 }
694 } else {
695 dol_print_error($this->db);
696 return -1;
697 }
698
699 // We add properties fullxxx to all elements
700 foreach ($this->cats as $key => $val) {
701 if (isset($this->motherof[$key])) {
702 continue;
703 }
704 $this->buildPathFromId($key, 0);
705 }
706
707 $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
708 $this->full_arbo_loaded = 1;
709
710 return $this->cats;
711 }
712
721 private function buildPathFromId($id_categ, $protection = 0)
722 {
723 // Define fullpath
724 if (!empty($this->cats[$id_categ]['id_mere'])) {
725 $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
726 $this->cats[$id_categ]['fullpath'] .= '_'.$id_categ;
727 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename'];
728 $this->cats[$id_categ]['fullrelativename'] .= '/'.$this->cats[$id_categ]['label'];
729 $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel'];
730 $this->cats[$id_categ]['fulllabel'] .= ' >> '.$this->cats[$id_categ]['label'];
731 } else {
732 $this->cats[$id_categ]['fullpath'] = '_'.$id_categ;
733 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$id_categ]['label'];
734 $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];
735 }
736 // We count number of _ to have level (we use strlen that is faster than dol_strlen)
737 $this->cats[$id_categ]['level'] = strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath']));
738
739 // Process children
740 $protection++;
741 if ($protection > 20) {
742 return; // We never go more than 20 levels
743 }
744 if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
745 foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {
746 $this->buildPathFromId($val, $protection);
747 }
748 }
749 }
750
757 public function refreshcachenboffile($all = 0)
758 {
759 global $conf;
760 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
761
762 $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
763 $filelist = dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$');
764
765 // Test if filelist is in database
766
767
768 // Update request
769 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
770 $sql .= " cachenbofdoc = '".count($filelist)."'";
771 if (empty($all)) { // By default
772 $sql .= " WHERE rowid = ".((int) $this->id);
773 } else {
774 $sql .= " WHERE entity = ".$conf->entity;
775 }
776
777 dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG);
778 $resql = $this->db->query($sql);
779 if ($resql) {
780 $this->cachenbofdoc = count($filelist);
781 return $this->cachenbofdoc;
782 } else {
783 $this->error = "Error ".$this->db->lasterror();
784 return -1;
785 }
786 }
787
788 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
801 public function call_trigger($triggerName, $user)
802 {
803 // phpcs:enable
804 global $langs, $conf;
805
806 include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
807 $interface = new Interfaces($this->db);
808 $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf);
809 if ($result < 0) {
810 if (!empty($this->errors)) {
811 $this->errors = array_merge($this->errors, $interface->errors);
812 } else {
813 $this->errors = $interface->errors;
814 }
815 }
816 return $result;
817 }
818}
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Definition security.php:604
$object ref
Definition info.php:79
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
Class to manage ECM directories.
__construct($db)
Constructor.
getNomUrl($withpicto=0, $option='', $max=0, $more='', $notooltip=0)
Return directory name you can click (and picto)
static LibStatut($status, $mode=0)
Return the status.
buildPathFromId($id_categ, $protection=0)
Define properties fullpath, fullrelativename, fulllabel of a directory of array this->cats and all it...
get_full_arbo($force=0)
Reconstruit l'arborescence des categories sous la forme d'un tableau à partir de la base de donnée Re...
load_motherof()
Load this->motherof that is array(id_son=>id_parent, ...)
getRelativePath($force=0)
Return relative path of a directory on disk.
refreshcachenboffile($all=0)
Refresh value for cachenboffile.
initAsSpecimen()
Initialise an instance with random values.
create($user)
Create record into database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
getLibStatut($mode=0)
Return the label of the status.
changeNbOfFiles($value)
Update cache of nb of documents into database.
fetch($id)
Load object in memory from database.
update($user=null, $notrigger=0)
Update database.
Class to manage triggers.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_dir($dir, $nophperrors=0)
Remove a directory (not recursive, so content must be empty).
dol_dir_list($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:62
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_now($mode='auto')
Return date for now.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
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...