Debug v16
This commit is contained in:
parent
55ddf1eabb
commit
a98599084d
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2015-2018 Frederic France <frederic.france@netlogic.fr>
|
/* Copyright (C) 2015-2018 Frederic France <frederic.france@netlogic.fr>
|
||||||
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
|
* Copyright (C) 2022 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -46,38 +47,47 @@ $action = GETPOST('action', 'aZ09');
|
|||||||
$provider = GETPOST('provider', 'aZ09');
|
$provider = GETPOST('provider', 'aZ09');
|
||||||
$label = GETPOST('label', 'aZ09');
|
$label = GETPOST('label', 'aZ09');
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'update') {
|
if ($action == 'add') { // $provider is OAUTH_XXX
|
||||||
$error = 0;
|
if ($provider && $provider != '-1') {
|
||||||
|
|
||||||
if (GETPOST('add') && $provider && $provider != '-1') { // $provider is OAUTH_XXX
|
|
||||||
$constname = strtoupper($provider).($label ? '-'.$label : '').'_ID';
|
$constname = strtoupper($provider).($label ? '-'.$label : '').'_ID';
|
||||||
dolibarr_set_const($db, $constname, 'ToComplete', 'chaine', 0, '', $conf->entity);
|
|
||||||
} else {
|
|
||||||
foreach ($conf->global as $key => $val) {
|
|
||||||
if (!empty($val) && preg_match('/^OAUTH_.+_ID$/', $key)) {
|
|
||||||
$constvalue = str_replace('_ID', '', $key);
|
|
||||||
if (!dolibarr_set_const($db, $constvalue.'_ID', GETPOST($constvalue.'_ID'), 'chaine', 0, '', $conf->entity)) {
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
// If we reset this provider, we also remove the secret
|
|
||||||
if (!dolibarr_set_const($db, $constvalue.'_SECRET', GETPOST($constvalue.'_ID') ? GETPOST($constvalue.'_SECRET') : '', 'chaine', 0, '', $conf->entity)) {
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$error) {
|
if (getDolGlobalString($constname)) {
|
||||||
setEventMessages($langs->trans("SetupSaved"), null);
|
setEventMessages($langs->trans("AOAuthEntryForThisProviderAndLabelAlreadyHasAKey"), null, 'errors');
|
||||||
|
$error++;
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
dolibarr_set_const($db, $constname, 'ToComplete', 'chaine', 0, '', $conf->entity);
|
||||||
|
setEventMessages($langs->trans("OAuthProviderAdded"), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($action == 'update') {
|
||||||
|
foreach ($conf->global as $key => $val) {
|
||||||
|
if (!empty($val) && preg_match('/^OAUTH_.+_ID$/', $key)) {
|
||||||
|
$constvalue = str_replace('_ID', '', $key);
|
||||||
|
if (!dolibarr_set_const($db, $constvalue.'_ID', GETPOST($constvalue.'_ID'), 'chaine', 0, '', $conf->entity)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
// If we reset this provider, we also remove the secret
|
||||||
|
if (!dolibarr_set_const($db, $constvalue.'_SECRET', GETPOST($constvalue.'_ID') ? GETPOST($constvalue.'_SECRET') : '', 'chaine', 0, '', $conf->entity)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
setEventMessages($langs->trans("SetupSaved"), null);
|
||||||
|
} else {
|
||||||
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
@ -92,7 +102,7 @@ print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup');
|
|||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="action" value="update">';
|
print '<input type="hidden" name="action" value="add">';
|
||||||
|
|
||||||
$head = oauthadmin_prepare_head();
|
$head = oauthadmin_prepare_head();
|
||||||
|
|
||||||
@ -102,8 +112,8 @@ print dol_get_fiche_head($head, 'services', '', -1, 'technic');
|
|||||||
print '<span class="opacitymedium">'.$langs->trans("ListOfSupportedOauthProviders").'</span><br><br>';
|
print '<span class="opacitymedium">'.$langs->trans("ListOfSupportedOauthProviders").'</span><br><br>';
|
||||||
|
|
||||||
|
|
||||||
print '<select name="provider" id="provider">';
|
print '<select name="provider" id="provider" class="minwidth150">';
|
||||||
print '<option name="-1" value="-1">'.$langs->trans("Type").'</option>';
|
print '<option name="-1" value="-1">'.$langs->trans("OAuthProvider").'</option>';
|
||||||
foreach ($list as $key) {
|
foreach ($list as $key) {
|
||||||
$supported = 0;
|
$supported = 0;
|
||||||
$keyforsupportedoauth2array = $key[0];
|
$keyforsupportedoauth2array = $key[0];
|
||||||
@ -122,10 +132,16 @@ print '</select>';
|
|||||||
print ajax_combobox('provider');
|
print ajax_combobox('provider');
|
||||||
print ' <input type="text" name="label" value="" placeholder="'.$langs->trans("Label").'">';
|
print ' <input type="text" name="label" value="" placeholder="'.$langs->trans("Label").'">';
|
||||||
print ' <input type="submit" class="button small" name="add" value="'.$langs->trans("Add").'">';
|
print ' <input type="submit" class="button small" name="add" value="'.$langs->trans("Add").'">';
|
||||||
|
print '</form>';
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||||
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
|
print '<input type="hidden" name="action" value="update">';
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
|
|
||||||
|
|||||||
@ -12,9 +12,10 @@ TokenDeleted=Token deleted
|
|||||||
RequestAccess=Click here to request/renew access and receive a new token
|
RequestAccess=Click here to request/renew access and receive a new token
|
||||||
DeleteAccess=Click here to delete token
|
DeleteAccess=Click here to delete token
|
||||||
UseTheFollowingUrlAsRedirectURI=Use the following URL as the Redirect URI when creating your credentials with your OAuth provider:
|
UseTheFollowingUrlAsRedirectURI=Use the following URL as the Redirect URI when creating your credentials with your OAuth provider:
|
||||||
ListOfSupportedOauthProviders=Enter the credentials provided by your OAuth2 provider. Only supported OAuth2 providers are listedd here. These services may be used by other modules that need OAuth2 authentication.
|
ListOfSupportedOauthProviders=Add you OAuth2 token providers. Only supported OAuth2 providers are listedd here. These services may be used by other modules that need OAuth2 authentication.
|
||||||
OAuthSetupForLogin=Page to manage (generate/delete) OAuth tokens
|
OAuthSetupForLogin=Page to manage (generate/delete) OAuth tokens
|
||||||
SeePreviousTab=See previous tab
|
SeePreviousTab=See previous tab
|
||||||
|
OAuthProvider=OAuth provider
|
||||||
OAuthIDSecret=OAuth ID and Secret
|
OAuthIDSecret=OAuth ID and Secret
|
||||||
TOKEN_REFRESH=Token Refresh Present
|
TOKEN_REFRESH=Token Refresh Present
|
||||||
TOKEN_EXPIRED=Token expired
|
TOKEN_EXPIRED=Token expired
|
||||||
@ -32,4 +33,6 @@ OAUTH_URL_FOR_CREDENTIAL=Go to <a class="notasortlink" href="%s" target="_blank"
|
|||||||
OAUTH_STRIPE_TEST_NAME=OAuth Stripe Test
|
OAUTH_STRIPE_TEST_NAME=OAuth Stripe Test
|
||||||
OAUTH_STRIPE_LIVE_NAME=OAuth Stripe Live
|
OAUTH_STRIPE_LIVE_NAME=OAuth Stripe Live
|
||||||
OAUTH_ID=OAuth ID
|
OAUTH_ID=OAuth ID
|
||||||
OAUTH_SECRET=OAuth secret
|
OAUTH_SECRET=OAuth secret
|
||||||
|
OAuthProviderAdded=OAuth provider added
|
||||||
|
AOAuthEntryForThisProviderAndLabelAlreadyHasAKey=An OAuth entry for this provider and label already exists
|
||||||
Loading…
Reference in New Issue
Block a user