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
(defaults to "0") (optional)
Pass in 1 to print out content of comments.
-print_attachments_p
(defaults to "0") (optional)
Pass in 1 to print out attachments of comments, only works if print_content_p is 1.
-print_user_info_p
(defaults to "1") (optional)
-context_id
(optional)
Show only comments with given context_id
-my_comments_only_p
(defaults to "0") (optional)
Parameters:
object_id - 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):
%3 test_general_comments_create_retrieve general_comments_create_retrieve (test general-comments) general_comments_get_comments general_comments_get_comments test_general_comments_create_retrieve->general_comments_get_comments acs_package_root_dir acs_package_root_dir (public) general_comments_get_comments->acs_package_root_dir ad_conn ad_conn (public) general_comments_get_comments->ad_conn db_driverkey db_driverkey (public) general_comments_get_comments->db_driverkey db_multirow db_multirow (public) general_comments_get_comments->db_multirow export_vars export_vars (public) general_comments_get_comments->export_vars Class ::xowiki::includelet::my-general-comments Class ::xowiki::includelet::my-general-comments (public) Class ::xowiki::includelet::my-general-comments->general_comments_get_comments packages/download/www/one-archive.tcl packages/download/ www/one-archive.tcl packages/download/www/one-archive.tcl->general_comments_get_comments packages/download/www/one-revision.tcl packages/download/ www/one-revision.tcl packages/download/www/one-revision.tcl->general_comments_get_comments packages/faq/www/one-faq.tcl packages/faq/ www/one-faq.tcl packages/faq/www/one-faq.tcl->general_comments_get_comments packages/file-storage/www/file.tcl packages/file-storage/ www/file.tcl packages/file-storage/www/file.tcl->general_comments_get_comments

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 $html
Generic 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

[ hide source ] | [ make this the default ]
Show another procedure: