2009-05-08 14:08:54 +02:00
|
|
|
<?php
|
2012-10-26 15:20:47 +02:00
|
|
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.org>
|
|
|
|
|
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
2018-10-27 14:43:12 +02:00
|
|
|
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
2011-09-07 17:14:40 +02:00
|
|
|
*
|
2009-05-08 14:08:54 +02: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
|
2009-05-08 14:08:54 +02: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/>.
|
2009-05-08 14:08:54 +02:00
|
|
|
*/
|
|
|
|
|
|
2010-07-21 14:35:56 +02:00
|
|
|
/**
|
2015-11-22 17:17:06 +01:00
|
|
|
* \file htdocs/webservices/admin/index.php
|
2009-05-08 14:08:54 +02:00
|
|
|
* \ingroup webservices
|
|
|
|
|
* \brief Page to setup webservices module
|
|
|
|
|
*/
|
|
|
|
|
|
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';
|
2009-05-08 14:08:54 +02:00
|
|
|
|
|
|
|
|
$langs->load("admin");
|
|
|
|
|
|
2021-02-26 13:10:10 +01:00
|
|
|
if (!$user->admin) {
|
2012-10-26 15:20:47 +02:00
|
|
|
accessforbidden();
|
2021-02-26 13:10:10 +01:00
|
|
|
}
|
2009-05-08 14:08:54 +02:00
|
|
|
|
2019-11-13 19:35:39 +01:00
|
|
|
$actionsave = GETPOST("save");
|
2010-12-01 22:16:28 +01:00
|
|
|
|
|
|
|
|
// Sauvegardes parametres
|
2021-02-26 13:10:10 +01:00
|
|
|
if ($actionsave) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$i = 0;
|
2010-12-01 22:16:28 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
$db->begin();
|
2010-12-01 22:16:28 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
$i += dolibarr_set_const($db, 'WEBSERVICES_KEY', GETPOST("WEBSERVICES_KEY"), 'chaine', 0, '', $conf->entity);
|
2010-12-01 22:16:28 +01:00
|
|
|
|
2021-02-26 13:10:10 +01:00
|
|
|
if ($i >= 1) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$db->commit();
|
|
|
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
2021-02-26 13:10:10 +01:00
|
|
|
} else {
|
2020-10-31 14:32:18 +01:00
|
|
|
$db->rollback();
|
|
|
|
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
|
|
|
|
}
|
2009-05-08 14:08:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
llxHeader();
|
|
|
|
|
|
2019-11-13 19:35:39 +01:00
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
2020-12-12 18:37:51 +01:00
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
print load_fiche_titre($langs->trans("WebServicesSetup"), $linkback, 'title_setup');
|
2009-05-08 14:08:54 +02:00
|
|
|
|
2020-02-21 20:14:55 +01:00
|
|
|
print '<span class="opacitymedium">'.$langs->trans("WebServicesDesc")."</span><br>\n";
|
2010-12-01 22:16:28 +01:00
|
|
|
print "<br>\n";
|
|
|
|
|
|
2020-12-12 18:37:51 +01:00
|
|
|
print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
2019-12-18 23:12:31 +01:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2020-12-12 18:37:51 +01:00
|
|
|
print '<input type="hidden" name="action" value="save">';
|
|
|
|
|
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="noborder centpercent">';
|
2010-12-01 22:16:28 +01:00
|
|
|
|
2012-07-11 15:55:56 +02:00
|
|
|
print '<tr class="liste_titre">';
|
2010-12-01 22:16:28 +01:00
|
|
|
print "<td>".$langs->trans("Parameter")."</td>";
|
|
|
|
|
print "<td>".$langs->trans("Value")."</td>";
|
|
|
|
|
//print "<td>".$langs->trans("Examples")."</td>";
|
|
|
|
|
print "<td> </td>";
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
2020-12-12 18:37:51 +01:00
|
|
|
print '<tr class="oddeven">';
|
2012-07-11 15:55:56 +02:00
|
|
|
print '<td class="fieldrequired">'.$langs->trans("KeyForWebServicesAccess").'</td>';
|
2019-11-13 19:35:39 +01:00
|
|
|
print '<td><input type="text" class="flat" id="WEBSERVICES_KEY" name="WEBSERVICES_KEY" value="'.(GETPOST('WEBSERVICES_KEY') ?GETPOST('WEBSERVICES_KEY') : (!empty($conf->global->WEBSERVICES_KEY) ? $conf->global->WEBSERVICES_KEY : '')).'" size="40">';
|
2021-02-26 13:10:10 +01:00
|
|
|
if (!empty($conf->use_javascript_ajax)) {
|
2012-10-26 15:20:47 +02:00
|
|
|
print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
|
2021-02-26 13:10:10 +01:00
|
|
|
}
|
2012-10-26 15:20:47 +02:00
|
|
|
print '</td>';
|
2012-07-11 15:55:56 +02:00
|
|
|
print '<td> </td>';
|
|
|
|
|
print '</tr>';
|
2010-12-01 22:16:28 +01:00
|
|
|
|
|
|
|
|
print '</table>';
|
|
|
|
|
|
2021-08-20 14:41:30 +02:00
|
|
|
print $form->buttonsSaveCancel("Save", '');
|
2009-05-08 14:08:54 +02:00
|
|
|
|
2010-12-01 22:16:28 +01:00
|
|
|
print '</form>';
|
2009-05-08 14:08:54 +02:00
|
|
|
|
|
|
|
|
print '<br><br>';
|
|
|
|
|
|
2013-01-22 11:28:53 +01:00
|
|
|
// Webservices list
|
|
|
|
|
$webservices = array(
|
|
|
|
|
'user' => '',
|
|
|
|
|
'thirdparty' => '!empty($conf->societe->enabled)',
|
2013-10-25 11:39:14 +02:00
|
|
|
'contact' => '!empty($conf->societe->enabled)',
|
2013-01-22 11:28:53 +01:00
|
|
|
'productorservice' => '(!empty($conf->product->enabled) || !empty($conf->service->enabled))',
|
|
|
|
|
'order' => '!empty($conf->commande->enabled)',
|
|
|
|
|
'invoice' => '!empty($conf->facture->enabled)',
|
|
|
|
|
'supplier_invoice' => '!empty($conf->fournisseur->enabled)',
|
|
|
|
|
'actioncomm' => '!empty($conf->agenda->enabled)',
|
|
|
|
|
'category' => '!empty($conf->categorie->enabled)',
|
2022-06-14 17:53:17 +02:00
|
|
|
'project' => '!empty($conf->project->enabled)',
|
2020-10-31 14:32:18 +01:00
|
|
|
'other' => ''
|
2013-01-22 11:28:53 +01:00
|
|
|
);
|
|
|
|
|
|
2009-05-08 14:08:54 +02:00
|
|
|
|
2010-12-01 22:16:28 +01:00
|
|
|
// WSDL
|
2009-05-08 14:08:54 +02:00
|
|
|
print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>';
|
2021-02-26 13:10:10 +01:00
|
|
|
foreach ($webservices as $name => $right) {
|
|
|
|
|
if (!empty($right) && !verifCond($right)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-11-13 19:35:39 +01:00
|
|
|
$url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php?wsdl';
|
2021-11-22 02:35:55 +01:00
|
|
|
print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
|
2012-12-13 19:09:40 +01:00
|
|
|
}
|
2009-05-08 14:08:54 +02:00
|
|
|
print '<br>';
|
|
|
|
|
|
2010-12-01 22:16:28 +01:00
|
|
|
|
|
|
|
|
// Endpoint
|
2009-05-08 14:08:54 +02:00
|
|
|
print '<u>'.$langs->trans("EndPointIs").':</u><br>';
|
2021-02-26 13:10:10 +01:00
|
|
|
foreach ($webservices as $name => $right) {
|
|
|
|
|
if (!empty($right) && !verifCond($right)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-11-13 19:35:39 +01:00
|
|
|
$url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php';
|
2021-11-22 02:35:55 +01:00
|
|
|
print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
|
2012-12-13 19:09:40 +01:00
|
|
|
}
|
2009-05-08 14:08:54 +02:00
|
|
|
print '<br>';
|
|
|
|
|
|
2010-12-01 22:16:28 +01:00
|
|
|
|
2012-07-22 02:33:21 +02:00
|
|
|
print '<br>';
|
|
|
|
|
print $langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php');
|
|
|
|
|
|
2021-02-26 13:10:10 +01:00
|
|
|
if (!empty($conf->use_javascript_ajax)) {
|
2012-10-26 15:20:47 +02:00
|
|
|
print "\n".'<script type="text/javascript">';
|
|
|
|
|
print '$(document).ready(function () {
|
|
|
|
|
$("#generate_token").click(function() {
|
|
|
|
|
$.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
|
|
|
|
|
action: \'getrandompassword\',
|
|
|
|
|
generic: true
|
|
|
|
|
},
|
|
|
|
|
function(token) {
|
|
|
|
|
$("#WEBSERVICES_KEY").val(token);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});';
|
|
|
|
|
print '</script>';
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-04 15:58:05 +02:00
|
|
|
// End of page
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2012-10-26 15:20:47 +02:00
|
|
|
$db->close();
|