From: rkingdon Date: Sun, 21 Nov 2004 04:01:10 +0000 (+0000) Subject: Added vetting of conversationid; fixed bug 2194 (Problems with X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7decbe4b120be99de6002e9160c316c09afc7ec7;p=moodle.git Added vetting of conversationid; fixed bug 2194 (Problems with backup/restore); Tidied Postgres table. --- diff --git a/mod/dialogue/backuplib.php b/mod/dialogue/backuplib.php index 40bdbf8136..1ad94113a3 100644 --- a/mod/dialogue/backuplib.php +++ b/mod/dialogue/backuplib.php @@ -87,12 +87,13 @@ fwrite ($bf,full_tag("CTYPE",6,false,$conversation->ctype)); fwrite ($bf,full_tag("FORMAT",6,false,$conversation->format)); fwrite ($bf,full_tag("SUBJECT",6,false,$conversation->subject)); + + //if we've selected to backup users info, then execute backup_dialogue_entries + if ($preferences->mods["dialogue"]->userinfo) { + $status = backup_dialogue_entries($bf,$preferences,$conversation->id); + } //End entry $status =fwrite ($bf,end_tag("CONVERSATION",5,true)); - } - //if we've selected to backup users info, then execute backup_dialogue_entries - if ($preferences->mods["dialogue"]->userinfo) { - $status = backup_dialogue_entries($bf,$preferences,$conversation->id); } //Write end tag diff --git a/mod/dialogue/db/postgres7.sql b/mod/dialogue/db/postgres7.sql index f39673d57a..6ea981eee2 100644 --- a/mod/dialogue/db/postgres7.sql +++ b/mod/dialogue/db/postgres7.sql @@ -28,7 +28,7 @@ CREATE TABLE prefix_dialogue ( multipleconversations INT NOT NULL default '0', maildefault INT NOT NULL default '0', timemodified INT8 NOT NULL default '0', - name varchar(255) default NULL, + name varchar(255) NOT NULL default '', intro text ) ; @@ -81,3 +81,4 @@ CREATE INDEX prefix_dialogue_entries_userid_idx ON prefix_dialogue_entries (user # INSERT INTO prefix_log_display VALUES ('dialogue', 'view', 'dialogue', 'name'); + diff --git a/mod/dialogue/dialogues.php b/mod/dialogue/dialogues.php index 48f58562a0..9bba7443bf 100644 --- a/mod/dialogue/dialogues.php +++ b/mod/dialogue/dialogues.php @@ -48,7 +48,18 @@ require_variable($action); // need something to do! - + + // vet conversation id, if present + if (!empty($_REQUEST['cid'])) { + if ($conversation = get_record("dialogue_conversations", "id", $_REQUEST['cid'])) { + if (($conversation->userid <> $USER->id) and ($conversation->recipientid <> $USER->id)) { + error("Dialogue id incorrect"); + } + } else { + error("Dialogue: Conversation record not found"); + } + } + /************** close conversation ************************************/ if ($action == 'closeconversation') { if (empty($_GET['cid'])) { diff --git a/mod/dialogue/restorelib.php b/mod/dialogue/restorelib.php index c5249a5b95..b5e6f12460 100644 --- a/mod/dialogue/restorelib.php +++ b/mod/dialogue/restorelib.php @@ -182,7 +182,7 @@ $olduserid = backup_todb($entry_info['#']['USERID']['0']['#']); //Now, build the dialogue_ENTRIES record structure - $entry->dialogue = $new_dialogue_id; + $entry->dialogueid = $new_dialogue_id; $entry->conversationid = $new_conversation_id; $entry->userid = backup_todb($entry_info['#']['USERID']['0']['#']); $entry->timecreated = backup_todb($entry_info['#']['TIMECREATED']['0']['#']);