Fixed the upgrade_plugins function so that it automatically

handles the .sql file for first installation (just like activities)
This commit is contained in:
moodler 2006-04-16 16:50:55 +00:00
parent 0236ec73be
commit d87a9d7338
26 changed files with 31 additions and 285 deletions

View File

@ -179,11 +179,7 @@
print_header($strcurrentversion, $stradministration, $strcurrentversion,
"", "", false, " ", " ");
if (set_config("version", $version)) {
print_heading("Moodle $release ($version)");
print_continue("index.php");
die;
} else {
if (!set_config("version", $version)) {
$db->debug=true;
if (main_upgrade(0)) {
print_continue("index.php");

View File

@ -8,17 +8,6 @@ function enrol_authorize_upgrade($oldversion=0) {
$result = true;
if (!$tables = $db->MetaColumns($CFG->prefix . 'enrol_authorize')) {
$installfirst = true;
}
if ($oldversion == 0 || !empty($installfirst)) { // First time install
$result = modify_database("$CFG->dirroot/enrol/authorize/db/mysql.sql");
return $result; // RETURN, sql file contains last upgrades.
}
// Authorize module was installed before. Upgrades must be applied to SQL file.
if ($oldversion < 2005071600) {
// Be sure, only last 4 digit is inserted.
table_column('enrol_authorize', 'cclastfour', 'cclastfour', 'integer', '4', 'unsigned', '0', 'not null');

View File

@ -8,17 +8,6 @@ function enrol_authorize_upgrade($oldversion=0) {
$result = true;
if (!$tables = $db->MetaColumns($CFG->prefix . 'enrol_authorize')) {
$installfirst = true;
}
if ($oldversion == 0 || !empty($installfirst)) { // First time install
$result = modify_database("$CFG->dirroot/enrol/authorize/db/postgres7.sql");
return $result; // RETURN, sql file contains last upgrades.
}
// Authorize module was installed before. Upgrades must be applied to SQL file.
if ($oldversion < 2005071602) {
notify("If you are using the authorize.net enrolment plugin for credit card
handling, please ensure that you have turned loginhttps ON in Admin >> Variables >> Security.");

View File

@ -8,10 +8,6 @@ function enrol_paypal_upgrade($oldversion=0) {
$result = true;
if ($oldversion == 0) {
modify_database("$CFG->dirroot/enrol/paypal/db/mysql.sql");
}
return $result;
}

View File

@ -8,10 +8,6 @@ function enrol_paypal_upgrade($oldversion=0) {
$result = true;
if ($oldversion == 0) {
modify_database("$CFG->dirroot/enrol/paypal/db/postgres7.sql");
}
return $result;
}

View File

@ -76,21 +76,41 @@ function upgrade_plugins($type, $dir, $return) {
print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '', '', false, '&nbsp;', '&nbsp;');
}
print_heading($plugin->name .' plugin needs upgrading');
$upgrade_function = $type.'_'.$plugin->name .'_upgrade';
if (function_exists($upgrade_function)) {
$db->debug=true;
if ($upgrade_function($CFG->$pluginversion)) {
$db->debug=false;
// OK so far, now update the plugins record
if ($CFG->$pluginversion == 0) { // It's a new install of this plugin
if (file_exists($fullplug .'/db/'. $CFG->dbtype .'.sql')) {
$db->debug = true;
@set_time_limit(0); // To allow slow databases to complete the long SQL
if (modify_database($fullplug .'/db/'. $CFG->dbtype .'.sql')) {
// OK so far, now update the plugins record
set_config($pluginversion, $plugin->version);
notify(get_string('modulesuccess', '', $plugin->name), 'notifysuccess');
} else {
notify('Installing '. $plugin->name .' FAILED!');
}
$db->debug = false;
} else { // We'll assume no tables are necessary
set_config($pluginversion, $plugin->version);
notify(get_string('modulesuccess', '', $plugin->name), 'notifysuccess');
echo '<hr />';
} else {
$db->debug=false;
notify('Upgrading '. $plugin->name .' from '. $CFG->$pluginversion .' to '. $plugin->version .' FAILED!');
}
} else { // Upgrade existing install
$upgrade_function = $type.'_'.$plugin->name .'_upgrade';
if (function_exists($upgrade_function)) {
$db->debug=true;
if ($upgrade_function($CFG->$pluginversion)) {
$db->debug=false;
// OK so far, now update the plugins record
set_config($pluginversion, $plugin->version);
notify(get_string('modulesuccess', '', $plugin->name), 'notifysuccess');
} else {
$db->debug=false;
notify('Upgrading '. $plugin->name .' from '. $CFG->$pluginversion .' to '. $plugin->version .' FAILED!');
}
}
}
echo '<hr />';
$updated_plugins = true;
} else {
error('Version mismatch: '. $plugin->name .' can\'t downgrade '. $CFG->$pluginversion .' -> '. $plugin->version .' !');
}

View File

@ -5,18 +5,6 @@
function qtype_calculated_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/calculated/db/mysql.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -4,18 +4,6 @@
function qtype_calculated_upgrade($oldversion=0) {
global $CFG;
require_once("$CFG->libdir/questionlib.php");
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/calculated/db/postgres7.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_essay_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/essay/db/mysql.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_essay_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/essay/db/postgres7.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_match_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/match/db/mysql.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_match_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/match/db/postgres7.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_multianswer_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/multianswer/db/mysql.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_multianswer_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/multianswer/db/postgres7.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_multichoice_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/multichoice/db/mysql.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_multichoice_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/multichoice/db/postgres7.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_numerical_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/numerical/db/mysql.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_numerical_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/numerical/db/postgres7.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_randomsamatch_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/randomsamatch/db/mysql.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_randomsamatch_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/randomsamatch/db/postgres7.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_rqp_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/rqp/db/mysql.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_rqp_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/rqp/db/postgres7.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_shortanswer_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/shortanswer/db/mysql.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_shortanswer_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/shortanswer/db/postgres7.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_truefalse_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/truefalse/db/mysql.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}

View File

@ -5,18 +5,6 @@
function qtype_truefalse_upgrade($oldversion=0) {
global $CFG;
if ($oldversion == 0) { // First time install
$result = modify_database("$CFG->dirroot/question/type/truefalse/db/postgres7.sql");
return $result;
}
// Question type was installed before. Upgrades must be applied
// if ($oldversion < 2005071600) {
//
// }
return true;
}