dolibarr  21.0.0-alpha
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  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
30 // Load Dolibarr environment
31 require '../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array("admin", "members", "mailmanspip"));
38 
39 if (!$user->admin) {
41 }
42 
43 
44 $type = array('yesno', 'texte', 'chaine');
45 
46 $action = GETPOST('action', 'aZ09');
47 
48 
49 /*
50  * Actions
51  */
52 
53 // Action mise a jour ou ajout d'une constante
54 if ($action == 'update' || $action == 'add') {
55  $constnamearray = GETPOST("constname", 'array');
56  $constvaluearray = GETPOST("constvalue", 'array');
57  $consttypearray = GETPOST("consttype", 'array');
58  $constnotearray = GETPOST("constnote", 'array');
59 
60  // Action mise a jour ou ajout d'une constante
61  if ($action == 'update' || $action == 'add') {
62  foreach ($constnamearray as $key => $val) {
63  $constname = dol_escape_htmltag($constnamearray[$key]);
64  $constvalue = dol_escape_htmltag($constvaluearray[$key]);
65  $consttype = dol_escape_htmltag($consttypearray[$key]);
66  $constnote = dol_escape_htmltag($constnotearray[$key]);
67 
68  $res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity);
69 
70  if (!($res > 0)) {
71  $error++;
72  }
73  }
74 
75  if (!$error) {
76  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
77  } else {
78  setEventMessages($langs->trans("Error"), null, 'errors');
79  }
80  }
81 }
82 
83 // Action activation d'un sous module du module adherent
84 if ($action == 'set') {
85  $result = dolibarr_set_const($db, GETPOST("name", 'aZ09'), GETPOST("value"), '', 0, '', $conf->entity);
86  if ($result < 0) {
87  dol_print_error($db);
88  }
89 }
90 
91 // Action deactivation d'un sous module du module adherent
92 if ($action == 'unset') {
93  $result = dolibarr_del_const($db, GETPOST("name", 'aZ09'), $conf->entity);
94  if ($result < 0) {
95  dol_print_error($db);
96  }
97 }
98 
99 
100 
101 /*
102  * View
103  */
104 
105 $help_url = '';
106 
107 llxHeader('', $langs->trans("MailmanSpipSetup"), $help_url, '', 0, 0, '', '', '', 'mod-admin page-spip');
108 
109 
110 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
111 print load_fiche_titre($langs->trans("MailmanSpipSetup"), $linkback, 'title_setup');
112 
113 
114 $head = mailmanspip_admin_prepare_head();
115 
116 
117 /*
118  * Spip
119  */
120 if (getDolGlobalString('ADHERENT_USE_SPIP')) {
121  print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
122  print '<input type="hidden" name="token" value="'.newToken().'">';
123  print '<input type="hidden" name="action" value="update">';
124 
125  print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user');
126 
127  //$link=img_picto($langs->trans("Active"),'tick').' ';
128  $link = '<a href="'.$_SERVER["PHP_SELF"].'?action=unset&token='.newToken().'&value=0&name=ADHERENT_USE_SPIP">';
129  //$link.=$langs->trans("Disable");
130  $link .= img_picto($langs->trans("Activated"), 'switch_on');
131  $link .= '</a>';
132  // Edition des variables globales
133  $constantes = array(
134  'ADHERENT_SPIP_SERVEUR',
135  'ADHERENT_SPIP_DB',
136  'ADHERENT_SPIP_USER',
137  'ADHERENT_SPIP_PASS'
138  );
139 
140  print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
141  print '<br>';
142 
143  form_constantes($constantes, 2);
144 
145  print dol_get_fiche_end();
146 
147  print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
148 
149  print '</form>';
150 } else {
151  print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user');
152 
153  $link = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value=1&name=ADHERENT_USE_SPIP">';
154  //$link.=$langs->trans("Activate");
155  $link .= img_picto($langs->trans("Disabled"), 'switch_off');
156  $link .= '</a>';
157  print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
158 
159  print dol_get_fiche_end();
160 }
161 
162 // End of page
163 llxFooter();
164 $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).
Definition: admin.lib.php:656
form_constantes($tableau, $strictw3c=2, $helptext='', $text='Value')
Show array with constants to edit.
Definition: admin.lib.php:1684
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:580
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
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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...
getDolGlobalString($key, $default='')
Return 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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.