dolibarr  x.y.z
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
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 
31 $langs->load("admin");
32 
33 if (!$user->admin) {
35 }
36 
37 $actionsave = GETPOST("save");
38 
39 // Sauvegardes parametres
40 if ($actionsave) {
41  $i = 0;
42 
43  $db->begin();
44 
45  $i += dolibarr_set_const($db, 'WEBSERVICES_KEY', GETPOST("WEBSERVICES_KEY"), 'chaine', 0, '', $conf->entity);
46 
47  if ($i >= 1) {
48  $db->commit();
49  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
50  } else {
51  $db->rollback();
52  setEventMessages($langs->trans("Error"), null, 'errors');
53  }
54 }
55 
56 
57 /*
58  * View
59  */
60 
61 llxHeader();
62 
63 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
64 
65 print load_fiche_titre($langs->trans("WebServicesSetup"), $linkback, 'title_setup');
66 
67 print '<span class="opacitymedium">'.$langs->trans("WebServicesDesc")."</span><br>\n";
68 print "<br>\n";
69 
70 print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
71 print '<input type="hidden" name="token" value="'.newToken().'">';
72 print '<input type="hidden" name="action" value="save">';
73 
74 print '<table class="noborder centpercent">';
75 
76 print '<tr class="liste_titre">';
77 print "<td>".$langs->trans("Parameter")."</td>";
78 print "<td>".$langs->trans("Value")."</td>";
79 //print "<td>".$langs->trans("Examples")."</td>";
80 print "<td>&nbsp;</td>";
81 print "</tr>";
82 
83 print '<tr class="oddeven">';
84 print '<td class="fieldrequired">'.$langs->trans("KeyForWebServicesAccess").'</td>';
85 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">';
86 if (!empty($conf->use_javascript_ajax)) {
87  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
88 }
89 print '</td>';
90 print '<td>&nbsp;</td>';
91 print '</tr>';
92 
93 print '</table>';
94 
95 print $form->buttonsSaveCancel("Save", '');
96 
97 print '</form>';
98 
99 print '<br><br>';
100 
101 // Webservices list
102 $webservices = array(
103  'user' => '',
104  'thirdparty' => 'isModEnabled("societe")',
105  'contact' => 'isModEnabled("societe")',
106  'productorservice' => '(isModEnabled("product") || isModEnabled("service"))',
107  'order' => 'isModEnabled("commande")',
108  'invoice' => 'isModEnabled("facture")',
109  'supplier_invoice' => 'isModEnabled("fournisseur")',
110  'actioncomm' => 'isModEnabled("agenda")',
111  'category' => 'isModEnabled("categorie")',
112  'project' => 'isModEnabled("project")',
113  'other' => ''
114 );
115 
116 
117 // WSDL
118 print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>';
119 foreach ($webservices as $name => $right) {
120  if (!empty($right) && !verifCond($right)) {
121  continue;
122  }
123  $url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php?wsdl';
124  print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
125 }
126 print '<br>';
127 
128 
129 // Endpoint
130 print '<u>'.$langs->trans("EndPointIs").':</u><br>';
131 foreach ($webservices as $name => $right) {
132  if (!empty($right) && !verifCond($right)) {
133  continue;
134  }
135  $url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php';
136  print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
137 }
138 print '<br>';
139 
140 
141 print '<br>';
142 print $langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php');
143 
144 $constname = 'WEBSERVICES_KEY';
145 
146 print dolJSToSetRandomPassword($constname);
147 
148 
149 // End of page
150 llxFooter();
151 $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).
Definition: admin.lib.php:632
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $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.
verifCond($strToEvaluate)
Verify if condition in string is ok or not.
llxFooter()
Footer empty.
Definition: index.php:71
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
Definition: index.php:63
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token')
Ouput javacript 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.