recent-posters.tcl
List recent posters
- Location:
- /packages/forums/www/recent-posters.tcl
Related Files
[ hide source ] | [ make this the default ]
File Contents
ad_page_contract { List recent posters } { {num_days:integer,notnull 90} {min_posts:integer,notnull 2} {before ""} } -validate { check_num_days -requires num_days:integer { if {$num_days < 1 || $num_days > 1000000} { ad_complain "invalid value for number of days" } } check_before -requires before { if {$before ne "" && ![regexp {^\d\d\d\d[-]\d\d[-]\d\d$} $before]} { ad_complain "invalid value for start date" } } } if { $before eq "" } { set before_sql "current_timestamp" } else { if {[regexp {[^0-9-]} $before]} { ns_log notice "Invalid Date" ad_return_complaint 1 "Invalid Date" ad_script_abort } else { set before_sql "to_date(:before, 'YYYY-MM-DD')" } } set total_posts 0 db_multirow -extend { user_url posts_url } posters posters " select cc_users.user_id, first_names, last_name, email, count(message_id) as num_posts from cc_users, forums_messages where cc_users.user_id = forums_messages.user_id and posting_date between $before_sql - interval '$num_days days' and $before_sql group by cc_users.user_id, first_names, last_name, email having count(message_id) >= :min_posts order by num_posts desc " { set user_url [acs_community_member_url -user_id $user_id] set posts_url "[ad_conn package_url]user-history?[export_vars { user_id }]" if { [ad_conn user_id] == 0 } { set email {} } set total_posts [expr $total_posts + $num_posts] } set form_url [ad_conn url]