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
// 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
 * MFA configuration 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
 
26
require_once(__DIR__ . '/../../../config.php');
27
require_once(__DIR__ . '/lib.php');
28
require_once($CFG->libdir.'/adminlib.php');
29
require_once($CFG->libdir.'/tablelib.php');
30
 
31
require_login(null, false);
32
require_capability('moodle/site:config', context_system::instance());
33
 
34
$returnurl = get_local_referer(false);
35
 
36
$PAGE->set_url('/admin/tool/mfa/index.php');
37
 
38
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
1441 ariadna 39
$factor = optional_param('plugin', '', PARAM_ALPHANUMEXT);
1 efrain 40
 
41
if (empty($factor) || !\tool_mfa\plugininfo\factor::factor_exists($factor)) {
42
    throw new moodle_exception('factornotfound', 'tool_mfa', $returnurl, $factor);
43
}
44
 
45
if (empty($action) || !in_array($action, \tool_mfa\plugininfo\factor::get_factor_actions())) {
46
    throw new moodle_exception('actionnotfound', 'tool_mfa', $returnurl, $action);
47
}
48
 
49
require_sesskey();
50
 
1441 ariadna 51
$class = \core_plugin_manager::resolve_plugininfo_class('factor');
1 efrain 52
 
53
switch ($action) {
54
    case 'disable':
1441 ariadna 55
        $class::enable_plugin($factor, 0);
1 efrain 56
        break;
57
    case 'enable':
1441 ariadna 58
        $class::enable_plugin($factor, 1);
1 efrain 59
        break;
60
    case 'up':
1441 ariadna 61
        $class::change_plugin_order($factor, $class::MOVE_UP);
62
        break;
1 efrain 63
    case 'down':
1441 ariadna 64
        $class::change_plugin_order($factor, $class::MOVE_DOWN);
1 efrain 65
        break;
66
}
67
 
68
redirect($returnurl);