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.3 -r1.4 --- openacs-4/contrib/packages/general-comments/tcl/general-comments-procs.tcl 28 May 2003 00:54:13 -0000 1.3 +++ openacs-4/contrib/packages/general-comments/tcl/general-comments-procs.tcl 5 Jun 2003 00:50:27 -0000 1.4 @@ -22,27 +22,31 @@ } namespace eval general_comments {} +namespace eval general_comments::general_comment {} -ad_proc general_comments::general_comment { +ad_proc general_comments::general_comment::create { -object_id -comment_id -title -comment_mime_type -context_id {-user_id ""} {-creation_ip ""} + {-parent_id ""} -package_id -is_live -content } { - + # for now + set description $title + db_transaction { db_exec_plsql insert_comment {} - + db_1row get_revision { - select content_item.get_latest_revision(:comment_id) as revision_id + select content_item__get_latest_revision(:comment_id) as revision_id from dual - } + } db_dml set_content { update cr_revisions @@ -56,7 +60,7 @@ # a fail on permissions granting will not leave # the comment with incorrect permissions. if {![empty_string_p $user_id]} { - permission::grant -object_id $comment_id \ + permission::grant -object_id $comment_id \ -party_id $user_id \ -privilege "read" @@ -65,129 +69,11 @@ -privilege "write" } - } - return $revision_id -} - -ad_proc -public general_comments::get_comments_multirow { - -object_id - { -name comments } - { -return_url {}} - { -print_content:boolean } - { -print_attachments:boolean } -} { - Generates a multirow datasource in the callers namespace containing the - comment data. - - @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 - #[general_comments_package_url] - #if { [empty_string_p $package_url] } { - return "" - #} - - # initialize variables - if { $print_content_p == 0 } { - set content_select "" - set content "" - } else { - set content_select [db_map content_select] ;# ", r.content" } - upvar $name $name - db_multirow $name get_comments {} - } -ad_proc -deprecate -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 -} { - 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. -} { - - # -- 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" - if { $mime_type == "text/plain" } { - append html "[util_convert_plaintext_to_html $content]\n" - } else { - append html "$content\n" - } - 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 == "image_gif" || $mime_type == "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 { ![empty_string_p $attachments_html] } { - append html "
    [_ general-comments.Attachments]
    \n\n" - } else { - append html "

    " - } - } - append html "

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

    \n" - } else { - append html "
  • $title [_ general-comments.by] $author [_ general-comments.on] $pretty_date
    \n" - } - - return $html -} - - ad_proc -deprecated -public general_comments_get_comments { { -print_content_p 0 } { -print_attachments_p 0 } @@ -205,16 +91,15 @@ # parse the comments includable template inline and return the html # to the caller (thanks to bartt!) - general_comments::get_comments_multirow + return [template::adp_parse "[acs_root_dir]/packages/general-comments/lib/comments" [list object_id $object_id print_content_p $print_content_p return_url $return_url print_attachments_p $print_attachments_p]] } ad_proc -public general_comments_create_link { -object_name { -link_text {Add a comment} } -context_id - { -category {} } - object_id + object_id {return_url {}} } { Generates an html link to add a comment to an object. @@ -224,10 +109,9 @@ @param object_name The name of the object. @param link_text The text to display for the link. @param context_id The context_id for the comment. - @param category A category to associate comment to. -} { + } { # get the package url - set package_url [general_comments_package_url] + set package_url [general_comments_package_url] if { [empty_string_p $package_url] } { return "" } @@ -252,8 +136,9 @@ Returns a url pointing to the mounted general-comments package. Goes to the database on every invocation. } { - - if { [db_0or1row get_package_url "" ] } { +# set package_url [site_node_closest_ancestor_package general-comments] + set package_url "comments" + if { ![empty_string_p $package_url] } { return $package_url } else { # log an error message