dolibarr 22.0.5
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26define('NOSCANPOSTFORINJECTION', 1);
27define('NOSTYLECHECK', 1);
28
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
33
44// Load translation files required by the page
45$langs->loadLangs(array("admin", "other", "website"));
46
47if (!$user->admin) {
49}
50
51'
52@phan-var-force Website $object
53@phan-var-force WebsitePage $objectpage
54';
55
56$conf->dol_hide_leftmenu = 1; // Force hide of left menu.
57
58$error = 0;
59$website = GETPOST('website', 'alpha');
60$page = GETPOST('page', 'alpha');
61$pageid = GETPOSTINT('pageid');
62$action = GETPOST('action', 'aZ09');
63
64if (GETPOST('delete')) {
65 $action = 'delete';
66}
67if (GETPOST('preview')) {
68 $action = 'preview';
69}
70if (GETPOST('create')) {
71 $action = 'create';
72}
73if (GETPOST('editmedia')) {
74 $action = 'editmedia';
75}
76if (GETPOST('editcss')) {
77 $action = 'editcss';
78}
79if (GETPOST('editmenu')) {
80 $action = 'editmenu';
81}
82if (GETPOST('setashome')) {
83 $action = 'setashome';
84}
85if (GETPOST('editmeta')) {
86 $action = 'editmeta';
87}
88if (GETPOST('editcontent')) {
89 $action = 'editcontent';
90}
91
92if (empty($action)) {
93 $action = 'preview';
94}
95
96$permissiontoadd = $user->hasRight('collab', 'read');
97$permissiontodelete = $user->hasRight('collab', 'delete');
98
99
100/*
101 * Actions
102 */
103
104if (GETPOST('refreshsite')) {
105 $pageid = 0; // If we change the site, we reset the pageid.
106}
107if (GETPOST('refreshpage')) {
108 $action = 'preview';
109}
110
111
112// Add a collab page
113if ($action == 'add' && $permissiontoadd) {
114 $db->begin();
115
116 $objectpage->title = GETPOST('WEBSITE_TITLE');
117 $objectpage->pageurl = dol_sanitizeUrl(GETPOST('WEBSITE_PAGENAME'));
118 $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
119 $objectpage->keywords = GETPOST('WEBSITE_KEYWORD');
120
121 if (empty($objectpage->title)) {
122 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
123 $error++;
124 }
125
126 if (!$error) {
127 $res = $objectpage->create($user);
128 if ($res <= 0) {
129 $error++;
130 setEventMessages($objectpage->error, $objectpage->errors, 'errors');
131 }
132 }
133 if (!$error) {
134 $db->commit();
135 setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
136 $action = '';
137 } else {
138 $db->rollback();
139 }
140
141 $action = 'preview';
142 $id = $objectpage->id;
143}
144
145// Update page
146if ($action == 'delete' && $permissiontodelete) {
147 $db->begin();
148
149 $res = $object->fetch(0, $website);
150
151 $res = $objectpage->fetch($pageid, $object->fk_website);
152
153 if ($res > 0) {
154 $res = $objectpage->delete($user);
155 if (!($res > 0)) {
156 $error++;
157 setEventMessages($objectpage->error, $objectpage->errors, 'errors');
158 }
159
160 if (!$error) {
161 $db->commit();
162 setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
163
164 header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
165 exit;
166 } else {
167 $db->rollback();
168 }
169 } else {
170 dol_print_error($db);
171 }
172}
173
174
175
176/*
177 * View
178 */
179
180$form = new Form($db);
181
182$help_url = '';
183
184llxHeader('', $langs->trans("WebsiteSetup"), $help_url, '', 0, 0, '', '', '', '', '<!-- Begin div class="fiche" -->'."\n".'<div class="fichebutwithotherclass">');
185
186print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST"><div>';
187print '<input type="hidden" name="token" value="'.newToken().'">';
188if ($action == 'create') {
189 print '<input type="hidden" name="action" value="add">';
190}
191
192
193// Add a margin under toolbar ?
194$style = '';
195if ($action != 'preview' && $action != 'editcontent') {
196 $style = ' margin-bottom: 5px;';
197}
198
199//var_dump($objectpage);exit;
200print '<div class="centpercent websitebar">';
201
202
203
204
205print "</div>\n</form>\n";
206
207// End of page
208llxFooter();
209$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage generation of HTML components Only common components must be here.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_sanitizeUrl($stringtoclean, $type=1)
Clean a string to use it as an URL (into a href or src attribute)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.