Index: openacs-4/contrib/packages/general-comments/tcl/general-comments-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/tcl/Attic/general-comments-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/general-comments/tcl/general-comments-procs.tcl 19 May 2003 02:53:03 -0000 1.2 +++ openacs-4/contrib/packages/general-comments/tcl/general-comments-procs.tcl 28 May 2003 00:54:13 -0000 1.3 @@ -21,48 +21,24 @@ @cvs-id $Id$ } -# proc borrowed for trackback, refactor for new general comments package +namespace eval general_comments {} -ad_proc general_comment_new { +ad_proc general_comments::general_comment { -object_id -comment_id -title -comment_mime_type -context_id {-user_id ""} {-creation_ip ""} + -package_id -is_live - -category -content } { db_transaction { - db_exec_plsql insert_comment { - 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 - ); - end; - } + db_exec_plsql insert_comment {} - db_dml add_entry { - insert into general_comments - (comment_id, - object_id, - category) - values - (:comment_id, - :object_id, - :category) - } - db_1row get_revision { select content_item.get_latest_revision(:comment_id) as revision_id from dual @@ -94,26 +70,31 @@ } -ad_proc -public general_comments_get_comments { - { -print_content_p 0 } - { -print_attachments_p 0 } - object_id - {return_url {}} +ad_proc -public general_comments::get_comments_multirow { + -object_id + { -name comments } + { -return_url {}} + { -print_content:boolean } + { -print_attachments:boolean } } { - Generates a line item list of comments for the object_id. + Generates a multirow datasource in the callers namespace containing the + comment data. - @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, - only works if print_content_p is 1. + @param print_content switch: specify to print out content of comments. + @param print_attachments switch: specify to print out attachments of comments, + only works if print_content_p is also specified @param object_id The object_id to retrieve the comments for. + @param name name of the multirow datasource to create @param return_url A url for the user to return to after viewing a comment. + } { + # ewww, return a multirow in the variable specified! DaveB # get the package url - set package_url [general_comments_package_url] - if { [empty_string_p $package_url] } { + #[general_comments_package_url] + #if { [empty_string_p $package_url] } { return "" - } + #} # initialize variables if { $print_content_p == 0 } { @@ -122,34 +103,13 @@ } else { set content_select [db_map content_select] ;# ", r.content" } - # ns_log notice "content_select: $content_select" - - set html "" - db_foreach get_comments " - select g.comment_id, - r.title, - r.mime_type, - o.creation_user, - acs_object.name(o.creation_user) as author, - to_char(o.creation_date, 'MM-DD-YYYY') as pretty_date, - to_char(o.creation_date, 'Month DD, YYYY HH12:MI PM') as pretty_date2 - $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 - order by o.creation_date" { - # 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] - } - return $html + + upvar $name $name + db_multirow $name get_comments {} + } -ad_proc -private general_comments_print_comment { +ad_proc -deprecate -private general_comments_print_comment { comment_id title mime_type @@ -228,6 +188,27 @@ } +ad_proc -deprecated -public general_comments_get_comments { + { -print_content_p 0 } + { -print_attachments_p 0 } + object_id + {return_url {}} +} { + Generates a line item list of comments for the object_id. + + @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, + only works if print_content_p is 1. + @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. +} { + # parse the comments includable template inline and return the html + # to the caller (thanks to bartt!) + + general_comments::get_comments_multirow + +} + ad_proc -public general_comments_create_link { -object_name { -link_text {Add a comment} } @@ -280,70 +261,3 @@ return "" } } - -# these are being replaced with the above procs -namespace eval general_comments { - -ad_proc -deprecated get_comments {object_id return_url} { - Generates a line item list of comments for the object_id. - - @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. - - @see general_comments_get_comments -} { - - # get the package url - set package_url [db_string get_package_url_deprecated " - select site_node.url(s.node_id) - from site_nodes s, apm_packages a - where s.object_id = a.package_id and - a.package_key = 'general-comments'"] - - set html "" - db_foreach get_comments_deprecated " - 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" { - append html "