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 24/** 25 * \file htdocs/admin/spip.php 26 * \ingroup mailmanspip 27 * \brief Page to setup the module MailmanSpip (SPIP) 28 */ 29 30require '../main.inc.php'; 31require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; 32require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php'; 33require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; 34 35// Load translation files required by the page 36$langs->loadLangs(array("admin", "members", "mailmanspip")); 37 38if (!$user->admin) accessforbidden(); 39 40 41$type = array('yesno', 'texte', 'chaine'); 42 43$action = GETPOST('action', 'aZ09'); 44 45 46/* 47 * Actions 48 */ 49 50// Action mise a jour ou ajout d'une constante 51if ($action == 'update' || $action == 'add') 52{ 53 $constnamearray = GETPOST("constname", 'array'); 54 $constvaluearray = GETPOST("constvalue", 'array'); 55 $consttypearray = GETPOST("consttype", 'array'); 56 $constnotearray = GETPOST("constnote", 'array'); 57 58 // Action mise a jour ou ajout d'une constante 59 if ($action == 'update' || $action == 'add') 60 { 61 foreach ($constnamearray as $key => $val) 62 { 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)) $error++; 71 } 72 73 if (!$error) 74 { 75 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); 76 } else { 77 setEventMessages($langs->trans("Error"), null, 'errors'); 78 } 79 } 80} 81 82// Action activation d'un sous module du module adherent 83if ($action == 'set') 84{ 85 $result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); 86 if ($result < 0) 87 { 88 dol_print_error($db); 89 } 90} 91 92// Action desactivation d'un sous module du module adherent 93if ($action == 'unset') 94{ 95 $result = dolibarr_del_const($db, $_GET["name"], $conf->entity); 96 if ($result < 0) 97 { 98 dol_print_error($db); 99 } 100} 101 102 103 104/* 105 * View 106 */ 107 108$help_url = ''; 109 110llxHeader('', $langs->trans("MailmanSpipSetup"), $help_url); 111 112 113$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; 114print load_fiche_titre($langs->trans("MailmanSpipSetup"), $linkback, 'title_setup'); 115 116 117$head = mailmanspip_admin_prepare_head(); 118 119 120/* 121 * Spip 122 */ 123if (!empty($conf->global->ADHERENT_USE_SPIP)) 124{ 125 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; 126 print '<input type="hidden" name="token" value="'.newToken().'">'; 127 print '<input type="hidden" name="action" value="update">'; 128 129 print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user'); 130 131 //$link=img_picto($langs->trans("Active"),'tick').' '; 132 $link = '<a href="'.$_SERVER["PHP_SELF"].'?action=unset&token='.newToken().'&value=0&name=ADHERENT_USE_SPIP">'; 133 //$link.=$langs->trans("Disable"); 134 $link .= img_picto($langs->trans("Activated"), 'switch_on'); 135 $link .= '</a>'; 136 // Edition des varibales globales 137 $constantes = array( 138 'ADHERENT_SPIP_SERVEUR', 139 'ADHERENT_SPIP_DB', 140 'ADHERENT_SPIP_USER', 141 'ADHERENT_SPIP_PASS' 142 ); 143 144 print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); 145 print '<br>'; 146 147 form_constantes($constantes, 2); 148 149 print dol_get_fiche_end(); 150 151 print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>'; 152 153 print '</form>'; 154} else { 155 print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user'); 156 157 $link = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value=1&name=ADHERENT_USE_SPIP">'; 158 //$link.=$langs->trans("Activate"); 159 $link .= img_picto($langs->trans("Disabled"), 'switch_off'); 160 $link .= '</a>'; 161 print load_fiche_titre($langs->trans('SPIPTitle'), $link, ''); 162 163 print dol_get_fiche_end(); 164} 165 166// End of page 167llxFooter(); 168$db->close(); 169