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");
$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');
$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.");
$result = true;
- if ($oldversion == 0) {
- modify_database("$CFG->dirroot/enrol/paypal/db/mysql.sql");
- }
-
return $result;
}
$result = true;
- if ($oldversion == 0) {
- modify_database("$CFG->dirroot/enrol/paypal/db/postgres7.sql");
- }
-
return $result;
}
print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '', '', false, ' ', ' ');
}
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 .' !');
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}