general_comments_get_comments (public)
general_comments_get_comments [ -print_content_p print_content_p ] \ [ -print_attachments_p print_attachments_p ] \ [ -print_user_info_p print_user_info_p ] \ [ -context_id context_id ] \ [ -my_comments_only_p my_comments_only_p ] object_id \ [ return_url ]
Defined in packages/general-comments/tcl/general-comments-procs.tcl
Generates a line item list of comments for the object_id.
- Switches:
- -print_content_p (optional, integer, defaults to
"0"
)- Pass in 1 to print out content of comments.
- -print_attachments_p (optional, integer, defaults to
"0"
)- Pass in 1 to print out attachments of comments, only works if print_content_p is 1.
- -print_user_info_p (optional, integer, defaults to
"1"
)- -context_id (optional, integer, accept empty)
- Show only comments with given context_id
- -my_comments_only_p (optional, integer, defaults to
"0"
)- Parameters:
- object_id (required)
- The object_id to retrieve the comments for.
- return_url (optional)
- A url for the user to return to after viewing a comment.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- general_comments_create_retrieve
Source code: # get the package url set package_url [general_comments_package_url] if { $package_url eq "" } { return "" } # package_id array set node_array [site_node::get -url $package_url] set package_id $node_array(package_id) # set ordering set recent_on_top_p [parameter::get -package_id $package_id -parameter "RecentOnTopP" -default f] set sort_dir [expr {[string is true $recent_on_top_p] ? "desc" : "asc"}] # filter output to only see present user? set allow_my_comments_only_p [parameter::get -package_id $package_id -parameter "AllowDisplayMyCommentsLinkP" -default t] set user_id [expr {[string is true $my_comments_only_p] && [string is true $allow_my_comments_only_p] ? [ad_conn user_id] : ""}] db_multirow -local -extend { pretty_date pretty_date2 author_url view_url } comments get_comments_new [subst { select o.object_id as comment_id, r.title, r.mime_type, o.creation_user, o.creation_user as author, o.creation_date, case when :print_content_p = 1 then r.content else [expr {[db_driverkey ""] eq "oracle" ? "empty_blob()" : "''"}] end as content, ar.title as attachment_title, ar.mime_type as attachment_mime_type, coalesce(ae.label, ai.name) as attachment_name, ai.item_id as attachment_item_id, case when exists (select 1 from images where image_id = ai.item_id) then 't' else 'f' end as image_p, ae.url as attachment_url from cr_revisions r, acs_objects o left join cr_items ai on (:print_content_p = 1 and :print_attachments_p = 1 and o.object_id = ai.parent_id) left join cr_revisions ar on ai.live_revision = ar.revision_id left join cr_extlinks ae on ai.item_id = ae.extlink_id where o.object_id in (select comment_id from general_comments where object_id = :object_id) and r.revision_id = (select live_revision from cr_items where item_id = o.object_id) and (:context_id is null or o.context_id = :context_id) and (:user_id is null or o.creation_user = :user_id) order by o.creation_date $sort_dir }] { set author [person::name -person_id $author] if {$content ne ""} { set content [template::util::richtext::get_property html_value [list $content $mime_type]] } set pretty_date [lc_time_fmt $creation_date %x] set pretty_date2 [lc_time_fmt $creation_date "%q %X"] set author_url [export_vars -base /shared/community-member {{user_id $creation_user}}] set view_url [export_vars -base ${package_url}view-comment {comment_id return_url}] if {$image_p} { set attachment_url [export_vars -base ${package_url}view-image {{image_id $attachment_item_id} return_url}] } elseif {$attachment_url eq ""} { set attachment_url [export_vars -base ${package_url}file-download {{item_id $attachment_item_id}}] } } set template [acs_package_root_dir "general-comments"]/lib/comments.adp set template [template::themed_template $template] set code [template::adp_compile -file $template] set html [template::adp_eval code] return $htmlGeneric XQL file: packages/general-comments/tcl/general-comments-procs.xql
PostgreSQL XQL file: packages/general-comments/tcl/general-comments-procs-postgresql.xql
Oracle XQL file: packages/general-comments/tcl/general-comments-procs-oracle.xql