Repository navigation
Expand file tree
/
Copy pathsettings.php
More file actions
163 lines (141 loc) · 5.61 KB
/
Copy pathsettings.php
File metadata and controls
163 lines (141 loc) · 5.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plugin administration pages are defined here.
*
* @package tool_s3logs
* @category admin
* @copyright 2017 Matt Porritt <mattp@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
use tool_s3logs\admin_settings_aws_region;
if ($hassiteconfig) {
$settings = new admin_settingpage('tool_s3logs', get_string('pluginname', 'tool_s3logs'));
$ADMIN->add('tools', $settings);
$settings->add(new admin_setting_heading('tool_s3logs_settings', '', get_string('pluginnamedesc', 'tool_s3logs')));
if (! during_initial_install()) {
// General Settings.
$settings->add(new admin_setting_heading(
'tool_s3logs_general',
get_string('generalsettings', 'tool_s3logs'),
''
));
// Async check for S3 connection, permissions, and task health (uses core check API via AJAX).
$settings->add(new admin_setting_check(
'tool_s3logs/check_status',
new \tool_s3logs\check\status(),
true
));
$settings->add(new admin_setting_configcheckbox(
'tool_s3logs/enable',
get_string('enable', 'tool_s3logs'),
get_string('enable_desc', 'tool_s3logs'),
0
));
$settings->add(new admin_setting_configduration(
'tool_s3logs/maxruntime',
get_string('maxruntime', 'tool_s3logs'),
get_string('maxruntime_desc', 'tool_s3logs'),
'86400'
));
// Log Archive settings.
$settings->add(new admin_setting_heading(
'tool_s3logs_archive',
get_string('archivesettings', 'tool_s3logs'),
''
));
$settings->add(new admin_setting_configduration(
'tool_s3logs/maxlogage',
get_string('maxlogage', 'tool_s3logs'),
get_string('maxlogage_desc', 'tool_s3logs'),
60 * 60 * 24 * 30 * 18, // 18 months, expressed in seconds (standardising on a month as 30 days).
60 * 60 * 24 // Default unit: days.
));
$settings->add(new admin_setting_configtext(
'tool_s3logs/prefix',
get_string('prefix', 'tool_s3logs'),
get_string('prefix_desc', 'tool_s3logs'),
'',
PARAM_ALPHA
));
$settings->add(new admin_setting_configtext(
'tool_s3logs/courseids',
get_string('courseids', 'tool_s3logs'),
get_string('courseids_desc', 'tool_s3logs'),
'',
PARAM_SEQUENCE
));
$settings->add(new admin_setting_configselect(
'tool_s3logs/coursefiltermode',
get_string('coursefiltermode', 'tool_s3logs'),
get_string('coursefiltermode_desc', 'tool_s3logs'),
'include',
[
'include' => get_string('coursefiltermode_include', 'tool_s3logs'),
'exclude' => get_string('coursefiltermode_exclude', 'tool_s3logs'),
]
));
$settings->add(new admin_setting_configcheckbox(
'tool_s3logs/vacuum_after_delete',
get_string('vacuumafterdelete', 'tool_s3logs'),
get_string('vacuumafterdelete_desc', 'tool_s3logs'),
0
));
// AWS Bucket and S3 settings.
$settings->add(new admin_setting_heading(
'tool_s3logs_awss3',
get_string('awss3settings', 'tool_s3logs'),
''
));
$settings->add(new admin_setting_configtext(
'tool_s3logs/bucket',
get_string('bucket', 'tool_s3logs'),
get_string('bucket_desc', 'tool_s3logs'),
'',
PARAM_TEXT,
60
));
$settings->add(new admin_settings_aws_region(
'tool_s3logs/s3region',
get_string('s3region', 'tool_s3logs'),
get_string('s3region_desc', 'tool_s3logs'),
'ap-southeast-2'
));
$settings->add(new admin_setting_configcheckbox(
'tool_s3logs/usesdkcreds',
get_string('usesdkcreds', 'tool_s3logs'),
get_string('usesdkcreds_desc', 'tool_s3logs'),
0
));
$settings->add(new admin_setting_configtext(
'tool_s3logs/keyid',
get_string('keyid', 'tool_s3logs'),
get_string('keyid_desc', 'tool_s3logs'),
'',
PARAM_TEXT
));
$settings->add(new admin_setting_configpasswordunmask(
'tool_s3logs/secretkey',
get_string('secretkey', 'tool_s3logs'),
get_string('secretkey_desc', 'tool_s3logs'),
''
));
// Hide the explicit credential fields when using the SDK's default credential chain.
$settings->hide_if('tool_s3logs/keyid', 'tool_s3logs/usesdkcreds', 'checked');
$settings->hide_if('tool_s3logs/secretkey', 'tool_s3logs/usesdkcreds', 'checked');
}
}