Skip to content

Commit

Permalink
MDL-23104 cleanup after loancalc, lams, exercise and journal if no in…
Browse files Browse the repository at this point in the history
…stances present - these were moved to contrib and we do not want them to appear on during upgrade page if not used at all
  • Loading branch information
skodak committed Jul 6, 2010
1 parent 57bfc29 commit 39bc3eb
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
87 changes: 87 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4881,6 +4881,93 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2010070502);
}

if ($oldversion < 2010070601) {
// delete loan calc if not used - it was moved to contrib
if (!file_exists("$CFG->dirroot/blocks/loancalc/version.php")) {
if (!$DB->record_exists('block_instances', array('blockname'=>'loancalc'))) {
$DB->delete_records('block', array('name'=>'loancalc'));
}
}
upgrade_main_savepoint(true, 2010070601);
}

if ($oldversion < 2010070602) {
// delete exercise if not used and not installed - now in contrib (do not use adminlib uninstall functions, they may change)
if (!file_exists("$CFG->dirroot/mod/exercise/version.php")) {
if ($module = $DB->get_record('modules', array('name'=>'exercise'))) {
if (!$DB->record_exists('course_modules', array('module'=>$module->id))) {
//purge capabilities
$DB->delete_records_select('capabilities', "name LIKE ?", array('mod/exercise:%'));
$DB->delete_records_select('role_capabilities', "capability LIKE ?", array('mod/exercise:%'));
$tables = array('exercise', 'exercise_submissions', 'exercise_assessments', 'exercise_elements', 'exercise_rubrics', 'exercise_grades');
foreach ($tables as $tname) {
$table = new xmldb_table($tname);
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
}
$DB->delete_records('event', array('modulename' => 'exercise'));
$DB->delete_records('log', array('module' => 'exercise'));
$DB->delete_records('log_display', array('module' => 'exercise'));
$DB->delete_records('modules', array('name'=>'exercise'));
}
}
}
upgrade_main_savepoint(true, 2010070602);
}

if ($oldversion < 2010070603) {
// delete journal if not used and not installed - now in contrib (do not use adminlib uninstall functions, they may change)
if (!file_exists("$CFG->dirroot/mod/journal/version.php")) {
if ($module = $DB->get_record('modules', array('name'=>'journal'))) {
if (!$DB->record_exists('course_modules', array('module'=>$module->id))) {
//purge capabilities
$DB->delete_records_select('capabilities', "name LIKE ?", array('mod/journal:%'));
$DB->delete_records_select('role_capabilities', "capability LIKE ?", array('mod/journal:%'));
$tables = array('journal', 'journal_entries');
foreach ($tables as $tname) {
$table = new xmldb_table($tname);
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
}
$DB->delete_records('event', array('modulename' => 'journal'));
$DB->delete_records('log', array('module' => 'journal'));
$DB->delete_records('log_display', array('module' => 'journal'));
$DB->delete_records('modules', array('name'=>'journal'));
unset_config('journal_initialdisable');
}
}
}
upgrade_main_savepoint(true, 2010070603);
}

if ($oldversion < 2010070604) {
// delete lams if not used and not installed - now in contrib (do not use adminlib uninstall functions, they may change)
if (!file_exists("$CFG->dirroot/mod/lams/version.php")) {
if ($module = $DB->get_record('modules', array('name'=>'lams'))) {
if (!$DB->record_exists('course_modules', array('module'=>$module->id))) {
//purge capabilities
$DB->delete_records_select('capabilities', "name LIKE ?", array('mod/lams:%'));
$DB->delete_records_select('role_capabilities', "capability LIKE ?", array('mod/lams:%'));
$tables = array('lams', '');
foreach ($tables as $tname) {
$table = new xmldb_table($tname);
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
}
$DB->delete_records('event', array('modulename' => 'lams'));
$DB->delete_records('log', array('module' => 'lams'));
$DB->delete_records('log_display', array('module' => 'lams'));
$DB->delete_records('modules', array('name'=>'lams'));
unset_config('lams_initialdisable');
}
}
}
upgrade_main_savepoint(true, 2010070604);
}


return true;
}
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)

$version = 2010070502; // YYYYMMDD = date of the last version bump
$version = 2010070604; // YYYYMMDD = date of the last version bump
// XX = daily increments

$release = '2.0 Preview 4 (Build: 20100706)'; // Human-friendly version name
Expand Down

0 comments on commit 39bc3eb

Please sign in to comment.