Index: openacs-4/contrib/packages/general-comments/general-comments.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/Attic/general-comments.info,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/general-comments/general-comments.info 2 May 2003 15:48:43 -0000 1.1 +++ openacs-4/contrib/packages/general-comments/general-comments.info 5 Jun 2003 00:48:39 -0000 1.2 @@ -8,7 +8,7 @@ t comments - + oracle postgresql @@ -18,9 +18,8 @@ 2003-01-30 OpenACS - - - + + Index: openacs-4/contrib/packages/general-comments/lib/comments.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/lib/Attic/comments.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/general-comments/lib/comments.adp 22 May 2003 13:49:59 -0000 1.1 +++ openacs-4/contrib/packages/general-comments/lib/comments.adp 5 Jun 2003 00:49:06 -0000 1.2 @@ -1,8 +1,8 @@ - +

@comments.title@

-@comments.content@ +@comments.content@
-
  • $comments.title [_ general-comments.by] $author [_ general-comments.on] $comments.pretty_date
    +
  • @comments.title@ #general-comments.by# @comments.author@ #general-comments.on# @comments.pretty_date@
    \ No newline at end of file Index: openacs-4/contrib/packages/general-comments/lib/comments.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/lib/Attic/comments.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/general-comments/lib/comments.tcl 22 May 2003 13:49:59 -0000 1.1 +++ openacs-4/contrib/packages/general-comments/lib/comments.tcl 5 Jun 2003 00:49:06 -0000 1.2 @@ -5,12 +5,31 @@ # @param object_id # @param adp - optional path to adp to use for formatting # @comments - referecnce to multirow containing the comments +# @param print_content 1 print content of comments,0 just print titles/links +# @param print_attachments (not used until I implement attachments # # Dave Bauer # cvs-id: # +set package_url [general_comments_package_url] +if {![exists_and_not_null return_url]} { + set return_url "" +} + set print_content_p 1 +# initialize variables + +if { $print_content_p == 0 } { + set content_select "" + set content "" +} else { + set content_select [db_map content_select] ;# ", r.content" +} + +set community_member_url [parameter::get_from_package_key -parameter CommunityMemberUrl -default "/shared/community-member" -package_key acs-kernel ] +db_multirow comments get_comments {} + if {[info exists adp]} { ad_return_template $adp } else { Index: openacs-4/contrib/packages/general-comments/sql/postgresql/general-comments-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/sql/postgresql/Attic/general-comments-create.sql,v diff -u -N -r1.3 -r1.4 --- openacs-4/contrib/packages/general-comments/sql/postgresql/general-comments-create.sql 5 May 2003 01:21:05 -0000 1.3 +++ openacs-4/contrib/packages/general-comments/sql/postgresql/general-comments-create.sql 5 Jun 2003 00:49:52 -0000 1.4 @@ -13,25 +13,25 @@ -- create a table to extend cr_items create table general_comments ( comment_id integer constraint general_comments_comment_id_fk - references cr_revision (revision_id) on delete cascade + references cr_revisions (revision_id) on delete cascade constraint general_comments_pk primary key, - object_id integer constraint general_comments_object_id_fk + related_object_id integer constraint general_comments_object_id_fk references acs_objects (object_id) on delete cascade, - package_id integer constraing general_comments_package_id_fk + package_id integer constraint general_comments_package_id_fk references apm_packages (package_id) on delete cascade ); comment on table general_comments is ' Extends the cr_revisions table to hold item level data. '; -comment on column general_comments.object_id is ' +comment on column general_comments.related_object_id is ' The id of the object to associate message with '; -- unused catergory feature removed. Should be new categories package. DaveB -- create an index on foreign key constraint -create index general_comments_object_id_idx on general_comments (object_id); +create index general_comments_rel_object_id_idx on general_comments (related_object_id); create function inline_0 () returns integer as ' Index: openacs-4/contrib/packages/general-comments/sql/postgresql/general-comments-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/sql/postgresql/Attic/general-comments-drop.sql,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/general-comments/sql/postgresql/general-comments-drop.sql 2 May 2003 15:49:31 -0000 1.1 +++ openacs-4/contrib/packages/general-comments/sql/postgresql/general-comments-drop.sql 5 Jun 2003 00:49:52 -0000 1.2 @@ -42,7 +42,7 @@ where parent_id = comment_rec.comment_id); */ - perform acs_message__delete(comment_rec.comment_id); + perform general_comment__delete(comment_rec.comment_id); END LOOP; @@ -54,6 +54,6 @@ drop function inline_0 (); -- / - +select content_type__drop_type('general_comment',false,true); drop table general_comments; Index: openacs-4/contrib/packages/general-comments/sql/postgresql/general-comments-plsql-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/sql/postgresql/Attic/general-comments-plsql-create.sql,v diff -u -N -r1.5 -r1.6 --- openacs-4/contrib/packages/general-comments/sql/postgresql/general-comments-plsql-create.sql 28 May 2003 00:54:51 -0000 1.5 +++ openacs-4/contrib/packages/general-comments/sql/postgresql/general-comments-plsql-create.sql 5 Jun 2003 00:49:52 -0000 1.6 @@ -2,7 +2,7 @@ -- Dave Bauer dave@thedesignexperience.org -- 2003-05-04 -create functions general_comment__new( +create or replace function general_comment__new( integer, integer, integer, @@ -12,7 +12,7 @@ varchar, varchar, integer, - timestamp_tz, + timestamptz, varchar, varchar, boolean @@ -24,23 +24,27 @@ p_parent_id alias for $4; p_context_id alias for $5; p_title alias for $6; - p_description alias for $7 + p_description alias for $7; p_content alias for $8; p_creation_user alias for $9; p_creation_date alias for $10; p_creation_ip alias for $11; p_mime_type alias for $12; p_is_live alias for $13; v_item_id cr_items.item_id%TYPE; + v_revision_id cr_revisions.revision_id%TYPE; begin -- -- do something with p_is_live DaveB -- + if p_comment_id is null then + select into v_item_id acs_object_id_seq.nextval; + else + v_item_id := p_comment_id; + end if; - v_item_id := select nextval(acs_object_id_seq); - PERFORM content_item__new( - ''general_comment_'' || p_parent_id || ''_'' || v_item_id, + ''general_comment_'' || v_item_id, p_parent_id, v_item_id, NULL, @@ -52,35 +56,30 @@ ''general_comment'', p_title, p_description, + null, p_mime_type, p_content, ''text'' ); - v_revision_id := select latest_revision + + select into v_revision_id latest_revision from cr_items - where item_id=v_item_id + where item_id=v_item_id; - PERFORM content_revision__new( - - ); - insert into general_comments ( comment_id, - object_id + related_object_id ) values ( - p_comment_id, + v_item_id, p_object_id ); - perform acs_permission__grant_permission(p_comment_id, - p_creation_user, - ''read''); - perform acs_permission__grant_permission(p_comment_id, - p_creation_user, - ''write''); + if p_is_live then + perform content_item__set_live_revision(v_revision_id); + end if; return p_comment_id; end;' language 'plpgsql'; Index: openacs-4/contrib/packages/general-comments/tcl/general-comments-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/tcl/Attic/general-comments-procs-postgresql.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/contrib/packages/general-comments/tcl/general-comments-procs-postgresql.xql 28 May 2003 00:54:13 -0000 1.2 +++ openacs-4/contrib/packages/general-comments/tcl/general-comments-procs-postgresql.xql 5 Jun 2003 00:50:27 -0000 1.3 @@ -3,9 +3,8 @@ postgresql7.1 - + - select general_comment__new ( :comment_id, :object_id, @@ -14,17 +13,32 @@ :context_id, :title, :description, - :empty_blob(), - :creation_user, - :creation_date, + :content, + :user_id, + now(), :creation_ip, - :comment_mime_type + :comment_mime_type, :is_live - ); + ) + + + + + select content_item__get_latest_revision(:comment_id) as revision_id + + + update cr_revisions + set content = :content + where revision_id = :revision_id + + + + + @@ -45,6 +59,7 @@ r.revision_id = i.live_revision and o.object_id = g.comment_id order by o.creation_date + 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 -N -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$attachments_html
    \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 Index: openacs-4/contrib/packages/general-comments/www/comment-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/www/Attic/comment-add.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/general-comments/www/comment-add.adp 5 Jun 2003 00:50:43 -0000 1.1 @@ -0,0 +1 @@ + \ No newline at end of file Index: openacs-4/contrib/packages/general-comments/www/comment-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/www/Attic/comment-add.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/contrib/packages/general-comments/www/comment-add.tcl 2 May 2003 15:50:44 -0000 1.1 +++ openacs-4/contrib/packages/general-comments/www/comment-add.tcl 5 Jun 2003 00:50:43 -0000 1.2 @@ -9,9 +9,11 @@ @cvs-id $Id$ } { object_id:integer,notnull - { object_name "[acs_object_name $object_id]" } + comment_id:integer,optional { context_id "$object_id" } - { category "" } + { title "" } + { content "" } + { object_name "" } { return_url "" } } -properties { page_title:onevalue @@ -28,7 +30,20 @@ } # check to see if the user can create comments on this object -ad_require_permission $object_id general_comments_create +set user_id [ad_conn user_id] +set creation_ip [ad_conn peeraddr] +# this works unless we allow the comment-add page to be included +set package_id [ad_conn package_id] +set is_live "t" +# if {![ad_form_new_p -key comment_id]} { +# permission::require_permission -object_id $comment_id \ +# -party_id $user_id \ +# -privilege "write" +# } else { +# permission::require_permission -object_id $object_id \ +# -party_id $user_id \ +# -privilege "general_comment_create" +# } # ad_page_contract does not set object_name to # [acs_object_name $object_id] if object_name is passed @@ -37,17 +52,78 @@ set object_name [acs_object_name $object_id] } -set page_title "[_ general-comments.Add_a_comment_to]: $object_name" -set context "\"[_ general-comments.Add_comment]\"" -set target "comment-add-2" -set title "" -set content "" -set comment_mime_type "text/plain" +ad_form -name comment -export { object_id object_name context_id return_url} -confirm_template comment-confirm -form { + comment_id:key + {title:text + {label "[_ general_comments.Title]"} + {value $title} + {html {maxlength 200 size 50}} + } + {content:richtext + {label "[_ general_comments.Comment]"} + {value $content} + {html {cols 80 rows 20}} + } + {submit:text(submit) + {value "[_ general_comments.Proceed]"} + } +} -new_data { + set comment_mime_type [template::util::richtext::get_property format $content] + set content [template::util::richtext::get_property contents $content] + general_comments::general_comment::create \ + -object_id $object_id \ + -comment_id $comment_id \ + -title $title \ + -content $content \ + -comment_mime_type $comment_mime_type \ + -context_id $context_id \ + -package_id $package_id \ + -is_live $is_live \ + -user_id $user_id \ + -creation_ip $creation_ip + if {[exists_and_not_null return_url]} { + ad_returnredirect $return_url + } else { + ad_returnredirect "comment?[export_vars $object_id]" + } + ad_script_abort +} -edit_data { + general_comments::general_comment::set + general_comments::general_comment::create \ + -object_id $object_id \ + -comment_id $comment_id \ + -title $title \ + -content $content \ + -comment_mime_type $comment_mime_type \ + -context_id $context_id \ + -package_id $package_id \ + -is_live $is_live \ + -creation_user $user_id \ + -creation_ip $peer_addr + if {[exists_and_not_null return_url]} { + ad_returnredirect $return_url + } else { + ad_returnredirect "comment?[export_vars $object_id]" + } + ad_script_abort +} -ad_return_template "comment-ae" +if {[ad_form_new_p -key comment_id]} { + set page_title "[_ general-comments.Add_a_comment_to]: $object_name" + set context "\"[_ general-comments.Add_comment]\"" +} else { + set page_title "[_ general-comments.Edit_a_comment_to]: $object_name" + set context "\"[_ general-comments.Edit_comment]\"" +} +#set title "" +#set content "" +ad_return_template + + + Index: openacs-4/contrib/packages/general-comments/www/comment-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/www/Attic/comment-ae.adp,v diff -u -N --- openacs-4/contrib/packages/general-comments/www/comment-ae.adp 22 May 2003 13:53:29 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,37 +0,0 @@ - -@page_title;noquote@ -@context;noquote@ -comment.title - -@page_title@ - -
    -
    -<%= [export_form_vars comment_id object_id object_name context_id return_url] %> -#general-comments.Title#
    - -

    -#general-comments.Comment#
    -
    -#general-comments.Text_above_is# - -

    -
    -
    - -
    - - - - -