From 17237761eaebb9806566901c2c9c87f18bd13f33 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 16 Oct 2019 10:02:11 -0500 Subject: [PATCH] Whispeak: Don't show link to re-enrollment - refs BT#16215 --- main/inc/lib/userportal.lib.php | 5 ++++- plugin/whispeakauth/enrollment.php | 10 +++++++++- plugin/whispeakauth/view/record_audio.html.twig | 9 +-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 5f3d49be1f..11ef463573 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -954,7 +954,10 @@ class IndexManager ]; } - if (true === api_get_configuration_value('whispeak_auth_enabled')) { + if ( + true === api_get_configuration_value('whispeak_auth_enabled') && + !WhispeakAuthPlugin::checkUserIsEnrolled($userId) + ) { $itemTitle = WhispeakAuthPlugin::create()->get_title(); $items[] = [ diff --git a/plugin/whispeakauth/enrollment.php b/plugin/whispeakauth/enrollment.php index 29f70796fd..2b1ad6f987 100644 --- a/plugin/whispeakauth/enrollment.php +++ b/plugin/whispeakauth/enrollment.php @@ -12,6 +12,15 @@ $plugin = WhispeakAuthPlugin::create(); $plugin->protectTool(); +$isEnrolledAlready = WhispeakAuthPlugin::checkUserIsEnrolled($userId); + +if ($isEnrolledAlready) { + api_not_allowed( + true, + Display::return_message($plugin->get_lang('SpeechAuthAlreadyEnrolled'), 'warning') + ); +} + try { $sampleText = WhispeakAuthRequest::enrollmentSentence($plugin); } catch (Exception $exception) { @@ -27,7 +36,6 @@ $htmlHeadXtra[] = api_get_js('rtc/RecordRTC.js'); $htmlHeadXtra[] = api_get_js_simple(api_get_path(WEB_PLUGIN_PATH).'whispeakauth/assets/js/RecordAudio.js'); $template = new Template(); -$template->assign('is_authenticated', WhispeakAuthPlugin::checkUserIsEnrolled($userId)); $template->assign('action', 'enrollment'); $template->assign('sample_text', $sampleText); diff --git a/plugin/whispeakauth/view/record_audio.html.twig b/plugin/whispeakauth/view/record_audio.html.twig index ff25b7cc40..163e03278e 100644 --- a/plugin/whispeakauth/view/record_audio.html.twig +++ b/plugin/whispeakauth/view/record_audio.html.twig @@ -39,14 +39,7 @@

-
- {% if is_authenticated %} -
- - {{ 'SpeechAuthAlreadyEnrolled'|get_plugin_lang('WhispeakAuthPlugin') }} -
- {% endif %} -
+