MDL-51478 webservice: Enable the Mobile service by default

This commit is contained in:
Juan Leyva 2015-09-24 19:56:15 +02:00
parent fd57d685c7
commit 6b6deb8e74
2 changed files with 19 additions and 6 deletions

View File

@ -277,11 +277,18 @@ if ($hassiteconfig) {
$ADMIN->add('modules', new admin_category('webservicesettings', new lang_string('webservices', 'webservice')));
// Mobile
$temp = new admin_settingpage('mobile', new lang_string('mobile','admin'), 'moodle/site:config', false);
$enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
$enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
$temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
new lang_string('enablemobilewebservice', 'admin'),
new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), 0));
// We should wait to the installation to finish since we depend on some configuration values that are set once
// the admin user profile is configured.
if (!during_initial_install()) {
$enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
$enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
$default = is_https() ? 1 : 0;
$temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
new lang_string('enablemobilewebservice', 'admin'),
new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), $default));
}
$temp->add(new admin_setting_configtext('mobilecssurl', new lang_string('mobilecssurl', 'admin'), new lang_string('configmobilecssurl','admin'), '', PARAM_URL));
$ADMIN->add('webservicesettings', $temp);
/// overview page

View File

@ -7691,6 +7691,12 @@ class admin_setting_enablemobileservice extends admin_setting_configcheckbox {
public function get_setting() {
global $CFG;
// First check if is not set.
$result = $this->config_read($this->name);
if (is_null($result)) {
return null;
}
// For install cli script, $CFG->defaultuserroleid is not set so return 0
// Or if web services aren't enabled this can't be,
if (empty($CFG->defaultuserroleid) || empty($CFG->enablewebservices)) {
@ -7701,7 +7707,7 @@ class admin_setting_enablemobileservice extends admin_setting_configcheckbox {
$webservicemanager = new webservice();
$mobileservice = $webservicemanager->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE);
if ($mobileservice->enabled and $this->is_protocol_cap_allowed()) {
return $this->config_read($this->name); //same as returning 1
return $result;
} else {
return 0;
}