2012-01-11 17:43:38 +00:00
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
2012-07-29 13:55:19 +00:00
|
|
|
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
2012-01-11 17:43:38 +00:00
|
|
|
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
|
|
|
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
2018-10-27 12:43:12 +00:00
|
|
|
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
|
2013-08-20 14:50:33 +00:00
|
|
|
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
2012-01-11 17:43:38 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 14:36:08 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2012-01-11 17:43:38 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-09-23 19:55:30 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2012-01-11 17:43:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2013-06-05 13:44:42 +00:00
|
|
|
* \file htdocs/admin/spip.php
|
2012-07-29 13:55:19 +00:00
|
|
|
* \ingroup mailmanspip
|
|
|
|
|
* \brief Page to setup the module MailmanSpip (SPIP)
|
2012-01-11 17:43:38 +00:00
|
|
|
*/
|
|
|
|
|
|
2013-06-05 13:44:42 +00:00
|
|
|
require '../main.inc.php';
|
2012-08-22 21:11:24 +00:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php';
|
2013-06-06 16:31:33 +00:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
2012-01-11 17:43:38 +00:00
|
|
|
|
2018-05-26 16:52:14 +00:00
|
|
|
// Load translation files required by the page
|
2018-05-11 20:31:17 +00:00
|
|
|
$langs->loadLangs(array("admin", "members", "mailmanspip"));
|
2012-01-11 17:43:38 +00:00
|
|
|
|
2021-02-26 21:04:03 +00:00
|
|
|
if (!$user->admin) {
|
|
|
|
|
accessforbidden();
|
|
|
|
|
}
|
2012-01-11 17:43:38 +00:00
|
|
|
|
|
|
|
|
|
2020-02-18 22:47:25 +00:00
|
|
|
$type = array('yesno', 'texte', 'chaine');
|
2012-01-11 17:43:38 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
$action = GETPOST('action', 'aZ09');
|
2012-01-11 17:43:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Action mise a jour ou ajout d'une constante
|
2021-02-26 21:04:03 +00:00
|
|
|
if ($action == 'update' || $action == 'add') {
|
2020-02-16 18:33:58 +00:00
|
|
|
$constnamearray = GETPOST("constname", 'array');
|
|
|
|
|
$constvaluearray = GETPOST("constvalue", 'array');
|
|
|
|
|
$consttypearray = GETPOST("consttype", 'array');
|
|
|
|
|
$constnotearray = GETPOST("constnote", 'array');
|
2012-01-11 17:43:38 +00:00
|
|
|
|
2020-10-31 13:32:18 +00:00
|
|
|
// Action mise a jour ou ajout d'une constante
|
2021-02-26 21:04:03 +00:00
|
|
|
if ($action == 'update' || $action == 'add') {
|
|
|
|
|
foreach ($constnamearray as $key => $val) {
|
2020-10-31 13:32:18 +00:00
|
|
|
$constname = dol_escape_htmltag($constnamearray[$key]);
|
|
|
|
|
$constvalue = dol_escape_htmltag($constvaluearray[$key]);
|
|
|
|
|
$consttype = dol_escape_htmltag($consttypearray[$key]);
|
|
|
|
|
$constnote = dol_escape_htmltag($constnotearray[$key]);
|
|
|
|
|
|
|
|
|
|
$res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity);
|
|
|
|
|
|
2021-02-26 21:04:03 +00:00
|
|
|
if (!($res > 0)) {
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
2020-10-31 13:32:18 +00:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 21:04:03 +00:00
|
|
|
if (!$error) {
|
2020-10-31 13:32:18 +00:00
|
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
|
|
|
|
} else {
|
|
|
|
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-01-11 17:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Action activation d'un sous module du module adherent
|
2021-02-26 21:04:03 +00:00
|
|
|
if ($action == 'set') {
|
2020-10-31 13:32:18 +00:00
|
|
|
$result = dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity);
|
2021-02-26 21:04:03 +00:00
|
|
|
if ($result < 0) {
|
2020-10-31 13:32:18 +00:00
|
|
|
dol_print_error($db);
|
|
|
|
|
}
|
2012-01-11 17:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Action desactivation d'un sous module du module adherent
|
2021-02-26 21:04:03 +00:00
|
|
|
if ($action == 'unset') {
|
2020-10-31 13:32:18 +00:00
|
|
|
$result = dolibarr_del_const($db, $_GET["name"], $conf->entity);
|
2021-02-26 21:04:03 +00:00
|
|
|
if ($result < 0) {
|
2020-10-31 13:32:18 +00:00
|
|
|
dol_print_error($db);
|
|
|
|
|
}
|
2012-01-11 17:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-18 22:47:25 +00:00
|
|
|
$help_url = '';
|
2012-01-11 17:43:38 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
llxHeader('', $langs->trans("MailmanSpipSetup"), $help_url);
|
2012-01-11 17:43:38 +00:00
|
|
|
|
|
|
|
|
|
2020-02-18 22:47:25 +00:00
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
2019-01-27 10:55:16 +00:00
|
|
|
print load_fiche_titre($langs->trans("MailmanSpipSetup"), $linkback, 'title_setup');
|
2012-01-11 17:43:38 +00:00
|
|
|
|
|
|
|
|
|
2012-09-13 09:52:50 +00:00
|
|
|
$head = mailmanspip_admin_prepare_head();
|
2012-01-11 17:43:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Spip
|
|
|
|
|
*/
|
2021-02-26 21:04:03 +00:00
|
|
|
if (!empty($conf->global->ADHERENT_USE_SPIP)) {
|
2015-10-23 12:40:45 +00:00
|
|
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
2019-12-18 22:12:31 +00:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2019-09-04 09:33:07 +00:00
|
|
|
print '<input type="hidden" name="action" value="update">';
|
2019-05-21 13:31:56 +00:00
|
|
|
|
2020-10-22 20:50:03 +00:00
|
|
|
print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user');
|
2019-05-21 13:31:56 +00:00
|
|
|
|
2020-10-31 13:32:18 +00:00
|
|
|
//$link=img_picto($langs->trans("Active"),'tick').' ';
|
|
|
|
|
$link = '<a href="'.$_SERVER["PHP_SELF"].'?action=unset&token='.newToken().'&value=0&name=ADHERENT_USE_SPIP">';
|
|
|
|
|
//$link.=$langs->trans("Disable");
|
|
|
|
|
$link .= img_picto($langs->trans("Activated"), 'switch_on');
|
|
|
|
|
$link .= '</a>';
|
|
|
|
|
// Edition des varibales globales
|
|
|
|
|
$constantes = array(
|
|
|
|
|
'ADHERENT_SPIP_SERVEUR',
|
|
|
|
|
'ADHERENT_SPIP_DB',
|
|
|
|
|
'ADHERENT_SPIP_USER',
|
|
|
|
|
'ADHERENT_SPIP_PASS'
|
2012-01-11 17:43:38 +00:00
|
|
|
);
|
|
|
|
|
|
2020-10-31 13:32:18 +00:00
|
|
|
print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
|
2013-05-09 20:39:31 +00:00
|
|
|
print '<br>';
|
2019-05-21 13:31:56 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
form_constantes($constantes, 2);
|
2019-05-21 13:31:56 +00:00
|
|
|
|
2020-10-31 13:32:18 +00:00
|
|
|
print dol_get_fiche_end();
|
2015-10-23 12:40:45 +00:00
|
|
|
|
2020-10-31 13:32:18 +00:00
|
|
|
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
|
2019-05-21 13:31:56 +00:00
|
|
|
|
2020-10-31 13:32:18 +00:00
|
|
|
print '</form>';
|
2020-05-21 07:35:30 +00:00
|
|
|
} else {
|
2020-10-31 13:32:18 +00:00
|
|
|
print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user');
|
2019-05-21 13:31:56 +00:00
|
|
|
|
2021-09-19 16:03:38 +00:00
|
|
|
$link = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value=1&name=ADHERENT_USE_SPIP">';
|
2020-10-31 13:32:18 +00:00
|
|
|
//$link.=$langs->trans("Activate");
|
|
|
|
|
$link .= img_picto($langs->trans("Disabled"), 'switch_off');
|
|
|
|
|
$link .= '</a>';
|
|
|
|
|
print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
|
2019-05-21 13:31:56 +00:00
|
|
|
|
2020-10-31 13:32:18 +00:00
|
|
|
print dol_get_fiche_end();
|
2012-01-11 17:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-28 16:03:14 +00:00
|
|
|
// End of page
|
2012-01-11 17:43:38 +00:00
|
|
|
llxFooter();
|
|
|
|
|
$db->close();
|