Skip to content

Commit

Permalink
MDL-28313 fix incorrect enrol database settings upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 14, 2011
1 parent 93d82f4 commit 0954c43
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
14 changes: 7 additions & 7 deletions enrol/database/db/install.php
@@ -1,5 +1,4 @@
<?php <?php

// This file is part of Moodle - http://moodle.org/ // This file is part of Moodle - http://moodle.org/
// //
// Moodle is free software: you can redistribute it and/or modify // Moodle is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -62,9 +61,9 @@ function xmldb_enrol_database_install() {
set_config('localuserfield', $CFG->enrol_localuserfield, 'enrol_database'); set_config('localuserfield', $CFG->enrol_localuserfield, 'enrol_database');
unset_config('enrol_localuserfield'); unset_config('enrol_localuserfield');
} }
if (isset($CFG->enrol_localrolefield)) { if (isset($CFG->enrol_db_localrolefield)) {
set_config('localrolefield', $CFG->enrol_localrolefield, 'enrol_database'); set_config('localrolefield', $CFG->enrol_db_localrolefield, 'enrol_database');
unset_config('enrol_localrolefield'); unset_config('enrol_db_localrolefield');
} }
if (isset($CFG->enrol_remotecoursefield)) { if (isset($CFG->enrol_remotecoursefield)) {
set_config('remotecoursefield', $CFG->enrol_remotecoursefield, 'enrol_database'); set_config('remotecoursefield', $CFG->enrol_remotecoursefield, 'enrol_database');
Expand All @@ -74,9 +73,9 @@ function xmldb_enrol_database_install() {
set_config('remoteuserfield', $CFG->enrol_remoteuserfield, 'enrol_database'); set_config('remoteuserfield', $CFG->enrol_remoteuserfield, 'enrol_database');
unset_config('enrol_remoteuserfield'); unset_config('enrol_remoteuserfield');
} }
if (isset($CFG->enrol_remoterolefield)) { if (isset($CFG->enrol_db_remoterolefield)) {
set_config('remoterolefield', $CFG->enrol_remoterolefield, 'enrol_database'); set_config('remoterolefield', $CFG->enrol_db_remoterolefield, 'enrol_database');
unset_config('enrol_remoterolefield'); unset_config('enrol_db_remoterolefield');
} }
if (isset($CFG->enrol_db_defaultcourseroleid)) { if (isset($CFG->enrol_db_defaultcourseroleid)) {
set_config('defaultrole', $CFG->enrol_db_defaultcourseroleid, 'enrol_database'); set_config('defaultrole', $CFG->enrol_db_defaultcourseroleid, 'enrol_database');
Expand All @@ -96,6 +95,7 @@ function xmldb_enrol_database_install() {
unset_config('enrol_db_ignorehiddencourse'); unset_config('enrol_db_ignorehiddencourse');
} }


unset_config('enrol_db_disableunenrol');






Expand Down
43 changes: 43 additions & 0 deletions enrol/database/db/upgrade.php
@@ -0,0 +1,43 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Database enrolment plugin upgrade.
*
* @package enrol
* @subpackage database
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
function xmldb_enrol_database_upgrade($oldversion) {
global $DB;

$dbman = $DB->get_manager();

// fix leftovers after incorrect 2.x upgrade in install.php
if ($oldversion < 2010073101) {
unset_config('enrol_db_localrolefield');
unset_config('enrol_db_remoterolefield');
unset_config('enrol_db_disableunenrol');

upgrade_plugin_savepoint(true, 2010073101, 'enrol', 'database');
}


return true;
}
2 changes: 1 addition & 1 deletion enrol/database/version.php
Expand Up @@ -26,5 +26,5 @@


defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();


$plugin->version = 2010073100; $plugin->version = 2010073101;
//TODO: should we add cron sync? //TODO: should we add cron sync?

0 comments on commit 0954c43

Please sign in to comment.