MDL-43146 enrol_imsenterprise: missing sesskey protection
[moodle.git] / enrol / imsenterprise / settings.php
CommitLineData
fa36ca3d 1<?php
fa36ca3d
AB
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/**
18 * IMS Enterprise enrolments plugin settings and presets.
19 *
31ac2aef 20 * @package enrol_imsenterprise
97c65be5
PS
21 * @copyright 2010 Eugene Venter
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
fa36ca3d
AB
23 */
24
97795859 25defined('MOODLE_INTERNAL') || die();
fa36ca3d
AB
26
27if ($ADMIN->fulltree) {
79c5c3fa 28 require_once($CFG->dirroot.'/enrol/imsenterprise/locallib.php');
fa36ca3d 29
295e4fa8
DP
30 $settings->add(new admin_setting_heading('enrol_imsenterprise_settings', '',
31 get_string('pluginname_desc', 'enrol_imsenterprise')));
fa36ca3d 32
295e4fa8
DP
33 // General settings.
34 $settings->add(new admin_setting_heading('enrol_imsenterprise_basicsettings',
35 get_string('basicsettings', 'enrol_imsenterprise'), ''));
fa36ca3d 36
295e4fa8
DP
37 $settings->add(new admin_setting_configtext('enrol_imsenterprise/imsfilelocation',
38 get_string('location', 'enrol_imsenterprise'), '', ''));
fa36ca3d 39
295e4fa8
DP
40 $settings->add(new admin_setting_configtext('enrol_imsenterprise/logtolocation',
41 get_string('logtolocation', 'enrol_imsenterprise'), '', ''));
fa36ca3d 42
295e4fa8
DP
43 $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/mailadmins',
44 get_string('mailadmins', 'enrol_imsenterprise'), '', 0));
fa36ca3d 45
295e4fa8
DP
46 // User data options.
47 $settings->add(new admin_setting_heading('enrol_imsenterprise_usersettings',
48 get_string('usersettings', 'enrol_imsenterprise'), ''));
fa36ca3d 49
295e4fa8
DP
50 $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewusers',
51 get_string('createnewusers', 'enrol_imsenterprise'), get_string('createnewusers_desc', 'enrol_imsenterprise'), 0));
fa36ca3d 52
295e4fa8
DP
53 $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imsdeleteusers',
54 get_string('deleteusers', 'enrol_imsenterprise'), get_string('deleteusers_desc', 'enrol_imsenterprise'), 0));
fa36ca3d 55
295e4fa8
DP
56 $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/fixcaseusernames',
57 get_string('fixcaseusernames', 'enrol_imsenterprise'), '', 0));
fa36ca3d 58
295e4fa8
DP
59 $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/fixcasepersonalnames',
60 get_string('fixcasepersonalnames', 'enrol_imsenterprise'), '', 0));
fa36ca3d 61
295e4fa8
DP
62 $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imssourcedidfallback',
63 get_string('sourcedidfallback', 'enrol_imsenterprise'), get_string('sourcedidfallback_desc', 'enrol_imsenterprise'), 0));
fa36ca3d 64
295e4fa8
DP
65 $settings->add(new admin_setting_heading('enrol_imsenterprise_usersettings_roles',
66 get_string('roles', 'enrol_imsenterprise'), get_string('imsrolesdescription', 'enrol_imsenterprise')));
fa36ca3d
AB
67
68 if (!during_initial_install()) {
55bcef29 69 $coursecontext = context_course::instance(SITEID);
74f64f62 70 $assignableroles = get_assignable_roles($coursecontext);
fa36ca3d
AB
71 $assignableroles = array('0' => get_string('ignore', 'enrol_imsenterprise')) + $assignableroles;
72 $imsroles = new imsenterprise_roles();
fa36ca3d 73 foreach ($imsroles->get_imsroles() as $imsrolenum => $imsrolename) {
295e4fa8
DP
74 $settings->add(new admin_setting_configselect('enrol_imsenterprise/imsrolemap'.$imsrolenum,
75 format_string('"'.$imsrolename.'" ('.$imsrolenum.')'), '',
76 (int)$imsroles->determine_default_rolemapping($imsrolenum), $assignableroles));
fa36ca3d
AB
77 }
78 }
79
295e4fa8
DP
80 // Course data options.
81 $settings->add(new admin_setting_heading('enrol_imsenterprise_coursesettings',
82 get_string('coursesettings', 'enrol_imsenterprise'), ''));
fa36ca3d 83
295e4fa8
DP
84 $settings->add(new admin_setting_configtext('enrol_imsenterprise/truncatecoursecodes',
85 get_string('truncatecoursecodes', 'enrol_imsenterprise'), get_string('truncatecoursecodes_desc', 'enrol_imsenterprise'),
86 0, PARAM_INT, 2));
fa36ca3d 87
295e4fa8
DP
88 $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewcourses',
89 get_string('createnewcourses', 'enrol_imsenterprise'), get_string('createnewcourses_desc', 'enrol_imsenterprise'), 0));
fa36ca3d 90
295e4fa8
DP
91 $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewcategories',
92 get_string('createnewcategories', 'enrol_imsenterprise'), get_string('createnewcategories_desc', 'enrol_imsenterprise'),
93 0));
fa36ca3d 94
295e4fa8
DP
95 $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imsunenrol',
96 get_string('allowunenrol', 'enrol_imsenterprise'), get_string('allowunenrol_desc', 'enrol_imsenterprise'), 0));
a65c11b0
AS
97
98 if (!during_initial_install()) {
66dad719
DM
99 $imscourses = new imsenterprise_courses();
100 foreach ($imscourses->get_courseattrs() as $courseattr) {
101
295e4fa8 102 // The assignable values of this course attribute.
66dad719
DM
103 $assignablevalues = $imscourses->get_imsnames($courseattr);
104 $name = get_string('setting' . $courseattr, 'enrol_imsenterprise');
105 $description = get_string('setting' . $courseattr . 'description', 'enrol_imsenterprise');
106 $defaultvalue = (string) $imscourses->determine_default_coursemapping($courseattr);
295e4fa8
DP
107 $settings->add(new admin_setting_configselect('enrol_imsenterprise/imscoursemap' . $courseattr, $name,
108 $description, $defaultvalue, $assignablevalues));
a65c11b0
AS
109 }
110 }
fa36ca3d 111
295e4fa8
DP
112 // Miscellaneous.
113 $settings->add(new admin_setting_heading('enrol_imsenterprise_miscsettings',
114 get_string('miscsettings', 'enrol_imsenterprise'), ''));
fa36ca3d 115
295e4fa8
DP
116 $settings->add(new admin_setting_configtext('enrol_imsenterprise/imsrestricttarget',
117 get_string('restricttarget', 'enrol_imsenterprise'), get_string('restricttarget_desc', 'enrol_imsenterprise'), ''));
fa36ca3d 118
295e4fa8
DP
119 $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imscapitafix',
120 get_string('usecapitafix', 'enrol_imsenterprise'), get_string('usecapitafix_desc', 'enrol_imsenterprise'), 0));
fa36ca3d 121
caf76650
DP
122 $importurl = new moodle_url('/enrol/imsenterprise/importnow.php', array('sesskey' => sesskey()));
123 $importnowstring = get_string('aftersaving...', 'enrol_imsenterprise').' ';
124 $importnowstring .= html_writer::link($importurl, get_string('doitnow', 'enrol_imsenterprise'));
fa36ca3d
AB
125 $settings->add(new admin_setting_heading('enrol_imsenterprise_doitnowmessage', '', $importnowstring));
126}