Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 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  use core_admin\local\settings\autocomplete;
  30  
  31  if ($hassiteconfig) {
  32  
  33      // We should wait to the installation to finish since we depend on some configuration values that are set once
  34      // the admin user profile is configured.
  35      if (!during_initial_install()) {
  36          $enablemobiledocurl = new moodle_url(get_docs_url('Enable_mobile_web_services'));
  37          $enablemobiledoclink = html_writer::link($enablemobiledocurl, new lang_string('documentation'));
  38          $default = is_https() ? 1 : 0;
  39          $optionalsubsystems = $ADMIN->locate('optionalsubsystems');
  40          $optionalsubsystems->add(new admin_setting_enablemobileservice('enablemobilewebservice',
  41                  new lang_string('enablemobilewebservice', 'admin'),
  42                  new lang_string('configenablemobilewebservice', 'admin', $enablemobiledoclink), $default));
  43      }
  44  
  45      $ismobilewsdisabled = empty($CFG->enablemobilewebservice);
  46      $ADMIN->add('root',
  47          new admin_category('mobileapp', new lang_string('mobileapp', 'tool_mobile'), $ismobilewsdisabled),
  48          'development'
  49      );
  50  
  51      $temp = new admin_settingpage('mobilesettings',
  52          new lang_string('mobilesettings', 'tool_mobile'),
  53          'moodle/site:config',
  54          $ismobilewsdisabled
  55      );
  56  
  57      $temp->add(new admin_setting_configtext('tool_mobile/apppolicy', new lang_string('apppolicy', 'tool_mobile'),
  58          new lang_string('apppolicy_help', 'tool_mobile'), '', PARAM_URL));
  59  
  60      $ADMIN->add('mobileapp', $temp);
  61  
  62      $featuresnotice = null;
  63      if (empty($CFG->disablemobileappsubscription)) {
  64          // General notification about limited features due to app restrictions.
  65          $subscriptionurl = (new moodle_url("/$CFG->admin/tool/mobile/subscription.php"))->out(false);
  66          $notify = new \core\output\notification(
  67              get_string('moodleappsportalfeatureswarning', 'tool_mobile', $subscriptionurl),
  68              \core\output\notification::NOTIFY_WARNING);
  69          $featuresnotice = $OUTPUT->render($notify);
  70      }
  71  
  72      $hideappsubscription = (isset($CFG->disablemobileappsubscription) && !empty($CFG->disablemobileappsubscription));
  73      $hideappsubscription = $ismobilewsdisabled || $hideappsubscription;
  74  
  75      $ADMIN->add(
  76          'mobileapp',
  77          new admin_externalpage(
  78              'mobileappsubscription',
  79              new lang_string('mobileappsubscription', 'tool_mobile'),
  80              "$CFG->wwwroot/$CFG->admin/tool/mobile/subscription.php",
  81              'moodle/site:config',
  82              $hideappsubscription
  83          )
  84      );
  85  
  86      // Type of login.
  87      $temp = new admin_settingpage(
  88          'mobileauthentication',
  89          new lang_string('mobileauthentication', 'tool_mobile'),
  90          'moodle/site:config',
  91          $ismobilewsdisabled
  92      );
  93  
  94      $temp->add(new admin_setting_heading('tool_mobile/moodleappsportalfeaturesauth', '', $featuresnotice));
  95  
  96      $options = array(
  97          tool_mobile\api::LOGIN_VIA_APP => new lang_string('loginintheapp', 'tool_mobile'),
  98          tool_mobile\api::LOGIN_VIA_BROWSER => new lang_string('logininthebrowser', 'tool_mobile'),
  99          tool_mobile\api::LOGIN_VIA_EMBEDDED_BROWSER => new lang_string('loginintheembeddedbrowser', 'tool_mobile'),
 100      );
 101      $temp->add(new admin_setting_configselect('tool_mobile/typeoflogin',
 102                  new lang_string('typeoflogin', 'tool_mobile'),
 103                  new lang_string('typeoflogin_desc', 'tool_mobile'), 1, $options));
 104  
 105      $options = [
 106          tool_mobile\api::QR_CODE_DISABLED => new lang_string('qrcodedisabled', 'tool_mobile'),
 107          tool_mobile\api::QR_CODE_URL => new lang_string('qrcodetypeurl', 'tool_mobile'),
 108      ];
 109      $qrcodetypedefault = tool_mobile\api::QR_CODE_URL;
 110  
 111      if (is_https()) {   // Allow QR login for https sites.
 112          $options[tool_mobile\api::QR_CODE_LOGIN] = new lang_string('qrcodetypelogin', 'tool_mobile');
 113          $qrcodetypedefault = tool_mobile\api::QR_CODE_LOGIN;
 114      }
 115  
 116      $temp->add(new admin_setting_configselect('tool_mobile/qrcodetype',
 117                  new lang_string('qrcodetype', 'tool_mobile'),
 118                  new lang_string('qrcodetype_desc', 'tool_mobile'), $qrcodetypedefault, $options));
 119  
 120      $temp->add(new admin_setting_configduration('tool_mobile/qrkeyttl',
 121          new lang_string('qrkeyttl', 'tool_mobile'),
 122          new lang_string('qrkeyttl_desc', 'tool_mobile'), tool_mobile\api::LOGIN_QR_KEY_TTL, MINSECS));
 123      $temp->hide_if('tool_mobile/qrkeyttl', 'tool_mobile/qrcodetype', 'neq', tool_mobile\api::QR_CODE_LOGIN);
 124  
 125      $temp->add(new admin_setting_configtext('tool_mobile/forcedurlscheme',
 126                  new lang_string('forcedurlscheme_key', 'tool_mobile'),
 127                  new lang_string('forcedurlscheme', 'tool_mobile'), 'moodlemobile', PARAM_NOTAGS));
 128  
 129      $temp->add(new admin_setting_configtext('tool_mobile/minimumversion',
 130                  new lang_string('minimumversion_key', 'tool_mobile'),
 131                  new lang_string('minimumversion', 'tool_mobile'), '', PARAM_NOTAGS));
 132  
 133      $options = [
 134          60 => new lang_string('numminutes', '', 1),
 135          180 => new lang_string('numminutes', '', 3),
 136          360 => new lang_string('numminutes', '', 6),
 137          900 => new lang_string('numminutes', '', 15),
 138          1800 => new lang_string('numminutes', '', 30),
 139          3600 => new lang_string('numminutes', '', 60)
 140      ];
 141      $temp->add(new admin_setting_configselect('tool_mobile/autologinmintimebetweenreq',
 142          new lang_string('autologinmintimebetweenreq', 'tool_mobile'),
 143          new lang_string('autologinmintimebetweenreq_desc', 'tool_mobile'), 360, $options));
 144  
 145      $ADMIN->add('mobileapp', $temp);
 146  
 147      // Appearance related settings.
 148      $temp = new admin_settingpage(
 149          'mobileappearance',
 150          new lang_string('mobileappearance', 'tool_mobile'),
 151          'moodle/site:config',
 152          $ismobilewsdisabled
 153      );
 154  
 155      if (!empty($featuresnotice)) {
 156          $temp->add(new admin_setting_heading('tool_mobile/moodleappsportalfeaturesappearance', '', $featuresnotice));
 157      }
 158  
 159      $temp->add(new admin_setting_configtext('mobilecssurl', new lang_string('mobilecssurl', 'tool_mobile'),
 160                  new lang_string('configmobilecssurl', 'tool_mobile'), '', PARAM_URL));
 161  
 162      // Reference to Branded Mobile App.
 163      if (empty($CFG->disableserviceads_branded)) {
 164          $temp->add(new admin_setting_description('moodlebrandedappreference',
 165              new lang_string('moodlebrandedapp', 'admin'),
 166              new lang_string('moodlebrandedappreference', 'admin')
 167          ));
 168      }
 169  
 170      $temp->add(new admin_setting_heading('tool_mobile/smartappbanners',
 171                  new lang_string('smartappbanners', 'tool_mobile'), ''));
 172  
 173      $temp->add(new admin_setting_configcheckbox('tool_mobile/enablesmartappbanners',
 174                  new lang_string('enablesmartappbanners', 'tool_mobile'),
 175                  new lang_string('enablesmartappbanners_desc', 'tool_mobile'), 0));
 176  
 177      $temp->add(new admin_setting_configtext('tool_mobile/iosappid', new lang_string('iosappid', 'tool_mobile'),
 178                  new lang_string('iosappid_desc', 'tool_mobile'), tool_mobile\api::DEFAULT_IOS_APP_ID, PARAM_ALPHANUM));
 179  
 180      $temp->add(new admin_setting_configtext('tool_mobile/androidappid', new lang_string('androidappid', 'tool_mobile'),
 181                  new lang_string('androidappid_desc', 'tool_mobile'), tool_mobile\api::DEFAULT_ANDROID_APP_ID, PARAM_NOTAGS));
 182  
 183      $temp->add(new admin_setting_configtext('tool_mobile/setuplink', new lang_string('setuplink', 'tool_mobile'),
 184          new lang_string('setuplink_desc', 'tool_mobile'), 'https://download.moodle.org/mobile', PARAM_URL));
 185  
 186      $ADMIN->add('mobileapp', $temp);
 187  
 188      // Features related settings.
 189      $temp = new admin_settingpage(
 190          'mobilefeatures',
 191          new lang_string('mobilefeatures', 'tool_mobile'),
 192          'moodle/site:config',
 193          $ismobilewsdisabled
 194      );
 195  
 196      if (!empty($featuresnotice)) {
 197          $temp->add(new admin_setting_heading('tool_mobile/moodleappsportalfeatures', '', $featuresnotice));
 198      }
 199  
 200      $temp->add(new admin_setting_heading('tool_mobile/logout',
 201                  new lang_string('logout'), ''));
 202  
 203      $temp->add(new admin_setting_configcheckbox('tool_mobile/forcelogout',
 204                  new lang_string('forcelogout', 'tool_mobile'),
 205                  new lang_string('forcelogout_desc', 'tool_mobile'), 0));
 206  
 207      $temp->add(new admin_setting_heading('tool_mobile/features',
 208                  new lang_string('mobilefeatures', 'tool_mobile'), ''));
 209  
 210      $options = tool_mobile\api::get_features_list();
 211      $temp->add(new admin_setting_configmultiselect('tool_mobile/disabledfeatures',
 212                  new lang_string('disabledfeatures', 'tool_mobile'),
 213                  new lang_string('disabledfeatures_desc', 'tool_mobile'), array(), $options));
 214  
 215      $temp->add(new admin_setting_configtextarea('tool_mobile/custommenuitems',
 216                  new lang_string('custommenuitems', 'tool_mobile'),
 217                  new lang_string('custommenuitems_desc', 'tool_mobile'), '', PARAM_RAW, '50', '10'));
 218  
 219      // File type exclusionlist.
 220      $choices = [];
 221      foreach (core_filetypes::get_types() as $key => $info) {
 222          $text = '.' . $key;
 223          if (!empty($info['type'])) {
 224              $text .= ' (' . $info['type'] . ')';
 225          }
 226          $choices[$key] = $text;
 227      }
 228  
 229      $attributes = [
 230          'manageurl' => new \moodle_url('/admin/tool/filetypes/index.php'),
 231          'managetext' => get_string('managefiletypes', 'tool_mobile'),
 232          'multiple' => true,
 233          'delimiter' => ',',
 234          'placeholder' => get_string('filetypeexclusionlistplaceholder', 'tool_mobile')
 235      ];
 236      $temp->add(new autocomplete('tool_mobile/filetypeexclusionlist',
 237          new lang_string('filetypeexclusionlist', 'tool_mobile'),
 238          new lang_string('filetypeexclusionlist_desc', 'tool_mobile'), array(), $choices, $attributes));
 239  
 240      $temp->add(new admin_setting_heading('tool_mobile/language',
 241                  new lang_string('language'), ''));
 242  
 243      $temp->add(new admin_setting_configtextarea('tool_mobile/customlangstrings',
 244                  new lang_string('customlangstrings', 'tool_mobile'),
 245                  new lang_string('customlangstrings_desc', 'tool_mobile'), '', PARAM_RAW, '50', '10'));
 246  
 247      $ADMIN->add('mobileapp', $temp);
 248  }