mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-74643 tool_mobile: Update API to support supportavailability config
Co-authored-by: Juan Leyva <juanleyvadelgado@gmail.com>
This commit is contained in:
parent
e3b3ba90c8
commit
336d8c5fab
3 changed files with 24 additions and 6 deletions
|
@ -167,6 +167,9 @@ class api {
|
|||
// We need this to make work the format text functions.
|
||||
$PAGE->set_context($context);
|
||||
|
||||
// Check if contacting site support is available to all visitors.
|
||||
$sitesupportavailable = (isset($CFG->supportavailability) && $CFG->supportavailability == CONTACT_SUPPORT_ANYONE);
|
||||
|
||||
list($authinstructions, $notusedformat) = external_format_text($CFG->auth_instructions, FORMAT_MOODLE, $context->id);
|
||||
list($maintenancemessage, $notusedformat) = external_format_text($CFG->maintenance_message, FORMAT_MOODLE, $context->id);
|
||||
$settings = array(
|
||||
|
@ -198,7 +201,8 @@ class api {
|
|||
'tool_mobile_androidappid' => get_config('tool_mobile', 'androidappid'),
|
||||
'tool_mobile_setuplink' => clean_param(get_config('tool_mobile', 'setuplink'), PARAM_URL),
|
||||
'tool_mobile_qrcodetype' => clean_param(get_config('tool_mobile', 'qrcodetype'), PARAM_INT),
|
||||
'supportpage' => clean_param($CFG->supportpage, PARAM_URL),
|
||||
'supportpage' => $sitesupportavailable ? clean_param($CFG->supportpage, PARAM_URL) : '',
|
||||
'supportavailability' => clean_param($CFG->supportavailability, PARAM_INT),
|
||||
);
|
||||
|
||||
$typeoflogin = get_config('tool_mobile', 'typeoflogin');
|
||||
|
@ -236,8 +240,8 @@ class api {
|
|||
}
|
||||
}
|
||||
|
||||
// If age is verified, return also the admin contact details.
|
||||
if ($settings['agedigitalconsentverification']) {
|
||||
// If age is verified or support is available to all visitors, also return the admin contact details.
|
||||
if ($settings['agedigitalconsentverification'] || $sitesupportavailable) {
|
||||
$settings['supportname'] = clean_param($CFG->supportname, PARAM_NOTAGS);
|
||||
$settings['supportemail'] = clean_param($CFG->supportemail, PARAM_EMAIL);
|
||||
}
|
||||
|
@ -330,9 +334,17 @@ class api {
|
|||
}
|
||||
|
||||
if (empty($section) or $section == 'supportcontact') {
|
||||
$settings->supportname = $CFG->supportname;
|
||||
$settings->supportemail = $CFG->supportemail ?? null;
|
||||
$settings->supportpage = $CFG->supportpage;
|
||||
$settings->supportavailability = $CFG->supportavailability;
|
||||
|
||||
if ($CFG->supportavailability == CONTACT_SUPPORT_DISABLED) {
|
||||
$settings->supportname = null;
|
||||
$settings->supportemail = null;
|
||||
$settings->supportpage = null;
|
||||
} else {
|
||||
$settings->supportname = $CFG->supportname;
|
||||
$settings->supportemail = $CFG->supportemail ?? null;
|
||||
$settings->supportpage = $CFG->supportpage;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($section) || $section === 'graceperiodsettings') {
|
||||
|
|
|
@ -175,6 +175,8 @@ class external extends external_api {
|
|||
'supportemail' => new external_value(PARAM_EMAIL, 'Site support contact email
|
||||
(only if age verification is enabled).', VALUE_OPTIONAL),
|
||||
'supportpage' => new external_value(PARAM_URL, 'Site support page link.', VALUE_OPTIONAL),
|
||||
'supportavailability' => new external_value(PARAM_INT, 'Determines who has access to contact site support.',
|
||||
VALUE_OPTIONAL),
|
||||
'autolang' => new external_value(PARAM_INT, 'Whether to detect default language
|
||||
from browser setting.', VALUE_OPTIONAL),
|
||||
'lang' => new external_value(PARAM_LANG, 'Default language for the site.', VALUE_OPTIONAL),
|
||||
|
|
|
@ -92,6 +92,7 @@ class externallib_test extends externallib_advanced_testcase {
|
|||
'tool_mobile_setuplink' => get_config('tool_mobile', 'setuplink'),
|
||||
'tool_mobile_qrcodetype' => get_config('tool_mobile', 'qrcodetype'),
|
||||
'supportpage' => $CFG->supportpage,
|
||||
'supportavailability' => $CFG->supportavailability,
|
||||
'warnings' => array()
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -111,6 +112,7 @@ class externallib_test extends externallib_advanced_testcase {
|
|||
set_config('disabledfeatures', 'myoverview', 'tool_mobile');
|
||||
set_config('minimumversion', '3.8.0', 'tool_mobile');
|
||||
set_config('supportemail', 'test@test.com');
|
||||
set_config('supportavailability', CONTACT_SUPPORT_ANYONE);
|
||||
|
||||
// Enable couple of issuers.
|
||||
$issuer = \core\oauth2\api::create_standard_issuer('google');
|
||||
|
@ -132,6 +134,7 @@ class externallib_test extends externallib_advanced_testcase {
|
|||
$expected['agedigitalconsentverification'] = true;
|
||||
$expected['supportname'] = $CFG->supportname;
|
||||
$expected['supportemail'] = $CFG->supportemail;
|
||||
$expected['supportavailability'] = $CFG->supportavailability;
|
||||
$expected['autolang'] = '1';
|
||||
$expected['lang'] = ''; // Expect empty because it was set to an invalid lang.
|
||||
$expected['tool_mobile_disabledfeatures'] = 'myoverview';
|
||||
|
@ -226,6 +229,7 @@ class externallib_test extends externallib_advanced_testcase {
|
|||
'value' => get_config('core_admin', 'coursecolor' . $number)
|
||||
];
|
||||
}
|
||||
$expected[] = ['name' => 'supportavailability', 'value' => $CFG->supportavailability];
|
||||
$expected[] = ['name' => 'supportname', 'value' => $CFG->supportname];
|
||||
$expected[] = ['name' => 'supportemail', 'value' => $CFG->supportemail];
|
||||
$expected[] = ['name' => 'supportpage', 'value' => $CFG->supportpage];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue