dolibarr 21.0.0-beta
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
31{
35 public $element = 'ecm_directories';
36
40 public $table_element = 'ecm_directories';
41
45 public $picto = 'folder-open';
46
50 public $id;
51
55 public $label;
56
60 public $fk_parent;
61
65 public $description;
66
70 public $cachenbofdoc = -1; // By default cache initialized with value 'not calculated'
71
75 public $date_c;
76
80 public $date_m;
81
85 public $fk_user_m;
86
90 public $fk_user_c;
91
95 public $ref;
96
100 public $cats = array();
101
105 public $motherof = array();
106
110 public $forbiddenchars = array('<', '>', ':', '/', '\\', '?', '*', '|', '"');
111
115 public $forbiddencharsdir = array('<', '>', ':', '?', '*', '|', '"');
116
120 public $full_arbo_loaded;
121
127 public function __construct($db)
128 {
129 $this->db = $db;
130 }
131
132
139 public function create($user)
140 {
141 global $conf, $langs;
142
143 $error = 0;
144 $now = dol_now();
145
146 // Clean parameters
147 $this->label = dol_sanitizeFileName(trim($this->label));
148 $this->description = trim($this->description);
149 $this->date_c = $now;
150 $this->fk_user_c = $user->id;
151 if ($this->fk_parent <= 0) {
152 $this->fk_parent = 0;
153 }
154
155
156 // Check if same directory does not exists with this name
157 $relativepath = $this->label;
158 if ($this->fk_parent > 0) {
159 $parent = new EcmDirectory($this->db);
160 $parent->fetch($this->fk_parent);
161 $relativepath = $parent->getRelativePath().$relativepath;
162 }
163 $relativepath = preg_replace('/([\/])+/i', '/', $relativepath); // Avoid duplicate / or \
164 //print $relativepath.'<br>';
165
166 $cat = new EcmDirectory($this->db);
167 $cate_arbo = $cat->get_full_arbo(1);
168 $pathfound = 0;
169 foreach ($cate_arbo as $key => $categ) {
170 $path = str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']);
171 //print $relativepath.' - '.$path.'<br>';
172 if ($path == $relativepath) {
173 $pathfound = 1;
174 break;
175 }
176 }
177
178 if ($pathfound) {
179 $this->error = "ErrorDirAlreadyExists";
180 dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING);
181 return -1;
182 } else {
183 $this->db->begin();
184
185 // Insert request
186 $sql = "INSERT INTO ".MAIN_DB_PREFIX."ecm_directories(";
187 $sql .= "label,";
188 $sql .= "entity,";
189 $sql .= "fk_parent,";
190 $sql .= "description,";
191 $sql .= "cachenbofdoc,";
192 $sql .= "date_c,";
193 $sql .= "fk_user_c";
194 $sql .= ") VALUES (";
195 $sql .= " '".$this->db->escape($this->label)."',";
196 $sql .= " '".$this->db->escape($conf->entity)."',";
197 $sql .= " ".($this->fk_parent > 0 ? ((int) $this->fk_parent) : "null").",";
198 $sql .= " '".$this->db->escape($this->description)."',";
199 $sql .= " ".((int) $this->cachenbofdoc).",";
200 $sql .= " '".$this->db->idate($this->date_c)."',";
201 $sql .= " ".($this->fk_user_c > 0 ? ((int) $this->fk_user_c) : "null");
202 $sql .= ")";
203
204 dol_syslog(get_class($this)."::create", LOG_DEBUG);
205 $resql = $this->db->query($sql);
206 if ($resql) {
207 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ecm_directories");
208
209 $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
210 $result = dol_mkdir($dir);
211 if ($result < 0) {
212 $error++;
213 $this->error = "ErrorFailedToCreateDir";
214 }
215
216 // Call trigger
217 $result = $this->call_trigger('MYECMDIR_CREATE', $user);
218 if ($result < 0) {
219 $error++;
220 }
221 // End call triggers
222
223 if (!$error) {
224 $this->db->commit();
225 return $this->id;
226 } else {
227 $this->db->rollback();
228 return -1;
229 }
230 } else {
231 $this->error = "Error ".$this->db->lasterror();
232 $this->db->rollback();
233 return -1;
234 }
235 }
236 }
237
245 public function update($user = null, $notrigger = 0)
246 {
247 global $conf, $langs;
248
249 $error = 0;
250
251 // Clean parameters
252 $this->label = trim($this->label);
253 $this->description = trim($this->description);
254 if ($this->fk_parent <= 0) {
255 $this->fk_parent = 0;
256 }
257
258 $this->db->begin();
259
260 // Update request
261 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
262 $sql .= " label = '".$this->db->escape($this->label)."',";
263 $sql .= " fk_parent = ".($this->fk_parent > 0 ? ((int) $this->fk_parent) : "null").",";
264 $sql .= " description = '".$this->db->escape($this->description)."'";
265 $sql .= " WHERE rowid = ".((int) $this->id);
266
267 dol_syslog(get_class($this)."::update", LOG_DEBUG);
268 $resql = $this->db->query($sql);
269 if (!$resql) {
270 $error++;
271 $this->error = "Error ".$this->db->lasterror();
272 }
273
274 if (!$error && !$notrigger) {
275 // Call trigger
276 $result = $this->call_trigger('MYECMDIR_MODIFY', $user);
277 if ($result < 0) {
278 $error++;
279 }
280 // End call triggers
281 }
282
283 if (!$error) {
284 $this->db->commit();
285 return 1;
286 } else {
287 $this->db->rollback();
288 return -1;
289 }
290 }
291
292
299 public function changeNbOfFiles($value)
300 {
301 // Update request
302 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
303 if (preg_match('/[0-9]+/', $value)) {
304 $sql .= " cachenbofdoc = ".(int) $value;
305 } else {
306 $sql .= " cachenbofdoc = cachenbofdoc ".preg_replace('/[^\-\+]/', '', $value)." 1";
307 }
308 $sql .= " WHERE rowid = ".((int) $this->id);
309
310 dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG);
311 $resql = $this->db->query($sql);
312 if (!$resql) {
313 $this->error = "Error ".$this->db->lasterror();
314 return -1;
315 } else {
316 if (preg_match('/[0-9]+/', $value)) {
317 $this->cachenbofdoc = (int) $value;
318 } elseif ($value == '+') {
319 $this->cachenbofdoc++;
320 } elseif ($value == '-') {
321 $this->cachenbofdoc--;
322 }
323 }
324
325 return 1;
326 }
327
328
335 public function fetch($id)
336 {
337 $sql = "SELECT";
338 $sql .= " t.rowid,";
339 $sql .= " t.label,";
340 $sql .= " t.fk_parent,";
341 $sql .= " t.description,";
342 $sql .= " t.cachenbofdoc,";
343 $sql .= " t.fk_user_c,";
344 $sql .= " t.fk_user_m,";
345 $sql .= " t.date_c as date_c,";
346 $sql .= " t.tms as date_m";
347 $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
348 $sql .= " WHERE t.rowid = ".((int) $id);
349
350 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
351 $resql = $this->db->query($sql);
352 if ($resql) {
353 $obj = $this->db->fetch_object($resql);
354 if ($obj) {
355 $this->id = $obj->rowid;
356 $this->ref = $obj->rowid;
357
358 $this->label = $obj->label;
359 $this->fk_parent = $obj->fk_parent;
360 $this->description = $obj->description;
361 $this->cachenbofdoc = (int) $obj->cachenbofdoc;
362 $this->fk_user_m = $obj->fk_user_m;
363 $this->fk_user_c = $obj->fk_user_c;
364 $this->date_c = $this->db->jdate($obj->date_c);
365 $this->date_m = $this->db->jdate($obj->date_m);
366 }
367
368 // Retrieve all extrafields for ecm_files
369 // fetch optionals attributes and labels
370 $this->fetch_optionals();
371
372 $this->db->free($resql);
373
374 return $obj ? 1 : 0;
375 } else {
376 $this->error = "Error ".$this->db->lasterror();
377 return -1;
378 }
379 }
380
381
390 public function delete($user, $mode = 'all', $deletedirrecursive = 0)
391 {
392 global $conf, $langs;
393 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
394
395 $error = 0;
396
397 $relativepath = '__MUST_NOT_EXIST__';
398 if ($mode != 'databaseonly') {
399 $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3
400 }
401
402 dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath));
403
404 $this->db->begin();
405
406 $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
407 $sql .= " WHERE rowid=".((int) $this->id);
408
409 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
410 $resql = $this->db->query($sql);
411 if (!$resql) {
412 $this->db->rollback();
413 $this->error = "Error ".$this->db->lasterror();
414 return -2;
415 } else {
416 // Call trigger
417 $result = $this->call_trigger('MYECMDIR_DELETE', $user);
418 if ($result < 0) {
419 $this->db->rollback();
420 return -2;
421 }
422 // End call triggers
423 }
424
425 $file = '__MUST_NOT_EXIST__';
426 if ($mode != 'databaseonly') {
427 $file = $conf->ecm->dir_output."/".$relativepath;
428 if ($deletedirrecursive) {
429 $result = @dol_delete_dir_recursive($file, 0, 0);
430 } else {
431 $result = @dol_delete_dir($file, 0);
432 }
433 }
434
435 if ($result || !@is_dir(dol_osencode($file))) {
436 $this->db->commit();
437 } else {
438 $this->error = 'ErrorFailToDeleteDir';
439 dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
440 $this->db->rollback();
441 $error++;
442 }
443
444 if (!$error) {
445 return 1;
446 } else {
447 return -1;
448 }
449 }
450
451
459 public function initAsSpecimen()
460 {
461 $this->id = 0;
462
463 $this->label = 'MyDirectory';
464 $this->fk_parent = 0;
465 $this->description = 'This is a directory';
466
467 return 1;
468 }
469
470
481 public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0)
482 {
483 global $langs, $hookmanager;
484
485 $result = '';
486 //$newref=str_replace('_',' ',$this->ref);
487 $newref = $this->ref;
488 $label = img_picto('', $this->picto, '', 0, 0, 0, '', 'paddingrightonly') . $langs->trans("ShowECMSection") . ': ' . $newref;
489 $linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
490
491 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
492 if ($option == 'index') {
493 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
494 }
495 if ($option == 'indexexpanded') {
496 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
497 }
498 if ($option == 'indexnotexpanded') {
499 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
500 }
501 $linkend = '</a>';
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 @phan-suppress-next-line PhanTypeSuspiciousStringExpression
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
617 return '';
618 }
619
620
621 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
642 public function get_full_arbo($force = 0)
643 {
644 // phpcs:enable
645 global $conf;
646
647 if (empty($force) && !empty($this->full_arbo_loaded)) {
648 return $this->cats;
649 }
650
651 // Init this->motherof that is array(id_son=>id_parent, ...)
652 $this->load_motherof();
653
654 // Charge tableau des categories
655 $sql = "SELECT c.rowid as rowid, c.label as label,";
656 $sql .= " c.description as description, c.cachenbofdoc,";
657 $sql .= " c.fk_user_c,";
658 $sql .= " c.date_c,";
659 $sql .= " u.login as login_c,";
660 $sql .= " u.statut as statut_c,";
661 $sql .= " ca.rowid as rowid_fille";
662 $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c";
663 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca";
664 $sql .= " ON c.rowid = ca.fk_parent";
665 $sql .= " WHERE c.fk_user_c = u.rowid";
666 $sql .= " AND c.entity = ".$conf->entity;
667 $sql .= " ORDER BY c.label, c.rowid";
668
669 dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG);
670 $resql = $this->db->query($sql);
671 if ($resql) {
672 $this->cats = array();
673 $i = 0;
674 // This assignment in condition is not a bug. It allows walking the results.
675 while ($obj = $this->db->fetch_object($resql)) {
676 $this->cats[$obj->rowid]['id'] = $obj->rowid;
677 $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : '');
678 $this->cats[$obj->rowid]['label'] = $obj->label;
679 $this->cats[$obj->rowid]['description'] = $obj->description;
680 $this->cats[$obj->rowid]['cachenbofdoc'] = (int) $obj->cachenbofdoc;
681 $this->cats[$obj->rowid]['date_c'] = $this->db->jdate($obj->date_c);
682 $this->cats[$obj->rowid]['fk_user_c'] = (int) $obj->fk_user_c;
683 $this->cats[$obj->rowid]['statut_c'] = (int) $obj->statut_c;
684 $this->cats[$obj->rowid]['login_c'] = $obj->login_c;
685
686 if (!empty($obj->rowid_fille)) {
687 if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) {
688 $newelempos = count($this->cats[$obj->rowid]['id_children']);
689 //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements<br>";
690 $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille;
691 } else {
692 //print "this->cats[".$obj->rowid."]['id_children'] n'est pas encore un tableau<br>";
693 $this->cats[$obj->rowid]['id_children'] = array($obj->rowid_fille);
694 }
695 }
696 $i++;
697 }
698 } else {
699 dol_print_error($this->db);
700 return -1;
701 }
702
703 // We add properties fullxxx to all elements
704 foreach ($this->cats as $key => $val) {
705 if (isset($this->motherof[$key])) {
706 continue;
707 }
708 $this->buildPathFromId($key, 0);
709 }
710
711 $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', 1, 0);
712 $this->full_arbo_loaded = 1;
713
714 return $this->cats;
715 }
716
725 private function buildPathFromId($id_categ, $protection = 0)
726 {
727 // Define fullpath
728 if (!empty($this->cats[$id_categ]['id_mere'])) {
729 $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
730 $this->cats[$id_categ]['fullpath'] .= '_'.$id_categ;
731 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename'];
732 $this->cats[$id_categ]['fullrelativename'] .= '/'.$this->cats[$id_categ]['label'];
733 $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel'];
734 $this->cats[$id_categ]['fulllabel'] .= ' >> '.$this->cats[$id_categ]['label'];
735 } else {
736 $this->cats[$id_categ]['fullpath'] = '_'.$id_categ;
737 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$id_categ]['label'];
738 $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];
739 }
740 // We count number of _ to have level (we use strlen that is faster than dol_strlen)
741 $this->cats[$id_categ]['level'] = strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath']));
742
743 // Process children
744 $protection++;
745 if ($protection > 20) {
746 return; // We never go more than 20 levels
747 }
748 if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
749 foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {
750 $this->buildPathFromId($val, $protection);
751 }
752 }
753 }
754
761 public function refreshcachenboffile($all = 0)
762 {
763 global $conf;
764 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
765
766 $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
767 $filelist = dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$');
768
769 // Test if filelist is in database
770
771
772 // Update request
773 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
774 $sql .= " cachenbofdoc = '".count($filelist)."'";
775 if (empty($all)) { // By default
776 $sql .= " WHERE rowid = ".((int) $this->id);
777 } else {
778 $sql .= " WHERE entity = ".$conf->entity;
779 }
780
781 dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG);
782 $resql = $this->db->query($sql);
783 if ($resql) {
784 $this->cachenbofdoc = count($filelist);
785 return $this->cachenbofdoc;
786 } else {
787 $this->error = "Error ".$this->db->lasterror();
788 return -1;
789 }
790 }
791
792 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
805 public function call_trigger($triggerName, $user)
806 {
807 // phpcs:enable
808 global $langs, $conf;
809
810 include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
811 $interface = new Interfaces($this->db);
812 $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf);
813 if ($result < 0) {
814 if (!empty($this->errors)) {
815 $this->errors = array_merge($this->errors, $interface->errors);
816 } else {
817 $this->errors = $interface->errors;
818 }
819 }
820 return $result;
821 }
822}
$object ref
Definition info.php:89
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 $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:171
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)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79