MDL-52105 enrol_self: fix upgrade savepoint
[moodle.git] / enrol / self / db / upgrade.php
CommitLineData
8a486fdb
PS
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/>.
16
17/**
18 * This file keeps track of upgrades to the self enrolment plugin
19 *
20 * @package enrol_self
e8c82aac 21 * @copyright 2012 Petr Skoda {@link http://skodak.org}
8a486fdb
PS
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25defined('MOODLE_INTERNAL') || die();
26
27function xmldb_enrol_self_upgrade($oldversion) {
e8c82aac 28 global $CFG;
f94891cc 29
147bae8f
EL
30 // Moodle v2.8.0 release upgrade line.
31 // Put any upgrade step following this.
32
b758ab30
EL
33 // Moodle v2.9.0 release upgrade line.
34 // Put any upgrade step following this.
35
6d29c4ac
EL
36 // Moodle v3.0.0 release upgrade line.
37 // Put any upgrade step following this.
38
4da854a6
EL
39 // Moodle v3.1.0 release upgrade line.
40 // Put any upgrade step following this.
41
33b6da53
SL
42 // Moodle v3.2.0 release upgrade line.
43 // Put any upgrade step following this.
44
45 if ($oldversion < 2016052301) {
46 global $DB;
47 // Get roles with manager archetype.
48 $managerroles = get_archetype_roles('manager');
49 if (!empty($managerroles)) {
50 // Remove wrong CAP_PROHIBIT from self:holdkey.
51 foreach ($managerroles as $role) {
52 $DB->execute("DELETE
53 FROM {role_capabilities}
54 WHERE roleid = ? AND capability = ? AND permission = ?",
55 array($role->id, 'enrol/self:holdkey', CAP_PROHIBIT));
56 }
57 }
fb8723d9 58 upgrade_plugin_savepoint(true, 2016052301, 'enrol', 'self');
33b6da53
SL
59 }
60
8a486fdb
PS
61 return true;
62}