mirror of
https://github.com/moodle/moodle.git
synced 2025-05-15 04:36:13 +02:00
OK, some big changes here to the front end, particularly in course categories and course display. Course categories can now be nested (to any level). Courses and course categories can now be manually sorted any way required. There is a groovy front end for managing these, and a better range of options for formatting the front page. It all still needs some polishing, which I'll be doing over the next couple of days, including better auto-sorting. I would not use this on production systems just yet.
199 lines
8.1 KiB
PHP
199 lines
8.1 KiB
PHP
<?PHP //$Id$
|
|
//
|
|
// This file keeps track of upgrades to Moodle.
|
|
//
|
|
// Sometimes, changes between versions involve
|
|
// alterations to database structures and other
|
|
// major things that may break installations.
|
|
//
|
|
// The upgrade function in this file will attempt
|
|
// to perform all the necessary actions to upgrade
|
|
// your older installtion to the current version.
|
|
//
|
|
// If there's something it cannot do itself, it
|
|
// will tell you what you need to do.
|
|
//
|
|
// Versions are defined by /version.php
|
|
//
|
|
// This file is tailored to PostgreSQL 7
|
|
|
|
function main_upgrade($oldversion=0) {
|
|
|
|
global $CFG, $THEME;
|
|
|
|
$result = true;
|
|
|
|
|
|
if ($oldversion < 2003010101) {
|
|
delete_records("log_display", "module", "user");
|
|
$new->module = "user";
|
|
$new->action = "view";
|
|
$new->mtable = "user";
|
|
$new->field = "CONCAT(firstname,\" \",lastname)";
|
|
insert_record("log_display", $new);
|
|
|
|
delete_records("log_display", "module", "course");
|
|
$new->module = "course";
|
|
$new->action = "view";
|
|
$new->mtable = "course";
|
|
$new->field = "fullname";
|
|
insert_record("log_display", $new);
|
|
$new->action = "update";
|
|
insert_record("log_display", $new);
|
|
$new->action = "enrol";
|
|
insert_record("log_display", $new);
|
|
}
|
|
|
|
//support user based course creating
|
|
if ($oldversion < 2003032400) {
|
|
execute_sql("CREATE TABLE {$CFG->prefix}user_coursecreators (
|
|
id int8 SERIAL PRIMARY KEY,
|
|
userid int8 NOT NULL default '0'
|
|
)");
|
|
}
|
|
|
|
if ($oldversion < 2003041400) {
|
|
table_column("course_modules", "", "visible", "integer", "1", "unsigned", "1", "not null", "score");
|
|
}
|
|
|
|
if ($oldversion < 2003042104) { // Try to update permissions of all files
|
|
if ($files = get_directory_list($CFG->dataroot)) {
|
|
echo "Attempting to update permissions for all files... ignore any errors.";
|
|
foreach ($files as $file) {
|
|
echo "$CFG->dataroot/$file<br>";
|
|
@chmod("$CFG->dataroot/$file", $CFG->directorypermissions);
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($oldversion < 2003042400) {
|
|
// Rebuild all course caches, because of changes to do with visible variable
|
|
if ($courses = get_records_sql("SELECT * FROM {$CFG->prefix}course")) {
|
|
require_once("$CFG->dirroot/course/lib.php");
|
|
foreach ($courses as $course) {
|
|
$modinfo = serialize(get_array_of_activities($course->id));
|
|
|
|
if (!set_field("course", "modinfo", $modinfo, "id", $course->id)) {
|
|
notify("Could not cache module information for course '$course->fullname'!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($oldversion < 2003042500) {
|
|
// Convert all usernames to lowercase.
|
|
$users = get_records_sql("SELECT id, username FROM {$CFG->prefix}user");
|
|
$cerrors = "";
|
|
$rarray = array();
|
|
|
|
foreach ($users as $user) { // Check for possible conflicts
|
|
$lcname = trim(moodle_strtolower($user->username));
|
|
if (in_array($lcname, $rarray)) {
|
|
$cerrors .= $user->id."->".$lcname.'<br/>' ;
|
|
} else {
|
|
array_push($rarray,$lcname);
|
|
}
|
|
}
|
|
|
|
if ($cerrors != '') {
|
|
notify("Error: Cannot convert usernames to lowercase.
|
|
Following usernames would overlap (id->username):<br/> $cerrors .
|
|
Please resolve overlapping errors.");
|
|
$result = false;
|
|
}
|
|
|
|
$cerrors = "";
|
|
echo "Checking userdatabase:<br>";
|
|
foreach ($users as $user) {
|
|
$lcname = trim(moodle_strtolower($user->username));
|
|
if ($lcname != $user->username) {
|
|
$convert = set_field("user" , "username" , $lcname, "id", $user->id);
|
|
if (!$convert) {
|
|
if ($cerrors){
|
|
$cerrors .= ", ";
|
|
}
|
|
$cerrors .= $item;
|
|
} else {
|
|
echo ".";
|
|
}
|
|
}
|
|
}
|
|
if ($cerrors != '') {
|
|
notify("There were errors when converting following usernames to lowercase.
|
|
'$cerrors' . Sorry, but you will need to fix your database by hand.");
|
|
$result = false;
|
|
}
|
|
}
|
|
|
|
if ($oldversion < 2003042700) {
|
|
/// Changing to multiple indexes
|
|
execute_sql(" CREATE INDEX {$CFG->prefix}log_coursemoduleaction_idx ON {$CFG->prefix}log (course,module,action) ");
|
|
execute_sql(" CREATE INDEX {$CFG->prefix}log_courseuserid_idx ON {$CFG->prefix}log (course,userid) ");
|
|
}
|
|
|
|
if ($oldversion < 2003042801) {
|
|
execute_sql("CREATE TABLE {$CFG->prefix}course_display (
|
|
id SERIAL PRIMARY KEY,
|
|
course integer NOT NULL default '0',
|
|
userid integer NOT NULL default '0',
|
|
display integer NOT NULL default '0'
|
|
)");
|
|
|
|
execute_sql("CREATE INDEX {$CFG->prefix}course_display_courseuserid_idx ON {$CFG->prefix}course_display (course,userid)");
|
|
}
|
|
|
|
if ($oldversion < 2003050400) {
|
|
table_column("course_sections", "", "visible", "integer", "1", "unsigned", "1", "", "");
|
|
}
|
|
|
|
if ($oldversion < 2003050401) {
|
|
table_column("user", "", "lang", "VARCHAR", "5", "", "$CFG->lang" ,"NOT NULL","");
|
|
}
|
|
|
|
if ($oldversion < 2003050900) {
|
|
table_column("modules", "", "visible", "integer", "1", "unsigned", "1", "", "");
|
|
}
|
|
|
|
if ($oldversion < 2003050902) {
|
|
if (get_records("modules", "name", "pgassignment")) {
|
|
print_simple_box("Note: the pgassignment module will soon be deleted from CVS! Go to the new 'Manage Modules' page and DELETE IT from your system", "center", "50%", "$THEME->cellheading", "20", "noticebox");
|
|
}
|
|
}
|
|
|
|
if ($oldversion < 2003051600) {
|
|
print_simple_box("Thanks for upgrading!<p>There are many changes since the last release. Please read the release notes carefully. If you are using CUSTOM themes you will need to edit them. You will also need to check your site's config.php file.", "center", "50%", "$THEME->cellheading", "20", "noticebox");
|
|
}
|
|
|
|
if ($oldversion < 2003052300) {
|
|
table_column("user", "", "autosubscribe", "integer", "1", "unsigned", "1", "", "htmleditor");
|
|
}
|
|
|
|
if ($oldversion < 2003072100) {
|
|
table_column("course", "", "visible", "integer", "1", "unsigned", "1", "", "marker");
|
|
}
|
|
|
|
if ($oldversion < 2003072101) {
|
|
table_column("course_sections", "sequence", "sequence", "text", "", "", "", "", "");
|
|
}
|
|
|
|
if ($oldversion < 2003072800) {
|
|
print_simple_box("The following database index improves performance, but can be quite large - if you are upgrading and you have problems with a limited quota you may want to delete this index later from the '{$CFG->prefix}log' table in your database", "center", "50%", "$THEME->cellheading", "20", "noticebox");
|
|
flush();
|
|
execute_sql(" CREATE INDEX {$CFG->prefix}log_timecoursemoduleaction_idx ON {$CFG->prefix}log (time,course,module,action) ");
|
|
execute_sql(" CREATE INDEX {$CFG->prefix}user_students_courseuserid_idx ON {$CFG->prefix}user_students (course,userid) ");
|
|
execute_sql(" CREATE INDEX {$CFG->prefix}user_teachers_courseuserid_idx ON {$CFG->prefix}user_teachers (course,userid) ");
|
|
}
|
|
|
|
if ($oldversion < 2003072802) {
|
|
table_column("course_categories", "", "description", "text", "", "", "");
|
|
table_column("course_categories", "", "parent", "integer", "10", "unsigned");
|
|
table_column("course_categories", "", "sortorder", "integer", "10", "unsigned");
|
|
table_column("course_categories", "", "courseorder", "text", "", "", "");
|
|
table_column("course_categories", "", "visible", "integer", "1", "unsigned", "1");
|
|
table_column("course_categories", "", "timemodified", "integer", "10", "unsigned");
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
?>
|