dolibarr 20.0.0
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
30{
34 public $element = 'ecm_directories';
35
39 public $table_element = 'ecm_directories';
40
44 public $picto = 'folder-open';
45
49 public $id;
50
54 public $label;
55
59 public $fk_parent;
60
64 public $description;
65
69 public $cachenbofdoc = -1; // By default cache initialized with value 'not calculated'
70
74 public $date_c;
75
79 public $date_m;
80
84 public $fk_user_m;
85
89 public $fk_user_c;
90
94 public $ref;
95
99 public $cats = array();
100
104 public $motherof = array();
105
109 public $forbiddenchars = array('<', '>', ':', '/', '\\', '?', '*', '|', '"');
110
114 public $forbiddencharsdir = array('<', '>', ':', '?', '*', '|', '"');
115
119 public $full_arbo_loaded;
120
126 public function __construct($db)
127 {
128 $this->db = $db;
129 }
130
131
138 public function create($user)
139 {
140 global $conf, $langs;
141
142 $error = 0;
143 $now = dol_now();
144
145 // Clean parameters
146 $this->label = dol_sanitizeFileName(trim($this->label));
147 $this->description = trim($this->description);
148 $this->date_c = $now;
149 $this->fk_user_c = $user->id;
150 if ($this->fk_parent <= 0) {
151 $this->fk_parent = 0;
152 }
153
154
155 // Check if same directory does not exists with this name
156 $relativepath = $this->label;
157 if ($this->fk_parent > 0) {
158 $parent = new EcmDirectory($this->db);
159 $parent->fetch($this->fk_parent);
160 $relativepath = $parent->getRelativePath().$relativepath;
161 }
162 $relativepath = preg_replace('/([\/])+/i', '/', $relativepath); // Avoid duplicate / or \
163 //print $relativepath.'<br>';
164
165 $cat = new EcmDirectory($this->db);
166 $cate_arbo = $cat->get_full_arbo(1);
167 $pathfound = 0;
168 foreach ($cate_arbo as $key => $categ) {
169 $path = str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']);
170 //print $relativepath.' - '.$path.'<br>';
171 if ($path == $relativepath) {
172 $pathfound = 1;
173 break;
174 }
175 }
176
177 if ($pathfound) {
178 $this->error = "ErrorDirAlreadyExists";
179 dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING);
180 return -1;
181 } else {
182 $this->db->begin();
183
184 // Insert request
185 $sql = "INSERT INTO ".MAIN_DB_PREFIX."ecm_directories(";
186 $sql .= "label,";
187 $sql .= "entity,";
188 $sql .= "fk_parent,";
189 $sql .= "description,";
190 $sql .= "cachenbofdoc,";
191 $sql .= "date_c,";
192 $sql .= "fk_user_c";
193 $sql .= ") VALUES (";
194 $sql .= " '".$this->db->escape($this->label)."',";
195 $sql .= " '".$this->db->escape($conf->entity)."',";
196 $sql .= " ".($this->fk_parent > 0 ? ((int) $this->fk_parent) : "null").",";
197 $sql .= " '".$this->db->escape($this->description)."',";
198 $sql .= " ".((int) $this->cachenbofdoc).",";
199 $sql .= " '".$this->db->idate($this->date_c)."',";
200 $sql .= " ".($this->fk_user_c > 0 ? ((int) $this->fk_user_c) : "null");
201 $sql .= ")";
202
203 dol_syslog(get_class($this)."::create", LOG_DEBUG);
204 $resql = $this->db->query($sql);
205 if ($resql) {
206 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ecm_directories");
207
208 $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
209 $result = dol_mkdir($dir);
210 if ($result < 0) {
211 $error++;
212 $this->error = "ErrorFailedToCreateDir";
213 }
214
215 // Call trigger
216 $result = $this->call_trigger('MYECMDIR_CREATE', $user);
217 if ($result < 0) {
218 $error++;
219 }
220 // End call triggers
221
222 if (!$error) {
223 $this->db->commit();
224 return $this->id;
225 } else {
226 $this->db->rollback();
227 return -1;
228 }
229 } else {
230 $this->error = "Error ".$this->db->lasterror();
231 $this->db->rollback();
232 return -1;
233 }
234 }
235 }
236
244 public function update($user = null, $notrigger = 0)
245 {
246 global $conf, $langs;
247
248 $error = 0;
249
250 // Clean parameters
251 $this->label = trim($this->label);
252 $this->description = trim($this->description);
253 if ($this->fk_parent <= 0) {
254 $this->fk_parent = 0;
255 }
256
257 $this->db->begin();
258
259 // Update request
260 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
261 $sql .= " label = '".$this->db->escape($this->label)."',";
262 $sql .= " fk_parent = ".($this->fk_parent > 0 ? ((int) $this->fk_parent) : "null").",";
263 $sql .= " description = '".$this->db->escape($this->description)."'";
264 $sql .= " WHERE rowid = ".((int) $this->id);
265
266 dol_syslog(get_class($this)."::update", LOG_DEBUG);
267 $resql = $this->db->query($sql);
268 if (!$resql) {
269 $error++;
270 $this->error = "Error ".$this->db->lasterror();
271 }
272
273 if (!$error && !$notrigger) {
274 // Call trigger
275 $result = $this->call_trigger('MYECMDIR_MODIFY', $user);
276 if ($result < 0) {
277 $error++;
278 }
279 // End call triggers
280 }
281
282 if (!$error) {
283 $this->db->commit();
284 return 1;
285 } else {
286 $this->db->rollback();
287 return -1;
288 }
289 }
290
291
298 public function changeNbOfFiles($value)
299 {
300 // Update request
301 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
302 if (preg_match('/[0-9]+/', $value)) {
303 $sql .= " cachenbofdoc = ".(int) $value;
304 } else {
305 $sql .= " cachenbofdoc = cachenbofdoc ".$value." 1";
306 }
307 $sql .= " WHERE rowid = ".((int) $this->id);
308
309 dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG);
310 $resql = $this->db->query($sql);
311 if (!$resql) {
312 $this->error = "Error ".$this->db->lasterror();
313 return -1;
314 } else {
315 if (preg_match('/[0-9]+/', $value)) {
316 $this->cachenbofdoc = (int) $value;
317 } elseif ($value == '+') {
318 $this->cachenbofdoc++;
319 } elseif ($value == '-') {
320 $this->cachenbofdoc--;
321 }
322 }
323
324 return 1;
325 }
326
327
334 public function fetch($id)
335 {
336 $sql = "SELECT";
337 $sql .= " t.rowid,";
338 $sql .= " t.label,";
339 $sql .= " t.fk_parent,";
340 $sql .= " t.description,";
341 $sql .= " t.cachenbofdoc,";
342 $sql .= " t.fk_user_c,";
343 $sql .= " t.fk_user_m,";
344 $sql .= " t.date_c as date_c,";
345 $sql .= " t.tms as date_m";
346 $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
347 $sql .= " WHERE t.rowid = ".((int) $id);
348
349 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
350 $resql = $this->db->query($sql);
351 if ($resql) {
352 $obj = $this->db->fetch_object($resql);
353 if ($obj) {
354 $this->id = $obj->rowid;
355 $this->ref = $obj->rowid;
356
357 $this->label = $obj->label;
358 $this->fk_parent = $obj->fk_parent;
359 $this->description = $obj->description;
360 $this->cachenbofdoc = $obj->cachenbofdoc;
361 $this->fk_user_m = $obj->fk_user_m;
362 $this->fk_user_c = $obj->fk_user_c;
363 $this->date_c = $this->db->jdate($obj->date_c);
364 $this->date_m = $this->db->jdate($obj->date_m);
365 }
366
367 // Retrieve all extrafields for ecm_files
368 // fetch optionals attributes and labels
369 $this->fetch_optionals();
370
371 $this->db->free($resql);
372
373 return $obj ? 1 : 0;
374 } else {
375 $this->error = "Error ".$this->db->lasterror();
376 return -1;
377 }
378 }
379
380
389 public function delete($user, $mode = 'all', $deletedirrecursive = 0)
390 {
391 global $conf, $langs;
392 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
393
394 $error = 0;
395
396 if ($mode != 'databaseonly') {
397 $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3
398 }
399
400 dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath));
401
402 $this->db->begin();
403
404 $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
405 $sql .= " WHERE rowid=".((int) $this->id);
406
407 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
408 $resql = $this->db->query($sql);
409 if (!$resql) {
410 $this->db->rollback();
411 $this->error = "Error ".$this->db->lasterror();
412 return -2;
413 } else {
414 // Call trigger
415 $result = $this->call_trigger('MYECMDIR_DELETE', $user);
416 if ($result < 0) {
417 $this->db->rollback();
418 return -2;
419 }
420 // End call triggers
421 }
422
423 if ($mode != 'databaseonly') {
424 $file = $conf->ecm->dir_output."/".$relativepath;
425 if ($deletedirrecursive) {
426 $result = @dol_delete_dir_recursive($file, 0, 0);
427 } else {
428 $result = @dol_delete_dir($file, 0);
429 }
430 }
431
432 if ($result || !@is_dir(dol_osencode($file))) {
433 $this->db->commit();
434 } else {
435 $this->error = 'ErrorFailToDeleteDir';
436 dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
437 $this->db->rollback();
438 $error++;
439 }
440
441 if (!$error) {
442 return 1;
443 } else {
444 return -1;
445 }
446 }
447
448
456 public function initAsSpecimen()
457 {
458 $this->id = 0;
459
460 $this->label = 'MyDirectory';
461 $this->fk_parent = 0;
462 $this->description = 'This is a directory';
463
464 return 1;
465 }
466
467
478 public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0)
479 {
480 global $langs, $hookmanager;
481
482 $result = '';
483 //$newref=str_replace('_',' ',$this->ref);
484 $newref = $this->ref;
485 $label = $langs->trans("ShowECMSection").': '.$newref;
486 $linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
487
488 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
489 if ($option == 'index') {
490 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
491 }
492 if ($option == 'indexexpanded') {
493 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
494 }
495 if ($option == 'indexnotexpanded') {
496 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
497 }
498 $linkend = '</a>';
499
500 //$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
501 $picto = 'dir';
502
503 $result .= $linkstart;
504 if ($withpicto) {
505 $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
506 }
507 if ($withpicto != 2) {
508 $result .= ($max ? dol_trunc($newref, $max, 'middle') : $newref);
509 }
510 $result .= $linkend;
511
512 global $action;
513 $hookmanager->initHooks(array($this->element . 'dao'));
514 $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
515 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
516 if ($reshook > 0) {
517 $result = $hookmanager->resPrint;
518 } else {
519 $result .= $hookmanager->resPrint;
520 }
521 return $result;
522 }
523
530 public function getRelativePath($force = 0)
531 {
532 $this->get_full_arbo($force);
533
534 $ret = '';
535 $idtosearch = $this->id;
536 $i = 0;
537 do {
538 // Get index cursor in this->cats for id_mere
539 $cursorindex = -1;
540 foreach ($this->cats as $key => $val) {
541 if ($this->cats[$key]['id'] == $idtosearch) {
542 $cursorindex = $key;
543 break;
544 }
545 }
546 //print "c=".$idtosearch."-".$cursorindex;
547
548 if ($cursorindex >= 0) {
549 // Path is label sanitized (no space and no special char) and concatenated
550 $ret = dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret;
551
552 $idtosearch = $this->cats[$cursorindex]['id_mere'];
553 $i++;
554 }
555 } while ($cursorindex >= 0 && !empty($idtosearch) && $i < 100); // i avoid infinite loop
556
557 return $ret;
558 }
559
560 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
566 public function load_motherof()
567 {
568 // phpcs:enable
569 global $conf;
570
571 $this->motherof = array();
572
573 // Load array[child]=parent
574 $sql = "SELECT fk_parent as id_parent, rowid as id_son";
575 $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories";
576 $sql .= " WHERE fk_parent != 0";
577 $sql .= " AND entity = ".$conf->entity;
578
579 dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
580 $resql = $this->db->query($sql);
581 if ($resql) {
582 // This assignment in condition is not a bug. It allows walking the results.
583 while ($obj = $this->db->fetch_object($resql)) {
584 $this->motherof[$obj->id_son] = $obj->id_parent;
585 }
586 return 1;
587 } else {
588 dol_print_error($this->db);
589 return -1;
590 }
591 }
592
593
600 public function getLibStatut($mode = 0)
601 {
602 return $this->LibStatut($this->status, $mode);
603 }
604
605 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
613 public static function LibStatut($status, $mode = 0)
614 {
615 // phpcs:enable
616 global $langs;
617 return '';
618 }
619
620
621 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
641 public function get_full_arbo($force = 0)
642 {
643 // phpcs:enable
644 global $conf;
645
646 if (empty($force) && !empty($this->full_arbo_loaded)) {
647 return $this->cats;
648 }
649
650 // Init this->motherof that is array(id_son=>id_parent, ...)
651 $this->load_motherof();
652
653 // Charge tableau des categories
654 $sql = "SELECT c.rowid as rowid, c.label as label,";
655 $sql .= " c.description as description, c.cachenbofdoc,";
656 $sql .= " c.fk_user_c,";
657 $sql .= " c.date_c,";
658 $sql .= " u.login as login_c,";
659 $sql .= " u.statut as statut_c,";
660 $sql .= " ca.rowid as rowid_fille";
661 $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c";
662 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca";
663 $sql .= " ON c.rowid = ca.fk_parent";
664 $sql .= " WHERE c.fk_user_c = u.rowid";
665 $sql .= " AND c.entity = ".$conf->entity;
666 $sql .= " ORDER BY c.label, c.rowid";
667
668 dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG);
669 $resql = $this->db->query($sql);
670 if ($resql) {
671 $this->cats = array();
672 $i = 0;
673 // This assignment in condition is not a bug. It allows walking the results.
674 while ($obj = $this->db->fetch_object($resql)) {
675 $this->cats[$obj->rowid]['id'] = $obj->rowid;
676 $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : '');
677 $this->cats[$obj->rowid]['label'] = $obj->label;
678 $this->cats[$obj->rowid]['description'] = $obj->description;
679 $this->cats[$obj->rowid]['cachenbofdoc'] = $obj->cachenbofdoc;
680 $this->cats[$obj->rowid]['date_c'] = $this->db->jdate($obj->date_c);
681 $this->cats[$obj->rowid]['fk_user_c'] = (int) $obj->fk_user_c;
682 $this->cats[$obj->rowid]['statut_c'] = (int) $obj->statut_c;
683 $this->cats[$obj->rowid]['login_c'] = $obj->login_c;
684
685 if (!empty($obj->rowid_fille)) {
686 if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) {
687 $newelempos = count($this->cats[$obj->rowid]['id_children']);
688 //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements<br>";
689 $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille;
690 } else {
691 //print "this->cats[".$obj->rowid."]['id_children'] n'est pas encore un tableau<br>";
692 $this->cats[$obj->rowid]['id_children'] = array($obj->rowid_fille);
693 }
694 }
695 $i++;
696 }
697 } else {
698 dol_print_error($this->db);
699 return -1;
700 }
701
702 // We add properties fullxxx to all elements
703 foreach ($this->cats as $key => $val) {
704 if (isset($this->motherof[$key])) {
705 continue;
706 }
707 $this->buildPathFromId($key, 0);
708 }
709
710 $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
711 $this->full_arbo_loaded = 1;
712
713 return $this->cats;
714 }
715
724 private function buildPathFromId($id_categ, $protection = 0)
725 {
726 // Define fullpath
727 if (!empty($this->cats[$id_categ]['id_mere'])) {
728 $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
729 $this->cats[$id_categ]['fullpath'] .= '_'.$id_categ;
730 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename'];
731 $this->cats[$id_categ]['fullrelativename'] .= '/'.$this->cats[$id_categ]['label'];
732 $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel'];
733 $this->cats[$id_categ]['fulllabel'] .= ' >> '.$this->cats[$id_categ]['label'];
734 } else {
735 $this->cats[$id_categ]['fullpath'] = '_'.$id_categ;
736 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$id_categ]['label'];
737 $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];
738 }
739 // We count number of _ to have level (we use strlen that is faster than dol_strlen)
740 $this->cats[$id_categ]['level'] = strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath']));
741
742 // Process children
743 $protection++;
744 if ($protection > 20) {
745 return; // We never go more than 20 levels
746 }
747 if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
748 foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {
749 $this->buildPathFromId($val, $protection);
750 }
751 }
752 }
753
760 public function refreshcachenboffile($all = 0)
761 {
762 global $conf;
763 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
764
765 $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
766 $filelist = dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$');
767
768 // Test if filelist is in database
769
770
771 // Update request
772 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
773 $sql .= " cachenbofdoc = '".count($filelist)."'";
774 if (empty($all)) { // By default
775 $sql .= " WHERE rowid = ".((int) $this->id);
776 } else {
777 $sql .= " WHERE entity = ".$conf->entity;
778 }
779
780 dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG);
781 $resql = $this->db->query($sql);
782 if ($resql) {
783 $this->cachenbofdoc = count($filelist);
784 return $this->cachenbofdoc;
785 } else {
786 $this->error = "Error ".$this->db->lasterror();
787 return -1;
788 }
789 }
790
791 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
804 public function call_trigger($triggerName, $user)
805 {
806 // phpcs:enable
807 global $langs, $conf;
808
809 include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
810 $interface = new Interfaces($this->db);
811 $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf);
812 if ($result < 0) {
813 if (!empty($this->errors)) {
814 $this->errors = array_merge($this->errors, $interface->errors);
815 } else {
816 $this->errors = $interface->errors;
817 }
818 }
819 return $result;
820 }
821}
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition security.php:637
$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($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:63
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
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 the value of a given key, which produces ascending (default) or descending out...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...