dolibarr 18.0.9
ecmdirectory.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2008-2012 Regis Houssin <regis.houssin@inodbox.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
29{
33 public $element = 'ecm_directories';
34
38 public $table_element = 'ecm_directories';
39
43 public $picto = 'folder-open';
44
48 public $id;
49
53 public $label;
54
58 public $fk_parent;
59
63 public $description;
64
68 public $cachenbofdoc = -1; // By default cache initialized with value 'not calculated'
69
73 public $date_c;
74
78 public $date_m;
79
83 public $fk_user_m;
84
88 public $fk_user_c;
89
93 public $ref;
94
98 public $cats = array();
99
103 public $motherof = array();
104
108 public $forbiddenchars = array('<', '>', ':', '/', '\\', '?', '*', '|', '"');
109
113 public $forbiddencharsdir = array('<', '>', ':', '?', '*', '|', '"');
114
118 public $full_arbo_loaded;
119
125 public function __construct($db)
126 {
127 $this->db = $db;
128 return 1;
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++; $this->error = "ErrorFailedToCreateDir";
212 }
213
214 // Call trigger
215 $result = $this->call_trigger('MYECMDIR_CREATE', $user);
216 if ($result < 0) {
217 $error++;
218 }
219 // End call triggers
220
221 if (!$error) {
222 $this->db->commit();
223 return $this->id;
224 } else {
225 $this->db->rollback();
226 return -1;
227 }
228 } else {
229 $this->error = "Error ".$this->db->lasterror();
230 $this->db->rollback();
231 return -1;
232 }
233 }
234 }
235
243 public function update($user = null, $notrigger = 0)
244 {
245 global $conf, $langs;
246
247 $error = 0;
248
249 // Clean parameters
250 $this->label = trim($this->label);
251 $this->description = trim($this->description);
252 if ($this->fk_parent <= 0) {
253 $this->fk_parent = 0;
254 }
255
256 $this->db->begin();
257
258 // Update request
259 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
260 $sql .= " label = '".$this->db->escape($this->label)."',";
261 $sql .= " fk_parent = ".($this->fk_parent > 0 ? ((int) $this->fk_parent) : "null").",";
262 $sql .= " description = '".$this->db->escape($this->description)."'";
263 $sql .= " WHERE rowid = ".((int) $this->id);
264
265 dol_syslog(get_class($this)."::update", LOG_DEBUG);
266 $resql = $this->db->query($sql);
267 if (!$resql) {
268 $error++;
269 $this->error = "Error ".$this->db->lasterror();
270 }
271
272 if (!$error && !$notrigger) {
273 // Call trigger
274 $result = $this->call_trigger('MYECMDIR_MODIFY', $user);
275 if ($result < 0) {
276 $error++;
277 }
278 // End call triggers
279 }
280
281 if (!$error) {
282 $this->db->commit();
283 return 1;
284 } else {
285 $this->db->rollback();
286 return -1;
287 }
288 }
289
290
297 public function changeNbOfFiles($value)
298 {
299 global $conf;
300
301 if ($value == 'database') {
302 $relativepath = $conf->ecm->dir_output . '/' . $this->getRelativePath(); // Ex: dir1/dir2/dir3/
303 $relativepath = preg_replace('/^' . preg_quote(DOL_DATA_ROOT, '/') . '/', '', $relativepath);
304 $relativepath = trim($relativepath, '/');
305
306 // Get nb file in relative path
307 $sql = "SELECT COUNT(*) AS nb";
308 $sql .= " FROM " . $this->db->prefix() . "ecm_files";
309 $sql .= " WHERE filepath = '" . $this->db->escape($relativepath) . "'";
310
311 dol_syslog(get_class($this) . "::changeNbOfFiles - Get nb file in relative path", LOG_DEBUG);
312 $resql = $this->db->query($sql);
313 if (!$resql) {
314 $this->error = "Error " . $this->db->lasterror();
315 return -1;
316 } else {
317 $value = 0;
318 if ($obj = $this->db->fetch_object($resql)) {
319 $value = (int) $obj->nb;
320 }
321 }
322 }
323
324 // Update request
325 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
326 if (preg_match('/[0-9]+/', $value)) {
327 $sql .= " cachenbofdoc = ".(int) $value;
328 } else {
329 $sql .= " cachenbofdoc = cachenbofdoc " . preg_replace('/[^\-]/', '', $value) . " 1";
330 }
331 $sql .= " WHERE rowid = ".((int) $this->id);
332
333 dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG);
334 $resql = $this->db->query($sql);
335 if (!$resql) {
336 $this->error = "Error ".$this->db->lasterror();
337 return -1;
338 } else {
339 if (preg_match('/[0-9]+/', $value)) {
340 $this->cachenbofdoc = (int) $value;
341 } elseif ($value == '+') {
342 $this->cachenbofdoc++;
343 } elseif ($value == '-') {
344 $this->cachenbofdoc--;
345 }
346 }
347
348 return 1;
349 }
350
351
358 public function fetch($id)
359 {
360 $sql = "SELECT";
361 $sql .= " t.rowid,";
362 $sql .= " t.label,";
363 $sql .= " t.fk_parent,";
364 $sql .= " t.description,";
365 $sql .= " t.cachenbofdoc,";
366 $sql .= " t.fk_user_c,";
367 $sql .= " t.fk_user_m,";
368 $sql .= " t.date_c as date_c,";
369 $sql .= " t.tms as date_m";
370 $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
371 $sql .= " WHERE t.rowid = ".((int) $id);
372
373 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
374 $resql = $this->db->query($sql);
375 if ($resql) {
376 $obj = $this->db->fetch_object($resql);
377 if ($obj) {
378 $this->id = $obj->rowid;
379 $this->ref = $obj->rowid;
380
381 $this->label = $obj->label;
382 $this->fk_parent = $obj->fk_parent;
383 $this->description = $obj->description;
384 $this->cachenbofdoc = $obj->cachenbofdoc;
385 $this->fk_user_m = $obj->fk_user_m;
386 $this->fk_user_c = $obj->fk_user_c;
387 $this->date_c = $this->db->jdate($obj->date_c);
388 $this->date_m = $this->db->jdate($obj->date_m);
389 }
390
391 // Retrieve all extrafields for ecm_files
392 // fetch optionals attributes and labels
393 $this->fetch_optionals();
394
395 $this->db->free($resql);
396
397 return $obj ? 1 : 0;
398 } else {
399 $this->error = "Error ".$this->db->lasterror();
400 return -1;
401 }
402 }
403
404
413 public function delete($user, $mode = 'all', $deletedirrecursive = 0)
414 {
415 global $conf, $langs;
416 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
417
418 $error = 0;
419
420 if ($mode != 'databaseonly') {
421 $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3
422 }
423
424 dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath));
425
426 $this->db->begin();
427
428 $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
429 $sql .= " WHERE rowid=".((int) $this->id);
430
431 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
432 $resql = $this->db->query($sql);
433 if (!$resql) {
434 $this->db->rollback();
435 $this->error = "Error ".$this->db->lasterror();
436 return -2;
437 } else {
438 // Call trigger
439 $result = $this->call_trigger('MYECMDIR_DELETE', $user);
440 if ($result < 0) {
441 $this->db->rollback();
442 return -2;
443 }
444 // End call triggers
445 }
446
447 if ($mode != 'databaseonly') {
448 $file = $conf->ecm->dir_output."/".$relativepath;
449 if ($deletedirrecursive) {
450 $result = @dol_delete_dir_recursive($file, 0, 0);
451 } else {
452 $result = @dol_delete_dir($file, 0);
453 }
454 }
455
456 if ($result || !@is_dir(dol_osencode($file))) {
457 $this->db->commit();
458 } else {
459 $this->error = 'ErrorFailToDeleteDir';
460 dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
461 $this->db->rollback();
462 $error++;
463 }
464
465 if (!$error) {
466 return 1;
467 } else {
468 return -1;
469 }
470 }
471
472
480 public function initAsSpecimen()
481 {
482 $this->id = 0;
483
484 $this->label = 'MyDirectory';
485 $this->fk_parent = '0';
486 $this->description = 'This is a directory';
487 }
488
489
500 public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0)
501 {
502 global $langs, $hookmanager;
503
504 $result = '';
505 //$newref=str_replace('_',' ',$this->ref);
506 $newref = $this->ref;
507 $label = $langs->trans("ShowECMSection").': '.$newref;
508 $linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
509
510 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
511 if ($option == 'index') {
512 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
513 }
514 if ($option == 'indexexpanded') {
515 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
516 }
517 if ($option == 'indexnotexpanded') {
518 $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
519 }
520 $linkend = '</a>';
521
522 //$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
523 $picto = 'dir';
524
525 $result .= $linkstart;
526 if ($withpicto) {
527 $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
528 }
529 if ($withpicto != 2) {
530 $result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref);
531 }
532 $result .= $linkend;
533
534 global $action;
535 $hookmanager->initHooks(array($this->element . 'dao'));
536 $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
537 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
538 if ($reshook > 0) {
539 $result = $hookmanager->resPrint;
540 } else {
541 $result .= $hookmanager->resPrint;
542 }
543 return $result;
544 }
545
552 public function getRelativePath($force = 0)
553 {
554 $this->get_full_arbo($force);
555
556 $ret = '';
557 $idtosearch = $this->id;
558 $i = 0;
559 do {
560 // Get index cursor in this->cats for id_mere
561 $cursorindex = -1;
562 foreach ($this->cats as $key => $val) {
563 if ($this->cats[$key]['id'] == $idtosearch) {
564 $cursorindex = $key;
565 break;
566 }
567 }
568 //print "c=".$idtosearch."-".$cursorindex;
569
570 if ($cursorindex >= 0) {
571 // Path is label sanitized (no space and no special char) and concatenated
572 $ret = dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret;
573
574 $idtosearch = $this->cats[$cursorindex]['id_mere'];
575 $i++;
576 }
577 } while ($cursorindex >= 0 && !empty($idtosearch) && $i < 100); // i avoid infinite loop
578
579 return $ret;
580 }
581
582 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
588 public function load_motherof()
589 {
590 // phpcs:enable
591 global $conf;
592
593 $this->motherof = array();
594
595 // Load array[child]=parent
596 $sql = "SELECT fk_parent as id_parent, rowid as id_son";
597 $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories";
598 $sql .= " WHERE fk_parent != 0";
599 $sql .= " AND entity = ".$conf->entity;
600
601 dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
602 $resql = $this->db->query($sql);
603 if ($resql) {
604 // This assignment in condition is not a bug. It allows walking the results.
605 while ($obj = $this->db->fetch_object($resql)) {
606 $this->motherof[$obj->id_son] = $obj->id_parent;
607 }
608 return 1;
609 } else {
610 dol_print_error($this->db);
611 return -1;
612 }
613 }
614
615
622 public function getLibStatut($mode = 0)
623 {
624 return $this->LibStatut($this->status, $mode);
625 }
626
627 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
635 public static function LibStatut($status, $mode = 0)
636 {
637 // phpcs:enable
638 global $langs;
639 return '';
640 }
641
642
643 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
663 public function get_full_arbo($force = 0)
664 {
665 // phpcs:enable
666 global $conf;
667
668 if (empty($force) && !empty($this->full_arbo_loaded)) {
669 return $this->cats;
670 }
671
672 // Init this->motherof that is array(id_son=>id_parent, ...)
673 $this->load_motherof();
674
675 // Charge tableau des categories
676 $sql = "SELECT c.rowid as rowid, c.label as label,";
677 $sql .= " c.description as description, c.cachenbofdoc,";
678 $sql .= " c.fk_user_c,";
679 $sql .= " c.date_c,";
680 $sql .= " u.login as login_c,";
681 $sql .= " u.statut as statut_c,";
682 $sql .= " ca.rowid as rowid_fille";
683 $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c";
684 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca";
685 $sql .= " ON c.rowid = ca.fk_parent";
686 $sql .= " WHERE c.fk_user_c = u.rowid";
687 $sql .= " AND c.entity = ".$conf->entity;
688 $sql .= " ORDER BY c.label, c.rowid";
689
690 dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG);
691 $resql = $this->db->query($sql);
692 if ($resql) {
693 $this->cats = array();
694 $i = 0;
695 // This assignment in condition is not a bug. It allows walking the results.
696 while ($obj = $this->db->fetch_object($resql)) {
697 $this->cats[$obj->rowid]['id'] = $obj->rowid;
698 $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : '');
699 $this->cats[$obj->rowid]['label'] = $obj->label;
700 $this->cats[$obj->rowid]['description'] = $obj->description;
701 $this->cats[$obj->rowid]['cachenbofdoc'] = $obj->cachenbofdoc;
702 $this->cats[$obj->rowid]['date_c'] = $this->db->jdate($obj->date_c);
703 $this->cats[$obj->rowid]['fk_user_c'] = (int) $obj->fk_user_c;
704 $this->cats[$obj->rowid]['statut_c'] = (int) $obj->statut_c;
705 $this->cats[$obj->rowid]['login_c'] = $obj->login_c;
706
707 if (!empty($obj->rowid_fille)) {
708 if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) {
709 $newelempos = count($this->cats[$obj->rowid]['id_children']);
710 //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements<br>";
711 $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille;
712 } else {
713 //print "this->cats[".$obj->rowid."]['id_children'] n'est pas encore un tableau<br>";
714 $this->cats[$obj->rowid]['id_children'] = array($obj->rowid_fille);
715 }
716 }
717 $i++;
718 }
719 } else {
720 dol_print_error($this->db);
721 return -1;
722 }
723
724 // We add properties fullxxx to all elements
725 foreach ($this->cats as $key => $val) {
726 if (isset($this->motherof[$key])) {
727 continue;
728 }
729 $this->buildPathFromId($key, 0);
730 }
731
732 $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
733 $this->full_arbo_loaded = 1;
734
735 return $this->cats;
736 }
737
746 private function buildPathFromId($id_categ, $protection = 0)
747 {
748 // Define fullpath
749 if (!empty($this->cats[$id_categ]['id_mere'])) {
750 $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
751 $this->cats[$id_categ]['fullpath'] .= '_'.$id_categ;
752 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename'];
753 $this->cats[$id_categ]['fullrelativename'] .= '/'.$this->cats[$id_categ]['label'];
754 $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel'];
755 $this->cats[$id_categ]['fulllabel'] .= ' >> '.$this->cats[$id_categ]['label'];
756 } else {
757 $this->cats[$id_categ]['fullpath'] = '_'.$id_categ;
758 $this->cats[$id_categ]['fullrelativename'] = $this->cats[$id_categ]['label'];
759 $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];
760 }
761 // We count number of _ to have level (we use strlen that is faster than dol_strlen)
762 $this->cats[$id_categ]['level'] = strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath']));
763
764 // Process children
765 $protection++;
766 if ($protection > 20) {
767 return; // We never go more than 20 levels
768 }
769 if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
770 foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {
771 $this->buildPathFromId($val, $protection);
772 }
773 }
774 }
775
782 public function refreshcachenboffile($all = 0)
783 {
784 global $conf;
785 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
786
787 $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
788 $filelist = dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$');
789
790 // Test if filelist is in database
791
792
793 // Update request
794 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
795 $sql .= " cachenbofdoc = '".count($filelist)."'";
796 if (empty($all)) { // By default
797 $sql .= " WHERE rowid = ".((int) $this->id);
798 } else {
799 $sql .= " WHERE entity = ".$conf->entity;
800 }
801
802 dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG);
803 $resql = $this->db->query($sql);
804 if ($resql) {
805 $this->cachenbofdoc = count($filelist);
806 return $this->cachenbofdoc;
807 } else {
808 $this->error = "Error ".$this->db->lasterror();
809 return -1;
810 }
811 }
812
813 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
826 public function call_trigger($triggerName, $user)
827 {
828 // phpcs:enable
829 global $langs, $conf;
830
831 include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
832 $interface = new Interfaces($this->db);
833 $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf);
834 if ($result < 0) {
835 if (!empty($this->errors)) {
836 $this->errors = array_merge($this->errors, $interface->errors);
837 } else {
838 $this->errors = $interface->errors;
839 }
840 }
841 return $result;
842 }
843}
$object ref
Definition info.php:78
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
Class to manage ECM directories.
__construct($db)
Constructor.
getNomUrl($withpicto=0, $option='', $max=0, $more='', $notooltip=0)
Return directory name you can click (and picto)
static LibStatut($status, $mode=0)
Return the status.
buildPathFromId($id_categ, $protection=0)
Define properties fullpath, fullrelativename, fulllabel of a directory of array this->cats and all it...
get_full_arbo($force=0)
Reconstruit l'arborescence des categories sous la forme d'un tableau à partir de la base de donnée Re...
load_motherof()
Load this->motherof that is array(id_son=>id_parent, ...)
getRelativePath($force=0)
Return relative path of a directory on disk.
refreshcachenboffile($all=0)
Refresh value for cachenboffile.
initAsSpecimen()
Initialise an instance with random values.
create($user)
Create record into database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
getLibStatut($mode=0)
Return the label of the status.
changeNbOfFiles($value)
Update cache of nb of documents into database.
fetch($id)
Load object in memory from database.
update($user=null, $notrigger=0)
Update database.
Class to manage triggers.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_dir($dir, $nophperrors=0)
Remove a directory (not recursive, so content must be empty).
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:62
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_now($mode='auto')
Return date for now.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...