dolibarr  13.0.2
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 = 'dir';
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->fk_parent = trim($this->fk_parent);
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) {
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->db->escape($this->fk_parent)."',";
198  $sql .= " '".$this->db->escape($this->description)."',";
199  $sql .= " ".$this->cachenbofdoc.",";
200  $sql .= " '".$this->db->idate($this->date_c)."',";
201  $sql .= " '".$this->db->escape($this->fk_user_c)."'";
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++; $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->fk_parent = trim($this->fk_parent);
253  $this->description = trim($this->description);
254 
255  // Check parameters
256  // Put here code to add control on parameters values
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->db->escape($this->fk_parent)."',";
264  $sql .= " description='".$this->db->escape($this->description)."'";
265  $sql .= " WHERE rowid=".$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 ".$value." 1";
307  }
308  $sql .= " WHERE rowid = ".$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 = $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  if ($mode != 'databaseonly') {
398  $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3
399  }
400 
401  dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath));
402 
403  $this->db->begin();
404 
405  $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
406  $sql .= " WHERE rowid=".$this->id;
407 
408  dol_syslog(get_class($this)."::delete", LOG_DEBUG);
409  $resql = $this->db->query($sql);
410  if (!$resql) {
411  $this->db->rollback();
412  $this->error = "Error ".$this->db->lasterror();
413  return -2;
414  } else {
415  // Call trigger
416  $result = $this->call_trigger('MYECMDIR_DELETE', $user);
417  if ($result < 0) {
418  $this->db->rollback();
419  return -2;
420  }
421  // End call triggers
422  }
423 
424  if ($mode != 'databaseonly') {
425  $file = $conf->ecm->dir_output."/".$relativepath;
426  if ($deletedirrecursive) {
427  $result = @dol_delete_dir_recursive($file, 0, 0);
428  } else {
429  $result = @dol_delete_dir($file, 0);
430  }
431  }
432 
433  if ($result || !@is_dir(dol_osencode($file))) {
434  $this->db->commit();
435  } else {
436  $this->error = 'ErrorFailToDeleteDir';
437  dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
438  $this->db->rollback();
439  $error++;
440  }
441 
442  if (!$error) {
443  return 1;
444  } else {
445  return -1;
446  }
447  }
448 
449 
457  public function initAsSpecimen()
458  {
459  $this->id = 0;
460 
461  $this->label = 'MyDirectory';
462  $this->fk_parent = '0';
463  $this->description = 'This is a directory';
464  }
465 
466 
477  public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0)
478  {
479  global $langs;
480 
481  $result = '';
482  //$newref=str_replace('_',' ',$this->ref);
483  $newref = $this->ref;
484  $label = $langs->trans("ShowECMSection").': '.$newref;
485  $linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
486 
487  $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
488  if ($option == 'index') {
489  $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
490  }
491  if ($option == 'indexexpanded') {
492  $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
493  }
494  if ($option == 'indexnotexpanded') {
495  $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
496  }
497  $linkend = '</a>';
498 
499  //$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
500  $picto = 'dir';
501 
502  $result .= $linkstart;
503  if ($withpicto) {
504  $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
505  }
506  if ($withpicto != 2) {
507  $result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref);
508  }
509  $result .= $linkend;
510 
511  return $result;
512  }
513 
520  public function getRelativePath($force = 0)
521  {
522  $this->get_full_arbo($force);
523 
524  $ret = '';
525  $idtosearch = $this->id;
526  $i = 0;
527  do {
528  // Get index cursor in this->cats for id_mere
529  $cursorindex = -1;
530  foreach ($this->cats as $key => $val) {
531  if ($this->cats[$key]['id'] == $idtosearch) {
532  $cursorindex = $key;
533  break;
534  }
535  }
536  //print "c=".$idtosearch."-".$cursorindex;
537 
538  if ($cursorindex >= 0) {
539  // Path is label sanitized (no space and no special char) and concatenated
540  $ret = dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret;
541 
542  $idtosearch = $this->cats[$cursorindex]['id_mere'];
543  $i++;
544  }
545  } while ($cursorindex >= 0 && !empty($idtosearch) && $i < 100); // i avoid infinite loop
546 
547  return $ret;
548  }
549 
550  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
556  public function load_motherof()
557  {
558  // phpcs:enable
559  global $conf;
560 
561  $this->motherof = array();
562 
563  // Load array[child]=parent
564  $sql = "SELECT fk_parent as id_parent, rowid as id_son";
565  $sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories";
566  $sql .= " WHERE fk_parent != 0";
567  $sql .= " AND entity = ".$conf->entity;
568 
569  dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
570  $resql = $this->db->query($sql);
571  if ($resql) {
572  // This assignment in condition is not a bug. It allows walking the results.
573  while ($obj = $this->db->fetch_object($resql)) {
574  $this->motherof[$obj->id_son] = $obj->id_parent;
575  }
576  return 1;
577  } else {
578  dol_print_error($this->db);
579  return -1;
580  }
581  }
582 
583 
590  public function getLibStatut($mode = 0)
591  {
592  return $this->LibStatut($this->status, $mode);
593  }
594 
595  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
603  public static function LibStatut($status, $mode = 0)
604  {
605  // phpcs:enable
606  global $langs;
607  return '';
608  }
609 
610 
611  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
631  public function get_full_arbo($force = 0)
632  {
633  // phpcs:enable
634  global $conf;
635 
636  if (empty($force) && !empty($this->full_arbo_loaded)) {
637  return $this->cats;
638  }
639 
640  // Init this->motherof that is array(id_son=>id_parent, ...)
641  $this->load_motherof();
642 
643  // Charge tableau des categories
644  $sql = "SELECT c.rowid as rowid, c.label as label,";
645  $sql .= " c.description as description, c.cachenbofdoc,";
646  $sql .= " c.fk_user_c,";
647  $sql .= " c.date_c,";
648  $sql .= " u.login as login_c,";
649  $sql .= " ca.rowid as rowid_fille";
650  $sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c";
651  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca";
652  $sql .= " ON c.rowid = ca.fk_parent";
653  $sql .= " WHERE c.fk_user_c = u.rowid";
654  $sql .= " AND c.entity = ".$conf->entity;
655  $sql .= " ORDER BY c.label, c.rowid";
656 
657  dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG);
658  $resql = $this->db->query($sql);
659  if ($resql) {
660  $this->cats = array();
661  $i = 0;
662  // This assignment in condition is not a bug. It allows walking the results.
663  while ($obj = $this->db->fetch_object($resql)) {
664  $this->cats[$obj->rowid]['id'] = $obj->rowid;
665  $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : '');
666  $this->cats[$obj->rowid]['label'] = $obj->label;
667  $this->cats[$obj->rowid]['description'] = $obj->description;
668  $this->cats[$obj->rowid]['cachenbofdoc'] = $obj->cachenbofdoc;
669  $this->cats[$obj->rowid]['date_c'] = $this->db->jdate($obj->date_c);
670  $this->cats[$obj->rowid]['fk_user_c'] = $obj->fk_user_c;
671  $this->cats[$obj->rowid]['login_c'] = $obj->login_c;
672 
673  if (!empty($obj->rowid_fille)) {
674  if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) {
675  $newelempos = count($this->cats[$obj->rowid]['id_children']);
676  //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements<br>";
677  $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille;
678  } else {
679  //print "this->cats[".$obj->rowid."]['id_children'] n'est pas encore un tableau<br>";
680  $this->cats[$obj->rowid]['id_children'] = array($obj->rowid_fille);
681  }
682  }
683  $i++;
684  }
685  } else {
686  dol_print_error($this->db);
687  return -1;
688  }
689 
690  // We add properties fullxxx to all elements
691  foreach ($this->cats as $key => $val) {
692  if (isset($motherof[$key])) {
693  continue;
694  }
695  $this->build_path_from_id_categ($key, 0);
696  }
697 
698  $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
699  $this->full_arbo_loaded = 1;
700 
701  return $this->cats;
702  }
703 
704  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
713  public function build_path_from_id_categ($id_categ, $protection = 0)
714  {
715  // phpcs:enable
716  // Define fullpath
717  if (!empty($this->cats[$id_categ]['id_mere'])) {
718  $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
719  $this->cats[$id_categ]['fullpath'] .= '_'.$id_categ;
720  $this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename'];
721  $this->cats[$id_categ]['fullrelativename'] .= '/'.$this->cats[$id_categ]['label'];
722  $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel'];
723  $this->cats[$id_categ]['fulllabel'] .= ' >> '.$this->cats[$id_categ]['label'];
724  } else {
725  $this->cats[$id_categ]['fullpath'] = '_'.$id_categ;
726  $this->cats[$id_categ]['fullrelativename'] = $this->cats[$id_categ]['label'];
727  $this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];
728  }
729  // We count number of _ to have level (we use strlen that is faster than dol_strlen)
730  $this->cats[$id_categ]['level'] = strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath']));
731 
732  // Traite ces enfants
733  $protection++;
734  if ($protection > 20) {
735  return; // On ne traite pas plus de 20 niveaux
736  }
737  if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
738  foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {
739  $this->build_path_from_id_categ($val, $protection);
740  }
741  }
742  }
743 
750  public function refreshcachenboffile($all = 0)
751  {
752  global $conf;
753  include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
754 
755  $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath();
756  $filelist = dol_dir_list($dir, 'files', 0, '', '(\.meta|_preview.*\.png)$');
757 
758  // Test if filelist is in database
759 
760 
761  // Update request
762  $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
763  $sql .= " cachenbofdoc = '".count($filelist)."'";
764  if (empty($all)) { // By default
765  $sql .= " WHERE rowid = ".$this->id;
766  } else {
767  $sql .= " WHERE entity = ".$conf->entity;
768  }
769 
770  dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG);
771  $resql = $this->db->query($sql);
772  if ($resql) {
773  $this->cachenbofdoc = count($filelist);
774  return $this->cachenbofdoc;
775  } else {
776  $this->error = "Error ".$this->db->lasterror();
777  return -1;
778  }
779  }
780 
781  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
794  public function call_trigger($triggerName, $user)
795  {
796  // phpcs:enable
797  global $langs, $conf;
798 
799  include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
800  $interface = new Interfaces($this->db);
801  $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf);
802  if ($result < 0) {
803  if (!empty($this->errors)) {
804  $this->errors = array_merge($this->errors, $interface->errors);
805  } else {
806  $this->errors = $interface->errors;
807  }
808  }
809  return $result;
810  }
811 }
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
get_full_arbo($force=0)
Reconstruit l&#39;arborescence des categories sous la forme d&#39;un tableau à partir de la base de donnée Re...
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:750
dol_now($mode= 'auto')
Return date for now.
call_trigger($triggerName, $user)
Call trigger based on this instance.
build_path_from_id_categ($id_categ, $protection=0)
Define properties fullpath, fullrelativename, fulllabel of a directory of array this-&gt;cats and all it...
getRelativePath($force=0)
Return relative path of a directory on disk.
refreshcachenboffile($all=0)
Refresh value for cachenboffile.
$conf db
API class for accounts.
Definition: inc.php:54
initAsSpecimen()
Initialise an instance with random values.
fetch($id)
Load object in memory from database.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
getLibStatut($mode=0)
Retourne le libelle du status d&#39;un user (actif, inactif)
getNomUrl($withpicto=0, $option= '', $max=0, $more= '', $notooltip=0)
Return directory name you can click (and picto)
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories) ...
Definition: files.lib.php:1286
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
__construct($db)
Constructor.
static LibStatut($status, $mode=0)
Return the status.
create($user)
Create record into database.
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this-&gt;array_options This method is in most cases call...
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...
changeNbOfFiles($value)
Update cache of nb of documents into database.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
update($user=null, $notrigger=0)
Update database.
dol_print_error($db= '', $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 &#39;...&#39; if string larger than length.
load_motherof()
Load this-&gt;motherof that is array(id_son=&gt;id_parent, ...)
dol_delete_dir($dir, $nophperrors=0)
Remove a directory (not recursive, so content must be empty).
Definition: files.lib.php:1262
Class to manage ECM directories.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
Class to manage triggers.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...