dolibarr 19.0.3
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
24define('NOSCANPOSTFORINJECTION', 1);
25define('NOSTYLECHECK', 1);
26
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
31
32// Load translation files required by the page
33$langs->loadLangs(array("admin", "other", "website"));
34
35if (!$user->admin) {
37}
38
39$conf->dol_hide_leftmenu = 1; // Force hide of left menu.
40
41$error = 0;
42$website = GETPOST('website', 'alpha');
43$page = GETPOST('page', 'alpha');
44$pageid = GETPOST('pageid', 'int');
45$action = GETPOST('action', 'aZ09');
46
47if (GETPOST('delete')) {
48 $action = 'delete';
49}
50if (GETPOST('preview')) {
51 $action = 'preview';
52}
53if (GETPOST('create')) {
54 $action = 'create';
55}
56if (GETPOST('editmedia')) {
57 $action = 'editmedia';
58}
59if (GETPOST('editcss')) {
60 $action = 'editcss';
61}
62if (GETPOST('editmenu')) {
63 $action = 'editmenu';
64}
65if (GETPOST('setashome')) {
66 $action = 'setashome';
67}
68if (GETPOST('editmeta')) {
69 $action = 'editmeta';
70}
71if (GETPOST('editcontent')) {
72 $action = 'editcontent';
73}
74
75if (empty($action)) {
76 $action = 'preview';
77}
78
79
80
81
82/*
83 * Actions
84 */
85
86if (GETPOST('refreshsite')) {
87 $pageid = 0; // If we change the site, we reset the pageid.
88}
89if (GETPOST('refreshpage')) {
90 $action = 'preview';
91}
92
93
94// Add a collab page
95if ($action == 'add') {
96 $db->begin();
97
98 $objectpage->title = GETPOST('WEBSITE_TITLE');
99 $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
100 $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
101 $objectpage->keywords = GETPOST('WEBSITE_KEYWORD');
102
103 if (empty($objectpage->title)) {
104 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
105 $error++;
106 }
107
108 if (!$error) {
109 $res = $objectpage->create($user);
110 if ($res <= 0) {
111 $error++;
112 setEventMessages($objectpage->error, $objectpage->errors, 'errors');
113 }
114 }
115 if (!$error) {
116 $db->commit();
117 setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
118 $action = '';
119 } else {
120 $db->rollback();
121 }
122
123 $action = 'preview';
124 $id = $objectpage->id;
125}
126
127// Update page
128if ($action == 'delete') {
129 $db->begin();
130
131 $res = $object->fetch(0, $website);
132
133 $res = $objectpage->fetch($pageid, $object->fk_website);
134
135 if ($res > 0) {
136 $res = $objectpage->delete($user);
137 if (!($res > 0)) {
138 $error++;
139 setEventMessages($objectpage->error, $objectpage->errors, 'errors');
140 }
141
142 if (!$error) {
143 $db->commit();
144 setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
145
146 header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
147 exit;
148 } else {
149 $db->rollback();
150 }
151 } else {
152 dol_print_error($db);
153 }
154}
155
156
157
158/*
159 * View
160 */
161
162$form = new Form($db);
163
164$help_url = '';
165
166llxHeader('', $langs->trans("WebsiteSetup"), $help_url, '', 0, '', '', '', '', '', '<!-- Begin div class="fiche" -->'."\n".'<div class="fichebutwithotherclass">');
167
168print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST"><div>';
169print '<input type="hidden" name="token" value="'.newToken().'">';
170if ($action == 'create') {
171 print '<input type="hidden" name="action" value="add">';
172}
173
174
175// Add a margin under toolbar ?
176$style = '';
177if ($action != 'preview' && $action != 'editcontent') {
178 $style = ' margin-bottom: 5px;';
179}
180
181//var_dump($objectpage);exit;
182print '<div class="centpercent websitebar">';
183
184
185
186
187print "</div>\n</form>\n";
188
189// End of page
190llxFooter();
191$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage generation of HTML components Only common components must be here.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.