Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 
32
require_once(__DIR__ . '/../../../config.php');
33
 
34
header('Content-Type: application/json; charset: utf-8');
35
 
36
$mobilesettings = get_config('tool_mobile');
37
// Display manifest contents only if all the required conditions are met.
38
if (!empty($CFG->enablemobilewebservice) && !empty($mobilesettings->enablesmartappbanners) &&
39
        !empty($mobilesettings->androidappid)) {
40
 
41
    $manifest = new StdClass;
42
    $manifest->short_name = format_string($SITE->shortname, true, [
43
        'context' => \core\context\system::instance(),
44
    ]);
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;