Index: openacs-4/packages/chat/tcl/chat-ajax-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/chat/tcl/chat-ajax-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/chat/tcl/chat-ajax-procs.tcl 7 Jun 2007 09:14:24 -0000 1.5 +++ openacs-4/packages/chat/tcl/chat-ajax-procs.tcl 21 Jun 2007 11:06:29 -0000 1.6 @@ -4,32 +4,77 @@ @creation-date 2006-02-02 @author Gustaf Neumann @author Peter Alberer +<<<<<<< chat-ajax-procs.tcl @cvs-id $Id$ +======= + @cvs-id $Id$ +>>>>>>> 1.5 } namespace eval ::chat { ::xo::ChatClass Chat -superclass ::xo::Chat - - Chat instproc render {} { - my orderby time - set result "" + + + Chat instproc login {} { + my instvar array user_id now chat_id - foreach child [my children] { - - set msg [$child msg] - set user_id [$child user_id] - set color [$child color] - set timelong [clock format [$child time]] - set timeshort [clock format [$child time] -format {[%H:%M:%S]}] - set userlink [my user_link -user_id $user_id -color $color] - append result "
$userlink:" \ - "
\n" - } - return $result - } + + db_1row room_info { + select maximal_participants as maximal + from chat_rooms as cp + where cp.room_id = :chat_id + } + db_1row room_info { + select count(cr.room_id) as count + from chat_room_user_id as cr + where cr.room_id = :chat_id + } + if { $count < $maximal} { + db_1row room_info { + select count(cr.room_id) as count2 + from chat_room_user_id as cr + where cr.user_id = :user_id + and cr.room_id = :chat_id + } + if { $count2 == 0 } { + db_dml insert_users {insert into chat_room_user_id (room_id,user_id) values (:chat_id,:user_id);} + } + } + if { $count == $maximal} { + + db_1row room_info { + select count(chat_room_user_id.user_id) as count + from chat_room_user_id + where chat_room_user_id.user_id = :user_id + and chat_room_user_id.room_id = :chat_id + } + if { $count == 0 } { + if { [permission::permission_p -party_id $user_id -object_id [dotlrn::get_package_id] -privilege admin] } { + + } else { + + ns_return 200 text/html "\ + " \ - "