MDL-43146 enrol_imsenterprise: missing sesskey protection
[moodle.git] / enrol / imsenterprise / settings.php
1 <?php
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/>.
17 /**
18  * IMS Enterprise enrolments plugin settings and presets.
19  *
20  * @package    enrol_imsenterprise
21  * @copyright  2010 Eugene Venter
22  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23  */
25 defined('MOODLE_INTERNAL') || die();
27 if ($ADMIN->fulltree) {
28     require_once($CFG->dirroot.'/enrol/imsenterprise/locallib.php');
30     $settings->add(new admin_setting_heading('enrol_imsenterprise_settings', '',
31         get_string('pluginname_desc', 'enrol_imsenterprise')));
33     // General settings.
34     $settings->add(new admin_setting_heading('enrol_imsenterprise_basicsettings',
35         get_string('basicsettings', 'enrol_imsenterprise'), ''));
37     $settings->add(new admin_setting_configtext('enrol_imsenterprise/imsfilelocation',
38         get_string('location', 'enrol_imsenterprise'), '', ''));
40     $settings->add(new admin_setting_configtext('enrol_imsenterprise/logtolocation',
41         get_string('logtolocation', 'enrol_imsenterprise'), '', ''));
43     $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/mailadmins',
44         get_string('mailadmins', 'enrol_imsenterprise'), '', 0));
46     // User data options.
47     $settings->add(new admin_setting_heading('enrol_imsenterprise_usersettings',
48         get_string('usersettings', 'enrol_imsenterprise'), ''));
50     $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewusers',
51         get_string('createnewusers', 'enrol_imsenterprise'), get_string('createnewusers_desc', 'enrol_imsenterprise'), 0));
53     $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imsdeleteusers',
54         get_string('deleteusers', 'enrol_imsenterprise'), get_string('deleteusers_desc', 'enrol_imsenterprise'), 0));
56     $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/fixcaseusernames',
57         get_string('fixcaseusernames', 'enrol_imsenterprise'), '', 0));
59     $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/fixcasepersonalnames',
60         get_string('fixcasepersonalnames', 'enrol_imsenterprise'), '', 0));
62     $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imssourcedidfallback',
63         get_string('sourcedidfallback', 'enrol_imsenterprise'), get_string('sourcedidfallback_desc', 'enrol_imsenterprise'), 0));
65     $settings->add(new admin_setting_heading('enrol_imsenterprise_usersettings_roles',
66         get_string('roles', 'enrol_imsenterprise'), get_string('imsrolesdescription', 'enrol_imsenterprise')));
68     if (!during_initial_install()) {
69         $coursecontext = context_course::instance(SITEID);
70         $assignableroles = get_assignable_roles($coursecontext);
71         $assignableroles = array('0' => get_string('ignore', 'enrol_imsenterprise')) + $assignableroles;
72         $imsroles = new imsenterprise_roles();
73         foreach ($imsroles->get_imsroles() as $imsrolenum => $imsrolename) {
74             $settings->add(new admin_setting_configselect('enrol_imsenterprise/imsrolemap'.$imsrolenum,
75                 format_string('"'.$imsrolename.'" ('.$imsrolenum.')'), '',
76                 (int)$imsroles->determine_default_rolemapping($imsrolenum), $assignableroles));
77         }
78     }
80     // Course data options.
81     $settings->add(new admin_setting_heading('enrol_imsenterprise_coursesettings',
82         get_string('coursesettings', 'enrol_imsenterprise'), ''));
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));
88     $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewcourses',
89         get_string('createnewcourses', 'enrol_imsenterprise'), get_string('createnewcourses_desc', 'enrol_imsenterprise'), 0));
91     $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/createnewcategories',
92         get_string('createnewcategories', 'enrol_imsenterprise'), get_string('createnewcategories_desc', 'enrol_imsenterprise'),
93         0));
95     $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imsunenrol',
96         get_string('allowunenrol', 'enrol_imsenterprise'), get_string('allowunenrol_desc', 'enrol_imsenterprise'), 0));
98     if (!during_initial_install()) {
99         $imscourses = new imsenterprise_courses();
100         foreach ($imscourses->get_courseattrs() as $courseattr) {
102             // The assignable values of this course attribute.
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);
107             $settings->add(new admin_setting_configselect('enrol_imsenterprise/imscoursemap' . $courseattr, $name,
108                 $description, $defaultvalue, $assignablevalues));
109         }
110     }
112     // Miscellaneous.
113     $settings->add(new admin_setting_heading('enrol_imsenterprise_miscsettings',
114         get_string('miscsettings', 'enrol_imsenterprise'), ''));
116     $settings->add(new admin_setting_configtext('enrol_imsenterprise/imsrestricttarget',
117         get_string('restricttarget', 'enrol_imsenterprise'), get_string('restricttarget_desc', 'enrol_imsenterprise'), ''));
119     $settings->add(new admin_setting_configcheckbox('enrol_imsenterprise/imscapitafix',
120         get_string('usecapitafix', 'enrol_imsenterprise'), get_string('usecapitafix_desc', 'enrol_imsenterprise'), 0));
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'));
125     $settings->add(new admin_setting_heading('enrol_imsenterprise_doitnowmessage', '', $importnowstring));