diff --git a/htdocs/api/admin/api.php b/htdocs/api/admin/api.php new file mode 100644 index 00000000000..0e1673715d2 --- /dev/null +++ b/htdocs/api/admin/api.php @@ -0,0 +1,138 @@ + + * Copyright (C) 2005-2010 Laurent Destailleur + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2015 Regis Houssin + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (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 + * along with this program. If not, see . + */ + +/** + * \file htdocs/api/admin/api.php + * \ingroup api + * \brief Page to setup api module + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + +$langs->load("admin"); + +if (! $user->admin) + accessforbidden(); + +$actionsave=GETPOST("save"); + +// Sauvegardes parametres +if ($actionsave) +{ + $i=0; + + $db->begin(); + + $i+=dolibarr_set_const($db,'API_KEY',trim(GETPOST("API_KEY")),'chaine',0,'',$conf->entity); + + if ($i >= 1) + { + $db->commit(); + setEventMessage($langs->trans("SetupSaved")); + } + else + { + $db->rollback(); + setEventMessage($langs->trans("Error"), 'errors'); + } +} + + +/* + * View + */ + +llxHeader(); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("ApiSetup"),$linkback,'title_setup'); + +print $langs->trans("ApiDesc")."
\n"; +print "
\n"; + +print '
'; +print ''; +print ''; + +print ''; +print ""; +print ""; +print ""; +print ""; + +print ''; +print ''; +print ''; +print ''; +print ''; + +print '
".$langs->trans("Parameter")."".$langs->trans("Value")." 
'.$langs->trans("KeyForApiAccess").''; +if (! empty($conf->use_javascript_ajax)) + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); +print ' 
'; + +print '
'; +print ''; +print '
'; + +print '
'; + +print '

'; + +// API endpoint +print ''.$langs->trans("ApiEndPointIs").':
'; +$url=DOL_MAIN_URL_ROOT.'/public/api/'; +print img_picto('','object_globe.png').' '.$url."
\n"; +$url=DOL_MAIN_URL_ROOT.'/public/api/.json'; +print img_picto('','object_globe.png').' '.$url."
\n"; + +// Explorer +print ''.$langs->trans("ApiExporerIs").':
'; +$url=DOL_MAIN_URL_ROOT.'/public/api/explorer/index.html'; +print img_picto('','object_globe.png').' '.$url."
\n"; + +print '
'; + + +print '
'; +print $langs->trans("OnlyActiveElementsAreExposed", DOL_URL_ROOT.'/admin/modules.php'); + +if (! empty($conf->use_javascript_ajax)) +{ + print "\n".''; +} + + +llxFooter(); +$db->close(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f6041a2abf0..973390d7994 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -526,6 +526,8 @@ Module2500Name=Electronic Content Management Module2500Desc=Save and share documents Module2600Name=WebServices Module2600Desc=Enable the Dolibarr web services server +Module2610Name=Api +Module2610Desc=Enable the Dolibarr REST API Module2650Name=WebServices (client) Module2650Desc=Enable the Dolibarr web services client (Can be used to push data/requests to external servers. Supplier orders supported only for the moment) Module2700Name=Gravatar @@ -1554,6 +1556,13 @@ WebServicesSetup=Webservices module setup WebServicesDesc=By enabling this module, Dolibarr become a web service server to provide miscellaneous web services. WSDLCanBeDownloadedHere=WSDL descriptor files of provided services can be download here EndPointIs=SOAP clients must send their requests to the Dolibarr endpoint available at Url +##### API #### +ApiSetup=API module setup +ApiDesc=By enabling this module, Dolibarr become a REST server to provide miscellaneous web services. +KeyForApiAccess=Key to use API (parameter "api_key") +ApiEndPointIs=You can access to the API at url +ApiExporerIs=You can explore the API at url +OnlyActiveElementsAreExposed=Only elements from enabled modules are exposed ##### Bank ##### BankSetupModule=Bank module setup FreeLegalTextOnChequeReceipts=Free text on cheque receipts