Index: openacs-4/packages/chat/www/transcript-new.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/chat/www/transcript-new.tcl,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/chat/www/transcript-new.tcl 18 Jan 2019 17:14:36 -0000 1.9
+++ openacs-4/packages/chat/www/transcript-new.tcl 3 Sep 2024 15:37:36 -0000 1.10
@@ -2,7 +2,7 @@
ad_page_contract {
Display available all available chat messages.
} {
- room_id:naturalnum,notnull
+ room_id:object_type(chat_room)
} -properties {
context_bar:onevalue
title:onevalue
@@ -23,17 +23,78 @@
set transcript_name "[_ chat.transcript_of_date] [clock format [clock seconds] -format "%d.%m.%y %H:%M:%S"]"
set description ""
set contents ""
-set action "transcript-new-2"
set submit_label "[_ chat.Create_transcript]"
-set active_p [room_active_status $room_id]
+set r [::xo::db::Class get_instance_from_db -id $room_id]
+set active_p [$r set active_p]
-#Build a list of all message.
-db_foreach get_archives_messages {} {
- append contents "\[$creation_date\] [chat_user_name $creation_user]: $msg
\n"
+set messages [$r transcript_messages]
+set messages_html "
"
+foreach m $messages {
+ append messages_html "$m
"
}
+append messages_html "
"
-ad_return_template "transcript-entry"
+ad_form \
+ -name transcript_entry \
+ -export {transcript_id room_id} \
+ -has_submit 1 \
+ -actions {$action} \
+ -form {
+ {transcript_name:text(text)
+ {label {[_ chat.Transcript_name]}}
+ {help_text {}}
+ {html {size 60}}
+ {value {$transcript_name}}
+ }
+ {delete_messages:text(checkbox),optional
+ {label {[_ chat.Delete_messages]}}
+ {options {{"#chat.delete_messages_after_transcript#" t}}}
+ }
+ {deactivate_room:text(checkbox),optional
+ {label {[_ chat.Room_deactivate]}}
+ {options {{"#chat.deactivate_room_after_transcript#" t}}}
+ }
+ {description:text(textarea),optional
+ {label {[_ chat.Description]}}
+ }
+ {messages:text(inform),optional,noquote
+ {label {[_ chat.Contents]}}
+ {value {$messages_html}}
+ }
+ {submit:text(submit)
+ {label $submit_label}
+ }
+ } -on_submit {
+ permission::require_permission -object_id $room_id -privilege chat_transcript_create
+
+ set user_id [ad_conn user_id]
+ set creation_ip [ad_conn peeraddr]
+
+ set r [::xo::db::Class get_instance_from_db -id $room_id]
+
+ set transcript_id [$r create_transcript \
+ -pretty_name $transcript_name \
+ -description $description \
+ -creation_user $user_id \
+ -creation_ip $creation_ip]
+ ns_log notice "DELETE MESSAGES: $delete_messages"
+ if { $delete_messages eq "t" } {
+ $r delete_messages
+ # forward the information to AJAX
+ ::chat::Chat flush_messages -chat_id $room_id
+ }
+
+ if { $deactivate_room eq "t" } {
+ $r set active_p false
+ $r save
+ }
+
+ ad_returnredirect "chat-transcript?room_id=$room_id&transcript_id=$transcript_id"
+ ad_script_abort
+ }
+
+
# Local variables:
# mode: tcl
# tcl-indent-level: 4