ad_general_comments_list

one of the documented procedures in this installation of the ACS
Usage:
ad_general_comments_list   db   on_what_id   on_which_table   item   { module "" }   { submodule "" }   { return_url "" }   { show_time "" }   { solicit_more_p "1" }
What it does:
Generates the list of comments for this item with the appropriate add/edit links for the general comments system.
Defined in: /web/philip/tcl/ad-general-comments.tcl

Source code:




    if [ad_parameter AdminEditingOptionsInlineP "general-comments" 0] {
	# look to see if this person is an administrator
	set administrator_p [ad_permission_p $db $module $submodule]
    } else {
	set administrator_p 0
    }

    # see if the comment system is inactivated for this module
    if ![ad_parameter SolicitCommentsP $module 1] {
	return ""
    }

    set user_id [ad_get_user_id]
    if [empty_string_p $return_url] {
	set return_url [ns_conn url]?[export_ns_set_vars "url"]
    }
    set approved_clause "and general_comments.approved_p = 't'"

    set return_string ""

    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,
           to_char(modified_date, 'Month DD, YYYY HH:MI AM') as pretty_modified_long,
           to_char(modified_date, 'MM/DD/YY HH24:MI') as pretty_modified_time,
           to_char(modified_date, 'MM/DD/YY') as pretty_modified_date
    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
    order by comment_date asc"]

    set first_iteration_p 1
    while {[ns_db getrow $db $selection]} {
	set_variables_after_query
	if $first_iteration_p {
	    append return_string "<h4>Comments</h4>\n"
	    set first_iteration_p 0
	}
        switch $show_time {
            modified_long {
                set extra "on $pretty_modified_long"
            } 
            modified_time {
                set extra "($pretty_modified_time)"
            } 
            modified_date {
                set extra "($pretty_modified_date)"
            } 
            default { 
                set extra {}
            }
        }
                 
	append return_string "<blockquote>\n[format_general_comment $comment_id $client_file_name $file_type $original_width $original_height $caption $content $comment_html_p $one_line]"

	append return_string "<br><br>-- <a href=\"/shared/community-member?user_id=$comment_user_id\">$commenter_name</a> $extra"
	# if the user posted the comment, they are allowed to edit it
	if {$user_id == $comment_user_id} {
	    append return_string "  <A HREF=\"/general-comments/comment-edit?[export_url_vars comment_id on_which_table on_what_id item module return_url submodule]\">(edit your comment)</a>"
	} elseif { $administrator_p } {
	    append return_string " <A HREF=\"/general-comments/comment-edit?[export_url_vars comment_id on_which_table on_what_id item module submodule return_url]\">(edit)</a>"
	}

	append return_string "</blockquote>\n<br>\n"
    }
    
    if { !$first_iteration_p } {
	append return_string "</blockquote>\n"
    }
    if { $solicit_more_p } { 
        append return_string "
    <center>
    <A HREF=\"/general-comments/comment-add?[export_url_vars on_which_table on_what_id item module return_url]\">Add a comment</a>
    </center>"
    }
    
    return $return_string


philg@mit.edu