ad_chat_user_contributions db user_id purposeWhat it does:
Returns a list of priority, title, and an unordered list HTML fragment. All the chat messages posted by a user.Defined in: /web/philip/tcl/chat-defs.tcl
Source code:
if { $purpose == "site_admin" } { set n_msgs [database_to_tcl_string $db " select count(*) from chat_msgs where creation_user = $user_id and system_note_p = 'f'"] if { $n_msgs == 0 } { return [list] } if { $n_msgs > 100 } { return [list 1 "Chat" "More than 100 chat messages. View <a href=\"/admin/chat/msgs-for-user?user_id=$user_id\">here</a>."] } set selection [ns_db select $db " select cr.pretty_name, cr.scope, cr.group_id, cm.msg, u.first_names || ' ' || u.last_name as recipient, ug.group_name, ug.short_name, decode(cr.scope, 'public', 1, 'group', 2, 'user', 3, 4) as scope_ordering from chat_rooms cr, chat_msgs cm, users u, user_groups ug where cm.creation_user = $user_id and cm.chat_room_id = cr.chat_room_id(+) and cm.recipient_user = u.user_id(+) and cm.system_note_p = 'f' and cr.group_id= ug.group_id(+) order by scope_ordering, cr.pretty_name, u.first_names, u.last_name, cm.creation_date desc"] set items "" set last_chat_room "" set last_recipient " " set item_counter 0 set last_group_id "" while { [ns_db getrow $db $selection] } { set_variables_after_query switch $scope { public { if { $item_counter==0 } { append items " </ul><h4>Public Chat Rooms</h4><ul>" } } group { if { $last_group_id!=$group_id } { append items " </ul><h4>$group_name Chat Rooms</h4><ul>" } } } if { ![empty_string_p $pretty_name] && $last_chat_room != $pretty_name } { append items "Messages in $pretty_name<br><br>\n" set last_chat_room $pretty_name } if { ![empty_string_p $recipient] && $recipient != $last_recipient } { append items "</ul><h4>Messages to $recipient</h4><ul>\n" set last_recipient $recipient } append items "<li>$msg\n" set last_group_id $group_id incr item_counter } return [list 1 "Chat" "<ul><ul>\n$items\n</ul></ul>"] } else { return [list] }