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