dolibarr  20.0.0-beta
configcss.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2023-2024 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
4  * Copyright (C) 2023-2024 Patrice Andreani <pandreani@easya.solutions>
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 
26 // Load Dolibarr environment
27 require_once "../../main.inc.php";
28 require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
29 require_once DOL_DOCUMENT_ROOT . "/webportal/lib/webportal.lib.php";
30 
31 // Translations
32 $langs->loadLangs(array("admin", "hrm", "other", "website"));
33 
34 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
35 $hookmanager->initHooks(array('webportalsetup', 'globalsetup'));
36 
37 // Parameters
38 $action = GETPOST('action', 'aZ09');
39 $backtopage = GETPOST('backtopage', 'alpha');
40 
41 if (empty($action)) {
42  $action = 'edit';
43 }
44 
45 // Access control
46 if (!$user->admin) {
48 }
49 
50 
51 /*
52  * Actions
53  */
54 
55 $parameters = array();
56 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
57 if ($reshook < 0) {
58  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
59 }
60 
61 // Convert action set_XXX and del_XXX to set var (this is used when no javascript on for ajax_constantonoff)
62 $regs = array();
63 if (preg_match('/^(set|del)_([A-Z_]+)$/', $action, $regs)) {
64  if ($regs[1] == 'set') {
65  dolibarr_set_const($db, $regs[2], 1, 'chaine', 0, '', $conf->entity);
66  } else {
67  dolibarr_del_const($db, $regs[2], $conf->entity);
68  }
69 }
70 
71 if ($action == 'updatecss') {
72  dolibarr_set_const($db, "WEBPORTAL_CUSTOM_CSS", GETPOST('WEBPORTAL_CUSTOM_CSS', 'restricthtml'), 'chaine', 0, '', $conf->entity);
73  dolibarr_set_const($db, "WEBPORTAL_PARAMS_REV", ((int) $conf->global->WEBPORTAL_PARAMS_REV) + 1, 'chaine', 0, '', $conf->entity);
74 }
75 
76 
77 /*
78  * View
79  */
80 
81 $title = "WebPortalSetup";
82 
83 $wikihelp = 'EN:First_setup|FR:Premiers_param&eacute;trages|ES:Primeras_configuraciones';
84 
85 llxHeader(
86  '',
87  $langs->trans($title),
88  $wikihelp,
89  '',
90  0,
91  0,
92  array(
93  '/includes/ace/src/ace.js',
94  '/includes/ace/src/ext-statusbar.js',
95  '/includes/ace/src/ext-language_tools.js',
96  ),
97  array()
98 );
99 
100 // Subheader
101 $linkback = '<a href="' . ($backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans("BackToModuleList") . '</a>';
102 
103 print load_fiche_titre($langs->trans($title), $linkback, 'title_setup');
104 
105 // Configuration header
106 $head = webportalAdminPrepareHead();
107 print dol_get_fiche_head($head, 'css', $langs->trans($title), -1, "webportal");
108 
109 // Setup page goes here
110 echo '<span class="opacitymedium">' . $langs->trans("WebPortalCSS") . '</span><br><br>';
111 
112 //WYSIWYG Editor
113 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
114 
115 print '<form enctype="multipart/form-data" method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
116 
117 print '<input type="hidden" name="token" value="' . newToken() . '">';
118 print '<input type="hidden" name="action" value="updatecss">';
119 
120 clearstatcache();
121 
122 // editeur CSS
123 print '<div class="div-table-responsive-no-min">';
124 print '<table summary="edit" class="noborder centpercent editmode tableforfield">';
125 
126 print '<tr class="liste_titre">';
127 print '<td colspan="2">';
128 
129 $customcssValue = getDolGlobalString('WEBPORTAL_CUSTOM_CSS');
130 
131 $doleditor = new DolEditor('WEBPORTAL_CUSTOM_CSS', $customcssValue, '80%', 400, 'Basic', 'In', true, false, 'ace', 10, '90%');
132 $doleditor->Create(0, '', true, 'css', 'css');
133 print '</td></tr>' . "\n";
134 
135 print '</table>' . "\n";
136 print '</div>';
137 
138 print '<div class="center">';
139 print '<input class="button button-save reposition buttonforacesave" type="submit" name="submit" value="' . $langs->trans("Save") . '">';
140 //print '<input class="button button-cancel reposition" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
141 print '</div>';
142 
143 print '</form>';
144 
145 // Page end
146 print dol_get_fiche_end();
147 
148 // End of page
149 llxFooter();
150 $db->close();
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition: card.php:58
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:656
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:580
if(GETPOSTISSET('MAIN_AGENDA_XCAL_EXPORTKEY')) if(GETPOSTISSET('MAIN_AGENDA_EXPORT_PAST_DELAY')) if(GETPOSTISSET('MAIN_AGENDA_EXPORT_CACHE')) if(GETPOSTISSET('AGENDA_EXPORT_FIX_TZ')) if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
Definition: agenda_xcal.php:90
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 a WYSIWYG editor.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
webportalAdminPrepareHead()
Prepare admin pages header.