dolibarr  16.0.5
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 require '../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 
30 $langs->load("admin");
31 
32 if (!$user->admin) {
34 }
35 
36 $actionsave = GETPOST("save");
37 
38 // Sauvegardes parametres
39 if ($actionsave) {
40  $i = 0;
41 
42  $db->begin();
43 
44  $i += dolibarr_set_const($db, 'WEBSERVICES_KEY', GETPOST("WEBSERVICES_KEY"), 'chaine', 0, '', $conf->entity);
45 
46  if ($i >= 1) {
47  $db->commit();
48  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
49  } else {
50  $db->rollback();
51  setEventMessages($langs->trans("Error"), null, 'errors');
52  }
53 }
54 
55 
56 /*
57  * View
58  */
59 
60 llxHeader();
61 
62 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
63 
64 print load_fiche_titre($langs->trans("WebServicesSetup"), $linkback, 'title_setup');
65 
66 print '<span class="opacitymedium">'.$langs->trans("WebServicesDesc")."</span><br>\n";
67 print "<br>\n";
68 
69 print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
70 print '<input type="hidden" name="token" value="'.newToken().'">';
71 print '<input type="hidden" name="action" value="save">';
72 
73 print '<table class="noborder centpercent">';
74 
75 print '<tr class="liste_titre">';
76 print "<td>".$langs->trans("Parameter")."</td>";
77 print "<td>".$langs->trans("Value")."</td>";
78 //print "<td>".$langs->trans("Examples")."</td>";
79 print "<td>&nbsp;</td>";
80 print "</tr>";
81 
82 print '<tr class="oddeven">';
83 print '<td class="fieldrequired">'.$langs->trans("KeyForWebServicesAccess").'</td>';
84 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">';
85 if (!empty($conf->use_javascript_ajax)) {
86  print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
87 }
88 print '</td>';
89 print '<td>&nbsp;</td>';
90 print '</tr>';
91 
92 print '</table>';
93 
94 print $form->buttonsSaveCancel("Save", '');
95 
96 print '</form>';
97 
98 print '<br><br>';
99 
100 // Webservices list
101 $webservices = array(
102  'user' => '',
103  'thirdparty' => '!empty($conf->societe->enabled)',
104  'contact' => '!empty($conf->societe->enabled)',
105  'productorservice' => '(!empty($conf->product->enabled) || !empty($conf->service->enabled))',
106  'order' => '!empty($conf->commande->enabled)',
107  'invoice' => '!empty($conf->facture->enabled)',
108  'supplier_invoice' => '!empty($conf->fournisseur->enabled)',
109  'actioncomm' => '!empty($conf->agenda->enabled)',
110  'category' => '!empty($conf->categorie->enabled)',
111  'project' => '!empty($conf->project->enabled)',
112  'other' => ''
113 );
114 
115 
116 // WSDL
117 print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>';
118 foreach ($webservices as $name => $right) {
119  if (!empty($right) && !verifCond($right)) {
120  continue;
121  }
122  $url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php?wsdl';
123  print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
124 }
125 print '<br>';
126 
127 
128 // Endpoint
129 print '<u>'.$langs->trans("EndPointIs").':</u><br>';
130 foreach ($webservices as $name => $right) {
131  if (!empty($right) && !verifCond($right)) {
132  continue;
133  }
134  $url = DOL_MAIN_URL_ROOT.'/webservices/server_'.$name.'.php';
135  print img_picto('', 'globe').' <a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$url."</a><br>\n";
136 }
137 print '<br>';
138 
139 
140 print '<br>';
141 print $langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php');
142 
143 if (!empty($conf->use_javascript_ajax)) {
144  print "\n".'<script type="text/javascript">';
145  print '$(document).ready(function () {
146  $("#generate_token").click(function() {
147  $.get( "'.DOL_URL_ROOT.'/core/ajax/security.php", {
148  action: \'getrandompassword\',
149  generic: true
150  },
151  function(token) {
152  $("#WEBSERVICES_KEY").val(token);
153  });
154  });
155  });';
156  print '</script>';
157 }
158 
159 // End of page
160 llxFooter();
161 $db->close();
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
verifCond
verifCond($strToEvaluate)
Verify if condition in string is ok or not.
Definition: functions.lib.php:8582
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
llxFooter
llxFooter()
Footer empty.
Definition: index.php:71
llxHeader
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
dolibarr_set_const
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:627
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933