Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 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  use tool_mobile\api;
  35  
  36  header('Content-Type: application/json; charset: utf-8');
  37  
  38  $mobilesettings = get_config('tool_mobile');
  39  // Display manifest contents only if all the required conditions are met.
  40  if (!empty($CFG->enablemobilewebservice) && !empty($mobilesettings->enablesmartappbanners) &&
  41          !empty($mobilesettings->androidappid)) {
  42  
  43      $manifest = new StdClass;
  44      $manifest->short_name = format_string($SITE->shortname);
  45      $manifest->prefer_related_applications = true;
  46      $manifest->icons = [(object)
  47          [
  48              'sizes' => '144x144',
  49              'type' => 'image/png',
  50              'src' => "$CFG->wwwroot/$CFG->admin/tool/mobile/pix/icon_144.png"
  51          ]
  52      ];
  53      $manifest->related_applications = [(object)
  54          [
  55              'platform' => 'play',
  56              'id' => $mobilesettings->androidappid,
  57          ]
  58      ];
  59      echo json_encode($manifest);
  60  }
  61  die;