2010-03-27 17:35:49 +01:00
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
* Copyright (C) 2003 Eric Seigne <erics@rycks.com>
|
|
|
|
|
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
|
|
|
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
|
|
|
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
2012-04-04 16:53:59 +02:00
|
|
|
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
2024-11-04 23:53:20 +01:00
|
|
|
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
2010-03-27 17:35:49 +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
|
2010-03-27 17:35:49 +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/>.
|
2010-03-27 17:35:49 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-25 03:47:45 +01:00
|
|
|
* \file htdocs/externalsite/admin/index.php
|
2010-04-20 16:27:47 +02:00
|
|
|
* \ingroup externalsite
|
2021-03-25 03:47:45 +01:00
|
|
|
* \brief Page to setup module external site
|
2010-03-27 17:35:49 +01:00
|
|
|
*/
|
|
|
|
|
|
2021-02-25 22:50:40 +01:00
|
|
|
if (!defined('NOSCANPOSTFORINJECTION')) {
|
|
|
|
|
define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test
|
|
|
|
|
}
|
2018-02-08 19:00:13 +01:00
|
|
|
|
2022-09-07 20:08:59 +02:00
|
|
|
// Load Dolibarr environment
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
2010-03-27 17:35:49 +01:00
|
|
|
|
2024-11-04 23:53:20 +01:00
|
|
|
/**
|
|
|
|
|
* @var Conf $conf
|
|
|
|
|
* @var DoliDB $db
|
2024-11-10 23:47:14 +01:00
|
|
|
* @var Form $form
|
2024-11-04 23:53:20 +01:00
|
|
|
* @var HookManager $hookmanager
|
|
|
|
|
* @var Translate $langs
|
|
|
|
|
* @var User $user
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Load translation files required by the page
|
|
|
|
|
$langs->loadLangs(array('admin', 'other', 'externalsite'));
|
2010-03-27 17:35:49 +01:00
|
|
|
|
2021-02-25 22:50:40 +01:00
|
|
|
if (!$user->admin) {
|
2020-03-23 15:54:02 +01:00
|
|
|
accessforbidden();
|
2021-02-25 22:50:40 +01:00
|
|
|
}
|
2010-03-27 17:35:49 +01:00
|
|
|
|
2020-09-16 19:39:50 +02:00
|
|
|
$action = GETPOST('action', 'aZ09');
|
2011-09-06 11:25:32 +02:00
|
|
|
|
2021-03-25 03:47:45 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
|
|
|
|
|
2024-01-13 19:48:41 +01:00
|
|
|
// Sauvegardes parameters
|
2021-02-25 22:50:40 +01:00
|
|
|
if ($action == 'update') {
|
2020-04-10 10:59:32 +02:00
|
|
|
$i = 0;
|
2010-03-27 17:35:49 +01:00
|
|
|
|
2020-03-23 15:54:02 +01:00
|
|
|
$db->begin();
|
2012-11-04 21:19:12 +01:00
|
|
|
|
2021-03-25 03:44:38 +01:00
|
|
|
$label = GETPOST('EXTERNALSITE_LABEL', 'alphanohtml');
|
|
|
|
|
|
2021-12-17 12:01:25 +01:00
|
|
|
// exturl can be an url or a HTML string
|
2022-01-19 15:20:10 +01:00
|
|
|
$exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml');
|
2023-06-03 13:56:06 +02:00
|
|
|
$exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1, array(), 1);
|
2021-12-17 12:01:25 +01:00
|
|
|
$exturl = dol_string_onlythesehtmlattributes($exturl);
|
2020-03-23 15:54:02 +01:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$i += dolibarr_set_const($db, 'EXTERNALSITE_LABEL', trim($label), 'chaine', 0, '', $conf->entity);
|
|
|
|
|
$i += dolibarr_set_const($db, 'EXTERNALSITE_URL', trim($exturl), 'chaine', 0, '', $conf->entity);
|
2020-03-23 15:54:02 +01:00
|
|
|
|
2021-02-25 22:50:40 +01:00
|
|
|
if ($i >= 2) {
|
2020-03-23 15:54:02 +01:00
|
|
|
$db->commit();
|
|
|
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
2020-05-21 15:05:19 +02:00
|
|
|
} else {
|
2020-03-23 15:54:02 +01:00
|
|
|
$db->rollback();
|
|
|
|
|
setEventMessages($db->lasterror(), null, 'errors');
|
|
|
|
|
}
|
2010-03-27 17:35:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
|
2024-08-10 23:48:11 +02:00
|
|
|
llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-externalsite page-index');
|
2010-03-27 17:35:49 +01:00
|
|
|
|
2020-04-10 10:59:32 +02: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("ExternalSiteSetup"), $linkback, 'title_setup');
|
2013-03-24 07:14:59 +01:00
|
|
|
print '<br>';
|
|
|
|
|
|
2021-03-25 03:44:38 +01:00
|
|
|
print '<span class="opacitymedium">'.$langs->trans("Module100Desc")."</span><br>\n";
|
2012-11-14 11:31:08 +01:00
|
|
|
print '<br>';
|
2010-03-27 17:35:49 +01:00
|
|
|
|
|
|
|
|
print '<form name="externalsiteconfig" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
2019-12-18 23:12:31 +01:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2010-03-27 17:35:49 +01:00
|
|
|
print '<input type="hidden" name="action" value="update">';
|
|
|
|
|
print "<table class=\"noborder\" width=\"100%\">";
|
|
|
|
|
|
|
|
|
|
print "<tr class=\"liste_titre\">";
|
|
|
|
|
print "<td width=\"30%\">".$langs->trans("Parameter")."</td>";
|
|
|
|
|
print "<td>".$langs->trans("Value")."</td>";
|
|
|
|
|
print "<td>".$langs->trans("Examples")."</td>";
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
|
|
|
|
|
print '<tr class="oddeven">';
|
2012-11-04 21:19:12 +01:00
|
|
|
print '<td class="fieldrequired">'.$langs->trans("Label")."</td>";
|
2023-12-04 12:12:12 +01:00
|
|
|
print "<td><input type=\"text\" class=\"flat\" name=\"EXTERNALSITE_LABEL\" value=\"".(GETPOST('EXTERNALSITE_LABEL', 'alpha') ? GETPOST('EXTERNALSITE_LABEL', 'alpha') : ((!getDolGlobalString('EXTERNALSITE_LABEL') || getDolGlobalString('EXTERNALSITE_LABEL') == 'ExternalSite') ? '' : $conf->global->EXTERNALSITE_LABEL))."\" size=\"12\"></td>";
|
2014-11-20 06:34:50 +01:00
|
|
|
print "<td>".$langs->trans("ExampleMyMenuEntry")."</td>";
|
2011-01-24 21:18:59 +01:00
|
|
|
print "</tr>";
|
|
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
|
|
|
|
|
print '<tr class="oddeven">';
|
2012-11-04 21:19:12 +01:00
|
|
|
print '<td class="fieldrequired">'.$langs->trans("ExternalSiteURL")."</td>";
|
2018-02-08 19:00:13 +01:00
|
|
|
print '<td><textarea class="flat minwidth500" name="EXTERNALSITE_URL">';
|
2021-03-27 15:22:48 +01:00
|
|
|
|
2022-01-19 15:20:10 +01:00
|
|
|
$exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml');
|
2023-06-03 13:56:06 +02:00
|
|
|
$exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1, array(), 1);
|
2021-12-17 12:01:25 +01:00
|
|
|
$exturl = dol_string_onlythesehtmlattributes($exturl);
|
2021-03-27 15:22:48 +01:00
|
|
|
|
2023-12-04 12:12:12 +01:00
|
|
|
print(GETPOSTISSET('EXTERNALSITE_URL') ? $exturl : (!getDolGlobalString('EXTERNALSITE_URL') ? '' : $conf->global->EXTERNALSITE_URL));
|
2018-02-08 19:00:13 +01:00
|
|
|
print '</textarea></td>';
|
2010-03-27 17:35:49 +01:00
|
|
|
print "<td>http://localhost/myurl/";
|
2018-02-08 19:00:13 +01:00
|
|
|
print "<br>https://wikipedia.org/";
|
|
|
|
|
print "<br><iframe>...</iframe>";
|
2010-03-27 17:35:49 +01:00
|
|
|
print "</td>";
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
|
|
|
|
print "</table>";
|
|
|
|
|
|
|
|
|
|
|
2021-08-20 14:41:30 +02:00
|
|
|
print $form->buttonsSaveCancel("Save", '');
|
2010-03-27 17:35:49 +01:00
|
|
|
|
|
|
|
|
print "</form>\n";
|
|
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2012-11-04 21:19:12 +01:00
|
|
|
|
|
|
|
|
$db->close();
|