This commit is contained in:
Víctor Déniz 2022-01-10 23:15:11 +00:00
commit 7146bd1dfa

View File

@ -9831,33 +9831,8 @@ class admin_setting_enablemobileservice extends admin_setting_configcheckbox {
// Allow rest:use capability for authenticated user. // Allow rest:use capability for authenticated user.
$this->set_protocol_cap(true); $this->set_protocol_cap(true);
} else { } else {
//disable web service system if no other services are enabled // Disable the mobile service.
$otherenabledservices = $DB->get_records_select('external_services',
'enabled = :enabled AND (shortname != :shortname OR shortname IS NULL)', array('enabled' => 1,
'shortname' => MOODLE_OFFICIAL_MOBILE_SERVICE));
if (empty($otherenabledservices)) {
set_config('enablewebservices', false);
// Also disable REST server.
$activeprotocols = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
$protocolkey = array_search('rest', $activeprotocols);
if ($protocolkey !== false) {
unset($activeprotocols[$protocolkey]);
$updateprotocol = true;
}
if ($updateprotocol) {
set_config('webserviceprotocols', implode(',', $activeprotocols));
}
// Disallow rest:use capability for authenticated user.
$this->set_protocol_cap(false);
}
//disable the mobile service
$mobileservice = $webservicemanager->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE); $mobileservice = $webservicemanager->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE);
$mobileservice->enabled = 0; $mobileservice->enabled = 0;
$webservicemanager->update_external_service($mobileservice); $webservicemanager->update_external_service($mobileservice);