Index: openacs-4/packages/chat/www/ajax/chat.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/chat/www/ajax/Attic/chat.tcl,v
diff -u -N -r1.2 -r1.3
--- openacs-4/packages/chat/www/ajax/chat.tcl 24 Jun 2006 14:23:42 -0000 1.2
+++ openacs-4/packages/chat/www/ajax/chat.tcl 7 Jun 2007 09:14:25 -0000 1.3
@@ -1,16 +1,49 @@
ad_page_contract {
a tiny chat client
- @author Gustaf Neumann (gustaf.neumann@wu-wien.ac.at)
- @creation-date Jan 31, 2006
- @cvs-id $Id$
+ @author Gustaf Neumann (gustaf.neumann@wu-wien.ac.at) and Pablo Mu�oz (pablomp@tid.es)
+
} -query {
- m
+ m
id
s
- {msg:optional,allhtml ""}
+ {msg:optional,allhtml ""}
}
+set room [::chat::Chat create new -volatile -chat_id $id]
+set active_users [$room nr_active_users]
+set user_id [ad_conn user_id]
+
+
+
+
+db_1row room_info {
+ select maximal_participants as maximal
+ from chat_rooms as cp
+ where cp.room_id = :id
+}
+if { $active_users >= $maximal} {
+ #If the user is active and the room is full
+ 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 = :id
+ }
+ if { $count == 0 } {
+ if { [permission::permission_p -party_id $user_id -object_id [dotlrn::get_package_id] -privilege admin] } {
+
+ } else {
+ #blanco
+
+ ns_return 200 text/html "
\
+ [_ chat.You_dont_have_permission_room]
\
+ "
+ ad_script_abort
+ }
+ }
+}
+
set ban_p [permission::permission_p -object_id $id -privilege "chat_ban"]
if {$ban_p} {
ns_return 200 text/html "\
@@ -19,9 +52,58 @@
ad_script_abort
}
+db_1row date {
+ select r.end_date as date, pretty_name as name
+ from chat_rooms as r
+ where r.room_id = :id
+ }
+if { [clock format [clock seconds] -format "%Y/%m%d"] > $date } {
+ db_0or1row update_closed {
+ update chat_rooms SET open = 'false'
+ WHERE room_id = :id;
+ select 1;
+ }
+ ns_return 200 text/html "\
+ [_ chat.closed_room]
\
+ "
+ ad_script_abort
+}
+set user_id [ad_conn user_id]
+db_1row room_info {
+ select distinct count(cp.user_id1) as count1
+ from chat_private_room_users as cp
+ where cp.room_id = :id
+ and cp.user_id1 = :user_id
+}
+
+db_1row room_info {
+ select distinct count(cp.user_id1) as count2
+ from chat_private_room_users as cp
+ where cp.room_id = :id
+ and cp.user_id2 = :user_id
+}
+db_1row room_info {
+ select cr.private as private
+ from chat_rooms as cr
+ where cr.room_id = :id
+}
+if { $count1 == 0 && $count2 == 0 } {
+ if { $private eq "t" } {
+ ns_return 200 text/html "\
+ [_ chat.You_dont_have_permission_room]
\
+ "
+ ad_script_abort
+ }
+
+}
+
+
set message_output ""
set user_output "-"
+set files_output "-"
+
+#crea el objeto de tipo xotcl
::chat::Chat c1 -volatile -chat_id $id -session_id $s
switch -- $m {
@@ -43,13 +125,26 @@
set message_output [c1 $m]
}
get_updates {
- set message_output [c1 get_new]
+
+ set message_output [c1 get_new]
+
set user_output [c1 get_users]
+
+ set files_output [c1 get_files]
+
+
}
get_users {
+
c1 encoder noencode
set user_output [c1 get_users]
+
}
+ get_files {
+
+ c1 encoder noencode
+ set files_output [c1 get_files]
+ }
default {ns_log error "--c unknown method $m called."}
}
@@ -64,17 +159,25 @@
#users { width: 100%; font-size: 12px; color: #666666; font-family: Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Arial, sans-serif; }
#users .user {text-align: left; vertical-align: top; font-weight:bold; }
#users .timestamp {text-align: right; vertical-align: top; }
+#files { width: 100%; font-size: 12px; color: #666666; font-family: Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Arial, sans-serif; }
+#files .file {text-align: left; vertical-align: top; font-weight:bold; }
-"
+"
if { $message_output ne "" } {
append output "$message_output
\n"
}
if { $user_output ne "-" } {
+
append output "\n"
}
+if { $files_output ne "-" } {
+
+ append output "\n"
+}
+
append output "
"