dolibarr 21.0.0-beta
spip.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4 * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
7 * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
8 * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
9 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32// Load Dolibarr environment
33require '../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
37
46// Load translation files required by the page
47$langs->loadLangs(array("admin", "members", "mailmanspip"));
48
49if (!$user->admin) {
51}
52
53
54$action = GETPOST('action', 'aZ09');
55
56
57/*
58 * Actions
59 */
60$error = 0;
61
62// Action mise a jour ou ajout d'une constante
63if ($action == 'update' || $action == 'add') {
64 $constnamearray = GETPOST("constname", 'array');
65 $constvaluearray = GETPOST("constvalue", 'array');
66 $constnotearray = GETPOST("constnote", 'array');
67
68 // Action mise a jour ou ajout d'une constante
69 if ($action == 'update' || $action == 'add') {
70 foreach ($constnamearray as $key => $val) {
71 $constname = dol_escape_htmltag($constnamearray[$key]);
72 $constvalue = dol_escape_htmltag($constvaluearray[$key]);
73 $constnote = dol_escape_htmltag($constnotearray[$key]);
74
75 $res = dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, $constnote, $conf->entity);
76
77 if (!($res > 0)) {
78 $error++;
79 }
80 }
81
82 if (!$error) {
83 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
84 } else {
85 setEventMessages($langs->trans("Error"), null, 'errors');
86 }
87 }
88}
89
90// Action activation d'un sous module du module adherent
91if ($action == 'set') {
92 $result = dolibarr_set_const($db, GETPOST("name", 'aZ09'), GETPOST("value"), '', 0, '', $conf->entity);
93 if ($result < 0) {
94 dol_print_error($db);
95 }
96}
97
98// Action deactivation d'un sous module du module adherent
99if ($action == 'unset') {
100 $result = dolibarr_del_const($db, GETPOST("name", 'aZ09'), $conf->entity);
101 if ($result < 0) {
102 dol_print_error($db);
103 }
104}
105
106
107
108/*
109 * View
110 */
111
112$help_url = '';
113
114llxHeader('', $langs->trans("MailmanSpipSetup"), $help_url, '', 0, 0, '', '', '', 'mod-admin page-spip');
115
116
117$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
118print load_fiche_titre($langs->trans("MailmanSpipSetup"), $linkback, 'title_setup');
119
120
121$head = mailmanspip_admin_prepare_head();
122
123
124/*
125 * Spip
126 */
127if (getDolGlobalString('ADHERENT_USE_SPIP')) {
128 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
129 print '<input type="hidden" name="token" value="'.newToken().'">';
130 print '<input type="hidden" name="action" value="update">';
131
132 print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user');
133
134 //$link=img_picto($langs->trans("Active"),'tick').' ';
135 $link = '<a href="'.$_SERVER["PHP_SELF"].'?action=unset&token='.newToken().'&value=0&name=ADHERENT_USE_SPIP">';
136 //$link.=$langs->trans("Disable");
137 $link .= img_picto($langs->trans("Activated"), 'switch_on');
138 $link .= '</a>';
139 // Edition des variables globales
140 $constantes = array(
141 'ADHERENT_SPIP_SERVEUR',
142 'ADHERENT_SPIP_DB',
143 'ADHERENT_SPIP_USER',
144 'ADHERENT_SPIP_PASS'
145 );
146
147 print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
148 print '<br>';
149
150 form_constantes($constantes, 2);
151
152 print dol_get_fiche_end();
153
154 print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
155
156 print '</form>';
157} else {
158 print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user');
159
160 $link = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value=1&name=ADHERENT_USE_SPIP">';
161 //$link.=$langs->trans("Activate");
162 $link .= img_picto($langs->trans("Disabled"), 'switch_off');
163 $link .= '</a>';
164 print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
165
166 print dol_get_fiche_end();
167}
168
169// End of page
170llxFooter();
171$db->close();
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).
form_constantes($tableau, $strictw3c=2, $helptext='', $text='Value')
Show array with constants to edit.
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
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:71
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.