Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Settings
  19   *
  20   * This file contains settings used by tool_mobile
  21   *
  22   * @package    tool_mobile
  23   * @copyright  2016 Juan Leyva
  24   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  if ($hassiteconfig) {
  30  
  31      $ADMIN->add('root', new admin_category('mobileapp', new lang_string('mobileapp', 'tool_mobile')), 'development');
  32  
  33      $temp = new admin_settingpage('mobilesettings', new lang_string('mobilesettings', 'tool_mobile'), 'moodle/site:config', false);
  34  
  35      // We should wait to the installation to finish since we depend on some configuration values that are set once
  36      // the admin user profile is configured.
  37      if (!during_initial_install()) {
  38          $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
  39          $enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
  40          $default = is_https() ? 1 : 0;
  41          $temp->add(new admin_setting_enablemobileservice('enablemobilewebservice',
  42                  new lang_string('enablemobilewebservice', 'admin'),
  43                  new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), $default));
  44      }
  45  
  46      $temp->add(new admin_setting_configtext('tool_mobile/apppolicy', new lang_string('apppolicy', 'tool_mobile'),
  47          new lang_string('apppolicy_help', 'tool_mobile'), '', PARAM_URL));
  48  
  49      $ADMIN->add('mobileapp', $temp);
  50  
  51      $featuresnotice = null;
  52      if (empty($CFG->disablemobileappsubscription)) {
  53          // General notification about limited features due to app restrictions.
  54          $subscriptionurl = (new moodle_url("/$CFG->admin/tool/mobile/subscription.php"))->out(false);
  55          $notify = new \core\output\notification(
  56              get_string('moodleappsportalfeatureswarning', 'tool_mobile', $subscriptionurl),
  57              \core\output\notification::NOTIFY_WARNING);
  58          $featuresnotice = $OUTPUT->render($notify);
  59      }
  60  
  61      $hideappsubscription = empty($CFG->enablemobilewebservice);
  62      $hideappsubscription = $hideappsubscription || (isset($CFG->disablemobileappsubscription) && !empty($CFG->disablemobileappsubscription));
  63  
  64      $ADMIN->add(
  65          'mobileapp',
  66          new admin_externalpage(
  67              'mobileappsubscription',
  68              new lang_string('mobileappsubscription', 'tool_mobile'),
  69              "$CFG->wwwroot/$CFG->admin/tool/mobile/subscription.php",
  70              'moodle/site:config',
  71              $hideappsubscription
  72          )
  73      );
  74  
  75      // Type of login.
  76      $temp = new admin_settingpage(
  77          'mobileauthentication',
  78          new lang_string('mobileauthentication', 'tool_mobile'),
  79          'moodle/site:config',
  80          empty($CFG->enablemobilewebservice)
  81      );
  82  
  83      $temp->add(new admin_setting_heading('tool_mobile/moodleappsportalfeaturesauth', '', $featuresnotice));
  84  
  85      $options = array(
  86          tool_mobile\api::LOGIN_VIA_APP => new lang_string('loginintheapp', 'tool_mobile'),
  87          tool_mobile\api::LOGIN_VIA_BROWSER => new lang_string('logininthebrowser', 'tool_mobile'),
  88          tool_mobile\api::LOGIN_VIA_EMBEDDED_BROWSER => new lang_string('loginintheembeddedbrowser', 'tool_mobile'),
  89      );
  90      $temp->add(new admin_setting_configselect('tool_mobile/typeoflogin',
  91                  new lang_string('typeoflogin', 'tool_mobile'),
  92                  new lang_string('typeoflogin_desc', 'tool_mobile'), 1, $options));
  93  
  94      $options = [
  95          tool_mobile\api::QR_CODE_DISABLED => new lang_string('qrcodedisabled', 'tool_mobile'),
  96          tool_mobile\api::QR_CODE_URL => new lang_string('qrcodetypeurl', 'tool_mobile'),
  97      ];
  98      $qrcodetypedefault = tool_mobile\api::QR_CODE_URL;
  99  
 100      if (is_https()) {   // Allow QR login for https sites.
 101          $options[tool_mobile\api::QR_CODE_LOGIN] = new lang_string('qrcodetypelogin', 'tool_mobile');
 102          $qrcodetypedefault = tool_mobile\api::QR_CODE_LOGIN;
 103      }
 104  
 105      $temp->add(new admin_setting_configselect('tool_mobile/qrcodetype',
 106                  new lang_string('qrcodetype', 'tool_mobile'),
 107                  new lang_string('qrcodetype_desc', 'tool_mobile'), $qrcodetypedefault, $options));
 108  
 109      $temp->add(new admin_setting_configtext('tool_mobile/forcedurlscheme',
 110                  new lang_string('forcedurlscheme_key', 'tool_mobile'),
 111                  new lang_string('forcedurlscheme', 'tool_mobile'), 'moodlemobile', PARAM_NOTAGS));
 112  
 113      $temp->add(new admin_setting_configtext('tool_mobile/minimumversion',
 114                  new lang_string('minimumversion_key', 'tool_mobile'),
 115                  new lang_string('minimumversion', 'tool_mobile'), '', PARAM_NOTAGS));
 116  
 117      $ADMIN->add('mobileapp', $temp);
 118  
 119      // Appearance related settings.
 120      $temp = new admin_settingpage(
 121          'mobileappearance',
 122          new lang_string('mobileappearance', 'tool_mobile'),
 123          'moodle/site:config',
 124          empty($CFG->enablemobilewebservice)
 125      );
 126  
 127      if (!empty($featuresnotice)) {
 128          $temp->add(new admin_setting_heading('tool_mobile/moodleappsportalfeaturesappearance', '', $featuresnotice));
 129      }
 130  
 131      $temp->add(new admin_setting_configtext('mobilecssurl', new lang_string('mobilecssurl', 'tool_mobile'),
 132                  new lang_string('configmobilecssurl', 'tool_mobile'), '', PARAM_URL));
 133  
 134      // Reference to Branded Mobile App.
 135      if (empty($CFG->disableserviceads_branded)) {
 136          $temp->add(new admin_setting_description('moodlebrandedappreference',
 137              new lang_string('moodlebrandedapp', 'admin'),
 138              new lang_string('moodlebrandedappreference', 'admin')
 139          ));
 140      }
 141  
 142      $temp->add(new admin_setting_heading('tool_mobile/smartappbanners',
 143                  new lang_string('smartappbanners', 'tool_mobile'), ''));
 144  
 145      $temp->add(new admin_setting_configcheckbox('tool_mobile/enablesmartappbanners',
 146                  new lang_string('enablesmartappbanners', 'tool_mobile'),
 147                  new lang_string('enablesmartappbanners_desc', 'tool_mobile'), 0));
 148  
 149      $temp->add(new admin_setting_configtext('tool_mobile/iosappid', new lang_string('iosappid', 'tool_mobile'),
 150                  new lang_string('iosappid_desc', 'tool_mobile'), tool_mobile\api::DEFAULT_IOS_APP_ID, PARAM_ALPHANUM));
 151  
 152      $temp->add(new admin_setting_configtext('tool_mobile/androidappid', new lang_string('androidappid', 'tool_mobile'),
 153                  new lang_string('androidappid_desc', 'tool_mobile'), tool_mobile\api::DEFAULT_ANDROID_APP_ID, PARAM_NOTAGS));
 154  
 155      $temp->add(new admin_setting_configtext('tool_mobile/setuplink', new lang_string('setuplink', 'tool_mobile'),
 156          new lang_string('setuplink_desc', 'tool_mobile'), 'https://download.moodle.org/mobile', PARAM_URL));
 157  
 158      $ADMIN->add('mobileapp', $temp);
 159  
 160      // Features related settings.
 161      $temp = new admin_settingpage(
 162          'mobilefeatures',
 163          new lang_string('mobilefeatures', 'tool_mobile'),
 164          'moodle/site:config',
 165          empty($CFG->enablemobilewebservice)
 166      );
 167  
 168      if (!empty($featuresnotice)) {
 169          $temp->add(new admin_setting_heading('tool_mobile/moodleappsportalfeatures', '', $featuresnotice));
 170      }
 171  
 172      $temp->add(new admin_setting_heading('tool_mobile/logout',
 173                  new lang_string('logout'), ''));
 174  
 175      $temp->add(new admin_setting_configcheckbox('tool_mobile/forcelogout',
 176                  new lang_string('forcelogout', 'tool_mobile'),
 177                  new lang_string('forcelogout_desc', 'tool_mobile'), 0));
 178  
 179      $temp->add(new admin_setting_heading('tool_mobile/features',
 180                  new lang_string('mobilefeatures', 'tool_mobile'), ''));
 181  
 182      $options = tool_mobile\api::get_features_list();
 183      $temp->add(new admin_setting_configmultiselect('tool_mobile/disabledfeatures',
 184                  new lang_string('disabledfeatures', 'tool_mobile'),
 185                  new lang_string('disabledfeatures_desc', 'tool_mobile'), array(), $options));
 186  
 187      $temp->add(new admin_setting_configtextarea('tool_mobile/custommenuitems',
 188                  new lang_string('custommenuitems', 'tool_mobile'),
 189                  new lang_string('custommenuitems_desc', 'tool_mobile'), '', PARAM_RAW, '50', '10'));
 190  
 191      $temp->add(new admin_setting_heading('tool_mobile/language',
 192                  new lang_string('language'), ''));
 193  
 194      $temp->add(new admin_setting_configtextarea('tool_mobile/customlangstrings',
 195                  new lang_string('customlangstrings', 'tool_mobile'),
 196                  new lang_string('customlangstrings_desc', 'tool_mobile'), '', PARAM_RAW, '50', '10'));
 197  
 198      $ADMIN->add('mobileapp', $temp);
 199  }