static_get_comments_and_links db url_stub { post_body " " }What it does:
Returns a list of comment_bytes link_bytes options_list comment_option link_option or the empty string if this page isn't registered in the databaseDefined in: /web/philip/tcl/ad-html.tcl
Source code:
set user_id [ad_get_user_id] set selection [ns_db 0or1row $db "select page_id,accept_comments_p,accept_links_p,inline_comments_p,inline_links_p from static_pages where url_stub = '[DoubleApos $url_stub]'"] if { $selection == "" } { # this page isn't registered in the database so we can't # accept comments on it or anything ns_log Notice "Someone grabbed $url_stub but we weren't able to offer a comment link because this page isn't registered in the db" return "" } else { set_variables_after_query set options_list [list] set comment_bytes "" if { $inline_comments_p == "t" } { # we display comments in-line set selection [ns_db select $db "select comments.comment_id, comments.page_id, comments.user_id as poster_user_id, users.first_names || ' ' || users.last_name as user_name, message, posting_time, html_p, client_file_name, file_type, original_width, original_height, caption from static_pages sp, comments_not_deleted comments, users where sp.page_id = comments.page_id and comments.user_id = users.user_id and comments.page_id = $page_id and comments.comment_type = 'alternative_perspective' order by posting_time"] set at_least_one_comment_found_p 0 while { [ns_db getrow $db $selection] } { set_variables_after_query set at_least_one_comment_found_p 1 append comment_bytes "<blockquote> [format_static_comment $comment_id $client_file_name $file_type $original_width $original_height $caption $message $html_p] " if { $user_id == $poster_user_id} { # the user wrote the message, so let him/her edit it append comment_bytes " \[ <A HREF=\"/comments/persistent-edit?comment_id=$comment_id\">edit your comment</a> \]\n" } append comment_bytes "<br><br>\n -- <A HREF=\"/shared/community-member?user_id=$poster_user_id\">$user_name</a>" append comment_bytes ", [util_AnsiDatetoPrettyDate $posting_time]" append comment_bytes "</blockquote>\n" } } if { $accept_comments_p == "t" && $inline_comments_p == "t" } { # we only display the option if we're inlining comments; # we assume that if the comments aren't in line but are legal # then the publisher has an explicit link set comment_option "<a href=\"/comments/add?page_id=$page_id\">Add a comment</a>" lappend options_list $comment_option } else { set comment_option "" } # links set link_bytes "" if { $inline_links_p == "t" } { set selection [ns_db select $db "select links.page_id, links.user_id as poster_user_id, users.first_names || ' ' || users.last_name as user_name, links.link_title, links.link_description, links.url from static_pages sp, links, users where sp.page_id = links.page_id and users.user_id = links.user_id and links.page_id = $page_id and status = 'live' order by posting_time"] while { [ns_db getrow $db $selection] } { set_variables_after_query append link_bytes "<li><a href=\"$url\" rel=\"nofollow\">$link_title</a>- $link_description" if { $user_id == $poster_user_id} { # the user added, so let him/her edit it append link_bytes " (<A HREF=\"/links/edit?page_id=$page_id&url=[ns_urlencode $url]\">edit/delete</a>)" } else { # the user did not add it, link to the community_member page append link_bytes " <font size=-1>(contributed by <A HREF=\"/shared/community-member?user_id=$poster_user_id\">$user_name</a>)</font>" } append link_bytes "\n<p>\n" } } if { $accept_links_p == "t" && $inline_links_p == "t" } { # we only display the option if we're inlining links; # we assume that if the links aren't in line but are legal # then the publisher has an explicit link set link_option "<a href=\"/links/add?page_id=$page_id\">Add a link</a>" lappend options_list $link_option } else { set link_option "" } } return [list $comment_bytes $link_bytes $options_list $comment_option $link_option]