Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
// This file is part of Moodle - http://moodle.org/
4
//
5
// Moodle is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// Moodle is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17
 
18
/**
19
* This file defines settingpages and externalpages under the "badges" section
20
*
21
* @package    core
22
* @subpackage badges
23
* @copyright  2012 onwards Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
24
* @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
* @author     Yuliya Bozhko <yuliya.bozhko@totaralms.com>
26
*/
27
 
28
global $SITE;
29
 
30
if (($hassiteconfig || has_any_capability(array(
31
            'moodle/badges:viewawarded',
32
            'moodle/badges:createbadge',
33
            'moodle/badges:manageglobalsettings',
34
            'moodle/badges:awardbadge',
35
            'moodle/badges:configurecriteria',
36
            'moodle/badges:configuremessages',
37
            'moodle/badges:configuredetails',
38
            'moodle/badges:deletebadge'), $systemcontext))) {
39
 
40
    require_once($CFG->libdir . '/badgeslib.php');
41
 
42
    $globalsettings = new admin_settingpage('badgesettings', new lang_string('badgesettings', 'badges'),
43
            array('moodle/badges:manageglobalsettings'), empty($CFG->enablebadges));
44
 
45
    $globalsettings->add(new admin_setting_configtext('badges_defaultissuername',
46
            new lang_string('defaultissuername', 'badges'),
47
            new lang_string('defaultissuername_desc', 'badges'),
48
            $SITE->fullname ? $SITE->fullname : $SITE->shortname, PARAM_TEXT));
49
 
50
    $globalsettings->add(new admin_setting_configtext('badges_defaultissuercontact',
51
            new lang_string('defaultissuercontact', 'badges'),
52
            new lang_string('defaultissuercontact_desc', 'badges'),
53
            get_config('moodle','supportemail'), PARAM_EMAIL));
54
 
55
    $globalsettings->add(new admin_setting_configtext('badges_badgesalt',
56
            new lang_string('badgesalt', 'badges'),
57
            new lang_string('badgesalt_desc', 'badges'),
58
            'badges' . $SITE->timecreated, PARAM_ALPHANUM));
59
 
60
    $globalsettings->add(new admin_setting_configcheckbox('badges_allowcoursebadges',
61
            new lang_string('allowcoursebadges', 'badges'),
62
            new lang_string('allowcoursebadges_desc', 'badges'), 1));
63
 
64
    $globalsettings->add(new admin_setting_configcheckbox('badges_allowexternalbackpack',
65
            new lang_string('allowexternalbackpack', 'badges'),
66
            new lang_string('allowexternalbackpack_desc', 'badges'), 1));
67
 
1441 ariadna 68
    $defaultcanvasregions = [
69
        'Australia|https://au.badgr.io|https://api.au.badgr.io/v2',
70
        'Canada|https://ca.badgr.io|https://api.ca.badgr.io/v2',
71
        'Europe|https://eu.badgr.io|https://api.eu.badgr.io/v2',
72
        'Singapore|https://sg.badgr.io|https://api.sg.badgr.io/v2',
73
        'United States|https://badgr.io|https://api.badgr.io/v2',
74
    ];
75
    $globalsettings->add(new admin_setting_configtextarea(
76
        'badges_canvasregions',
77
        new lang_string('canvasregions', 'badges'),
78
        new lang_string('canvasregions_desc', 'badges'),
79
        implode("\n", $defaultcanvasregions),
80
        PARAM_RAW,
81
    ));
82
 
1 efrain 83
    $ADMIN->add('badges', $globalsettings);
84
 
85
    $ADMIN->add('badges',
86
        new admin_externalpage('managebadges',
87
            new lang_string('managebadges', 'badges'),
88
            new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_SITE)),
89
            array(
90
                'moodle/badges:viewawarded',
91
                'moodle/badges:createbadge',
92
                'moodle/badges:awardbadge',
93
                'moodle/badges:configurecriteria',
94
                'moodle/badges:configuremessages',
95
                'moodle/badges:configuredetails',
96
                'moodle/badges:deletebadge'
97
            ),
98
            empty($CFG->enablebadges)
99
        )
100
    );
101
 
102
    $ADMIN->add('badges',
103
        new admin_externalpage('newbadge',
104
            new lang_string('newbadge', 'badges'),
1441 ariadna 105
            new moodle_url('/badges/edit.php', ['action' => 'new']),
1 efrain 106
            array('moodle/badges:createbadge'), empty($CFG->enablebadges)
107
        )
108
    );
109
 
110
    $ADMIN->add('badges',
111
        new admin_externalpage('managebackpacks',
112
            new lang_string('managebackpacks', 'badges'),
113
            new moodle_url('/badges/backpacks.php'),
114
            array('moodle/badges:manageglobalsettings'), empty($CFG->enablebadges) || empty($CFG->badges_allowexternalbackpack)
115
        )
116
    );
117
}