MDL-72119 admin: Move Enable WS for mobile to Advanced features
authorSara Arjona <sara@moodle.com>
Thu, 12 Aug 2021 13:44:17 +0000 (15:44 +0200)
committerSara Arjona <sara@moodle.com>
Mon, 13 Sep 2021 06:29:22 +0000 (08:29 +0200)
The "Enable web services for mobile devices" setting has been moved
from the "Mobile app settings" page to "Advanced features".
Besides, the "Mobile app" section and the "Mobile settings" page
won't be displayed if WS for mobile devices setting is disabled.

admin/tool/mobile/settings.php

index 029390c..4f0f17a 100644 (file)
@@ -30,21 +30,30 @@ use core_admin\local\settings\autocomplete;
 
 if ($hassiteconfig) {
 
-    $ADMIN->add('root', new admin_category('mobileapp', new lang_string('mobileapp', 'tool_mobile')), 'development');
-
-    $temp = new admin_settingpage('mobilesettings', new lang_string('mobilesettings', 'tool_mobile'), 'moodle/site:config', false);
-
     // 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',
+        $optionalsubsystems = $ADMIN->locate('optionalsubsystems');
+        $optionalsubsystems->add(new admin_setting_enablemobileservice('enablemobilewebservice',
                 new lang_string('enablemobilewebservice', 'admin'),
                 new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), $default));
     }
 
+    $ismobilewsdisabled = empty($CFG->enablemobilewebservice);
+    $ADMIN->add('root',
+        new admin_category('mobileapp', new lang_string('mobileapp', 'tool_mobile'), $ismobilewsdisabled),
+        'development'
+    );
+
+    $temp = new admin_settingpage('mobilesettings',
+        new lang_string('mobilesettings', 'tool_mobile'),
+        'moodle/site:config',
+        $ismobilewsdisabled
+    );
+
     $temp->add(new admin_setting_configtext('tool_mobile/apppolicy', new lang_string('apppolicy', 'tool_mobile'),
         new lang_string('apppolicy_help', 'tool_mobile'), '', PARAM_URL));
 
@@ -60,8 +69,8 @@ if ($hassiteconfig) {
         $featuresnotice = $OUTPUT->render($notify);
     }
 
-    $hideappsubscription = empty($CFG->enablemobilewebservice);
-    $hideappsubscription = $hideappsubscription || (isset($CFG->disablemobileappsubscription) && !empty($CFG->disablemobileappsubscription));
+    $hideappsubscription = (isset($CFG->disablemobileappsubscription) && !empty($CFG->disablemobileappsubscription));
+    $hideappsubscription = $ismobilewsdisabled || $hideappsubscription;
 
     $ADMIN->add(
         'mobileapp',
@@ -79,7 +88,7 @@ if ($hassiteconfig) {
         'mobileauthentication',
         new lang_string('mobileauthentication', 'tool_mobile'),
         'moodle/site:config',
-        empty($CFG->enablemobilewebservice)
+        $ismobilewsdisabled
     );
 
     $temp->add(new admin_setting_heading('tool_mobile/moodleappsportalfeaturesauth', '', $featuresnotice));
@@ -123,7 +132,7 @@ if ($hassiteconfig) {
         'mobileappearance',
         new lang_string('mobileappearance', 'tool_mobile'),
         'moodle/site:config',
-        empty($CFG->enablemobilewebservice)
+        $ismobilewsdisabled
     );
 
     if (!empty($featuresnotice)) {
@@ -164,7 +173,7 @@ if ($hassiteconfig) {
         'mobilefeatures',
         new lang_string('mobilefeatures', 'tool_mobile'),
         'moodle/site:config',
-        empty($CFG->enablemobilewebservice)
+        $ismobilewsdisabled
     );
 
     if (!empty($featuresnotice)) {