mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-53368 recaptcha: Implement compact display mode
This commit is contained in:
parent
753fd18d1b
commit
dcc351e61d
@ -104,9 +104,10 @@ function recaptcha_lang($lang = null) {
|
||||
* @param string $apiurl URL for reCAPTCHA API
|
||||
* @param string $pubkey The public key for reCAPTCHA
|
||||
* @param string $lang Language to use. If not provided, get current language.
|
||||
* @param bool $compactmode If true, use the compact widget.
|
||||
* @return string - The HTML to be embedded in the user's form.
|
||||
*/
|
||||
function recaptcha_get_challenge_html($apiurl, $pubkey, $lang = null) {
|
||||
function recaptcha_get_challenge_html($apiurl, $pubkey, $lang = null, bool $compactmode = false) {
|
||||
global $CFG, $PAGE;
|
||||
|
||||
// To use reCAPTCHA you must have an API key.
|
||||
@ -127,7 +128,10 @@ function recaptcha_get_challenge_html($apiurl, $pubkey, $lang = null) {
|
||||
$apicode .= "</script>\n";
|
||||
|
||||
$return = html_writer::script($jscode, '');
|
||||
$return .= html_writer::div('', 'recaptcha_element', array('id' => 'recaptcha_element'));
|
||||
$return .= html_writer::div('', 'recaptcha_element', [
|
||||
'id' => 'recaptcha_element',
|
||||
'data-size' => ($compactmode ? 'compact' : 'normal'),
|
||||
]);
|
||||
$return .= $apicode;
|
||||
|
||||
return $return;
|
||||
|
@ -90,6 +90,8 @@ being forced open in all behat tests.
|
||||
* New method login_captcha_enabled() is created to check whether the login captcha is enabled or not.
|
||||
* New method validate_login_captcha() is created to validate the login captcha.
|
||||
* A new parameter $loginrecaptcha has been added to the authenticate_user_login() to check whether the login captcha is needed to verify or not. The default value is false.
|
||||
* A new parameter $compactmode has been added to the recaptcha_get_challenge_html() to define whether the reCaptcha element should be displayed in the compact mode or not.
|
||||
Default value is false.
|
||||
|
||||
=== 4.2 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user