Merge branch 'MDL-51177-master' of git://github.com/andrewnicols/moodle
[moodle.git] / admin / tool / mobile / mobile.webmanifest.php
blobfd764578bfdbfc6a2948ef0bd6c19f6d108f3d14
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.
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/>.
17 /**
18 * Web manifest for including a native app banner.
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
25 * @package tool_mobile
26 * @copyright 2017 Juan Leyva
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 define('NO_DEBUG_DISPLAY', true);
31 define('NO_MOODLE_COOKIES', true);
33 require_once(__DIR__ . '/../../../config.php');
34 use tool_mobile\api;
36 header('Content-Type: application/json; charset: utf-8');
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)) {
43 $manifest = new StdClass;
44 $manifest->short_name = format_string($SITE->shortname);
45 $manifest->prefer_related_applications = true;
46 $manifest->icons = [(object)
48 'sizes' => '144x144',
49 'type' => 'image/png',
50 'src' => "$CFG->wwwroot/$CFG->admin/tool/mobile/pix/icon_144.png"
53 $manifest->related_applications = [(object)
55 'platform' => 'play',
56 'id' => $mobilesettings->androidappid,
59 echo json_encode($manifest);
61 die;