Fix for bug #1280: the "showrecent" course setting has to go.

The pgsql .php update script needs to be updated, but I 'm not sure about
the pgsql alter table syntax... mysql works, oracle is still under dev, so
no problem there.
This commit is contained in:
defacer 2004-04-29 10:28:19 +00:00
parent 0ef7c97344
commit 10ee08cc65
4 changed files with 72 additions and 71 deletions

View File

@ -1,16 +1,16 @@
<?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.
//
// 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
// If there's something it cannot do itself, it
// will tell you what you need to do.
//
// Versions are defined by /version.php
@ -83,7 +83,7 @@ function main_upgrade($oldversion=0) {
}
if ($oldversion < 2002101701) {
execute_sql(" ALTER TABLE `reading` RENAME `resource` "); // Small line with big consequences!
execute_sql(" DELETE FROM `log_display` WHERE module = 'reading'");
execute_sql(" DELETE FROM `log_display` WHERE module = 'reading'");
execute_sql(" INSERT INTO log_display VALUES ('resource', 'view', 'resource', 'name') ");
execute_sql(" UPDATE log SET module = 'resource' WHERE module = 'reading' ");
execute_sql(" UPDATE modules SET name = 'resource' WHERE name = 'reading' ");
@ -175,7 +175,7 @@ function main_upgrade($oldversion=0) {
if ($courses = get_records_sql("SELECT * FROM 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)) {
@ -205,7 +205,7 @@ function main_upgrade($oldversion=0) {
if ($courses = get_records_sql("SELECT * FROM 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)) {
@ -273,7 +273,7 @@ function main_upgrade($oldversion=0) {
execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX(course) ");
execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX(userid) ");
}
if ($oldversion < 2003041400) {
table_column("course_modules", "", "visible", "integer", "1", "unsigned", "1", "not null", "score");
}
@ -302,25 +302,25 @@ function main_upgrade($oldversion=0) {
}
}
if ($oldversion < 2003042500) {
// Convert all usernames to lowercase.
$users = get_records_sql("SELECT id, username FROM {$CFG->prefix}user");
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/>' ;
$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.");
notify("Error: Cannot convert usernames to lowercase.
Following usernames would overlap (id->username):<br/> $cerrors .
Please resolve overlapping errors.");
$result = false;
}
@ -333,15 +333,15 @@ function main_upgrade($oldversion=0) {
if (!$convert) {
if ($cerrors){
$cerrors .= ", ";
}
}
$cerrors .= $item;
} else {
echo ".";
}
}
}
}
if ($cerrors != '') {
notify("There were errors when converting following usernames to lowercase.
notify("There were errors when converting following usernames to lowercase.
'$cerrors' . Sorry, but you will need to fix your database by hand.");
$result = false;
}
@ -442,7 +442,7 @@ function main_upgrade($oldversion=0) {
if ($oldversion < 2003081500) {
// print_simple_box("Some important changes have been made to how course creators work. Formerly, they could create new courses and assign teachers, and teachers could edit courses. Now, ordinary teachers can no longer edit courses - they <b>need to be a teacher of a course AND a course creator</b>. A new site-wide configuration variable allows you to choose whether to allow course creators to create new courses as well (by default this is off). <p>The following update will automatically convert all your existing teachers into course creators, to maintain backward compatibility. Make sure you look at your upgraded site carefully and understand these new changes.", "center", "50%", "$THEME->cellheading", "20", "noticebox");
// $count = 0;
// $errorcount = 0;
// if ($teachers = get_records("user_teachers")) {
@ -522,32 +522,32 @@ function main_upgrade($oldversion=0) {
foreach ($courses as $course) {
notify("Processing $course->fullname ...", "green");
flush();
if ($users = get_records_select("user_teachers", "course = '$course->id'",
if ($users = get_records_select("user_teachers", "course = '$course->id'",
"id", "id, userid, timeaccess")) {
foreach ($users as $user) {
$loginfo = get_record_sql("SELECT id, time FROM {$CFG->prefix}log WHERE course = '$course->id' and userid = '$user->userid' ORDER by time DESC");
if (empty($loginfo->time)) {
$loginfo->time = 0;
}
execute_sql("UPDATE {$CFG->prefix}user_teachers SET timeaccess = '$loginfo->time'
execute_sql("UPDATE {$CFG->prefix}user_teachers SET timeaccess = '$loginfo->time'
WHERE userid = '$user->userid' AND course = '$course->id'", false);
}
}
if ($users = get_records_select("user_students", "course = '$course->id'",
if ($users = get_records_select("user_students", "course = '$course->id'",
"id", "id, userid, timeaccess")) {
foreach ($users as $user) {
$loginfo = get_record_sql("SELECT id, time FROM {$CFG->prefix}log
WHERE course = '$course->id' and userid = '$user->userid'
$loginfo = get_record_sql("SELECT id, time FROM {$CFG->prefix}log
WHERE course = '$course->id' and userid = '$user->userid'
ORDER by time DESC");
if (empty($loginfo->time)) {
$loginfo->time = 0;
}
execute_sql("UPDATE {$CFG->prefix}user_students
SET timeaccess = '$loginfo->time'
execute_sql("UPDATE {$CFG->prefix}user_students
SET timeaccess = '$loginfo->time'
WHERE userid = '$user->userid' AND course = '$course->id'", false);
}
}
}
@ -687,7 +687,7 @@ function main_upgrade($oldversion=0) {
if ($oldversion < 2004021500) {
table_column("groups", "", "hidepicture", "integer", "2", "unsigned", "0", "", "picture");
}
if ($oldversion < 2004021700) {
if (!empty($CFG->textfilters)) {
$CFG->textfilters = str_replace("tex_filter.php", "filter.php", $CFG->textfilters);
@ -748,6 +748,10 @@ function main_upgrade($oldversion=0) {
set_config("enablerssfeeds",0);
}
if ($oldversion < 2004042900) {
execute_sql(" ALTER TABLE `{$CFG->prefix}course` DROP `showrecent` ");
}
return $result;
}

View File

@ -47,7 +47,6 @@ CREATE TABLE `prefix_course` (
`guest` tinyint(2) unsigned NOT NULL default '0',
`startdate` int(10) unsigned NOT NULL default '0',
`numsections` smallint(5) unsigned NOT NULL default '1',
`showrecent` smallint(5) unsigned NOT NULL default '1',
`marker` int(10) unsigned NOT NULL default '0',
`maxbytes` int(10) unsigned NOT NULL default '0',
`showreports` int(4) unsigned NOT NULL default '0',

View File

@ -62,12 +62,11 @@ CREATE TABLE prefix_course (
guest number(2) default '0' not null,
startdate number(10) default '0' not null,
numsections number(5) default '1' not null,
showrecent number(5) default '1' not null,
marker number(10) default '0' not null,
visible number(10) default '1' not null,
timecreated number(10) default '0' not null,
timemodified number(10) default '0' not null
);
);
create index category on prefix_course(category);
@ -133,7 +132,7 @@ insert into prefix_course_categories (name) values ('name4');
select * from prefix_course_categories;
rem
rem
rem Table structure for table course_display
rem
@ -182,10 +181,10 @@ CREATE TABLE prefix_course_modules (
module number(10) default '0' not null,
instance number(10) default '0' not null,
section number(10) default '0' not null,
added number(10) default '0' not null,
added number(10) default '0' not null,
deleted number(1) default '0' not null,
score number(4) default '0' not null,
indent number(5) default '0' not null,
indent number(5) default '0' not null,
visible number(1) default '1' not null
);
@ -204,10 +203,10 @@ create or replace trigger p_course_modules_trig
.
/
insert into prefix_course_modules (course,module,instance,section,added,deleted,score,indent,visible) values (1,1,1,1,1,1,1,1,1);
insert into prefix_course_modules (course,module,instance,section,added,deleted,score,indent,visible) values (2,2,2,2,2,2,2,2,2);
insert into prefix_course_modules (course,module,instance,section,added,deleted,score,indent,visible) values (3,3,3,3,3,3,3,3,3);
insert into prefix_course_modules (course,module,instance,section,added,deleted,score,indent,visible) values (4,4,4,4,4,4,4,4,4);
insert into prefix_course_modules (course,module,instance,section,added,deleted,score,indent,visible) values (1,1,1,1,1,1,1,1,1);
insert into prefix_course_modules (course,module,instance,section,added,deleted,score,indent,visible) values (2,2,2,2,2,2,2,2,2);
insert into prefix_course_modules (course,module,instance,section,added,deleted,score,indent,visible) values (3,3,3,3,3,3,3,3,3);
insert into prefix_course_modules (course,module,instance,section,added,deleted,score,indent,visible) values (4,4,4,4,4,4,4,4,4);
select * from prefix_course_modules;
@ -241,10 +240,10 @@ create or replace trigger p_course_sections_trig
.
/
insert into prefix_course_sections (course,section,summary,sequence) values (1,1,1,1);
insert into prefix_course_sections (course,section,summary,sequence) values (2,2,2,2);
insert into prefix_course_sections (course,section,summary,sequence) values (3,3,3,3);
insert into prefix_course_sections (course,section,summary,sequence) values (4,4,4,4);
insert into prefix_course_sections (course,section,summary,sequence) values (1,1,1,1);
insert into prefix_course_sections (course,section,summary,sequence) values (2,2,2,2);
insert into prefix_course_sections (course,section,summary,sequence) values (3,3,3,3);
insert into prefix_course_sections (course,section,summary,sequence) values (4,4,4,4);
select * from prefix_course_sections;
@ -290,10 +289,10 @@ create or replace trigger p_log_trig
.
/
insert into prefix_log (time,userid,ip,course,module,action,url,info) values (1,1,'ip1',1,'module1','action1','url1','info1');
insert into prefix_log (time,userid,ip,course,module,action,url,info) values (2,2,'ip2',2,'module2','action2','url2','info2');
insert into prefix_log (time,userid,ip,course,module,action,url,info) values (3,3,'ip3',3,'module3','action3','url3','info3');
insert into prefix_log (time,userid,ip,course,module,action,url,info) values (4,4,'ip4',4,'module4','action4','url4','info4');
insert into prefix_log (time,userid,ip,course,module,action,url,info) values (1,1,'ip1',1,'module1','action1','url1','info1');
insert into prefix_log (time,userid,ip,course,module,action,url,info) values (2,2,'ip2',2,'module2','action2','url2','info2');
insert into prefix_log (time,userid,ip,course,module,action,url,info) values (3,3,'ip3',3,'module3','action3','url3','info3');
insert into prefix_log (time,userid,ip,course,module,action,url,info) values (4,4,'ip4',4,'module4','action4','url4','info4');
select * from prefix_log;
@ -314,10 +313,10 @@ CREATE TABLE prefix_log_display (
COMMENT on table prefix_log_display is 'For a particular module/action, specifies a moodle table/field.';
rem for testing only
rem insert into prefix_log_display (module,action,mtable,field) values ('module1','action1','mtable1','field1');
rem insert into prefix_log_display (module,action,mtable,field) values ('module2','action2','mtable2','field2');
rem insert into prefix_log_display (module,action,mtable,field) values ('module3','action3','mtable3','field3');
rem insert into prefix_log_display (module,action,mtable,field) values ('module4','action4','mtable4','field4');
rem insert into prefix_log_display (module,action,mtable,field) values ('module1','action1','mtable1','field1');
rem insert into prefix_log_display (module,action,mtable,field) values ('module2','action2','mtable2','field2');
rem insert into prefix_log_display (module,action,mtable,field) values ('module3','action3','mtable3','field3');
rem insert into prefix_log_display (module,action,mtable,field) values ('module4','action4','mtable4','field4');
select * from prefix_log_display;
@ -351,10 +350,10 @@ create or replace trigger p_modules_trig
.
/
insert into prefix_modules (name,version,cron,lastcron,search) values ('name1',1,1,1,'search1');
insert into prefix_modules (name,version,cron,lastcron,search) values ('name2',2,2,2,'search2');
insert into prefix_modules (name,version,cron,lastcron,search) values ('name3',3,3,3,'search3');
insert into prefix_modules (name,version,cron,lastcron,search) values ('name4',4,4,4,'search4');
insert into prefix_modules (name,version,cron,lastcron,search) values ('name1',1,1,1,'search1');
insert into prefix_modules (name,version,cron,lastcron,search) values ('name2',2,2,2,'search2');
insert into prefix_modules (name,version,cron,lastcron,search) values ('name3',3,3,3,'search3');
insert into prefix_modules (name,version,cron,lastcron,search) values ('name4',4,4,4,'search4');
select * from prefix_modules;
@ -404,7 +403,7 @@ CREATE TABLE prefix_user (
id number(10) primary key,
confirmed number(1) default '0' not null,
deleted number(1) default '0' not null,
username varchar2(100) default '' not null
username varchar2(100) default '' not null
constraint unq_username unique,
password varchar2(32) default '' not null,
idnumber varchar2(12) default NULL,
@ -452,7 +451,7 @@ create or replace trigger p_user_trig
.
/
insert into prefix_user ( confirmed, deleted, username, password, idnumber, firstname, lastname, email, icq, phone1, phone2, institution, department, address, city, country, lang, timezone, firstaccess, lastaccess, lastlogin, currentlogin, lastIP, secret, picture, url, description, mailformat, maildisplay, htmleditor, timemodified ) values ( 1, 1, 'username1', 'password1', 'idnumber1', 'firstname1', 'lastname1', 'email1', 'icq1', 'phone11', 'phone21', 'institution1', 'department1', 'address1', 'city1', 'c1', 'lang1', 1, 1, 1, 1, 1, 'lastIP1', 'secret1', 1, 'url1', 'description1', 1, 1, 1, 1);
insert into prefix_user ( confirmed, deleted, username, password, idnumber, firstname, lastname, email, icq, phone1, phone2, institution, department, address, city, country, lang, timezone, firstaccess, lastaccess, lastlogin, currentlogin, lastIP, secret, picture, url, description, mailformat, maildisplay, htmleditor, timemodified )
insert into prefix_user ( confirmed, deleted, username, password, idnumber, firstname, lastname, email, icq, phone1, phone2, institution, department, address, city, country, lang, timezone, firstaccess, lastaccess, lastlogin, currentlogin, lastIP, secret, picture, url, description, mailformat, maildisplay, htmleditor, timemodified )
values ( 2, 2, 'username2', 'password2', 'idnumber2', 'firstname2', 'lastname2', 'email2', 'icq2', 'phone12', 'phone22', 'institution2', 'department2', 'address2', 'city2', 'c2', 'lang2', 2, 2, 2, 2, 2, 'lastIP2', 'secret2', 2, 'url2', 'description2', 2, 2, 2, 2);
insert into prefix_user ( confirmed, deleted, username, password, idnumber, firstname, lastname, email, icq, phone1, phone2, institution, department, address, city, country, lang, timezone, firstaccess, lastaccess, lastlogin, currentlogin, lastIP, secret, picture, url, description, mailformat, maildisplay, htmleditor, timemodified ) values ( 3, 3, 'username3', 'password3', 'idnumber3', 'firstname3', 'lastname3', 'email3', 'icq3', 'phone13', 'phone23', 'institution3', 'department3', 'address3', 'city3', 'c3', 'lang3', 3, 3, 3, 3, 3, 'lastIP3', 'secret3', 3, 'url3', 'description3', 3, 3, 3, 3);
@ -487,10 +486,10 @@ create or replace trigger p_user_admins_trig
end;
.
/
insert into prefix_user_admins (userid) values (1);
insert into prefix_user_admins (userid) values (2);
insert into prefix_user_admins (userid) values (3);
insert into prefix_user_admins (userid) values (4);
insert into prefix_user_admins (userid) values (1);
insert into prefix_user_admins (userid) values (2);
insert into prefix_user_admins (userid) values (3);
insert into prefix_user_admins (userid) values (4);
select * from prefix_user_admins;
@ -524,10 +523,10 @@ create or replace trigger p_user_students_trig
end;
.
/
insert into prefix_user_students (userid,course,timestart,timeend,time) values (1,1,1,1,1);
insert into prefix_user_students (userid,course,timestart,timeend,time) values (2,2,2,2,2);
insert into prefix_user_students (userid,course,timestart,timeend,time) values (3,3,3,3,3);
insert into prefix_user_students (userid,course,timestart,timeend,time) values (4,4,4,4,4);
insert into prefix_user_students (userid,course,timestart,timeend,time) values (1,1,1,1,1);
insert into prefix_user_students (userid,course,timestart,timeend,time) values (2,2,2,2,2);
insert into prefix_user_students (userid,course,timestart,timeend,time) values (3,3,3,3,3);
insert into prefix_user_students (userid,course,timestart,timeend,time) values (4,4,4,4,4);
select * from prefix_user_students;
@ -565,10 +564,10 @@ create or replace trigger p_user_teachers_trig
end;
.
/
insert into prefix_user_teachers (userid,course,authority,role) values (1,1,1,'role1');
insert into prefix_user_teachers (userid,course,authority,role) values (2,2,2,'role2');
insert into prefix_user_teachers (userid,course,authority,role) values (3,3,3,'role3');
insert into prefix_user_teachers (userid,course,authority,role) values (3,3,3,'role3');
insert into prefix_user_teachers (userid,course,authority,role) values (1,1,1,'role1');
insert into prefix_user_teachers (userid,course,authority,role) values (2,2,2,'role2');
insert into prefix_user_teachers (userid,course,authority,role) values (3,3,3,'role3');
insert into prefix_user_teachers (userid,course,authority,role) values (3,3,3,'role3');
select * from prefix_user_teachers;

View File

@ -25,7 +25,6 @@ CREATE TABLE prefix_course (
guest integer NOT NULL default '0',
startdate integer NOT NULL default '0',
numsections integer NOT NULL default '1',
showrecent integer NOT NULL default '1',
marker integer NOT NULL default '0',
maxbytes integer NOT NULL default '0',
showreports integer NOT NULL default '0',