ad_general_comments_summary_sorted

one of the documented procedures in this installation of the ACS
Usage:
ad_general_comments_summary_sorted   db   on_what_id   on_which_table   item   { number_to_display "-1" }   { url_for_more_items "" }   { skip_sort "0" }
What it does:
Generates the line item list of comments made on this item. Sorts entries by comment_date and allows the user to specify the max entries to return (default is all). If you specify the max entries to return, and there are more, the link (you provide) is added to see them all. This link should basically be your return_url with a flag set so you know what your next call to this procedure will show all items.
Defined in: /web/philip/tcl/ad-general-comments.tcl

Source code:


    set user_id [ad_get_user_id]

    set approved_clause "and general_comments.approved_p = 't'"

    set return_url [ns_conn url]?[export_ns_set_vars "url"]

    # For backwards compatibility
    if { $skip_sort } {
	set sort_sql ""
    } else {
	set sort_sql "order by comment_date desc"
    }

    set selection [ns_db select $db "
    select general_comments.comment_id, content, comment_date, 
    first_names || ' ' || last_name as commenter_name, users.user_id as comment_user_id, 
    html_p as comment_html_p, client_file_name, file_type, original_width, original_height, 
    caption, one_line
    from general_comments, users
    where on_what_id= $on_what_id 
    and on_which_table = '[DoubleApos $on_which_table]' $approved_clause
    and general_comments.user_id = users.user_id $sort_sql"]

    set counter 0
    append return_string "<ul>"
    while {[ns_db getrow $db $selection]} {
	if { $number_to_display > 0 && $counter >= $number_to_display } {
	    if { ![empty_string_p $url_for_more_items] } {
		append return_string "<li>(<a href=\"$url_for_more_items\">more</a>)\n"
	    }
	    ns_db flush $db
	    break
	} 
	set_variables_after_query
	# if the user posted the comment, they are allowed to edit it
	 append return_string "<li><a href=/general-comments/view-one?[export_url_vars return_url comment_id item]>$one_line ($comment_date)</a> by <a href=\"/shared/community-member?user_id=$comment_user_id\">$commenter_name</a>"
	if { ![empty_string_p $client_file_name] } {
	    append return_string " <i>Attachment: <a href=\"/general-comments/attachment/$comment_id/$client_file_name\">$client_file_name</a></i>"
	}
	incr counter
    }

    append return_string "</ul>"


philg@mit.edu