1441 |
ariadna |
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 |
namespace core_admin\table;
|
|
|
18 |
|
|
|
19 |
use moodle_url;
|
|
|
20 |
use stdClass;
|
|
|
21 |
use html_writer;
|
|
|
22 |
use get_string_manager;
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* Availability admin settings.
|
|
|
26 |
*
|
|
|
27 |
* @package core_admin
|
|
|
28 |
* @copyright 2024 The Open University
|
|
|
29 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
30 |
*/
|
|
|
31 |
class availability_management_table extends plugin_management_table {
|
|
|
32 |
|
|
|
33 |
protected function get_table_id(): string {
|
|
|
34 |
return 'availabilityconditions_administration_table';
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
protected function get_plugintype(): string {
|
|
|
38 |
return 'availability';
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
protected function get_action_url(array $params = []): moodle_url {
|
|
|
42 |
return new moodle_url('/admin/tool/availabilityconditions/', $params);
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
public function guess_base_url(): void {
|
|
|
46 |
$this->define_baseurl(
|
|
|
47 |
new moodle_url('/admin/tool/availabilityconditions/')
|
|
|
48 |
);
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
protected function get_column_list(): array {
|
|
|
52 |
return [
|
|
|
53 |
'name' => get_string('plugin'),
|
|
|
54 |
'version' => get_string('version'),
|
|
|
55 |
'enabled' => get_string('enabled', 'admin'),
|
|
|
56 |
'defaultdisplaymode' => get_string('defaultdisplaymode', 'tool_availabilityconditions'),
|
|
|
57 |
];
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
public function setup(): void {
|
|
|
61 |
$this->set_attribute('id', 'availabilityconditions_administration_table');
|
|
|
62 |
$this->set_attribute('class', 'admintable generaltable');
|
|
|
63 |
parent::setup();
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
protected function col_name(stdClass $row): string {
|
|
|
67 |
return html_writer::span(
|
|
|
68 |
get_string('pluginname', 'availability_' . $row->plugininfo->name)
|
|
|
69 |
);
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
protected function col_defaultdisplaymode(stdClass $row): string {
|
|
|
73 |
global $OUTPUT, $CFG;
|
|
|
74 |
$displaymode = get_config('availability_' . $row->plugininfo->name, 'defaultdisplaymode') ? 'show' : 'hide';
|
|
|
75 |
$paramsdisplaymode = [
|
|
|
76 |
'sesskey' => sesskey(),
|
|
|
77 |
'plugin' => $row->plugininfo->name,
|
|
|
78 |
'displaymode' => $displaymode,
|
|
|
79 |
];
|
|
|
80 |
$urldisplaymode = new moodle_url('/' . $CFG->admin . '/tool/availabilityconditions/', $paramsdisplaymode);
|
|
|
81 |
|
|
|
82 |
return html_writer::link($urldisplaymode, $OUTPUT->pix_icon('t/' . $displaymode,
|
|
|
83 |
get_string($displaymode)), ['class' => 'display-mode-' . $row->plugininfo->name]);
|
|
|
84 |
}
|
|
|
85 |
}
|