2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * General plugin functions.
21 * @copyright 2016 Mark Nelson <markn@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 use enrol_lti\local\ltiadvantage\admin\admin_setting_registeredplatforms
;
27 defined('MOODLE_INTERNAL') ||
die;
28 // The 'Publish as LTI tool' node is a category.
29 $ADMIN->add('enrolments', new admin_category('enrolltifolder', new lang_string('pluginname', 'enrol_lti'),
30 $this->is_enabled() === false));
32 $settings = new admin_settingpage($section, "User default values", 'moodle/site:config', $this->is_enabled() === false);
33 // Add all the user default values settings to the first page.
34 if ($ADMIN->fulltree
) {
35 $settings->add(new admin_setting_heading('enrol_lti_settings', '', get_string('pluginname_desc', 'enrol_lti')));
37 if (!is_enabled_auth('lti')) {
38 $notify = new \core\output\notification
(get_string('authltimustbeenabled', 'enrol_lti'),
39 \core\output\notification
::NOTIFY_WARNING
);
40 $settings->add(new admin_setting_heading('enrol_lti_enable_auth_lti', '', $OUTPUT->render($notify)));
43 if (empty($CFG->allowframembedding
)) {
44 $notify = new \core\output\notification
(get_string('allowframeembedding', 'enrol_lti'),
45 \core\output\notification
::NOTIFY_WARNING
);
46 $settings->add(new admin_setting_heading('enrol_lti_enable_embedding', '', $OUTPUT->render($notify)));
49 $settings->add(new admin_setting_heading('enrol_lti_user_default_values',
50 get_string('userdefaultvalues', 'enrol_lti'), ''));
52 $choices = array(0 => get_string('emaildisplayno'),
53 1 => get_string('emaildisplayyes'),
54 2 => get_string('emaildisplaycourse'));
55 $maildisplay = isset($CFG->defaultpreference_maildisplay
) ?
$CFG->defaultpreference_maildisplay
: 2;
56 $settings->add(new admin_setting_configselect('enrol_lti/emaildisplay', get_string('emaildisplay'),
57 get_string('emaildisplay_help'), $maildisplay, $choices));
60 if (!empty($CFG->defaultcity
)) {
61 $city = $CFG->defaultcity
;
63 $settings->add(new admin_setting_configtext('enrol_lti/city', get_string('city'), '', $city));
66 if (!empty($CFG->country
)) {
67 $country = $CFG->country
;
69 $countries = array('' => get_string('selectacountry') . '...') +
get_string_manager()->get_list_of_countries();
70 $settings->add(new admin_setting_configselect('enrol_lti/country', get_string('selectacountry'), '', $country,
73 $settings->add(new admin_setting_configselect('enrol_lti/timezone', get_string('timezone'), '', 99,
74 core_date
::get_list_of_timezones(null, true)));
76 $settings->add(new admin_setting_configselect('enrol_lti/lang', get_string('preferredlanguage'), '', $CFG->lang
,
77 get_string_manager()->get_list_of_translations()));
79 $settings->add(new admin_setting_configtext('enrol_lti/institution', get_string('institution'), '', ''));
81 $ADMIN->add('enrolltifolder', $settings);
83 // Now, create a tool registrations settings page.
84 $settings = new admin_settingpage('enrolsettingslti_registrations', "Tool registration", 'moodle/site:config',
85 $this->is_enabled() === false);
87 $settings->add(new admin_setting_heading('enrol_lti_tool_registrations_heading',
88 get_string('registeredplatforms', 'enrol_lti'), ''));
89 $settings->add(new admin_setting_registeredplatforms());
91 $ADMIN->add('enrolltifolder', $settings);
93 // This adds a settings page to the 'publish as LTI tool' folder, hidden.
94 // On this page, we'll override the active node to force a match on enrolsettingslti_registrations settings page.
95 $ADMIN->add('enrolltifolder', new admin_externalpage('enrolsettingslti_registrations_edit',
96 get_string('registerplatformadd', 'enrol_lti'), "$CFG->wwwroot/$CFG->admin/enrol/lti/register_platform.php",
97 'moodle/site:config', true));
99 // And deployments add/edit.
100 $ADMIN->add('enrolltifolder', new admin_externalpage('enrolsettingslti_deployment_manage',
101 get_string('deployments', 'enrol_lti'), "$CFG->wwwroot/$CFG->admin/enrol/lti/manage_deployment.php",
102 'moodle/site:config', true));
104 // Tell core we're finished.