From 1a663b5105025d9bc256c4171292dfa7e4f7dd8c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 17 Sep 2022 13:41:07 +0200 Subject: [PATCH] Fix page to setup OAUTH --- htdocs/admin/oauth.php | 149 +++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 73 deletions(-) diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 772055f0809..a671888ec56 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -100,7 +100,7 @@ $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup'); -print '
'; +print ''; print ''; print ''; @@ -137,15 +137,8 @@ print '
'; print '
'; print '
'; +print dol_get_fiche_end(); -print '
'; -print ''; -print ''; - -print '
'; -print ''; - -$i = 0; //var_dump($list); foreach ($conf->global as $key => $val) { @@ -155,83 +148,93 @@ foreach ($conf->global as $key => $val) { } } -// $list is defined into oauth.lib.php to the list of supporter OAuth providers. -foreach ($listinsetup as $key) { - $supported = 0; - $keyforsupportedoauth2array = $key[0]; // May be OAUTH_GOOGLE_NAME or OAUTH_GOOGLE_xxx_NAME - $keyforsupportedoauth2array = preg_replace('/^OAUTH_/', '', $keyforsupportedoauth2array); - $keyforsupportedoauth2array = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array); - if (preg_match('/^.*-/', $keyforsupportedoauth2array)) { - $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array); - } else { - $keyforprovider = ''; - } - $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array); - $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; - if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) { - $supported = 1; - } - if (!$supported) { - continue; // show only supported - } +if (count($listinsetup) > 0) { + print ''; + print ''; + print ''; - $i++; + print '
'; + print '
'; - print ''; - // Api Name - $label = $langs->trans($keyforsupportedoauth2array); - print ''; - print ''; - print ''; + $i = 0; - if ($supported) { - $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php'; + // $list is defined into oauth.lib.php to the list of supporter OAuth providers. + foreach ($listinsetup as $key) { + $supported = 0; + $keyforsupportedoauth2array = $key[0]; // May be OAUTH_GOOGLE_NAME or OAUTH_GOOGLE_xxx_NAME + $keyforsupportedoauth2array = preg_replace('/^OAUTH_/', '', $keyforsupportedoauth2array); + $keyforsupportedoauth2array = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array); + if (preg_match('/^.*-/', $keyforsupportedoauth2array)) { + $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array); + } else { + $keyforprovider = ''; + } + $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array); + $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; + + if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) { + $supported = 1; + } + if (!$supported) { + continue; // show only supported + } + + $i++; + + print ''; + // Api Name + $label = $langs->trans($keyforsupportedoauth2array); + print ''; + print ''; + print ''; + + if ($supported) { + $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php'; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + print ''; + print ''; + } + + // Api Id print ''; - print ''; - print ''; + print ''; - } else { + + // Api Secret print ''; - print ''; - print ''; + print ''; + print ''; } - // Api Id - print ''; - print ''; - print ''; + print '
'; - print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"'); - print $label; - if ($keyforprovider) { - print ' ('.$keyforprovider.')'; - } else { - print ' ('.$langs->trans("NoName").')'; - } - print ''; - if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials'])) { - print $langs->trans("OAUTH_URL_FOR_CREDENTIAL", $supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials']); - } - print '
'; + print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"'); + print $label; + if ($keyforprovider) { + print ' ('.$keyforprovider.')'; + } else { + print ' ('.$langs->trans("NoName").')'; + } + print ''; + if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials'])) { + print $langs->trans("OAUTH_URL_FOR_CREDENTIAL", $supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials']); + } + print '
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; + print '
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''.$langs->trans("FeatureNotYetSupported").'
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; + print ''; print '
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''.$langs->trans("FeatureNotYetSupported").''; print '
'; - print '
'."\n"; + print '
'; - // Api Secret - print ''; - print ''; - print ''; - print ''; + print $form->buttonsSaveCancel("Modify", ''); + + print '
'; } -print ''."\n"; -print ''; - -print dol_get_fiche_end(); - -print $form->buttonsSaveCancel("Modify", ''); - -print ''; - // End of page llxFooter(); $db->close();