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 * LDAP authentication plugin upgrade code
21 * @copyright 2013 IƱaki Arenaza
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
28 * Function to upgrade auth_ldap.
29 * @param int $oldversion the version we are upgrading from
32 function xmldb_auth_ldap_upgrade($oldversion) {
35 // Moodle v3.1.0 release upgrade line.
36 // Put any upgrade step following this.
38 // Automatically generated Moodle v3.2.0 release upgrade line.
39 // Put any upgrade step following this.
41 if ($oldversion < 2017020700) {
42 // Convert info in config plugins from auth/ldap to auth_ldap.
43 upgrade_fix_config_auth_plugin_names('ldap');
44 upgrade_fix_config_auth_plugin_defaults('ldap');
45 upgrade_plugin_savepoint(true, 2017020700, 'auth', 'ldap');
48 // Automatically generated Moodle v3.3.0 release upgrade line.
49 // Put any upgrade step following this.
51 if ($oldversion < 2017080100) {
52 // The "auth_ldap/coursecreators" setting was replaced with "auth_ldap/coursecreatorcontext" (created
53 // dynamically from system-assignable roles) - so migrate any existing value to the first new slot.
54 if ($ldapcontext = get_config('auth_ldap', 'creators')) {
55 // Get info about the role that the old coursecreators setting would apply.
56 $creatorrole = get_archetype_roles('coursecreator');
57 $creatorrole = array_shift($creatorrole); // We can only use one, let's use the first.
59 // Create new setting.
60 set_config($creatorrole->shortname . 'context', $ldapcontext, 'auth_ldap');
62 // Delete old setting.
63 set_config('creators', null, 'auth_ldap');
65 upgrade_plugin_savepoint(true, 2017080100, 'auth', 'ldap');