$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
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)) {
$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;
}