From 5ce6f628ba50f28782f5ac759f980e80a38fce96 Mon Sep 17 00:00:00 2001 From: vyshane Date: Mon, 28 Aug 2006 03:51:38 +0000 Subject: [PATCH] Dropping forum.open and forum.assesspublic from .sql files. Added forum upgrade to roles code to postgres7.php. --- mod/forum/db/mysql.sql | 2 -- mod/forum/db/postgres7.php | 40 ++++++++++++++++++++++++++++++++++++++ mod/forum/db/postgres7.sql | 2 -- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/mod/forum/db/mysql.sql b/mod/forum/db/mysql.sql index 44ea4d7178..549a6cb06b 100644 --- a/mod/forum/db/mysql.sql +++ b/mod/forum/db/mysql.sql @@ -8,9 +8,7 @@ CREATE TABLE prefix_forum ( type enum('single','news','general','social','eachuser','teacher','qanda') NOT NULL default 'general', name varchar(255) NOT NULL default '', intro text NOT NULL default '', - open tinyint(2) unsigned NOT NULL default '2', assessed int(10) unsigned NOT NULL default '0', - assesspublic int(4) unsigned NOT NULL default '0', assesstimestart int(10) unsigned NOT NULL default '0', assesstimefinish int(10) unsigned NOT NULL default '0', scale int(10) NOT NULL default '0', diff --git a/mod/forum/db/postgres7.php b/mod/forum/db/postgres7.php index 6603f91363..d3c3bea5fb 100644 --- a/mod/forum/db/postgres7.php +++ b/mod/forum/db/postgres7.php @@ -218,6 +218,46 @@ function forum_upgrade($oldversion) { } // End if. } + + if ($oldversion < 2006081800) { + // Upgrades for new roles and capabilities support. + require_once($CFG->dirroot.'/mod/forum/lib.php'); + + $forummod = get_record('modules', 'name', 'forum'); + + if ($forums = get_records('forum')) { + + if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) { + notice('Default student role was not found. Roles and permissions '. + 'for all your forums will have to be manually set after '. + 'this upgrade.'); + } + if (!$guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) { + notice('Default guest role was not found. Roles and permissions '. + 'for teacher forums will have to be manually set after '. + 'this upgrade.'); + } + + foreach ($forums as $forum) { + if (!forum_convert_to_roles($forum, $forummod->id, + $studentroles, $guestroles)) { + notice('Forum with id '.$forum->id.' was not upgraded'); + } + } + + // Drop column forum.open. + modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN open;'); + + // Drop column forum.assesspublic. + modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN assesspublic;'); + + // We need to rebuild all the course caches to refresh the state of + // the forum modules. + rebuild_course_cache(); + + } // End if. + } + if ($oldversion < 2006082700) { $sql = "UPDATE {$CFG->prefix}forum_posts SET message = REPLACE(message, '".TRUSTTEXT."', '');"; $likecond = sql_ilike()." '%".TRUSTTEXT."%'"; diff --git a/mod/forum/db/postgres7.sql b/mod/forum/db/postgres7.sql index a88b18a62a..37fbe17d21 100644 --- a/mod/forum/db/postgres7.sql +++ b/mod/forum/db/postgres7.sql @@ -8,9 +8,7 @@ CREATE TABLE prefix_forum ( type varchar(10) CHECK (type IN ('single','news','general','social','eachuser','teacher','qanda')) NOT NULL default 'general', name varchar(255) NOT NULL default '', intro text NOT NULL default '', - open integer NOT NULL default '2', assessed integer NOT NULL default '0', - assesspublic integer NOT NULL default '0', assesstimestart integer NOT NULL default '0', assesstimefinish integer NOT NULL default '0', scale integer NOT NULL default '0', -- 2.39.5