dolibarr 20.0.5
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 global $conf;
301
302 if ($value == 'database') {
303 $relativepath = $conf->ecm->dir_output . '/' . $this->getRelativePath(); // Ex: dir1/dir2/dir3/
304 $relativepath = preg_replace('/^' . preg_quote(DOL_DATA_ROOT, '/') . '/', '', $relativepath);
305 $relativepath = trim($relativepath, '/');
306
307 // Get nb file in relative path
308 $sql = "SELECT COUNT(*) AS nb";
309 $sql .= " FROM " . $this->db->prefix() . "ecm_files";
310 $sql .= " WHERE filepath = '" . $this->db->escape($relativepath) . "'";
311
312 dol_syslog(get_class($this) . "::changeNbOfFiles - Get nb file in relative path", LOG_DEBUG);
313 $resql = $this->db->query($sql);
314 if (!$resql) {
315 $this->error = "Error " . $this->db->lasterror();
316 return -1;
317 } else {
318 $value = 0;
319 if ($obj = $this->db->fetch_object($resql)) {
320 $value = (int) $obj->nb;
321 }
322 }
323 }
324
325 // Update request
326 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
327 if (preg_match('/[0-9]+/', $value)) {
328 $sql .= " cachenbofdoc = ".(int) $value;
329 } else {
330 $sql .= " cachenbofdoc = cachenbofdoc " . preg_replace('/[^\-]/', '', $value) . " 1";
331 }
332 $sql .= " WHERE rowid = ".((int) $this->id);
333
334 dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG);
335 $resql = $this->db->query($sql);
336 if (!$resql) {
337 $this->error = "Error ".$this->db->lasterror();
338 return -1;
339 } else {
340 if (preg_match('/[0-9]+/', $value)) {
341 $this->cachenbofdoc = (int) $value;
342 } elseif ($value == '+') {
343 $this->cachenbofdoc++;
344 } elseif ($value == '-') {
345 $this->cachenbofdoc--;
346 }
347 }
348
349 return 1;
350 }
351
352
359 public function fetch($id)
360 {
361 $sql = "SELECT";
362 $sql .= " t.rowid,";
363 $sql .= " t.label,";
364 $sql .= " t.fk_parent,";
365 $sql .= " t.description,";
366 $sql .= " t.cachenbofdoc,";
367 $sql .= " t.fk_user_c,";
368 $sql .= " t.fk_user_m,";
369 $sql .= " t.date_c as date_c,";
370 $sql .= " t.tms as date_m";
371 $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
372 $sql .= " WHERE t.rowid = ".((int) $id);
373
374 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
375 $resql = $this->db->query($sql);
376 if ($resql) {
377 $obj = $this->db->fetch_object($resql);
378 if ($obj) {
379 $this->id = $obj->rowid;
380 $this->ref = $obj->rowid;
381
382 $this->label = $obj->label;
383 $this->fk_parent = $obj->fk_parent;
384 $this->description = $obj->description;
385 $this->cachenbofdoc = $obj->cachenbofdoc;
386 $this->fk_user_m = $obj->fk_user_m;
387 $this->fk_user_c = $obj->fk_user_c;
388 $this->date_c = $this->db->jdate($obj->date_c);
389 $this->date_m = $this->db->jdate($obj->date_m);
390 }
391
392 // Retrieve all extrafields for ecm_files
393 // fetch optionals attributes and labels
394 $this->fetch_optionals();
395
396 $this->db->free($resql);
397
398 return $obj ? 1 : 0;
399 } else {
400 $this->error = "Error ".$this->db->lasterror();
401 return -1;
402 }
403 }
404
405
414 public function delete($user, $mode = 'all', $deletedirrecursive = 0)
415 {
416 global $conf, $langs;
417 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
418
419 $error = 0;
420
421 if ($mode != 'databaseonly') {
422 $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3
423 }
424
425 dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath));
426
427 $this->db->begin();
428
429 $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
430 $sql .= " WHERE rowid=".((int) $this->id);
431
432 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
433 $resql = $this->db->query($sql);
434 if (!$resql) {
435 $this->db->rollback();
436 $this->error = "Error ".$this->db->lasterror();
437 return -2;
438 } else {
439 // Call trigger
440 $result = $this->call_trigger('MYECMDIR_DELETE', $user);
441 if ($result < 0) {
442 $this->db->rollback();
443 return -2;
444 }
445 // End call triggers
446 }
447
448 if ($mode != 'databaseonly') {
449 $file = $conf->ecm->dir_output."/".$relativepath;
450 if ($deletedirrecursive) {
451 $result = @dol_delete_dir_recursive($file, 0, 0);
452 } else {
453 $result = @dol_delete_dir($file, 0);
454 }
455 }
456
457 if ($result || !@is_dir(dol_osencode($file))) {
458 $this->db->commit();
459 } else {
460 $this->error = 'ErrorFailToDeleteDir';
461 dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
462 $this->db->rollback();
463 $error++;
464 }
465
466 if (!$error) {
467 return 1;
468 } else {
469 return -1;
470 }
471 }
472
473
481 public function initAsSpecimen()
482 {
483 $this->id = 0;
484
485 $this->label = 'MyDirectory';
486 $this->fk_parent = 0;
487 $this->description = 'This is a directory';
488
489 return 1;
490 }
491
492
503 public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0)
504 {
505 global $langs, $hookmanager;
506
507 $result = '';
508 //$newref=str_replace('_',' ',$this->ref);
509 $newref = $this->ref;
510 $label = $langs->trans("ShowECMSection").': '.$newref;
511 $linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
512
513 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
514 if ($option == 'index') {
515 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
516 }
517 if ($option == 'indexexpanded') {
518 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
519 }
520 if ($option == 'indexnotexpanded') {
521 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
522 }
523 $linkend = '</a>';
524
525 //$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
526 $picto = 'dir';
527
528 $result .= $linkstart;
529 if ($withpicto) {
530 $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
531 }
532 if ($withpicto != 2) {
533 $result .= ($max ? dol_trunc($newref, $max, 'middle') : $newref);
534 }
535 $result .= $linkend;
536
537 global $action;
538 $hookmanager->initHooks(array($this->element . 'dao'));
539 $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
540 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
541 if ($reshook > 0) {
542 $result = $hookmanager->resPrint;
543 } else {
544 $result .= $hookmanager->resPrint;
545 }
546 return $result;
547 }
548
555 public function getRelativePath($force = 0)
556 {
557 $this->get_full_arbo($force);
558
559 $ret = '';
560 $idtosearch = $this->id;
561 $i = 0;
562 do {
563 // Get index cursor in this->cats for id_mere
564 $cursorindex = -1;
565 foreach ($this->cats as $key => $val) {
566 if ($this->cats[$key]['id'] == $idtosearch) {
567 $cursorindex = $key;
568 break;
569 }
570 }
571 //print "c=".$idtosearch."-".$cursorindex;
572
573 if ($cursorindex >= 0) {
574 // Path is label sanitized (no space and no special char) and concatenated
575 $ret = dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret;
576
577 $idtosearch = $this->cats[$cursorindex]['id_mere'];
578 $i++;
579 }
580 } while ($cursorindex >= 0 && !empty($idtosearch) && $i < 100); // i avoid infinite loop
581
582 return $ret;
583 }
584
585 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
591 public function load_motherof()
592 {
593 // phpcs:enable
594 global $conf;
595
596 $this->motherof = array();
597
598 // Load array[child]=parent
599 $sql = "SELECT fk_parent as id_parent, rowid as id_son";
600 $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories";
601 $sql .= " WHERE fk_parent != 0";
602 $sql .= " AND entity = ".$conf->entity;
603
604 dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
605 $resql = $this->db->query($sql);
606 if ($resql) {
607 // This assignment in condition is not a bug. It allows walking the results.
608 while ($obj = $this->db->fetch_object($resql)) {
609 $this->motherof[$obj->id_son] = $obj->id_parent;
610 }
611 return 1;
612 } else {
613 dol_print_error($this->db);
614 return -1;
615 }
616 }
617
618
625 public function getLibStatut($mode = 0)
626 {
627 return $this->LibStatut($this->status, $mode);
628 }
629
630 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
638 public static function LibStatut($status, $mode = 0)
639 {
640 // phpcs:enable
641 global $langs;
642 return '';
643 }
644
645
646 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
666 public function get_full_arbo($force = 0)
667 {
668 // phpcs:enable
669 global $conf;
670
671 if (empty($force) && !empty($this->full_arbo_loaded)) {
672 return $this->cats;
673 }
674
675 // Init this->motherof that is array(id_son=>id_parent, ...)
676 $this->load_motherof();
677
678 // Charge tableau des categories
679 $sql = "SELECT c.rowid as rowid, c.label as label,";
680 $sql .= " c.description as description, c.cachenbofdoc,";
681 $sql .= " c.fk_user_c,";
682 $sql .= " c.date_c,";
683 $sql .= " u.login as login_c,";
684 $sql .= " u.statut as statut_c,";
685 $sql .= " ca.rowid as rowid_fille";
686 $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c";
687 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca";
688 $sql .= " ON c.rowid = ca.fk_parent";
689 $sql .= " WHERE c.fk_user_c = u.rowid";
690 $sql .= " AND c.entity = ".$conf->entity;
691 $sql .= " ORDER BY c.label, c.rowid";
692
693 dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG);
694 $resql = $this->db->query($sql);
695 if ($resql) {
696 $this->cats = array();
697 $i = 0;
698 // This assignment in condition is not a bug. It allows walking the results.
699 while ($obj = $this->db->fetch_object($resql)) {
700 $this->cats[$obj->rowid]['id'] = $obj->rowid;
701 $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : '');
702 $this->cats[$obj->rowid]['label'] = $obj->label;
703 $this->cats[$obj->rowid]['description'] = $obj->description;
704 $this->cats[$obj->rowid]['cachenbofdoc'] = $obj->cachenbofdoc;
705 $this->cats[$obj->rowid]['date_c'] = $this->db->jdate($obj->date_c);
706 $this->cats[$obj->rowid]['fk_user_c'] = (int) $obj->fk_user_c;
707 $this->cats[$obj->rowid]['statut_c'] = (int) $obj->statut_c;
708 $this->cats[$obj->rowid]['login_c'] = $obj->login_c;
709
710 if (!empty($obj->rowid_fille)) {
711 if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) {
712 $newelempos = count($this->cats[$obj->rowid]['id_children']);
713 //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements<br>";
714 $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille;
715 } else {
716 //print "this->cats[".$obj->rowid."]['id_children'] n'est pas encore un tableau<br>";
717 $this->cats[$obj->rowid]['id_children'] = array($obj->rowid_fille);
718 }
719 }
720 $i++;
721 }
722 } else {
723 dol_print_error($this->db);
724 return -1;
725 }
726
727 // We add properties fullxxx to all elements
728 foreach ($this->cats as $key => $val) {
729 if (isset($this->motherof[$key])) {
730 continue;
731 }
732 $this->buildPathFromId($key, 0);
733 }
734
735 $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
736 $this->full_arbo_loaded = 1;
737
738 return $this->cats;
739 }
740
749 private function buildPathFromId($id_categ, $protection = 0)
750 {
751 // Define fullpath
752 if (!empty($this->cats[$id_categ]['id_mere'])) {
753 $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
754 $this->cats[$id_categ]['fullpath'] .= '_'.$id_categ;
755 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename'];
756 $this->cats[$id_categ]['fullrelativename'] .= '/'.$this->cats[$id_categ]['label'];
757 $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel'];
758 $this->cats[$id_categ]['fulllabel'] .= ' >> '.$this->cats[$id_categ]['label'];
759 } else {
760 $this->cats[$id_categ]['fullpath'] = '_'.$id_categ;
761 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$id_categ]['label'];
762 $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];
763 }
764 // We count number of _ to have level (we use strlen that is faster than dol_strlen)
765 $this->cats[$id_categ]['level'] = strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath']));
766
767 // Process children
768 $protection++;
769 if ($protection > 20) {
770 return; // We never go more than 20 levels
771 }
772 if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
773 foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {
774 $this->buildPathFromId($val, $protection);
775 }
776 }
777 }
778
785 public function refreshcachenboffile($all = 0)
786 {
787 global $conf;
788 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
789
790 $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
791 $filelist = dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$');
792
793 // Test if filelist is in database
794
795
796 // Update request
797 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
798 $sql .= " cachenbofdoc = '".count($filelist)."'";
799 if (empty($all)) { // By default
800 $sql .= " WHERE rowid = ".((int) $this->id);
801 } else {
802 $sql .= " WHERE entity = ".$conf->entity;
803 }
804
805 dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG);
806 $resql = $this->db->query($sql);
807 if ($resql) {
808 $this->cachenbofdoc = count($filelist);
809 return $this->cachenbofdoc;
810 } else {
811 $this->error = "Error ".$this->db->lasterror();
812 return -1;
813 }
814 }
815
816 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
829 public function call_trigger($triggerName, $user)
830 {
831 // phpcs:enable
832 global $langs, $conf;
833
834 include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
835 $interface = new Interfaces($this->db);
836 $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf);
837 if ($result < 0) {
838 if (!empty($this->errors)) {
839 $this->errors = array_merge($this->errors, $interface->errors);
840 } else {
841 $this->errors = $interface->errors;
842 }
843 }
844 return $result;
845 }
846}
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...