Index: openacs-4/packages/chat-portlet/www/chat-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/chat-portlet/www/chat-portlet.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/chat-portlet/www/chat-portlet.tcl 7 Jun 2007 09:19:12 -0000 1.4 +++ openacs-4/packages/chat-portlet/www/chat-portlet.tcl 19 Nov 2007 14:12:54 -0000 1.5 @@ -17,14 +17,15 @@ ad_page_contract { The display logic for the chat portlet - @author agustin (Agustin.Lopez@uv.es) and Pablo Mu�oz (pablomp@tid.es) + @author agustin (Agustin.Lopez@uv.es) + @creation-date 2004-10-10 + @version $Id: chat-portlet.tcl,v 0.1 2004/10/10 } -properties { context:onevalue user_id:onevalue room_create_p:onevalue rooms:multirow - rooms3:multirow } array set config $cf @@ -36,363 +37,20 @@ set user_id [ad_conn user_id] set community_id [dotlrn_community::get_community_id] set room_create_p [ad_permission_p $user_id chat_room_create] - set default_mode [ad_parameter DefaultClient chat "ajax"] set num_rooms 0 -set path [ad_return_url] -set package_id [ad_conn package_id] -set room_create_p [permission::permission_p -object_id $package_id -privilege chat_room_create] -set rss_exists [rss_support::subscription_exists \ - -summary_context_id $package_id \ - -impl_name chat_rss] - -set rss_feed_url [chat_util_get_url $package_id]chat/rss/rss.xml - - - - - -if { $community_id eq "" } { - set query_name "rooms_list_all" - set list 0 +if { $community_id eq 0 } { + set query_name "rooms_list_all" } else { - set list 1 set query_name "rooms_list" } - - -db_multirow -extend { } rooms2 "rooms_list_all_comm" {} { -} -db_multirow -extend { active_users last_activity can_see_p rss_exists rss_feed_url2 rss_service admin_professor} rooms1 $query_name {} { - set room [::chat::Chat create new -volatile -chat_id $room_id] - set active_users [$room nr_active_users] - set last_activity [$room last_activity] +db_multirow -extend { can_see_p } rooms $query_name {} { set can_see_p 0 - set rss_exists [rss_support::subscription_exists -summary_context_id $room_id -impl_name chat_rss] - - set rss_feed_url2 [chat_util_get_url $package_id]/chat/rss/rss.tcl?room_id=$room_id - - - db_1row room_info { - select count(cru.rss_service) as counter - from chat_registered_users cru - where cru.user_id = :user_id - and cru.room_id = :room_id - and cru.rss_service = 'true' - } - if { $counter > 0} { - set rss_service 1 - } else { - set rss_service 0 - } - if {($active_p eq "t" && $user_p eq "t") || ($admin_p eq "t")} { set can_see_p 1 set num_rooms [expr $num_rooms + 1] - } - - #A professor who creates a rooom will be able to admin it. -db_1row room_info2 { - select count(cr.creator) as counter2 - from chat_rooms cr - where cr.room_id = :room_id - and cr.creator = :user_id - } - if { $counter2 > 0} { - set admin_professor "t" - } else { - set admin_professor "f" - } - + } } -set active_users 0 -db_multirow -extend { active_users last_activity can_see_p rss_exists rss_feed_url2 rss_service admin_professor} rooms3 "rooms_list2" {} { - set room [::chat::Chat create new -volatile -chat_id $room_id] - set active_users [$room nr_active_users] - set last_activity [$room last_activity] - set rss_exists [rss_support::subscription_exists -summary_context_id $room_id -impl_name chat_rss] - set rss_feed_url2 /rss/rss.tcl?room_id=$room_id - set rss_service 0 - db_1row room_info { - select count(cru.rss_service) as counter - from chat_registered_users cru - where cru.user_id = :user_id - and cru.room_id = :room_id - and cru.rss_service = 'true' - } - - if { $counter > 0} { - set rss_service 1 - } else { - set rss_service 0 - } - set can_see_p 0 - if {($active_p eq "t" && $user_p eq "t") || ($admin_p eq "t")} { - set can_see_p 1 - set num_rooms [expr $num_rooms + 1] - } - #A professor who creates a rooom will be able to admin it. - db_1row room_info2 { - select count(cr.creator) as counter2 - from chat_rooms cr - where cr.room_id = :room_id - and cr.creator = :user_id - } - if { $counter2 > 0} { - set admin_professor "t" - } else { - set admin_professor "f" - } - -} - - db_foreach open "select end_date,room_id from chat_rooms" { - if { [clock format [clock seconds] -format "%Y/%m%d"] > $end_date } { - db_0or1row update_closed { - update chat_rooms SET open = 'false' - WHERE room_id = :room_id; - select 1; - } - } else { - db_0or1row update_closed { - update chat_rooms SET open = 'true' - WHERE room_id = :room_id; - select 1; - } - } - - - } - - - -list::create \ - -name "rooms3" \ - -multirow "rooms3" \ - -key room_id \ - -pass_properties {room_create_p} \ - -row_pretty_plural [_ chat.room_options] \ - -elements { - open { - label "#chat-portlet.open_room#" - html { style "text-align:center;" width 15px} - display_template { - - -
- -
-
- -
- -
-
- } - } - private { - label "#chat-portlet.private_room#" - html { style "text-align:center;" width 15px} - display_template { - - -
- -
-
- -
- -
-
- } - } - - community { - label "#chat-portlet.community_class#" - html { style "text-align:center;" width 15px} - display_template { - - @rooms3.community@ - - } - } - pretty_name { - label "#chat.Room_name#" - html { align "center"} - display_template { - - @rooms3.pretty_name@ - - - (NO #chat.Active#) - -
@rooms3.description@
- } - } - active_users { - label "#chat.active_users#" - html { style "text-align:center;" } - } - last_activity { - label "#chat.last_activity#" - html { style "text-align:center;" width 15px} - } - rss { - label "#chat-portlet.rss#" - html { align "center" } - display_template { - - - -
#rss-support.Syndication_Feed# Subscribe via RSS

-
- #chat-portlet.no_rss# - -
- #chat-portlet.no_rss# - - } - } - admin { - label "#chat.actions#" - html { align "center" } - display_template { - - - \n#chat.room_admin# -
- \n#chat.Transcripts# -
- - \n#chat.room_change_options# -
- \n#chat.Transcripts# -
-
- - \n#chat.room_admin# -
- \n#chat.Transcripts# -
- } - } - - } - - -list::create \ - -name "rooms1" \ - -multirow "rooms1" \ - -key room_id \ - -pass_properties {room_create_p} \ - -row_pretty_plural [_ chat.room_options] \ - -elements { - open { - label "#chat-portlet.open_room#" - html { style "text-align:center;" width 15px} - display_template { - - -
- -
-
- -
- -
-
- } - } - private { - label "#chat-portlet.private_room#" - html { style "text-align:center;" width 1px} - display_template { - -
- -
-
- -
- -
-
- } - } - - community { - label "#chat-portlet.community#" - html { align "center"} - display_template { - @rooms1.community@ - } - } - pretty_name { - label "#chat.Room_name#" - html { align "center"} - display_template { - - - @rooms1.pretty_name@ - - - (NO #chat.Active#) - -
@rooms1.description@
- } - } - active_users { - label "#chat.active_users#" - html { style "text-align:center;" } - } - last_activity { - label "#chat.last_activity#" - html { style "text-align:center;" } - } - rss { - label "#chat-portlet.rss#" - html { align "center" } - display_template { - - - -
#rss-support.Syndication_Feed# Subscribe via RSS

-
- #chat-portlet.no_rss# - -
- #chat-portlet.no_rss# - - } - } - admin { - label "#chat.actions#" - html { align "center" } - display_template { - - - \n#chat.room_admin# -
- \n#chat.Transcripts# -
- - \n#chat.room_change_options# -
- \n#chat.Transcripts# -
-
- - \n#chat.room_admin# -
- \n#chat.Transcripts# -
- } - } - - } - ad_return_template