diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php index 820d25bf2d8..f5ea9e3fab2 100644 --- a/admin/settings/plugins.php +++ b/admin/settings/plugins.php @@ -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 diff --git a/lib/adminlib.php b/lib/adminlib.php index debcc5f1e21..ce151b9ff81 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -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; }