-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsettings.php
110 lines (91 loc) · 4.42 KB
/
settings.php
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
<?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 <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
use tool_s3logs\local\client\s3_client;
use tool_s3logs\admin_settings_aws_region;
global $PAGE;
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 ()) {
$clientstatus = '';
$sdkstatus = '';
// Check client actual status only when we are on the settings page.
if ($PAGE->has_set_url()) {
$settingsurl = new moodle_url('/admin/settings.php');
if ($settingsurl->compare($PAGE->url, URL_MATCH_BASE) && $PAGE->url->get_param('section') == 'tool_s3logs') {
$client = new s3_client();
$clientstatus = $client->get_client_status_message();
$sdkstatus = $client->get_sdk_credentials_status();
}
}
// General Settings.
$settings->add(new admin_setting_heading('tool_s3logs_general',
get_string('generalsettings', 'tool_s3logs'),
''));
$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_configtext('tool_s3logs/maxlogage',
get_string('maxlogage', 'tool_s3logs' ),
get_string('maxlogage_desc', 'tool_s3logs'),
18, PARAM_INT));
$settings->add(new admin_setting_configtext('tool_s3logs/prefix',
get_string('prefix', 'tool_s3logs' ),
get_string('prefix_desc', 'tool_s3logs'),
'', PARAM_ALPHA));
// AWS Bucket and S3 settings.
$settings->add(new admin_setting_heading('tool_s3logs_awss3',
get_string('awss3settings', 'tool_s3logs'),
$clientstatus));
$settings->add(new admin_setting_configcheckbox('tool_s3logs/usesdkcreds',
get_string('usesdkcreds', 'tool_s3logs'),
get_string('usesdkcreds_desc', 'tool_s3logs') . $sdkstatus, 0));
$settings->add(new admin_setting_configtext('tool_s3logs/bucket',
get_string('bucket', 'tool_s3logs' ),
get_string('bucket_desc', 'tool_s3logs'),
'', PARAM_TEXT));
$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'),
''));
$settings->add(new admin_settings_aws_region('tool_s3logs/s3region',
get_string('s3region', 'tool_s3logs'),
get_string('s3region_desc', 'tool_s3logs'),
'ap-southeast-2'));
}
}