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