dolibarr 20.0.2
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.org>
4 * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
31
32$langs->load("admin");
33
34if (!$user->admin) {
36}
37
38$actionsave = GETPOST("save");
39
40// Sauvegardes parameters
41if ($actionsave) {
42 $i = 0;
43
44 $db->begin();
45
46 $i += dolibarr_set_const($db, 'WEBSERVICES_KEY', GETPOST("WEBSERVICES_KEY"), 'chaine', 0, '', $conf->entity);
47
48 if ($i >= 1) {
49 $db->commit();
50 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
51 } else {
52 $db->rollback();
53 setEventMessages($langs->trans("Error"), null, 'errors');
54 }
55}
56
57
58/*
59 * View
60 */
61
62llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-webservices page-admin_index');
63
64$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
65
66print load_fiche_titre($langs->trans("WebServicesSetup"), $linkback, 'title_setup');
67
68print '<span class="opacitymedium">'.$langs->trans("WebServicesDesc")."</span><br>\n";
69print "<br>\n";
70
71print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
72print '<input type="hidden" name="token" value="'.newToken().'">';
73print '<input type="hidden" name="action" value="save">';
74
75print '<table class="noborder centpercent">';
76
77print '<tr class="liste_titre">';
78print "<td>".$langs->trans("Parameter")."</td>";
79print "<td>".$langs->trans("Value")."</td>";
80//print "<td>".$langs->trans("Examples")."</td>";
81print "<td>&nbsp;</td>";
82print "</tr>";
83
84print '<tr class="oddeven">';
85print '<td class="fieldrequired">'.$langs->trans("KeyForWebServicesAccess").'</td>';
86print '<td><input type="text" class="flat" id="WEBSERVICES_KEY" name="WEBSERVICES_KEY" value="'.(GETPOST('WEBSERVICES_KEY') ? GETPOST('WEBSERVICES_KEY') : (getDolGlobalString('WEBSERVICES_KEY') ? $conf->global->WEBSERVICES_KEY : '')).'" size="40">';
87if (!empty($conf->use_javascript_ajax)) {
88 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
89}
90print '</td>';
91print '<td>&nbsp;</td>';
92print '</tr>';
93
94print '</table>';
95
96print $form->buttonsSaveCancel("Save", '');
97
98print '</form>';
99
100print '<br><br>';
101
102// Webservices list
103$webservices = array(
104 'user' => '',
105 'thirdparty' => 'isModEnabled("societe")',
106 'contact' => 'isModEnabled("societe")',
107 'productorservice' => '(isModEnabled("product") || isModEnabled("service"))',
108 'order' => 'isModEnabled("order")',
109 'invoice' => 'isModEnabled("invoice")',
110 'supplier_invoice' => 'isModEnabled("fournisseur")',
111 'actioncomm' => 'isModEnabled("agenda")',
112 'category' => 'isModEnabled("category")',
113 'project' => 'isModEnabled("project")',
114 'other' => ''
115);
116
117
118// WSDL
119print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>';
120foreach ($webservices as $name => $right) {
121 if (!empty($right) && !verifCond($right)) {
122 continue;
123 }
124 $url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php?wsdl';
125 print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
126}
127print '<br>';
128
129
130// Endpoint
131print '<u>'.$langs->trans("EndPointIs").':</u><br>';
132foreach ($webservices as $name => $right) {
133 if (!empty($right) && !verifCond($right)) {
134 continue;
135 }
136 $url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php';
137 print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
138}
139print '<br>';
140
141
142print '<br>';
143print $langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php');
144
145$constname = 'WEBSERVICES_KEY';
146
147print dolJSToSetRandomPassword($constname);
148
149
150// End of page
151llxFooter();
152$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
verifCond($strToEvaluate, $onlysimplestring='1')
Verify if condition in string is ok or not.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript to autoset a generated password using default module into a HTML element.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.