]> git.mjollnir.org Git - moodle.git/commitdiff
Updated message databases with better time storage, and also some logging
authormoodler <moodler>
Tue, 28 Dec 2004 07:40:26 +0000 (07:40 +0000)
committermoodler <moodler>
Tue, 28 Dec 2004 07:40:26 +0000 (07:40 +0000)
for message reading and writing

lib/db/mysql.php
lib/db/mysql.sql
lib/db/postgres7.php
lib/db/postgres7.sql
version.php

index 9675ea30757dbe082dc90ca435558ad27d8eefd8..0879b4269973b963861d3243a3af601732d8d2cd 100644 (file)
@@ -1037,13 +1037,17 @@ function main_upgrade($oldversion=0) {
             PRIMARY KEY (id))");
     }       
 
-    if ($oldversion < 2004121600) {
+    if ($oldversion < 2004122800) {
+        execute_sql("DROP TABLE {$CFG->prefix}message", false);
+        execute_sql("DROP TABLE {$CFG->prefix}message_read", false);
+        execute_sql("DROP TABLE {$CFG->prefix}message_contacts", false);
+
         modify_database('',"CREATE TABLE `prefix_message` (
                                `id` int(10) unsigned NOT NULL auto_increment,
                                `useridfrom` int(10) NOT NULL default '0',
                                `useridto` int(10) NOT NULL default '0',
                                `message` text NOT NULL,
-                               `timemodified` int(10) NOT NULL default '0',
+                               `timecreated` int(10) NOT NULL default '0',
                                `messagetype` varchar(50) NOT NULL default '',
                                PRIMARY KEY  (`id`),
                                KEY `useridfrom` (`useridfrom`),
@@ -1055,15 +1059,28 @@ function main_upgrade($oldversion=0) {
                                `useridfrom` int(10) NOT NULL default '0',
                                `useridto` int(10) NOT NULL default '0',
                                `message` text NOT NULL,
-                               `timemodified` int(10) NOT NULL default '0',
+                               `timecreated` int(10) NOT NULL default '0',
+                               `timeread` int(10) NOT NULL default '0',
                                `messagetype` varchar(50) NOT NULL default '',
                                `mailed` tinyint(1) NOT NULL default '0',
                                PRIMARY KEY  (`id`),
                                KEY `useridfrom` (`useridfrom`),
                                KEY `useridto` (`useridto`)
                              ) TYPE=MyISAM COMMENT='Stores all messages that have been read';");
+
+        modify_database('',"CREATE TABLE `prefix_message_contacts` (
+                               `id` int(10) unsigned NOT NULL auto_increment,
+                               `userid` int(10) unsigned NOT NULL default '0',
+                               `contactid` int(10) unsigned NOT NULL default '0',
+                               `blocked` tinyint(1) unsigned NOT NULL default '0',
+                               PRIMARY KEY  (`id`),
+                               UNIQUE KEY `usercontact` (`userid`,`contactid`)
+                             ) TYPE=MyISAM COMMENT='Maintains lists of relationships between users';");
+
+        modify_database('', "INSERT INTO prefix_log_display VALUES ('message', 'write', 'user', 'CONCAT(firstname,\" \",lastname)'); ");
+        modify_database('', "INSERT INTO prefix_log_display VALUES ('message', 'read', 'user', 'CONCAT(firstname,\" \",lastname)'); ");
     }
-       
+
     return $result;
 
 }
index 7fefb5714faf1eb16188b08551ab5529ea1953bf..3bc9254cb7b03a81935f010857fe89434c7b9a0b 100644 (file)
@@ -309,7 +309,7 @@ CREATE TABLE `prefix_message` (
   `useridfrom` int(10) NOT NULL default '0',
   `useridto` int(10) NOT NULL default '0',
   `message` text NOT NULL,
-  `timemodified` int(10) NOT NULL default '0',
+  `timecreated` int(10) NOT NULL default '0',
   `messagetype` varchar(50) NOT NULL default '',
   PRIMARY KEY  (`id`),
   KEY `useridfrom` (`useridfrom`),
@@ -326,7 +326,8 @@ CREATE TABLE `prefix_message_read` (
   `useridfrom` int(10) NOT NULL default '0',
   `useridto` int(10) NOT NULL default '0',
   `message` text NOT NULL,
-  `timemodified` int(10) NOT NULL default '0',
+  `timecreated` int(10) NOT NULL default '0',
+  `timeread` int(10) NOT NULL default '0',
   `messagetype` varchar(50) NOT NULL default '',
   `mailed` tinyint(1) NOT NULL default '0',
   PRIMARY KEY  (`id`),
@@ -335,6 +336,20 @@ CREATE TABLE `prefix_message_read` (
 ) TYPE=MyISAM COMMENT='Stores all messages that have been read';
 # --------------------------------------------------------
 
+#
+# Table structure for table `message_contacts`
+#
+
+CREATE TABLE `prefix_message_contacts` (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `userid` int(10) unsigned NOT NULL default '0',
+  `contactid` int(10) unsigned NOT NULL default '0',
+  `blocked` tinyint(1) unsigned NOT NULL default '0',
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `usercontact` (`userid`,`contactid`)
+) TYPE=MyISAM COMMENT='Maintains lists of relationships between users';
+# --------------------------------------------------------
+
 #
 # Table structure for table `modules`
 #
@@ -537,3 +552,5 @@ INSERT INTO prefix_log_display VALUES ('course', 'user report', 'user', 'CONCAT(
 INSERT INTO prefix_log_display VALUES ('course', 'view', 'course', 'fullname');
 INSERT INTO prefix_log_display VALUES ('course', 'update', 'course', 'fullname');
 INSERT INTO prefix_log_display VALUES ('course', 'enrol', 'course', 'fullname');
+INSERT INTO prefix_log_display VALUES ('message', 'write', 'user', 'CONCAT(firstname," ",lastname)');
+INSERT INTO prefix_log_display VALUES ('message', 'read', 'user', 'CONCAT(firstname," ",lastname)');
index d2f6cae5df030b7db18bbf3e700842c723a14d35..f0238533724cb6e960f60ebd250f718e263009d8 100644 (file)
@@ -799,14 +799,25 @@ function main_upgrade($oldversion=0) {
                                 next_change integer NOT NULL default '0',
                                 current_offset integer NOT NULL default '0'
                              );");
+    }
+
+    if ($oldversion < 2004122800) {
+        execute_sql("DROP TABLE {$CFG->prefix}message", false);
+        execute_sql("DROP TABLE {$CFG->prefix}message_read", false);
+        execute_sql("DROP TABLE {$CFG->prefix}message_contacts", false);
 
+        execute_sql("DROP INDEX {$CFG->prefix}message_useridfrom_idx", false);
+        execute_sql("DROP INDEX {$CFG->prefix}message_useridto_idx", false);
+        execute_sql("DROP INDEX {$CFG->prefix}message_read_useridfrom_idx", false);
+        execute_sql("DROP INDEX {$CFG->prefix}message_read_useridto_idx", false);
+        execute_sql("DROP INDEX {$CFG->prefix}message_contacts_useridcontactid_idx", false);
 
         modify_database('',"CREATE TABLE prefix_message (
                                id SERIAL PRIMARY KEY,
                                useridfrom integer NOT NULL default '0',
                                useridto integer NOT NULL default '0',
                                message text,
-                               timemodified integer NOT NULL default '0',
+                               timecreated integer NOT NULL default '0',
                                messagetype varchar(50) NOT NULL default ''
                             );
 
@@ -818,7 +829,8 @@ function main_upgrade($oldversion=0) {
                                useridfrom integer NOT NULL default '0',
                                useridto integer NOT NULL default '0',
                                message text,
-                               timemodified integer NOT NULL default '0',
+                               timecreated integer NOT NULL default '0',
+                               timeread integer NOT NULL default '0',
                                messagetype varchar(50) NOT NULL default '',
                                mailed integer NOT NULL default '0'
                             );
@@ -826,7 +838,22 @@ function main_upgrade($oldversion=0) {
                             CREATE INDEX prefix_message_read_useridfrom_idx ON prefix_message_read (useridfrom);
                             CREATE INDEX prefix_message_read_useridto_idx ON prefix_message_read (useridto);
                             ");
+      
+        modify_database('',"CREATE TABLE prefix_message_contacts (
+                               id SERIAL PRIMARY KEY,
+                               userid integer NOT NULL default '0',
+                               contactid integer NOT NULL default '0',
+                               blocked integer NOT NULL default '0'
+                            );
+
+                            CREATE INDEX prefix_message_contacts_useridcontactid_idx ON prefix_message_contacts (userid,contactid);
+                            ");
+
+        modify_database('',"INSERT INTO prefix_log_display VALUES ('message', 'write', 'user', 'firstname||\' \'||lastname');
+                            INSERT INTO prefix_log_display VALUES ('message', 'read', 'user', 'firstname||\' \'||lastname');
+                            ");
     }
+       
                                 
     return $result;
 }
index e176e9dd4b901c80b9f038fa9d40a99b0fe9901b..22de7fb9e03a497b385890584ea9496ccbde4478 100644 (file)
@@ -187,7 +187,7 @@ CREATE TABLE prefix_message (
    useridfrom integer NOT NULL default '0',
    useridto integer NOT NULL default '0',
    message text,
-   timemodified integer NOT NULL default '0',
+   timecreated integer NOT NULL default '0',
    messagetype varchar(50) NOT NULL default ''
 );
 
@@ -199,7 +199,8 @@ CREATE TABLE prefix_message_read (
    useridfrom integer NOT NULL default '0',
    useridto integer NOT NULL default '0',
    message text,
-   timemodified integer NOT NULL default '0',
+   timecreated integer NOT NULL default '0',
+   timeread integer NOT NULL default '0',
    messagetype varchar(50) NOT NULL default '',
    mailed integer NOT NULL default '0'
 );
@@ -207,6 +208,15 @@ CREATE TABLE prefix_message_read (
 CREATE INDEX prefix_message_read_useridfrom_idx ON prefix_message_read (useridfrom);
 CREATE INDEX prefix_message_read_useridto_idx ON prefix_message_read (useridto);
 
+CREATE TABLE prefix_message_contacts (
+   id SERIAL PRIMARY KEY,
+   userid integer NOT NULL default '0',
+   contactid integer NOT NULL default '0',
+   blocked integer NOT NULL default '0'
+);
+
+CREATE INDEX prefix_message_contacts_useridcontactid_idx ON prefix_message_contacts (userid,contactid);
+
 CREATE TABLE prefix_modules (
    id SERIAL PRIMARY KEY,
    name varchar(20) NOT NULL default '',
@@ -373,3 +383,5 @@ INSERT INTO prefix_log_display VALUES ('course', 'user report', 'user', 'firstna
 INSERT INTO prefix_log_display VALUES ('course', 'view', 'course', 'fullname');
 INSERT INTO prefix_log_display VALUES ('course', 'update', 'course', 'fullname');
 INSERT INTO prefix_log_display VALUES ('course', 'enrol', 'course', 'fullname');
+INSERT INTO prefix_log_display VALUES ('message', 'write', 'user', 'firstname||\' \'||lastname');
+INSERT INTO prefix_log_display VALUES ('message', 'read', 'user', 'firstname||\' \'||lastname');
index 4628f5bedd32e7d6e08ba8d04a60bc42b0ca1636..f1a3dd0609066ae6ba808e6c8123de90852c00e7 100644 (file)
@@ -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 = 2004121600;  // YYYYMMDD = date of first major branch release 1.4
+   $version = 2004122800;  // YYYYMMDD = date of first major branch release 1.4
                            //       XY = increments within a single day
 
    $release = '1.5 UNSTABLE DEVELOPMENT';    // Human-friendly version name