dolibarr 20.0.2
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 = GETPOSTINT('pageid');
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$permissiontoadd = $user->hasRight('collab', 'read');
80$permissiontodelete = $user->hasRight('collab', 'delete');
81
82
83/*
84 * Actions
85 */
86
87if (GETPOST('refreshsite')) {
88 $pageid = 0; // If we change the site, we reset the pageid.
89}
90if (GETPOST('refreshpage')) {
91 $action = 'preview';
92}
93
94
95// Add a collab page
96if ($action == 'add' && $permissiontoadd) {
97 $db->begin();
98
99 $objectpage->title = GETPOST('WEBSITE_TITLE');
100 $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
101 $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
102 $objectpage->keywords = GETPOST('WEBSITE_KEYWORD');
103
104 if (empty($objectpage->title)) {
105 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
106 $error++;
107 }
108
109 if (!$error) {
110 $res = $objectpage->create($user);
111 if ($res <= 0) {
112 $error++;
113 setEventMessages($objectpage->error, $objectpage->errors, 'errors');
114 }
115 }
116 if (!$error) {
117 $db->commit();
118 setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs');
119 $action = '';
120 } else {
121 $db->rollback();
122 }
123
124 $action = 'preview';
125 $id = $objectpage->id;
126}
127
128// Update page
129if ($action == 'delete' && $permissiontodelete) {
130 $db->begin();
131
132 $res = $object->fetch(0, $website);
133
134 $res = $objectpage->fetch($pageid, $object->fk_website);
135
136 if ($res > 0) {
137 $res = $objectpage->delete($user);
138 if (!($res > 0)) {
139 $error++;
140 setEventMessages($objectpage->error, $objectpage->errors, 'errors');
141 }
142
143 if (!$error) {
144 $db->commit();
145 setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
146
147 header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
148 exit;
149 } else {
150 $db->rollback();
151 }
152 } else {
153 dol_print_error($db);
154 }
155}
156
157
158
159/*
160 * View
161 */
162
163$form = new Form($db);
164
165$help_url = '';
166
167llxHeader('', $langs->trans("WebsiteSetup"), $help_url, '', 0, '', '', '', '', '', '<!-- Begin div class="fiche" -->'."\n".'<div class="fichebutwithotherclass">');
168
169print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST"><div>';
170print '<input type="hidden" name="token" value="'.newToken().'">';
171if ($action == 'create') {
172 print '<input type="hidden" name="action" value="add">';
173}
174
175
176// Add a margin under toolbar ?
177$style = '';
178if ($action != 'preview' && $action != 'editcontent') {
179 $style = ' margin-bottom: 5px;';
180}
181
182//var_dump($objectpage);exit;
183print '<div class="centpercent websitebar">';
184
185
186
187
188print "</div>\n</form>\n";
189
190// End of page
191llxFooter();
192$db->close();
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()
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.
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.