| 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 |
* Provides an overview of installed availability conditions.
|
|
|
19 |
*
|
|
|
20 |
* You can also enable/disable them from this screen.
|
|
|
21 |
*
|
|
|
22 |
* @package tool_availabilityconditions
|
|
|
23 |
* @copyright 2014 The Open University
|
|
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
25 |
*/
|
|
|
26 |
|
|
|
27 |
require_once(__DIR__ . '/../../../config.php');
|
|
|
28 |
require_once($CFG->libdir . '/adminlib.php');
|
|
|
29 |
require_once($CFG->libdir . '/tablelib.php');
|
|
|
30 |
|
|
|
31 |
admin_externalpage_setup('manageavailability');
|
|
|
32 |
|
|
|
33 |
// Get sorted list of all availability condition plugins.
|
| 1441 |
ariadna |
34 |
$plugins = [];
|
| 1 |
efrain |
35 |
foreach (core_component::get_plugin_list('availability') as $plugin => $plugindir) {
|
|
|
36 |
if (get_string_manager()->string_exists('pluginname', 'availability_' . $plugin)) {
|
|
|
37 |
$strpluginname = get_string('pluginname', 'availability_' . $plugin);
|
|
|
38 |
} else {
|
|
|
39 |
$strpluginname = $plugin;
|
|
|
40 |
}
|
|
|
41 |
$plugins[$plugin] = $strpluginname;
|
|
|
42 |
}
|
|
|
43 |
core_collator::asort($plugins);
|
|
|
44 |
|
|
|
45 |
// Do plugin actions.
|
|
|
46 |
$pageurl = new moodle_url('/' . $CFG->admin . '/tool/availabilityconditions/');
|
| 1441 |
ariadna |
47 |
$classavailability = \core_plugin_manager::resolve_plugininfo_class('availability');
|
| 1 |
efrain |
48 |
if (($plugin = optional_param('plugin', '', PARAM_PLUGIN))) {
|
|
|
49 |
require_sesskey();
|
|
|
50 |
if (!array_key_exists($plugin, $plugins)) {
|
|
|
51 |
throw new \moodle_exception('invalidcomponent', 'error', $pageurl);
|
|
|
52 |
}
|
| 1441 |
ariadna |
53 |
$action = optional_param('action', '', PARAM_ALPHA);
|
|
|
54 |
if ($action === 'hide' && $classavailability::enable_plugin($plugin, 0)) {
|
|
|
55 |
\core\notification::add(
|
|
|
56 |
\core\notification::SUCCESS
|
|
|
57 |
);
|
|
|
58 |
} else if ($action === 'show' && $classavailability::enable_plugin($plugin, 1)) {
|
|
|
59 |
\core\notification::add(
|
|
|
60 |
\core\notification::SUCCESS
|
|
|
61 |
);
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
$displaymode = optional_param('displaymode', '', PARAM_ALPHA);
|
|
|
65 |
switch ($displaymode) {
|
| 1 |
efrain |
66 |
case 'hide' :
|
| 1441 |
ariadna |
67 |
$classavailability::update_display_mode($plugin, false);
|
| 1 |
efrain |
68 |
break;
|
|
|
69 |
case 'show' :
|
| 1441 |
ariadna |
70 |
$classavailability::update_display_mode($plugin, true);
|
| 1 |
efrain |
71 |
break;
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
// Always redirect back after an action.
|
|
|
75 |
redirect($pageurl);
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
echo $OUTPUT->header();
|
|
|
79 |
echo $OUTPUT->heading(get_string('manageplugins', 'availability'));
|
|
|
80 |
|
| 1441 |
ariadna |
81 |
$table = new \core_admin\table\availability_management_table();
|
|
|
82 |
$table->out();
|
| 1 |
efrain |
83 |
echo $OUTPUT->footer();
|