dolibarr 21.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
32
42$langs->load("admin");
43
44if (!$user->admin) {
46}
47
48$actionsave = GETPOST("save");
49
50// Sauvegardes parameters
51if ($actionsave) {
52 $i = 0;
53
54 $db->begin();
55
56 $i += dolibarr_set_const($db, 'WEBSERVICES_KEY', GETPOST("WEBSERVICES_KEY"), 'chaine', 0, '', $conf->entity);
57
58 if ($i >= 1) {
59 $db->commit();
60 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
61 } else {
62 $db->rollback();
63 setEventMessages($langs->trans("Error"), null, 'errors');
64 }
65}
66
67
68/*
69 * View
70 */
71
72llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-webservices page-admin_index');
73
74$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
75
76print load_fiche_titre($langs->trans("WebServicesSetup"), $linkback, 'title_setup');
77
78print '<span class="opacitymedium">'.$langs->trans("WebServicesDesc")."</span><br>\n";
79print "<br>\n";
80
81print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
82print '<input type="hidden" name="token" value="'.newToken().'">';
83print '<input type="hidden" name="action" value="save">';
84
85print '<table class="noborder centpercent">';
86
87print '<tr class="liste_titre">';
88print "<td>".$langs->trans("Parameter")."</td>";
89print "<td>".$langs->trans("Value")."</td>";
90//print "<td>".$langs->trans("Examples")."</td>";
91print "<td>&nbsp;</td>";
92print "</tr>";
93
94print '<tr class="oddeven">';
95print '<td class="fieldrequired">'.$langs->trans("KeyForWebServicesAccess").'</td>';
96print '<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">';
97if (!empty($conf->use_javascript_ajax)) {
98 print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
99}
100print '</td>';
101print '<td>&nbsp;</td>';
102print '</tr>';
103
104print '</table>';
105
106print $form->buttonsSaveCancel("Save", '');
107
108print '</form>';
109
110print '<br><br>';
111
112// Webservices list
113$webservices = array(
114 'user' => '',
115 'thirdparty' => 'isModEnabled("societe")',
116 'contact' => 'isModEnabled("societe")',
117 'productorservice' => '(isModEnabled("product") || isModEnabled("service"))',
118 'order' => 'isModEnabled("order")',
119 'invoice' => 'isModEnabled("invoice")',
120 'supplier_invoice' => 'isModEnabled("fournisseur")',
121 'actioncomm' => 'isModEnabled("agenda")',
122 'category' => 'isModEnabled("category")',
123 'project' => 'isModEnabled("project")',
124 'other' => ''
125);
126
127
128// WSDL
129print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>';
130foreach ($webservices as $name => $right) {
131 if (!empty($right) && !verifCond($right)) {
132 continue;
133 }
134 $url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php?wsdl';
135 print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
136}
137print '<br>';
138
139
140// Endpoint
141print '<u>'.$langs->trans("EndPointIs").':</u><br>';
142foreach ($webservices as $name => $right) {
143 if (!empty($right) && !verifCond($right)) {
144 continue;
145 }
146 $url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php';
147 print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
148}
149print '<br>';
150
151
152print '<br>';
153print $langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php');
154
155$constname = 'WEBSERVICES_KEY';
156
157print dolJSToSetRandomPassword($constname);
158
159
160// End of page
161llxFooter();
162$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).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.