Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 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   * Web manifest for including a native app banner.
  19   *
  20   * The banner is only displayed if the user has visited the site twice over two
  21   * separate days during the course of two weeks. There is an experimental chrome
  22   * flag to allow testing.
  23   * More information here: https://developer.android.com/distribute/users/banners.html
  24   *
  25   * @package    tool_mobile
  26   * @copyright  2017 Juan Leyva
  27   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  28   */
  29  
  30  define('NO_DEBUG_DISPLAY', true);
  31  define('NO_MOODLE_COOKIES', true);
  32  
  33  require_once(__DIR__ . '/../../../config.php');
  34  
  35  header('Content-Type: application/json; charset: utf-8');
  36  
  37  $mobilesettings = get_config('tool_mobile');
  38  // Display manifest contents only if all the required conditions are met.
  39  if (!empty($CFG->enablemobilewebservice) && !empty($mobilesettings->enablesmartappbanners) &&
  40          !empty($mobilesettings->androidappid)) {
  41  
  42      $manifest = new StdClass;
  43      $manifest->short_name = format_string($SITE->shortname, true, [
  44          'context' => context_system::instance(),
  45      ]);
  46      $manifest->prefer_related_applications = true;
  47      $manifest->icons = [(object)
  48          [
  49              'sizes' => '144x144',
  50              'type' => 'image/png',
  51              'src' => "$CFG->wwwroot/$CFG->admin/tool/mobile/pix/icon_144.png"
  52          ]
  53      ];
  54      $manifest->related_applications = [(object)
  55          [
  56              'platform' => 'play',
  57              'id' => $mobilesettings->androidappid,
  58          ]
  59      ];
  60      echo json_encode($manifest);
  61  }
  62  die;