dolibarr 21.0.0-beta
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 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
42// Load translation files required by the page
43$langs->loadLangs(array("admin", "other", "website"));
44
45if (!$user->admin) {
47}
48
49'@phan-var-force WebsitePage $objectpage';
50
51$conf->dol_hide_leftmenu = 1; // Force hide of left menu.
52
53$error = 0;
54$website = GETPOST('website', 'alpha');
55$page = GETPOST('page', 'alpha');
56$pageid = GETPOSTINT('pageid');
57$action = GETPOST('action', 'aZ09');
58
59if (GETPOST('delete')) {
60 $action = 'delete';
61}
62if (GETPOST('preview')) {
63 $action = 'preview';
64}
65if (GETPOST('create')) {
66 $action = 'create';
67}
68if (GETPOST('editmedia')) {
69 $action = 'editmedia';
70}
71if (GETPOST('editcss')) {
72 $action = 'editcss';
73}
74if (GETPOST('editmenu')) {
75 $action = 'editmenu';
76}
77if (GETPOST('setashome')) {
78 $action = 'setashome';
79}
80if (GETPOST('editmeta')) {
81 $action = 'editmeta';
82}
83if (GETPOST('editcontent')) {
84 $action = 'editcontent';
85}
86
87if (empty($action)) {
88 $action = 'preview';
89}
90
91$permissiontoadd = $user->hasRight('collab', 'read');
92$permissiontodelete = $user->hasRight('collab', 'delete');
93
94
95/*
96 * Actions
97 */
98
99if (GETPOST('refreshsite')) {
100 $pageid = 0; // If we change the site, we reset the pageid.
101}
102if (GETPOST('refreshpage')) {
103 $action = 'preview';
104}
105
106
107// Add a collab page
108if ($action == 'add' && $permissiontoadd) {
109 $db->begin();
110
111 $objectpage->title = GETPOST('WEBSITE_TITLE');
112 $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
113 $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
114 $objectpage->keywords = GETPOST('WEBSITE_KEYWORD');
115
116 if (empty($objectpage->title)) {
117 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
118 $error++;
119 }
120
121 if (!$error) {
122 $res = $objectpage->create($user);
123 if ($res <= 0) {
124 $error++;
125 setEventMessages($objectpage->error, $objectpage->errors, 'errors');
126 }
127 }
128 if (!$error) {
129 $db->commit();
130 setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
131 $action = '';
132 } else {
133 $db->rollback();
134 }
135
136 $action = 'preview';
137 $id = $objectpage->id;
138}
139
140// Update page
141if ($action == 'delete' && $permissiontodelete) {
142 $db->begin();
143
144 $res = $object->fetch(0, $website);
145
146 $res = $objectpage->fetch($pageid, $object->fk_website);
147
148 if ($res > 0) {
149 $res = $objectpage->delete($user);
150 if (!($res > 0)) {
151 $error++;
152 setEventMessages($objectpage->error, $objectpage->errors, 'errors');
153 }
154
155 if (!$error) {
156 $db->commit();
157 setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
158
159 header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
160 exit;
161 } else {
162 $db->rollback();
163 }
164 } else {
165 dol_print_error($db);
166 }
167}
168
169
170
171/*
172 * View
173 */
174
175$form = new Form($db);
176
177$help_url = '';
178
179llxHeader('', $langs->trans("WebsiteSetup"), $help_url, '', 0, 0, '', '', '', '', '<!-- Begin div class="fiche" -->'."\n".'<div class="fichebutwithotherclass">');
180
181print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST"><div>';
182print '<input type="hidden" name="token" value="'.newToken().'">';
183if ($action == 'create') {
184 print '<input type="hidden" name="action" value="add">';
185}
186
187
188// Add a margin under toolbar ?
189$style = '';
190if ($action != 'preview' && $action != 'editcontent') {
191 $style = ' margin-bottom: 5px;';
192}
193
194//var_dump($objectpage);exit;
195print '<div class="centpercent websitebar">';
196
197
198
199
200print "</div>\n</form>\n";
201
202// End of page
203llxFooter();
204$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
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.
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.