-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsettings.php
More file actions
115 lines (94 loc) · 5.7 KB
/
settings.php
File metadata and controls
115 lines (94 loc) · 5.7 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
<?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/>.
/**
* General plugin functions.
*
* @package enrol_lticoursetemplate
* @copyright 2016 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use enrol_lticoursetemplate\local\ltiadvantage\admin\admin_setting_registeredplatforms;
defined('MOODLE_INTERNAL') || die;
// The 'Publish as LTI Course Template tool' node is a category.
$ADMIN->add('enrolments', new admin_category('enrollticoursetemplatefolder', new lang_string('pluginname', 'enrol_lticoursetemplate'),
$this->is_enabled() === false));
$settings = new admin_settingpage($section, "User default values", 'moodle/site:config', $this->is_enabled() === false);
// Add all the user default values settings to the first page.
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('enrol_lticoursetemplate_settings', '', get_string('pluginname_desc', 'enrol_lticoursetemplate')));
if (!is_enabled_auth('lti')) {
$notify = new \core\output\notification(get_string('authltimustbeenabled', 'enrol_lticoursetemplate'),
\core\output\notification::NOTIFY_WARNING);
$settings->add(new admin_setting_heading('enrol_lticoursetemplate_enable_auth_lti', '', $OUTPUT->render($notify)));
}
if (empty($CFG->allowframembedding)) {
$notify = new \core\output\notification(get_string('allowframeembedding', 'enrol_lticoursetemplate'),
\core\output\notification::NOTIFY_WARNING);
$settings->add(new admin_setting_heading('enrol_lticoursetemplate_enable_embedding', '', $OUTPUT->render($notify)));
}
$settings->add(new admin_setting_heading('enrol_lticoursetemplate_user_default_values',
get_string('userdefaultvalues', 'enrol_lticoursetemplate'), ''));
$choices = array(0 => get_string('emaildisplayno'),
1 => get_string('emaildisplayyes'),
2 => get_string('emaildisplaycourse'));
$maildisplay = isset($CFG->defaultpreference_maildisplay) ? $CFG->defaultpreference_maildisplay : 2;
$settings->add(new admin_setting_configselect('enrol_lticoursetemplate/emaildisplay', get_string('emaildisplay'),
get_string('emaildisplay_help'), $maildisplay, $choices));
$city = '';
if (!empty($CFG->defaultcity)) {
$city = $CFG->defaultcity;
}
$settings->add(new admin_setting_configtext('enrol_lticoursetemplate/city', get_string('city'), '', $city));
$country = '';
if (!empty($CFG->country)) {
$country = $CFG->country;
}
$countries = array('' => get_string('selectacountry') . '...') + get_string_manager()->get_list_of_countries();
$settings->add(new admin_setting_configselect('enrol_lticoursetemplate/country', get_string('selectacountry'), '', $country,
$countries));
$settings->add(new admin_setting_configselect('enrol_lticoursetemplate/timezone', get_string('timezone'), '', 99,
core_date::get_list_of_timezones(null, true)));
$settings->add(new admin_setting_configselect('enrol_lticoursetemplate/lang', get_string('preferredlanguage'), '', $CFG->lang,
get_string_manager()->get_list_of_translations()));
$settings->add(new admin_setting_configtext('enrol_lticoursetemplate/institution', get_string('institution'), '', ''));
$settings->add(new admin_setting_heading('enrol_lticoursetemplate_admin_default_values',
get_string('admindefaultvalues', 'enrol_lticoursetemplate'), ''));
$manager = $USER->id;
if (!empty($CFG->manager)) {
$manager = $CFG->manager;
}
$settings->add(new admin_setting_configtext('enrol_lticoursetemplate/manager', get_string('manager',
'enrol_lticoursetemplate'), get_string('manager_help', 'enrol_lticoursetemplate'), $manager, PARAM_INT));
}
$ADMIN->add('enrollticoursetemplatefolder', $settings);
// Now, create a tool registrations settings page.
$settings = new admin_settingpage('enrolsettingsltict_registrations', "Tool registration", 'moodle/site:config',
$this->is_enabled() === false);
$settings->add(new admin_setting_heading('enrol_ct_tool_registrations_heading',
get_string('registeredplatforms', 'enrol_lticoursetemplate'), ''));
$settings->add(new admin_setting_registeredplatforms());
$ADMIN->add('enrollticoursetemplatefolder', $settings);
// This adds a settings page to the 'publish as LTI Course Template tool' folder, hidden.
// On this page, we'll override the active node to force a match on enrolsettingsltict_registrations settings page.
$ADMIN->add('enrollticoursetemplatefolder', new admin_externalpage('enrolsettingsltict_registrations_edit',
get_string('registerplatformadd', 'enrol_lticoursetemplate'), "$CFG->wwwroot/$CFG->admin/enrol/lticoursetemplate/register_platform.php",
'moodle/site:config', true));
// And deployments add/edit.
$ADMIN->add('enrollticoursetemplatefolder', new admin_externalpage('enrolsettingsltict_deployment_manage',
get_string('deployments', 'enrol_lticoursetemplate'), "$CFG->wwwroot/$CFG->admin/enrol/lticoursetemplate/manage_deployment.php",
'moodle/site:config', true));
// Tell core we're finished.
$settings = null;