Index: openacs-4/packages/general-comments/lib/comments.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/lib/comments.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/general-comments/lib/comments.adp 16 May 2018 11:56:59 -0000 1.1 @@ -0,0 +1,33 @@ +<% + # usages of the comments already wrap this HTML in a ul tag +%> + + +

@comments.title@

+ @comments.content@ + +
#general-comments.Attachments#
+ +
+

-- + @comments.author@ + #general-comments.on# @comments.pretty_date2@ + (#general-comments.view_details#) +

+
+ +
  • + @comments.title@ + + #general-comments.by# @comments.author@ + #general-comments.on# @comments.pretty_date@ + +
  • +
    +
    Index: openacs-4/packages/general-comments/tcl/general-comments-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/tcl/general-comments-procs-oracle.xql,v diff -u -N --- openacs-4/packages/general-comments/tcl/general-comments-procs-oracle.xql 7 Aug 2017 23:48:12 -0000 1.8 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,96 +0,0 @@ - - - - oracle8.1.6 - - - - - select g.comment_id, - r.title, - r.mime_type, - o.creation_user, - acs_object.name(o.creation_user) as author, - o.creation_date - $content_select - from general_comments g, - cr_revisions r, - acs_objects o - where g.object_id = :object_id and - r.revision_id = content_item.get_live_revision(g.comment_id) and - o.object_id = g.comment_id - $context_clause - $my_comments_clause - order by $orderby - - - - - - - - select g.comment_id, - r.title, - r.content, - r.mime_type, - o.creation_user, - to_char(o.creation_date, 'MM-DD-YYYY') as creation_date, - p.first_names || ' ' || p.last_name as author - from general_comments g, - cr_items i, - cr_revisions r, - acs_objects o, - persons p - where g.object_id = :object_id and - i.item_id = g.comment_id and - r.revision_id = i.live_revision and - o.object_id = g.comment_id and - p.person_id = o.creation_user - order by creation_date - - - - - - - - begin - :1 := acs_message.new ( - message_id => :comment_id, - title => :title, - mime_type => :comment_mime_type, - data => empty_blob(), - context_id => :context_id, - creation_user => :user_id, - creation_ip => :creation_ip, - is_live => :is_live, - rfc822_id => :rfc822_id - ); - end; - - - - - - - - - select content_item.get_latest_revision(:comment_id) as revision_id - from dual - - - - - - - - - update cr_revisions - set content = empty_blob() - where revision_id = :revision_id - returning content into :1 - - - - - Index: openacs-4/packages/general-comments/tcl/general-comments-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/tcl/general-comments-procs-postgresql.xql,v diff -u -N --- openacs-4/packages/general-comments/tcl/general-comments-procs-postgresql.xql 7 Aug 2017 23:48:12 -0000 1.9 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,101 +0,0 @@ - - - - postgresql7.1 - - - - - select g.comment_id, - r.title, - r.mime_type, - o.creation_user, - acs_object__name(o.creation_user) as author, - o.creation_date - $content_select - from general_comments g, - cr_revisions r, - acs_objects o - where g.object_id = :object_id and - r.revision_id = content_item__get_live_revision(g.comment_id) and - o.object_id = g.comment_id - $context_clause - $my_comments_clause - order by $orderby - - - - - - - - - - select g.comment_id, - r.title, - r.content, - r.mime_type, - o.creation_user, - to_char(o.creation_date, 'MM-DD-YYYY') as creation_date, - p.first_names || ' ' || p.last_name as author - from general_comments g, - cr_items i, - cr_revisions r, - acs_objects o, - persons p - where g.object_id = :object_id and - i.item_id = g.comment_id and - r.revision_id = i.live_revision and - o.object_id = g.comment_id and - p.person_id = o.creation_user - order by creation_date - - - - - - - - select acs_message__new ( - :comment_id, -- 1 p_message_id - NULL, -- 2 p_reply_to - current_timestamp, -- 3 p_sent_date - NULL, -- 4 p_sender - :rfc822_id, -- 5 p_rfc822_id - :title, -- 6 p_title - NULL, -- 7 p_description - :comment_mime_type, -- 8 p_mime_type - NULL, -- 9 p_text - NULL, -- empty_blob(), -- 10 p_data - -4, -- 11 p_parent_id - :context_id, -- 12 p_context_id - :user_id, -- 13 p_creation_user - :creation_ip, -- 14 p_creation_ip - 'acs_message', -- 15 p_object_type - :is_live -- 16 p_is_live - ) - - - - - - - - select content_item__get_latest_revision(:comment_id) as revision_id - - - - - - - - - - update cr_revisions - set content = :content - where revision_id = :revision_id - - - - - Index: openacs-4/packages/general-comments/tcl/general-comments-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/tcl/general-comments-procs.tcl,v diff -u -N -r1.24 -r1.25 --- openacs-4/packages/general-comments/tcl/general-comments-procs.tcl 1 May 2018 08:49:35 -0000 1.24 +++ openacs-4/packages/general-comments/tcl/general-comments-procs.tcl 16 May 2018 11:56:59 -0000 1.25 @@ -95,7 +95,6 @@ @param object_id The object_id to retrieve the comments for. @param return_url A url for the user to return to after viewing a comment. } { - # get the package url set package_url [general_comments_package_url] if { $package_url eq "" } { @@ -112,145 +111,83 @@ -parameter "RecentOnTopP" \ -default f] - if {[string is true $recent_on_top_p]} { - set orderby "o.creation_date desc" - } else { - set orderby "o.creation_date" - } + 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] - if {[string is true $my_comments_only_p] - && [string is true $allow_my_comments_only_p]} { - set user_id [ad_conn user_id] - set my_comments_clause "and o.creation_user = :user_id " - } else { - set my_comments_clause "" - } + set user_id [expr {[string is true $my_comments_only_p] && + [string is true $allow_my_comments_only_p] ? [ad_conn user_id] : ""}] - # initialize variables - if { $print_content_p == 0 } { - set content_select "" - set content "" - } else { - set content_select [db_map content_select] ;# ", r.content" - } - - if { $context_id ne "" } { - set context_clause "and o.context_id = :context_id" - } else { - set context_clause "" - } - - set html "" - db_foreach get_comments {} { + 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 + then r.content + else '' 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, + exists (select 1 from images + where image_id = ai.item_id) as image_p, + ae.url as attachment_url + from cr_revisions r, + acs_objects o + left join cr_items ai on (:print_content_p and + :print_attachments_p 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 [acs_object_name $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"] - # call on helper proc to print out comment - append html [general_comments_print_comment $comment_id $title $mime_type \ - $creation_user $author $pretty_date $pretty_date2 $content \ - $print_content_p $print_attachments_p $package_url $return_url $print_user_info_p] - } - return $html -} -ad_proc -private general_comments_print_comment { - comment_id - title - mime_type - creation_user - author - pretty_date - pretty_date2 - content - print_content_p - print_attachments_p - package_url - return_url - print_user_info_p -} { - Helper proc to format and print out a single comment. - @param comment_id The id of the comment. - @param title The title of the comment. - @param mime_type The mime_type of the comment. - @param creation_user The creation user of the comment. - @param author The name of the author. - @param pretty_date A short pretty date of the comment. - @param pretty_date2 A long pretty date of the comment. - @param content The content of the comment. - @param print_content_p Pass in 1 to print out content of comments. - @param print_attachments_p Pass in 1 to print out attachments of comments. - @param package_url The url to the mounted general-comments package instance. - @param return_url A url for the user to return to after viewing a comment. - @param print_user_info_p Pass 1 in to print out user name and time of entry. -} { - - # -- create query statements to retrieve attachments - # PRS: Moved inline for QueryExtractor - - # This part is really ugly. This will remain here until we figure out a way to - # move this into a template. - set html "" - if { $print_content_p == 1 } { - append html "

    $title

    \n" - - # convert to html - set richtext_list [list $content $mime_type] - append html [template::util::richtext::get_property html_value $richtext_list] - - if { $print_attachments_p == 1 } { - set attachments_html "" - db_foreach get_attachments " - select r.title, r.mime_type, i.name, i.item_id - from cr_items i, cr_revisions r - where i.parent_id = :comment_id - and r.revision_id = i.live_revision" { - - append attachments_html "
  • $title " - if { $mime_type eq "image_gif" || $mime_type eq "image/jpeg" } { - append attachments_html "($name)\n" - } else { - append attachments_html "($name)\n" - } - } - - db_foreach get_links " - select i.item_id, e.label, e.url - from cr_items i, cr_extlinks e - where i.parent_id = :comment_id and e.extlink_id = i.item_id" { - append attachments_html "
  • $label\n" - } - if { $attachments_html ne "" } { - append html "
    [_ general-comments.Attachments]
    \n\n" - } + 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}}] } - append html [subst {

    -- - $author - [_ general-comments.on] $pretty_date2 - ([_ general-comments.view_details])

    - }] - } else { - append html [subst { -
  • $title - }] - if {$print_user_info_p} { - append html [subst { - [_ general-comments.by] $author - [_ general-comments.on] $pretty_date
    - }] - } else { - append html "
    \n" - } } + 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 } - ad_proc -public general_comments_create_link { -object_name { -link_text #general-comments.Add_comment# } Index: openacs-4/packages/general-comments/tcl/general-comments-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/tcl/general-comments-procs.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/general-comments/tcl/general-comments-procs.xql 29 Sep 2003 17:45:48 -0000 1.2 +++ openacs-4/packages/general-comments/tcl/general-comments-procs.xql 16 May 2018 11:56:59 -0000 1.3 @@ -1,37 +1,9 @@ - - - - , r.content - - - - - - + + - select r.title, r.mime_type, i.name, i.item_id - from cr_items i, cr_revisions r - where i.parent_id = :comment_id - and r.revision_id = i.live_revision - - - - - - - - select i.item_id, e.label, e.url - from cr_items i, cr_extlinks e - where i.parent_id = :comment_id and e.extlink_id = i.item_id - - - - - - insert into general_comments (comment_id, object_id, @@ -41,8 +13,7 @@ :object_id, :category) - - - + +