31require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
43 public $element =
'websitepage';
48 public $table_element =
'website_page';
53 public $picto =
'file-code';
58 public $fk_element =
'fk_website_page';
63 protected $childtablesoncascade = array(
'categorie_website_page');
88 public $type_container;
118 public $allowed_in_frames;
123 public $disable_waf =
'NOSCANAUDIOFORINJECTION,NOSCANIFRAMEFORINJECTION,NOSCANOBJECTFORINJECTION';
138 public $grabbed_from;
148 public $fk_user_creat;
153 public $fk_user_modif;
158 public $author_alias;
176 const STATUS_DRAFT = 0;
177 const STATUS_VALIDATED = 1;
208 public $fields = array(
209 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'index' => 1,
'position' => 1,
'comment' =>
'Id'),
210 'pageurl' => array(
'type' =>
'varchar(16)',
'label' =>
'WEBSITE_PAGENAME',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'index' => 1,
'position' => 10,
'searchall' => 1,
'comment' =>
'Ref/alias of page'),
211 'aliasalt' => array(
'type' =>
'varchar(255)',
'label' =>
'AliasAlt',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'index' => 0,
'position' => 11,
'searchall' => 0,
'comment' =>
'Alias alternative of page'),
212 'type_container' => array(
'type' =>
'varchar(16)',
'label' =>
'Type',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'index' => 0,
'position' => 12,
'comment' =>
'Type of container'),
213 'title' => array(
'type' =>
'varchar(255)',
'label' =>
'Label',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'searchall' => 1,
'help' =>
'UseTextBetween5And70Chars'),
214 'description' => array(
'type' =>
'varchar(255)',
'label' =>
'Description',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'searchall' => 1),
215 'image' => array(
'type' =>
'varchar(255)',
'label' =>
'Image',
'enabled' => 1,
'visible' => 1,
'position' => 32,
'searchall' => 0,
'help' =>
'Relative path of media. Used if Type is "blogpost"'),
216 'keywords' => array(
'type' =>
'varchar(255)',
'label' =>
'Keywords',
'enabled' => 1,
'visible' => 1,
'position' => 45,
'searchall' => 0),
217 'lang' => array(
'type' =>
'varchar(6)',
'label' =>
'Lang',
'enabled' => 1,
'notnull' => -1,
'visible' => 1,
'position' => 45,
'searchall' => 0),
219 'fk_website' => array(
'type' =>
'integer',
'label' =>
'WebsiteId',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 40,
'searchall' => 0,
'foreignkey' =>
'websitepage.rowid'),
220 'fk_page' => array(
'type' =>
'integer',
'label' =>
'ParentPageId',
'enabled' => 1,
'visible' => 1,
'notnull' => -1,
'position' => 45,
'searchall' => 0,
'foreignkey' =>
'website.rowid'),
221 'allowed_in_frames' => array(
'type' =>
'integer',
'label' =>
'AllowedInFrames',
'enabled' => 1,
'visible' => -1,
'position' => 48,
'searchall' => 0,
'default' =>
'0'),
222 'htmlheader' => array(
'type' =>
'html',
'label' =>
'HtmlHeader',
'enabled' => 1,
'visible' => 0,
'position' => 50,
'searchall' => 0),
223 'content' => array(
'type' =>
'mediumtext',
'label' =>
'Content',
'enabled' => 1,
'visible' => 0,
'position' => 51,
'searchall' => 0),
224 'grabbed_from' => array(
'type' =>
'varchar(255)',
'label' =>
'GrabbedFrom',
'enabled' => 1,
'visible' => 1,
'index' => 1,
'position' => 400,
'comment' =>
'URL page content was grabbed from'),
225 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 500),
226 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 501),
228 'fk_user_creat' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserAuthor',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 510),
229 'author_alias' => array(
'type' =>
'varchar(64)',
'label' =>
'AuthorAlias',
'enabled' => 1,
'visible' => -1,
'index' => 0,
'position' => 511,
'comment' =>
'Author alias'),
230 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'visible' => -1,
'position' => 512),
232 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -1,
'index' => 1,
'position' => 1000,
'notnull' => -1),
233 'object_type' => array(
'type' =>
'varchar(255)',
'label' =>
'ObjectType',
'enabled' => 1,
'visible' => 0,
'position' => 46,
'searchall' => 0,
'help' =>
''),
234 'fk_object' => array(
'type' =>
'varchar(255)',
'label' =>
'ObjectId',
'enabled' => 1,
'visible' => 0,
'position' => 47,
'searchall' => 0,
'help' =>
''),
235 'status' => array(
'type' =>
'integer',
'label' =>
'Status',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 510),
260 $this->keywords =
dol_trunc($this->keywords, 255,
'right',
'utf-8', 1);
261 if ($this->aliasalt) {
262 $this->aliasalt =
','.preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $this->aliasalt)).
',';
265 $this->pageurl = preg_replace(
'/[^a-z0-9\-\_]/i',
'', $this->pageurl);
266 $this->pageurl = preg_replace(
'/\-\-+/',
'-', $this->pageurl);
267 $this->pageurl = preg_replace(
'/^\-/',
'', $this->pageurl);
270 $this->lang = preg_replace(
'/[_-].*$/',
'', trim($this->lang));
273 if (!$user->hasRight(
'website',
'writephp')) {
278 $this->error =
'Error: you try to create a page with PHP content without having permissions for that.';
279 $this->errors[] = $this->error;
300 public function fetch($id, $website_id =
null, $page =
null, $aliasalt =
null, $translationparentid = 0, $translationparentlang =
'')
306 $sql .=
" t.fk_website,";
307 $sql .=
' t.type_container,';
308 $sql .=
" t.pageurl,";
309 $sql .=
" t.aliasalt,";
311 $sql .=
" t.description,";
313 $sql .=
" t.keywords,";
314 $sql .=
" t.htmlheader,";
315 $sql .=
" t.content,";
317 $sql .=
" t.fk_page,";
318 $sql .=
" t.allowed_in_frames,";
319 $sql .=
" t.status,";
320 $sql .=
" t.grabbed_from,";
321 $sql .=
" t.date_creation,";
322 $sql .=
" t.tms as date_modification,";
323 $sql .=
" t.fk_user_creat,";
324 $sql .=
" t.author_alias,";
325 $sql .=
" t.fk_user_modif,";
326 $sql .=
" t.import_key,";
327 $sql .=
" t.object_type,";
328 $sql .=
" t.fk_object";
329 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
331 $sql .=
' WHERE 1 = 1';
333 $sql .=
' AND t.rowid = '.((int) $id);
336 $sql .=
' AND t.rowid <> '.((int) abs($id));
338 if (
null !== $website_id) {
339 $sql .=
" AND t.fk_website = '".$this->db->escape($website_id).
"'";
343 $tmppage = explode(
'/', $page);
344 if (!empty($tmppage[1])) {
345 $pagetouse = $tmppage[1];
346 if (strlen($tmppage[0])) {
347 $langtouse = $tmppage[0];
350 $sql .=
" AND t.pageurl = '".$this->db->escape($pagetouse).
"'";
352 $sql .=
" AND t.lang = '".$this->db->escape($langtouse).
"'";
356 $sql .=
" AND (t.aliasalt LIKE '%,".$this->db->escape($this->db->escapeforlike($aliasalt)).
",%' OR t.aliasalt LIKE '%, ".$this->db->escape($this->db->escapeforlike($aliasalt)).
",%')";
358 if ($translationparentid && $translationparentlang) {
359 $sql .=
" AND t.fk_page = ".((int) $translationparentid);
360 $sql .=
" AND t.lang = '".$this->db->escape($translationparentlang).
"'";
364 $sql .= $this->db->plimit(1);
366 $resql = $this->db->query($sql);
368 $numrows = $this->db->num_rows($resql);
370 $obj = $this->db->fetch_object($resql);
372 $this->
id = $obj->rowid;
374 $this->fk_website = $obj->fk_website;
375 $this->type_container = $obj->type_container;
377 $this->pageurl = $obj->pageurl;
378 $this->
ref = $obj->pageurl;
379 $this->aliasalt = preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $obj->aliasalt));
381 $this->title = $obj->title;
383 $this->image = $obj->image;
384 $this->keywords = $obj->keywords;
385 $this->htmlheader = $obj->htmlheader;
386 $this->content = $obj->content;
387 $this->lang = $obj->lang;
388 $this->fk_page = $obj->fk_page;
389 $this->allowed_in_frames = $obj->allowed_in_frames;
390 $this->
status = $obj->status;
391 $this->grabbed_from = $obj->grabbed_from;
392 $this->date_creation = $this->db->jdate($obj->date_creation);
393 $this->date_modification = $this->db->jdate($obj->date_modification);
394 $this->fk_user_creat = $obj->fk_user_creat;
395 $this->author_alias = $obj->author_alias;
396 $this->fk_user_modif = $obj->fk_user_modif;
397 $this->import_key = $obj->import_key;
398 $this->object_type = $obj->object_type;
399 $this->fk_object = $obj->fk_object;
401 $this->db->free($resql);
409 $this->errors[] =
'Error '.$this->db->lasterror();
410 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
429 public function fetchAll($websiteid =
'', $sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
437 $sql .=
" t.fk_website,";
438 $sql .=
" t.type_container,";
439 $sql .=
" t.pageurl,";
440 $sql .=
" t.aliasalt,";
442 $sql .=
" t.description,";
444 $sql .=
" t.keywords,";
445 $sql .=
" t.htmlheader,";
446 $sql .=
" t.content,";
448 $sql .=
" t.fk_page,";
449 $sql .=
" t.allowed_in_frames,";
450 $sql .=
" t.status,";
451 $sql .=
" t.grabbed_from,";
452 $sql .=
" t.date_creation,";
453 $sql .=
" t.tms as date_modification,";
454 $sql .=
" t.fk_user_creat,";
455 $sql .=
" t.author_alias,";
456 $sql .=
" t.fk_user_modif,";
457 $sql .=
" t.import_key,";
458 $sql .=
" t.object_type,";
459 $sql .=
" t.fk_object";
460 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
461 if (!empty($websiteid)) {
462 $sql .=
' WHERE t.fk_website = '.((int) $websiteid);
466 if (is_array($filter)) {
469 if (count($filter) > 0) {
470 foreach ($filter as $key => $value) {
471 if ($key ==
't.rowid' || $key ==
'rowid' || $key ==
't.fk_website' || $key ==
'fk_website' || $key ==
'status' || $key ==
't.status') {
472 $sqlwhere[] = $key.
" = ".((int) $value);
473 } elseif ($key ==
'type_container' || $key ==
't.type_container') {
474 $sqlwhere[] = $key.
" = '".$this->db->escape($value).
"'";
475 } elseif ($key ==
'lang' || $key ==
't.lang') {
476 $listoflang = array();
478 foreach (explode(
',', $value) as $tmpvalue) {
479 if ($tmpvalue ==
'null') {
483 $listoflang[] =
"'".$this->db->escape(substr(str_replace(
"'",
'', $tmpvalue), 0, 2)).
"'";
485 $stringtouse = $this->db->sanitize($key).
" IN (".$this->db->sanitize(implode(
',', $listoflang), 1).
")";
487 $stringtouse =
"(".$stringtouse.
" OR ".$this->db->sanitize($key).
" IS NULL)";
489 $sqlwhere[] = $stringtouse;
491 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($value).
"%'";
495 if (count($sqlwhere) > 0) {
496 if (!empty($websiteid)) {
497 $sql .=
" AND (".implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
499 $sql .=
" WHERE ".implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere);
509 $this->errors[] = $errormessage;
510 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
514 if (!empty($sortfield)) {
515 $sql .= $this->db->order($sortfield, $sortorder);
517 if (!empty($limit)) {
518 $sql .= $this->db->plimit($limit, $offset);
521 $resql = $this->db->query($sql);
523 $num = $this->db->num_rows($resql);
525 while ($obj = $this->db->fetch_object($resql)) {
526 $record =
new self($this->db);
528 $record->id = $obj->rowid;
529 $record->fk_website = $obj->fk_website;
530 $record->type_container = $obj->type_container;
531 $record->pageurl = $obj->pageurl;
532 $record->aliasalt = preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $obj->aliasalt));
533 $record->title = $obj->title;
534 $record->description = $obj->description;
535 $record->image = $obj->image;
536 $record->keywords = $obj->keywords;
537 $record->htmlheader = $obj->htmlheader;
538 $record->content = $obj->content;
539 $record->lang = $obj->lang;
540 $record->fk_page = $obj->fk_page;
541 $record->allowed_in_frames = $obj->allowed_in_frames;
542 $record->status = $obj->status;
543 $record->grabbed_from = $obj->grabbed_from;
544 $record->date_creation = $this->db->jdate($obj->date_creation);
545 $record->date_modification = $this->db->jdate($obj->date_modification);
546 $record->fk_user_creat = $obj->fk_user_creat;
547 $record->author_alias = $obj->author_alias;
548 $record->fk_user_modif = $obj->fk_user_modif;
549 $record->import_key = $obj->import_key;
550 $record->object_type = $obj->object_type;
551 $record->fk_object = $obj->fk_object;
553 $records[$record->id] = $record;
555 $this->db->free($resql);
559 $this->error =
'Error '.$this->db->lasterror();
560 $this->errors[] = $this->error;
561 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
576 public function countAll($websiteid, $filter =
'', $filtermode =
'AND')
582 $sql =
'SELECT COUNT(t.rowid) as nb';
583 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
584 $sql .=
' WHERE t.fk_website = '.((int) $websiteid);
587 if (is_array($filter)) {
590 if (count($filter) > 0) {
591 foreach ($filter as $key => $value) {
592 if ($key ==
't.rowid' || $key ==
'rowid' || $key ==
't.fk_website' || $key ==
'fk_website' || $key ==
'status' || $key ==
't.status') {
593 $sqlwhere[] = $key.
" = ".((int) $value);
594 } elseif ($key ==
'type_container' || $key ==
't.type_container') {
595 $sqlwhere[] = $key.
" = '".$this->db->escape($value).
"'";
596 } elseif ($key ==
'lang' || $key ==
't.lang') {
597 $listoflang = array();
599 foreach (explode(
',', $value) as $tmpvalue) {
600 if ($tmpvalue ==
'null') {
604 $listoflang[] =
"'".$this->db->escape(substr(str_replace(
"'",
'', $tmpvalue), 0, 2)).
"'";
606 $stringtouse = $this->db->sanitize($key).
" IN (".$this->db->sanitize(implode(
',', $listoflang), 1).
")";
608 $stringtouse =
"(".$stringtouse.
" OR ".$this->db->sanitize($key).
" IS NULL)";
610 $sqlwhere[] = $stringtouse;
612 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($value).
"%'";
616 if (count($sqlwhere) > 0) {
617 if (!empty($websiteid)) {
618 $sql .=
" AND (".implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
620 $sql .=
" WHERE ".implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere);
630 $this->errors[] = $errormessage;
631 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
635 $resql = $this->db->query($sql);
637 $obj = $this->db->fetch_object($resql);
642 $this->db->free($resql);
646 $this->error =
'Error '.$this->db->lasterror();
647 $this->errors[] = $this->error;
648 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
664 $this->keywords =
dol_trunc($this->keywords, 255,
'right',
'utf-8', 1);
665 if ($this->aliasalt) {
666 $this->aliasalt =
','.preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $this->aliasalt)).
',';
669 $this->pageurl = preg_replace(
'/[^a-z0-9\-\_]/i',
'', $this->pageurl);
670 $this->pageurl = preg_replace(
'/\-\-+/',
'-', $this->pageurl);
671 $this->pageurl = preg_replace(
'/^\-/',
'', $this->pageurl);
674 $this->lang = preg_replace(
'/[_-].*$/',
'', trim($this->lang));
676 if ($this->fk_page > 0) {
677 if (empty($this->lang)) {
678 $this->error =
"ErrorLanguageMandatoryIfPageSetAsTranslationOfAnother";
682 $tmppage->fetch((
int) $this->fk_page);
683 if ($tmppage->lang == $this->lang) {
684 $this->error =
"ErrorLanguageOfTranslatedPageIsSameThanThisPage";
699 public function delete(
User $user, $notrigger = 0)
707 foreach ($this->childtablesoncascade as $table) {
708 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$table;
709 $sql .=
" WHERE fk_website_page = ".(int) $this->
id;
711 $result = $this->db->query($sql);
714 $this->errors[] = $this->db->lasterror();
728 $websiteobj =
new Website($this->db);
729 $result = $websiteobj->fetch($this->fk_website);
732 global $dolibarr_main_data_root;
733 $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websiteobj->ref;
735 $filealias = $pathofwebsite.
'/'.$this->pageurl.
'.php';
736 $filetpl = $pathofwebsite.
'/page'.$this->
id.
'.tpl.php';
741 $this->error = $websiteobj->error;
742 $this->errors = $websiteobj->errors;
766 public function createFromClone(
User $user, $fromid, $newref, $newlang =
'', $istranslation = 0, $newwebsite = 0, $newtitle =
'', $website =
null)
768 global $hookmanager, $langs;
778 if (empty($newref) && !empty($newtitle)) {
783 if (empty($newref)) {
784 $langs->load(
"errors");
785 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE"));
789 if ($istranslation) {
790 if (is_null($website)) {
791 $website =
new Website($this->db);
793 $website->fetch(
$object->fk_website);
795 if ($website->id != $newwebsite) {
796 $langs->load(
"errors");
797 $this->error = $langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation");
813 $object->fk_user_creat = $user->id;
818 if (!empty($newlang)) {
822 if ($istranslation) {
823 if ($website->lang == $newlang) {
833 if (!empty($newwebsite)) {
834 $object->fk_website = $newwebsite;
837 $object->status = self::STATUS_DRAFT;
840 $object->context[
'createfromclone'] =
'createfromclone';
841 $result =
$object->create($user);
845 $this->errors =
$object->errors;
846 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
849 if ($istranslation) {
850 if ($website->lang == $newlang) {
852 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"website_page SET fk_page = ".((int) $result).
" WHERE rowid = ".((int) $fromid);
854 $result = $this->db->query($sql);
857 $this->error = $this->db->lasterror();
862 unset(
$object->context[
'createfromclone']);
870 $this->db->rollback();
887 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $maxlen = 24, $morecss =
'')
889 global $langs,
$conf, $db;
895 $label =
'<u>'.$langs->trans(
"Page").
'</u>';
897 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->
ref.
'<br>';
898 $label .=
'<b>'.$langs->trans(
'ID').
':</b> '.$this->
id.
'<br>';
899 $label .=
'<b>'.$langs->trans(
'Title').
':</b> '.$this->title.
'<br>';
900 $label .=
'<b>'.$langs->trans(
'Language').
':</b> '.$this->lang;
902 $url = DOL_URL_ROOT.
'/website/index.php?websiteid='.$this->fk_website.
'&pageid='.$this->id;
905 if (empty($notooltip)) {
907 $label = $langs->trans(
"ShowMyObject");
908 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
910 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
911 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
913 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
916 $linkstart =
'<a href="'.$url.
'"';
917 $linkstart .= $linkclose.
'>';
922 $result .= $linkstart;
924 $result .=
img_picto(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
926 if ($withpicto != 2) {
927 $result .= $this->ref;
958 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
961 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Offline');
962 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Online');
963 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Offline');
964 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Online');
967 $statusType =
'status5';
968 if ($status == self::STATUS_VALIDATED) {
969 $statusType =
'status4';
972 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
987 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1005 $this->fk_website = 0;
1006 $this->type_container =
'page';
1007 $this->pageurl =
'specimen';
1008 $this->aliasalt =
'specimenalt';
1009 $this->title =
'My Page';
1012 $this->keywords =
'keyword1, keyword2';
1013 $this->allowed_in_frames = 1;
1014 $this->htmlheader =
'';
1015 $this->content =
'<html><body>This is a html content</body></html>';
1016 $this->
status = self::STATUS_DRAFT;
1017 $this->grabbed_from =
'';
1018 $this->date_creation = $now - (24 * 30 * 3600);
1019 $this->date_modification = $now - (24 * 7 * 3600);
1020 $this->fk_user_creat = $user->id;
1021 $this->author_alias =
'mypublicpseudo';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent class of all other business classes (invoices, contracts, proposals, orders,...
createCommon(User $user, $notrigger=0)
Create object in the database.
updateCommon(User $user, $notrigger=0)
Update object into database.
setCategoriesCommon($categories, $type_categ='', $remove_existing=true)
Sets object to given categories.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
__construct(DoliDB $db)
Constructor.
fetch($id, $website_id=null, $page=null, $aliasalt=null, $translationparentid=0, $translationparentlang='')
Load object in memory from the database.
update(User $user, $notrigger=0)
Update object into database.
create(User $user, $notrigger=0)
Create object into database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
LibStatut($status, $mode=0)
Return the label of a given status.
createFromClone(User $user, $fromid, $newref, $newlang='', $istranslation=0, $newwebsite=0, $newtitle='', $website=null)
Load an object from its id and create a new one in database.
fetchAll($websiteid='', $sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Return array of all web site pages.
getLibStatut($mode=0)
Return the label of the status.
setCategories($categories)
Sets object to given categories.
getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
Return a link to the user card (with optionally the picto) Use this->id,this->lastname,...
countAll($websiteid, $filter='', $filtermode='AND')
Count objects in the database.
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...
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.
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_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
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)
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
global $dolibarr_main_demo