diff --git a/htdocs/ifttt/admin/index.php b/htdocs/ifttt/admin/index.php
index de3abbe3c2a..ec8fb8c756c 100644
--- a/htdocs/ifttt/admin/index.php
+++ b/htdocs/ifttt/admin/index.php
@@ -38,11 +38,12 @@ if (! $user->admin)
$action=GETPOST('action', 'aZ09');
-if ($action == 'setproductionmode')
+if ($action == 'set')
{
- $status = GETPOST('status', 'alpha');
+ $res1 = dolibarr_set_const($db, 'IFTTT_SERVICE_KEY', GETPOST('IFTTT_SERVICE_KEY', 'alpha'), 'chaine', 0, '', 0);
+ $res2 = dolibarr_set_const($db, 'IFTTT_DOLIBARR_ENDPOINT_SECUREKEY', GETPOST('IFTTT_DOLIBARR_ENDPOINT_SECUREKEY', 'alpha'), 'chaine', 0, '', 0);
- if (dolibarr_set_const($db, 'IFTTT_PRODUCTION_MODE', $status, 'chaine', 0, '', 0) > 0)
+ if ($res1 > 0 && $res2)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
@@ -66,38 +67,44 @@ print load_fiche_titre($langs->trans("IFTTTSetup"), $linkback, 'title_setup');
print $langs->trans("IFTTTDesc")."
\n";
print "
\n";
-//print '
';
+
print '
';
-/*
+
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
@@ -106,26 +113,13 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain
// Show message
$message='';
-$url=$urlwithroot.'/api/index.php/login?login=auserlogin&password=thepassword[&reset=1]';
-$message.=$langs->trans("UrlToGetKeyToUseAPIs").':
';
+$url=$urlwithroot.'/ifttt/index.php?securekey='.$conf->global->IFTTT_DOLIBARR_ENDPOINT_SECUREKEY;
+$message.=$langs->trans("UrlForIFTTT").':
';
$message.=img_picto('', 'object_globe.png').' '.$url;
print $message;
print '
';
print '
';
-// Explorer
-print ''.$langs->trans("ApiExporerIs").':
';
-if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer'))
-{
- $url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer';
- print img_picto('', 'object_globe.png').' '.$url."
\n";
-}
-else
-{
- print $langs->trans("NotAvailableWithThisDistribution");
-}
-
-*/
llxFooter();
$db->close();
diff --git a/htdocs/public/ifttt/index.php b/htdocs/public/ifttt/index.php
new file mode 100644
index 00000000000..a879dc1d41f
--- /dev/null
+++ b/htdocs/public/ifttt/index.php
@@ -0,0 +1,88 @@
+
+ *
+ * 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/public/ifttt/index.php
+ * \ingroup ifttt
+ * \brief Page to IFTTT endpoint agenda
+ * http://127.0.0.1/dolibarr/public/ifttt/index.php?securekey=...
+ */
+
+if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
+if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show
+if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
+if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
+if (! defined('NOLOGIN')) define("NOLOGIN", 1); // This means this output page does not require to be logged.
+if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
+
+// This is a wrapper, so header is empty
+
+/**
+ * Header function
+ *
+ * @return void
+ */
+function llxHeaderVierge()
+{
+ print 'IFTTT API';
+}
+/**
+ * Footer function
+ *
+ * @return void
+ */
+function llxFooterVierge()
+{
+ print '';
+}
+
+
+require '../../main.inc.php';
+
+// Security check
+if (empty($conf->ifttt->enabled)) accessforbidden('', 0, 0, 1);
+
+// Check config
+if (empty($conf->global->IFTTT_DOLIBARR_ENDPOINT_SECUREKEY))
+{
+ $user->getrights();
+
+ llxHeaderVierge();
+ print 'Module Agenda was not configured properly.
';
+ llxFooterVierge();
+ exit;
+}
+
+// Check exportkey
+if (empty($_GET["securekey"]) || $conf->global->IFTTT_DOLIBARR_ENDPOINT_SECUREKEY != $_GET["securekey"])
+{
+ $user->getrights();
+
+ llxHeaderVierge();
+ print 'Bad value for securekey.
';
+ llxFooterVierge();
+ exit;
+}
+
+
+// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
+$hookmanager->initHooks(array('iftttapi'));
+
+
+llxHeaderVierge();
+print 'TODO
';
+llxFooterVierge();