dolibarr 21.0.4
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 global $conf;
302
303 if ($value == 'database') {
304 $relativepath = $conf->ecm->dir_output . '/' . $this->getRelativePath(); // Ex: dir1/dir2/dir3/
305 $relativepath = preg_replace('/^' . preg_quote(DOL_DATA_ROOT, '/') . '/', '', $relativepath);
306 $relativepath = trim($relativepath, '/');
307
308 // Get nb file in relative path
309 $sql = "SELECT COUNT(*) AS nb";
310 $sql .= " FROM " . $this->db->prefix() . "ecm_files";
311 $sql .= " WHERE filepath = '" . $this->db->escape($relativepath) . "'";
312
313 dol_syslog(get_class($this) . "::changeNbOfFiles - Get nb file in relative path", LOG_DEBUG);
314 $resql = $this->db->query($sql);
315 if (!$resql) {
316 $this->error = "Error " . $this->db->lasterror();
317 return -1;
318 } else {
319 $value = 0;
320 if ($obj = $this->db->fetch_object($resql)) {
321 $value = (int) $obj->nb;
322 }
323 }
324 }
325
326 // Update request
327 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
328 if (preg_match('/[0-9]+/', $value)) {
329 $sql .= " cachenbofdoc = ".(int) $value;
330 } else {
331 $sql .= " cachenbofdoc = cachenbofdoc ".preg_replace('/[^\-\+]/', '', $value)." 1";
332 }
333 $sql .= " WHERE rowid = ".((int) $this->id);
334
335 dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG);
336 $resql = $this->db->query($sql);
337 if (!$resql) {
338 $this->error = "Error ".$this->db->lasterror();
339 return -1;
340 } else {
341 if (preg_match('/[0-9]+/', $value)) {
342 $this->cachenbofdoc = (int) $value;
343 } elseif ($value == '+') {
344 $this->cachenbofdoc++;
345 } elseif ($value == '-') {
346 $this->cachenbofdoc--;
347 }
348 }
349
350 return 1;
351 }
352
353
360 public function fetch($id)
361 {
362 $sql = "SELECT";
363 $sql .= " t.rowid,";
364 $sql .= " t.label,";
365 $sql .= " t.fk_parent,";
366 $sql .= " t.description,";
367 $sql .= " t.cachenbofdoc,";
368 $sql .= " t.fk_user_c,";
369 $sql .= " t.fk_user_m,";
370 $sql .= " t.date_c as date_c,";
371 $sql .= " t.tms as date_m";
372 $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
373 $sql .= " WHERE t.rowid = ".((int) $id);
374
375 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
376 $resql = $this->db->query($sql);
377 if ($resql) {
378 $obj = $this->db->fetch_object($resql);
379 if ($obj) {
380 $this->id = $obj->rowid;
381 $this->ref = $obj->rowid;
382
383 $this->label = $obj->label;
384 $this->fk_parent = $obj->fk_parent;
385 $this->description = $obj->description;
386 $this->cachenbofdoc = (int) $obj->cachenbofdoc;
387 $this->fk_user_m = $obj->fk_user_m;
388 $this->fk_user_c = $obj->fk_user_c;
389 $this->date_c = $this->db->jdate($obj->date_c);
390 $this->date_m = $this->db->jdate($obj->date_m);
391 }
392
393 // Retrieve all extrafields for ecm_files
394 // fetch optionals attributes and labels
395 $this->fetch_optionals();
396
397 $this->db->free($resql);
398
399 return $obj ? 1 : 0;
400 } else {
401 $this->error = "Error ".$this->db->lasterror();
402 return -1;
403 }
404 }
405
406
415 public function delete($user, $mode = 'all', $deletedirrecursive = 0)
416 {
417 global $conf, $langs;
418 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
419
420 $error = 0;
421
422 $relativepath = '__MUST_NOT_EXIST__';
423 if ($mode != 'databaseonly') {
424 $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3
425 }
426
427 dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath));
428
429 $this->db->begin();
430
431 $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
432 $sql .= " WHERE rowid=".((int) $this->id);
433
434 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
435 $resql = $this->db->query($sql);
436 if (!$resql) {
437 $this->db->rollback();
438 $this->error = "Error ".$this->db->lasterror();
439 return -2;
440 } else {
441 // Call trigger
442 $result = $this->call_trigger('MYECMDIR_DELETE', $user);
443 if ($result < 0) {
444 $this->db->rollback();
445 return -2;
446 }
447 // End call triggers
448 }
449
450 $file = '__MUST_NOT_EXIST__';
451 if ($mode != 'databaseonly') {
452 $file = $conf->ecm->dir_output."/".$relativepath;
453 if ($deletedirrecursive) {
454 $result = @dol_delete_dir_recursive($file, 0, 0);
455 } else {
456 $result = @dol_delete_dir($file, 0);
457 }
458 }
459
460 if ($result || !@is_dir(dol_osencode($file))) {
461 $this->db->commit();
462 } else {
463 $this->error = 'ErrorFailToDeleteDir';
464 dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
465 $this->db->rollback();
466 $error++;
467 }
468
469 if (!$error) {
470 return 1;
471 } else {
472 return -1;
473 }
474 }
475
476
484 public function initAsSpecimen()
485 {
486 $this->id = 0;
487
488 $this->label = 'MyDirectory';
489 $this->fk_parent = 0;
490 $this->description = 'This is a directory';
491
492 return 1;
493 }
494
495
506 public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0)
507 {
508 global $langs, $hookmanager;
509
510 $result = '';
511 //$newref=str_replace('_',' ',$this->ref);
512 $newref = $this->ref;
513 $label = img_picto('', $this->picto, '', 0, 0, 0, '', 'paddingrightonly') . $langs->trans("ShowECMSection") . ': ' . $newref;
514 $linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
515
516 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
517 if ($option == 'index') {
518 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
519 }
520 if ($option == 'indexexpanded') {
521 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
522 }
523 if ($option == 'indexnotexpanded') {
524 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
525 }
526 $linkend = '</a>';
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 @phan-suppress-next-line PhanTypeSuspiciousStringExpression
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
642 return '';
643 }
644
645
646 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
667 public function get_full_arbo($force = 0)
668 {
669 // phpcs:enable
670 global $conf;
671
672 if (empty($force) && !empty($this->full_arbo_loaded)) {
673 return $this->cats;
674 }
675
676 // Init this->motherof that is array(id_son=>id_parent, ...)
677 $this->load_motherof();
678
679 // Charge tableau des categories
680 $sql = "SELECT c.rowid as rowid, c.label as label,";
681 $sql .= " c.description as description, c.cachenbofdoc,";
682 $sql .= " c.fk_user_c,";
683 $sql .= " c.date_c,";
684 $sql .= " u.login as login_c,";
685 $sql .= " u.statut as statut_c,";
686 $sql .= " ca.rowid as rowid_fille";
687 $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c";
688 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca";
689 $sql .= " ON c.rowid = ca.fk_parent";
690 $sql .= " WHERE c.fk_user_c = u.rowid";
691 $sql .= " AND c.entity = ".$conf->entity;
692 $sql .= " ORDER BY c.label, c.rowid";
693
694 dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG);
695 $resql = $this->db->query($sql);
696 if ($resql) {
697 $this->cats = array();
698 $i = 0;
699 // This assignment in condition is not a bug. It allows walking the results.
700 while ($obj = $this->db->fetch_object($resql)) {
701 $this->cats[$obj->rowid]['id'] = $obj->rowid;
702 $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : '');
703 $this->cats[$obj->rowid]['label'] = $obj->label;
704 $this->cats[$obj->rowid]['description'] = $obj->description;
705 $this->cats[$obj->rowid]['cachenbofdoc'] = (int) $obj->cachenbofdoc;
706 $this->cats[$obj->rowid]['date_c'] = $this->db->jdate($obj->date_c);
707 $this->cats[$obj->rowid]['fk_user_c'] = (int) $obj->fk_user_c;
708 $this->cats[$obj->rowid]['statut_c'] = (int) $obj->statut_c;
709 $this->cats[$obj->rowid]['login_c'] = $obj->login_c;
710
711 if (!empty($obj->rowid_fille)) {
712 if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) {
713 $newelempos = count($this->cats[$obj->rowid]['id_children']);
714 //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements<br>";
715 $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille;
716 } else {
717 //print "this->cats[".$obj->rowid."]['id_children'] n'est pas encore un tableau<br>";
718 $this->cats[$obj->rowid]['id_children'] = array($obj->rowid_fille);
719 }
720 }
721 $i++;
722 }
723 } else {
724 dol_print_error($this->db);
725 return -1;
726 }
727
728 // We add properties fullxxx to all elements
729 foreach ($this->cats as $key => $val) {
730 if (isset($this->motherof[$key])) {
731 continue;
732 }
733 $this->buildPathFromId($key, 0);
734 }
735
736 $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', 1, 0);
737 $this->full_arbo_loaded = 1;
738
739 return $this->cats;
740 }
741
750 private function buildPathFromId($id_categ, $protection = 0)
751 {
752 // Define fullpath
753 if (!empty($this->cats[$id_categ]['id_mere'])) {
754 $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
755 $this->cats[$id_categ]['fullpath'] .= '_'.$id_categ;
756 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename'];
757 $this->cats[$id_categ]['fullrelativename'] .= '/'.$this->cats[$id_categ]['label'];
758 $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel'];
759 $this->cats[$id_categ]['fulllabel'] .= ' >> '.$this->cats[$id_categ]['label'];
760 } else {
761 $this->cats[$id_categ]['fullpath'] = '_'.$id_categ;
762 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$id_categ]['label'];
763 $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];
764 }
765 // We count number of _ to have level (we use strlen that is faster than dol_strlen)
766 $this->cats[$id_categ]['level'] = strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath']));
767
768 // Process children
769 $protection++;
770 if ($protection > 20) {
771 return; // We never go more than 20 levels
772 }
773 if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
774 foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {
775 $this->buildPathFromId($val, $protection);
776 }
777 }
778 }
779
786 public function refreshcachenboffile($all = 0)
787 {
788 global $conf;
789 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
790
791 $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
792 $filelist = dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$');
793
794 // Test if filelist is in database
795
796
797 // Update request
798 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
799 $sql .= " cachenbofdoc = '".count($filelist)."'";
800 if (empty($all)) { // By default
801 $sql .= " WHERE rowid = ".((int) $this->id);
802 } else {
803 $sql .= " WHERE entity = ".$conf->entity;
804 }
805
806 dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG);
807 $resql = $this->db->query($sql);
808 if ($resql) {
809 $this->cachenbofdoc = count($filelist);
810 return $this->cachenbofdoc;
811 } else {
812 $this->error = "Error ".$this->db->lasterror();
813 return -1;
814 }
815 }
816
817 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
830 public function call_trigger($triggerName, $user)
831 {
832 // phpcs:enable
833 global $langs, $conf;
834
835 include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
836 $interface = new Interfaces($this->db);
837 $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf);
838 if ($result < 0) {
839 if (!empty($this->errors)) {
840 $this->errors = array_merge($this->errors, $interface->errors);
841 } else {
842 $this->errors = $interface->errors;
843 }
844 }
845 return $result;
846 }
847}
$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($dir, $nophperrors=0)
Remove a directory (not recursive, so content must be empty).
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
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_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
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 the value of a given key, which produces ascending (default) or descending out...
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_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
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