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.1 -r1.2 --- openacs-4/contrib/packages/general-comments/tcl/general-comments-procs.tcl 2 May 2003 15:49:59 -0000 1.1 +++ openacs-4/contrib/packages/general-comments/tcl/general-comments-procs.tcl 19 May 2003 02:53:03 -0000 1.2 @@ -1,5 +1,10 @@ # /packages/general-comments/tcl/general-comments-procs.tcl +# daveb: removed old deprecated namespace procs +# : deprecated "new" none namespace procs +# : replaced with new and improved namespace procs. +# : yes, this is a disaster! + # Porting: Moved most queries from variables to in-line # for the QueryExtractor, appended '_deprecated' to # query-names in 'ad_proc -deprecated' functions. @@ -10,11 +15,85 @@ @author Phong Nguyen @author Pascal Scheffers + @author Dave Bauer @creation-date 2000-10-12 @cvs-id $Id$ } +# proc borrowed for trackback, refactor for new general comments package + +ad_proc general_comment_new { + -object_id + -comment_id + -title + -comment_mime_type + -context_id + {-user_id ""} + {-creation_ip ""} + -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_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 + } + + db_dml set_content { + update cr_revisions + set content = empty_blob() + where revision_id = :revision_id + returning content into :1 + } -blobs [list $content] + + # Grant the user sufficient permissions to + # created comment. This is done here to ensure that + # 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 \ + -party_id $user_id \ + -privilege "read" + + permission::grant -object_id $comment_id \ + -party_id $user_id \ + -privilege "write" + + } + } + return $revision_id +} + + ad_proc -public general_comments_get_comments { { -print_content_p 0 } { -print_attachments_p 0 }