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.11.6.3 -r1.11.6.4
--- openacs-4/packages/chat/tcl/chat-procs.tcl 22 Nov 2016 18:34:35 -0000 1.11.6.3
+++ openacs-4/packages/chat/tcl/chat-procs.tcl 23 Nov 2016 19:51:16 -0000 1.11.6.4
@@ -7,6 +7,10 @@
@cvs-id $Id$
}
+# TODO: all the remaining Java stuff should fade away at some point,
+# its status is unknown and we won't be allowed to have binaries into
+# the core by distros.
+
ad_proc -private chat_start_server {
} {
Start Java chat server.
@@ -135,8 +139,11 @@
chat_room_get -room_id $room_id -array room_info
if { $room_info(archive_p) == "t" } {
- if {[catch {chat_post_message_to_db -creation_user $user_id $room_id $msg} errmsg]} {
- ns_log error "chat_post_message_to_db: error: $errmsg"
+ if {[catch {
+ chat_post_message_to_db \
+ -creation_user $user_id $room_id $msg
+ } errmsg]} {
+ ad_log error "chat_post_message_to_db: error: $errmsg"
}
}
@@ -196,15 +203,27 @@
{-auto_transcript_p f}
{-login_messages_p t}
{-logout_messages_p t}
+ {-messages_time_window 600}
{-context_id ""}
{-creation_user ""}
{-creation_ip ""}
pretty_name
} {
Create new chat room. Return room_id if successful else raise error.
} {
+ if {[ad_conn isconnected] && $creation_user eq ""} {
+ set creation_user [ad_conn user_id]
+ }
+
db_transaction {
- set room_id [db_string create_room {}]
+ set room_id [::xo::db::sql::acs_object new \
+ -object_type "chat_room" \
+ -creation_user $creation_user \
+ -creation_ip $creation_ip \
+ -context_id $context_id]
+
+ db_dml insert_room {}
+
if {$creation_user ne ""} {
foreach privilege {edit view delete} {
permission::grant \
@@ -246,10 +265,11 @@
auto_transcript_p
login_messages_p
logout_messages_p
+ messages_time_window
} {
Edit information on chat room. All information require.
} {
- db_string edit_room {}
+ db_dml update_room {}
ns_cache_flush -- chat_room_get_not_cached $room_id
}
@@ -425,14 +445,6 @@
set default_client [parameter::get -parameter "DefaultClient" -default "ajax"]
- if {$default_client eq "java"} {
- set chat_msg "[chat_user_name $user_id]$user_id$room_id$message$status"
- # Add message to queue. Notify thread responsible for
- # broadcast message to applets.
- nsv_set chat html_message $chat_msg
- ns_mutex unlock [nsv_get chat new_message]
- }
-
# do not write messages to the database if the room should not be archived
chat_room_get -room_id $room_id -array room_info
if { $room_info(archive_p) == "f" } { return }
@@ -450,7 +462,14 @@
} {
Post moderate message to the chat room and broadcast to all applet clients. Only use by HTML client.
} {
- set chat_msg "[chat_user_name $user_id]$user_id$room_id$messagepending"
+ set chat_msg "
+
+ [chat_user_name $user_id]
+ $user_id
+ $room_id
+ $message
+ pending
+ "
# Add message to queue. Notify thread responsible for broadcast message to applets.
nsv_set chat html_message $chat_msg
@@ -520,16 +539,24 @@
} {
Create chat transcript.
} {
+ if {[ad_conn isconnected] && $creation_user eq ""} {
+ set creation_user [ad_conn user_id]
+ }
+
db_transaction {
- set transcript_id [db_string create_transcript {}]
- if { $transcript_id != 0 } {
- db_dml update_contents {}
- foreach privilege {edit view delete} {
- permission::grant \
- -party_id $creation_user \
- -object_id $transcript_id \
- -privilege chat_transcript_${privilege}
- }
+ set transcript_id [::xo::db::sql::acs_object new \
+ -object_type "chat_transcript" \
+ -creation_user $creation_user \
+ -creation_ip $creation_ip \
+ -context_id $context_id]
+
+ db_dml insert_transcript {}
+
+ foreach privilege {edit view delete} {
+ permission::grant \
+ -party_id $creation_user \
+ -object_id $transcript_id \
+ -privilege chat_transcript_${privilege}
}
}
@@ -552,10 +579,7 @@
} {
Edit chat transcript.
} {
- db_transaction {
- db_string edit_transcript {}
- db_dml update_contents {}
- }
+ db_dml update_transcript {}
}
ad_proc -private chat_flush_rooms {} {