Index: openacs-4/packages/chat/tcl/chat-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/chat/tcl/chat-procs.tcl,v diff -u -r1.24.2.2 -r1.24.2.3 --- openacs-4/packages/chat/tcl/chat-procs.tcl 26 Feb 2019 18:06:43 -0000 1.24.2.2 +++ openacs-4/packages/chat/tcl/chat-procs.tcl 28 Feb 2019 16:09:03 -0000 1.24.2.3 @@ -235,7 +235,26 @@ } { Log chat message to the database. } { - db_string post_message {} + chat_room_get -room_id $room_id -array c + if {$c(archive_p)} { + set msg_id [db_nextval acs_object_id_seq] + db_dml save_message { + insert into chat_msgs ( + msg_id, + room_id, + msg, + creation_user, + creation_ip, + creation_date) + values ( + :msg_id, + :room_id, + :msg, + :creation_user, + :creation_ip, + current_timestamp) + } + } } ad_proc -public chat_room_get { @@ -375,7 +394,17 @@ } { Delete chat room. } { - db_string delete_room {} + # Delete the transcripts explicitly, otherwise the acs_object + # related to them would stay around + foreach transcript_id [db_list get_transcripts { + select transcript_id from chat_transcripts + where room_id = :room_id + }] { + ::xo::db::sql::acs_object delete \ + -object_id $transcript_id + } + ::xo::db::sql::acs_object delete \ + -object_id $room_id ns_cache flush -- chat_room_cache $room_id } @@ -384,15 +413,21 @@ } { Delete all message in the room. } { - db_string delete_message {} + db_dml delete_message { + delete from chat_msgs + where room_id = :room_id + } } ad_proc -public chat_message_count { room_id } { Get message count in the room. } { - return [db_string message_count {} -default 0] + return [db_string message_count { + select count(*) from chat_msgs + where room_id = :room_id + } -default 0] } ad_proc -public room_active_status { @@ -596,7 +631,8 @@ } { Delete chat transcript. } { - db_string delete_transcript {} + ::xo::db::sql::acs_object delete \ + -object_id $transcript_id } ad_proc -public chat_transcript_edit {