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
// This program 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
// This program 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
 * Return app properties as XML
19
 *
20
 * @package mod_edusharing
21
 * @copyright metaVentis GmbH — http://metaventis.com
22
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
use EduSharingApiClient\EduSharingHelper;
26
use mod_edusharing\EduSharingService;
27
use mod_edusharing\MetadataLogic;
28
 
29
require_once(dirname(__FILE__) . '/../../config.php');
30
 
31
try {
32
    require_login();
33
} catch (Exception $exception) {
34
    echo $exception->getMessage();
35
    unset($exception);
36
    exit();
37
}
38
 
39
try {
40
    $publickey = get_config('edusharing', 'application_public_key');
41
} catch (Exception $exception) {
42
    $publickey = '';
43
    unset($exception);
44
}
45
 
46
if (empty($publickey)) {
47
    try {
48
        $keypair = EduSharingHelper::generateKeyPair();
49
        set_config('application_public_key', $keypair['publicKey'], 'edusharing');
50
        set_config('application_private_key', $keypair['privateKey'], 'edusharing');
51
    } catch (Exception $exception) {
52
        debugging($exception->getMessage());
53
    }
54
}
55
$logic    = new MetadataLogic(new EduSharingService());
56
$metadata = $logic->create_xml_metadata();
57
 
58
header('Content-type: text/xml');
59
print($metadata);
60
exit();