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
 * User preferences page
18
 *
19
 * @package     tool_mfa
20
 * @author      Mikhail Golenkov <golenkovm@gmail.com>
21
 * @copyright   Catalyst IT
22
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
require_once(__DIR__ . '/../../../config.php');
26
 
27
require_login(null, false);
28
if (isguestuser()) {
29
    throw new require_login_exception('error:isguestuser', 'tool_mfa');
30
}
31
 
32
$action = optional_param('action', '', PARAM_TEXT);
33
$factorid = optional_param('factorid', 0, PARAM_INT);
34
 
35
$context = context_user::instance($USER->id);
36
$PAGE->set_context($context);
37
$PAGE->set_url('/admin/tool/mfa/user_preferences.php');
38
$PAGE->set_pagelayout('standard');
39
$PAGE->set_title(get_string('preferences:header', 'tool_mfa'));
40
$PAGE->set_cacheable(false);
41
 
42
if ($node = $PAGE->settingsnav->find('usercurrentsettings', null)) {
43
    $PAGE->navbar->add($node->get_content(), $node->action());
44
}
45
$PAGE->navbar->add(get_string('preferences:header', 'tool_mfa'), new \moodle_url('/admin/tool/mfa/user_preferences.php'));
46
$OUTPUT = $PAGE->get_renderer('tool_mfa');
47
 
48
echo $OUTPUT->header();
49
if (!empty($action)) {
50
    if ($factorid != 0) {
51
        $instance = \tool_mfa\plugininfo\factor::get_instance_from_id($factorid);
52
        // Confirm factor is valid for the accessing user.
53
        if ($USER->id == $instance->userid) {
54
            $factor = \tool_mfa\plugininfo\factor::get_factor($instance->factor);
55
            $string = $factor->get_display_name().' - '.$instance->label;
56
            echo $OUTPUT->notification(get_string('factor'.$action, 'tool_mfa', $string), 'notifysuccess');
57
        }
58
    }
59
}
60
 
61
echo $OUTPUT->available_factors();
62
 
63
$renderer = $PAGE->get_renderer('tool_mfa');
64
echo $renderer->get_support_link();
65
 
66
\tool_mfa\manager::display_debug_notification();
67
 
68
echo $OUTPUT->footer();
69
 
70
if (!empty($SESSION->tool_mfa_setwantsurl) && $SESSION->tool_mfa_setwantsurl
71
    && \tool_mfa\manager::get_total_weight() >= 100) {
72
    unset($SESSION->wantsurl);
73
}