2012-01-11 18:43:38 +01:00
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
2012-07-29 15:55:19 +02:00
|
|
|
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
2012-01-11 18:43:38 +01:00
|
|
|
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
|
|
|
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
2018-10-27 14:43:12 +02:00
|
|
|
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
|
2013-08-20 16:50:33 +02:00
|
|
|
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
2024-09-18 03:27:25 +02:00
|
|
|
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
2024-09-20 01:45:17 +02:00
|
|
|
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
2012-01-11 18:43:38 +01: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 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2012-01-11 18:43:38 +01: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 21:55:30 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2012-01-11 18:43:38 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2013-06-05 15:44:42 +02:00
|
|
|
* \file htdocs/admin/spip.php
|
2012-07-29 15:55:19 +02:00
|
|
|
* \ingroup mailmanspip
|
|
|
|
|
* \brief Page to setup the module MailmanSpip (SPIP)
|
2012-01-11 18:43:38 +01:00
|
|
|
*/
|
|
|
|
|
|
2022-09-07 20:08:59 +02:00
|
|
|
// Load Dolibarr environment
|
2013-06-05 15:44:42 +02:00
|
|
|
require '../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php';
|
2013-06-06 18:31:33 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
2012-01-11 18:43:38 +01:00
|
|
|
|
2024-11-04 23:53:20 +01:00
|
|
|
/**
|
|
|
|
|
* @var Conf $conf
|
|
|
|
|
* @var DoliDB $db
|
|
|
|
|
* @var HookManager $hookmanager
|
|
|
|
|
* @var Translate $langs
|
|
|
|
|
* @var User $user
|
|
|
|
|
*/
|
|
|
|
|
|
2018-05-26 18:52:14 +02:00
|
|
|
// Load translation files required by the page
|
2018-05-11 22:31:17 +02:00
|
|
|
$langs->loadLangs(array("admin", "members", "mailmanspip"));
|
2012-01-11 18:43:38 +01:00
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if (!$user->admin) {
|
|
|
|
|
accessforbidden();
|
|
|
|
|
}
|
2012-01-11 18:43:38 +01:00
|
|
|
|
|
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
$action = GETPOST('action', 'aZ09');
|
2012-01-11 18:43:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
2024-11-10 11:16:23 +01:00
|
|
|
$error = 0;
|
2012-01-11 18:43:38 +01:00
|
|
|
|
|
|
|
|
// Action mise a jour ou ajout d'une constante
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($action == 'update' || $action == 'add') {
|
2020-02-16 19:33:58 +01:00
|
|
|
$constnamearray = GETPOST("constname", 'array');
|
|
|
|
|
$constvaluearray = GETPOST("constvalue", 'array');
|
|
|
|
|
$constnotearray = GETPOST("constnote", 'array');
|
2012-01-11 18:43:38 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
// Action mise a jour ou ajout d'une constante
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($action == 'update' || $action == 'add') {
|
|
|
|
|
foreach ($constnamearray as $key => $val) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$constname = dol_escape_htmltag($constnamearray[$key]);
|
|
|
|
|
$constvalue = dol_escape_htmltag($constvaluearray[$key]);
|
|
|
|
|
$constnote = dol_escape_htmltag($constnotearray[$key]);
|
|
|
|
|
|
2024-09-20 01:45:17 +02:00
|
|
|
$res = dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, $constnote, $conf->entity);
|
2020-10-31 14:32:18 +01:00
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if (!($res > 0)) {
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if (!$error) {
|
2020-10-31 14:32:18 +01:00
|
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
|
|
|
|
} else {
|
|
|
|
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-01-11 18:43:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Action activation d'un sous module du module adherent
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($action == 'set') {
|
2024-03-28 17:10:22 +01:00
|
|
|
$result = dolibarr_set_const($db, GETPOST("name", 'aZ09'), GETPOST("value"), '', 0, '', $conf->entity);
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($result < 0) {
|
2020-10-31 14:32:18 +01:00
|
|
|
dol_print_error($db);
|
|
|
|
|
}
|
2012-01-11 18:43:38 +01:00
|
|
|
}
|
|
|
|
|
|
2024-01-11 09:59:52 +01:00
|
|
|
// Action deactivation d'un sous module du module adherent
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($action == 'unset') {
|
2024-03-28 17:10:22 +01:00
|
|
|
$result = dolibarr_del_const($db, GETPOST("name", 'aZ09'), $conf->entity);
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($result < 0) {
|
2020-10-31 14:32:18 +01:00
|
|
|
dol_print_error($db);
|
|
|
|
|
}
|
2012-01-11 18:43:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-18 23:47:25 +01:00
|
|
|
$help_url = '';
|
2012-01-11 18:43:38 +01:00
|
|
|
|
2024-06-08 17:03:08 +02:00
|
|
|
llxHeader('', $langs->trans("MailmanSpipSetup"), $help_url, '', 0, 0, '', '', '', 'mod-admin page-spip');
|
2012-01-11 18:43:38 +01:00
|
|
|
|
|
|
|
|
|
2020-02-18 23:47:25 +01:00
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
2019-01-27 11:55:16 +01:00
|
|
|
print load_fiche_titre($langs->trans("MailmanSpipSetup"), $linkback, 'title_setup');
|
2012-01-11 18:43:38 +01:00
|
|
|
|
|
|
|
|
|
2012-09-13 11:52:50 +02:00
|
|
|
$head = mailmanspip_admin_prepare_head();
|
2012-01-11 18:43:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Spip
|
|
|
|
|
*/
|
2023-10-24 17:00:13 +02:00
|
|
|
if (getDolGlobalString('ADHERENT_USE_SPIP')) {
|
2015-10-23 14:40:45 +02:00
|
|
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
2019-12-18 23:12:31 +01:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2019-09-04 11:33:07 +02:00
|
|
|
print '<input type="hidden" name="action" value="update">';
|
2019-05-21 15:31:56 +02:00
|
|
|
|
2020-10-22 22:50:03 +02:00
|
|
|
print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), -1, 'user');
|
2019-05-21 15:31:56 +02:00
|
|
|
|
2020-10-31 14:32:18 +01: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>';
|
2024-01-11 09:59:52 +01:00
|
|
|
// Edition des variables globales
|
2020-10-31 14:32:18 +01:00
|
|
|
$constantes = array(
|
|
|
|
|
'ADHERENT_SPIP_SERVEUR',
|
|
|
|
|
'ADHERENT_SPIP_DB',
|
|
|
|
|
'ADHERENT_SPIP_USER',
|
|
|
|
|
'ADHERENT_SPIP_PASS'
|
2012-01-11 18:43:38 +01:00
|
|
|
);
|
|
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print load_fiche_titre($langs->trans('SPIPTitle'), $link, '');
|
2013-05-09 22:39:31 +02:00
|
|
|
print '<br>';
|
2019-05-21 15:31:56 +02:00
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
form_constantes($constantes, 2);
|
2019-05-21 15:31:56 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print dol_get_fiche_end();
|
2015-10-23 14:40:45 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
|
2019-05-21 15:31:56 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '</form>';
|
2020-05-21 09:35:30 +02:00
|
|
|
} else {
|
2020-10-31 14:32:18 +01:00
|
|
|
print dol_get_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user');
|
2019-05-21 15:31:56 +02:00
|
|
|
|
2021-09-19 18:03:38 +02:00
|
|
|
$link = '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value=1&name=ADHERENT_USE_SPIP">';
|
2020-10-31 14:32:18 +01: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 15:31:56 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print dol_get_fiche_end();
|
2012-01-11 18:43:38 +01:00
|
|
|
}
|
|
|
|
|
|
2018-07-28 18:03:14 +02:00
|
|
|
// End of page
|
2012-01-11 18:43:38 +01:00
|
|
|
llxFooter();
|
|
|
|
|
$db->close();
|