From 89d38fdddc8fcb231a1a99d116ee0c2c1b599352 Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Fri, 10 Mar 2006 06:50:37 +0000 Subject: [PATCH] adding blog support (development code) --- admin/configvars.php | 10 ++++++++++ lib/db/mysql.php | 43 ++++++++++++++++++++++++++++++++++++++++++ lib/db/mysql.sql | 45 ++++++++++++++++++++++++++++++++++++++++++++ lib/db/postgres7.php | 41 ++++++++++++++++++++++++++++++++++++++++ lib/db/postgres7.sql | 38 +++++++++++++++++++++++++++++++++++++ version.php | 2 +- 6 files changed, 178 insertions(+), 1 deletion(-) diff --git a/admin/configvars.php b/admin/configvars.php index 97ecd0568c..1123401417 100644 --- a/admin/configvars.php +++ b/admin/configvars.php @@ -92,6 +92,16 @@ class configvarrss extends configvar { $misc['mymoodleredirect'] = new configvar (get_string('configmymoodleredirect','admin'), choose_from_menu($noyesoptions,'mymoodleredirect',$config->mymoodleredirect,'','','',true)); + unset($options); + $options[5] = get_string('worldblogs','blog'); + $options[4] = get_string('siteblogs','blog'); + $options[3] = get_string('courseblogs','blog'); + $options[2] = get_string('groupblogs','blog'); + $options[1] = get_string('personalblogs','blog'); + $options[0] = get_string('diableblogs','blog'); + + $misc['bloglevel'] = new configvar (get_string('blogleveldes', 'admin'), + choose_from_menu ($options, 'bloglevel', $config->bloglevel,'','','',true)); //////////////////////////////////////////////////////////////////// /// OPERATING SYSTEM config variables diff --git a/lib/db/mysql.php b/lib/db/mysql.php index 8a694617ee..850a28d94d 100644 --- a/lib/db/mysql.php +++ b/lib/db/mysql.php @@ -1678,6 +1678,49 @@ function main_upgrade($oldversion=0) { execute_sql("UPDATE {$CFG->prefix}user_teachers SET enrol='manual' WHERE enrol=''"); } + + if ($oldversion < 2006031000) { + + modify_database("","CREATE TABLE prefix_post ( + `id` int(11) NOT NULL auto_increment, + `userid` int(11) NOT NULL default '0', + `courseid` int(11) NOT NULL default'0', + `groupid` int(11) NOT NULL default'0', + `moduleid` int(11) NOT NULL default'0', + `coursemoduleid` int(11) NOT NULL default'0', + `subject` varchar(128) NOT NULL default '', + `summary` longtext, + `content` longtext, + `uniquehash` varchar(128) NOT NULL default '', + `rating` int(11) NOT NULL default'0', + `format` int(11) NOT NULL default'0', + `publishstate` enum('draft','site','public') NOT NULL default 'draft', + `lastmodified` int(10) NOT NULL default '0', + `created` int(10) NOT NULL default '0', + PRIMARY KEY (`id`), + UNIQUE KEY `id_user_idx` (`id`, `userid`), + KEY `post_lastmodified_idx` (`lastmodified`), + KEY `post_subject_idx` (`subject`) + ) TYPE=MyISAM COMMENT='New moodle post table. Holds data posts such as forum entries or blog entries.';"); + + modify_database("","CREATE TABLE prefix_tags ( + `id` int(11) NOT NULL auto_increment, + `type` varchar(255) NOT NULL default 'official', + `userid` int(11) NOT NULL default'0', + `text` varchar(255) NOT NULL default '', + PRIMARY KEY (`id`) + ) TYPE=MyISAM COMMENT ='tags structure for moodle.';"); + + modify_database("","CREATE TABLE prefix_blog_tag_instance ( + `id` int(11) NOT NULL auto_increment, + `entryid` int(11) NOT NULL default'0', + `tagid` int(11) NOT NULL default'0', + `groupid` int(11) NOT NULL default'0', + `courseid` int(11) NOT NULL default'0', + `userid` int(11) NOT NULL default'0', + PRIMARY KEY (`id`) + ) TYPE=MyISAM COMMENT ='tag instance for blogs.';"); + } return $result; } diff --git a/lib/db/mysql.sql b/lib/db/mysql.sql index de3b7dd926..2ac4784f19 100644 --- a/lib/db/mysql.sql +++ b/lib/db/mysql.sql @@ -840,6 +840,51 @@ CREATE TABLE prefix_stats_user_monthly ( KEY `timeend` (`timeend`) ); +# +# Table structure for BRAND NEW MOODLE POST table `prefix_post` +# +CREATE TABLE prefix_post ( + `id` int(11) NOT NULL auto_increment, + `userid` int(11) NOT NULL default '0', + `courseid` int(11) NOT NULL default'0', + `groupid` int(11) NOT NULL default'0', + `moduleid` int(11) NOT NULL default'0', + `coursemoduleid` int(11) NOT NULL default'0', + `subject` varchar(128) NOT NULL default '', + `summary` longtext, + `content` longtext, + `uniquehash` varchar(128) NOT NULL default '', + `rating` int(11) NOT NULL default'0', + `format` int(11) NOT NULL default'0', + `publishstate` enum('draft','site','public') NOT NULL default 'draft', + `lastmodified` int(10) NOT NULL default '0', + `created` int(10) NOT NULL default '0', + PRIMARY KEY (`id`), + UNIQUE KEY `id_user_idx` (`id`, `userid`), + KEY `post_lastmodified_idx` (`lastmodified`), + KEY `post_subject_idx` (`subject`) +) TYPE=MyISAM COMMENT='New moodle post table. Holds data posts such as forum entries or blog entries.'; + +# tags are not limited to blogs +CREATE TABLE prefix_tags ( + `id` int(11) NOT NULL auto_increment, + `type` varchar(255) NOT NULL default 'official', + `userid` int(11) NOT NULL default'0', + `text` varchar(255) NOT NULL default '', + PRIMARY KEY (`id`) +) TYPE=MyISAM COMMENT ='tags structure for moodle.'; + +# instance of a tag for a blog +CREATE TABLE prefix_blog_tag_instance ( + `id` int(11) NOT NULL auto_increment, + `entryid` int(11) NOT NULL default'0', + `tagid` int(11) NOT NULL default'0', + `groupid` int(11) NOT NULL default'0', + `courseid` int(11) NOT NULL default'0', + `userid` int(11) NOT NULL default'0', + PRIMARY KEY (`id`) +) TYPE=MyISAM COMMENT ='tag instance for blogs.'; + INSERT INTO prefix_log_display VALUES ('user', 'view', 'user', 'CONCAT(firstname," ",lastname)'); INSERT INTO prefix_log_display VALUES ('course', 'user report', 'user', 'CONCAT(firstname," ",lastname)'); diff --git a/lib/db/postgres7.php b/lib/db/postgres7.php index f3555dc1db..b51d448cf4 100644 --- a/lib/db/postgres7.php +++ b/lib/db/postgres7.php @@ -1421,6 +1421,47 @@ function main_upgrade($oldversion=0) { execute_sql("UPDATE {$CFG->prefix}user_teachers SET enrol='manual' WHERE enrol=''"); } + + if ($oldversion > 2006031000) { + + modify_database("","CREATE TABLE prefix_post ( + id SERIAL PRIMARY KEY, + userid INTEGER NOT NULL default 0, + courseid INTEGER NOT NULL default 0, + groupid INTEGER NOT NULL default 0, + moduleid INTEGER NOT NULL default 0, + coursemoduleid INTEGER NOT NULL default 0, + subject varchar(128) NOT NULL default '', + summary longtext, + content longtext, + uniquehash varchar(128) NOT NULL default '', + rating INTEGER NOT NULL default 0, + format INTEGER NOT NULL default 0, + publishstate varchar(10) CHECK (type IN ('draft','site','public')) NOT NULL default 'draft', + lastmodified INTEGER NOT NULL default '0', + created INTEGER NOT NULL default '0' + );"); + + modify_database("","CREATE INDEX id_user_idx ON prefix_post (id, courseid);"); + modify_database("","CREATE INDEX post_lastmodified_idx ON prefix_post (lastmodified);"); + modify_database("","CREATE INDEX post_subject_idx ON prefix_post (subject);"); + + modify_database("","CREATE TABLE prefix_tags ( + id SERIAL PRIMARY KEY, + type varchar(255) NOT NULL default 'official', + userid INTEGER NOT NULL default 0, + text varchar(255) NOT NULL default '' + );"); + + modify_database("","CREATE TABLE prefix_blog_tag_instance ( + id SERIAL PRIMARY KEY, + entryid id SERIAL PRIMARY KEY, NOT NULL default 0, + tagid id SERIAL PRIMARY KEY, NOT NULL default 0, + groupid id SERIAL PRIMARY KEY, NOT NULL default 0, + courseid id SERIAL PRIMARY KEY, NOT NULL default 0, + userid id SERIAL PRIMARY KEY, NOT NULL default 0 + );"); + } return $result; } diff --git a/lib/db/postgres7.sql b/lib/db/postgres7.sql index 0314d20bf8..6ebc4d9385 100644 --- a/lib/db/postgres7.sql +++ b/lib/db/postgres7.sql @@ -620,6 +620,44 @@ CREATE INDEX prefix_stats_user_monthly_userid_idx ON prefix_stats_user_monthly ( CREATE INDEX prefix_stats_user_monthly_roleid_idx ON prefix_stats_user_monthly (roleid); CREATE INDEX prefix_stats_user_monthly_timeend_idx ON prefix_stats_user_monthly (timeend); +CREATE TABLE prefix_post ( + id SERIAL PRIMARY KEY, + userid INTEGER NOT NULL default 0, + courseid INTEGER NOT NULL default 0, + groupid INTEGER NOT NULL default 0, + moduleid INTEGER NOT NULL default 0, + coursemoduleid INTEGER NOT NULL default 0, + subject varchar(128) NOT NULL default '', + summary longtext, + content longtext, + uniquehash varchar(128) NOT NULL default '', + rating INTEGER NOT NULL default 0, + format INTEGER NOT NULL default 0, + publishstate varchar(10) CHECK (type IN ('draft','site','public')) NOT NULL default 'draft', + lastmodified INTEGER NOT NULL default '0', + created INTEGER NOT NULL default '0' +); + +CREATE INDEX id_user_idx ON prefix_post (id, courseid); +CREATE INDEX post_lastmodified_idx ON prefix_post (lastmodified); +CREATE INDEX post_subject_idx ON prefix_post (subject); + +CREATE TABLE prefix_tags ( + id SERIAL PRIMARY KEY, + type varchar(255) NOT NULL default 'official', + userid INTEGER NOT NULL default 0, + text varchar(255) NOT NULL default '' +); + +CREATE TABLE prefix_blog_tag_instance ( + id SERIAL PRIMARY KEY, + entryid id SERIAL PRIMARY KEY, NOT NULL default 0, + tagid id SERIAL PRIMARY KEY, NOT NULL default 0, + groupid id SERIAL PRIMARY KEY, NOT NULL default 0, + courseid id SERIAL PRIMARY KEY, NOT NULL default 0, + userid id SERIAL PRIMARY KEY, NOT NULL default 0 +); + INSERT INTO prefix_log_display VALUES ('user', 'view', 'user', 'firstname||\' \'||lastname'); INSERT INTO prefix_log_display VALUES ('course', 'user report', 'user', 'firstname||\' \'||lastname'); INSERT INTO prefix_log_display VALUES ('course', 'view', 'course', 'fullname'); diff --git a/version.php b/version.php index a74dfbca0c..d16c7b0691 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2006030901; // YYYYMMDD = date + $version = 2006031000; // YYYYMMDD = date // XY = increments within a single day $release = '1.6 development'; // Human-friendly version name -- 2.39.5