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 -r1.6 -r1.7 --- openacs-4/contrib/packages/general-comments/sql/postgresql/general-comments-plsql-create.sql 5 Jun 2003 00:49:52 -0000 1.6 +++ openacs-4/contrib/packages/general-comments/sql/postgresql/general-comments-plsql-create.sql 7 Jul 2003 01:51:03 -0000 1.7 @@ -3,114 +3,149 @@ -- 2003-05-04 create or replace function general_comment__new( - integer, - integer, - integer, - integer, - integer, - varchar, - varchar, - varchar, - integer, - timestamptz, - varchar, - varchar, - boolean - ) returns integer as ' + integer, + integer, + integer, + integer, + integer, + varchar, + varchar, + varchar, + integer, + timestamptz, + varchar, + varchar, + boolean + ) returns integer as ' declare - p_comment_id alias for $1; - p_object_id alias for $2; - p_package_id alias for $3; - p_parent_id alias for $4; + p_comment_id alias for $1; + p_object_id alias for $2; + p_package_id alias for $3; + 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; + 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; + 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; - PERFORM content_item__new( - ''general_comment_'' || v_item_id, - p_parent_id, - v_item_id, - NULL, - p_creation_date, - p_creation_user, - p_context_id, - p_creation_ip, - ''content_item'', - ''general_comment'', - p_title, - p_description, - null, - p_mime_type, - p_content, - ''text'' - ); + PERFORM content_item__new( + ''general_comment_'' || v_item_id, + p_parent_id, + v_item_id, + NULL, + p_creation_date, + p_creation_user, + p_context_id, + p_creation_ip, + ''content_item'', + ''general_comment'', + p_title, + p_description, + null, + p_mime_type, + p_content, + ''text'' + ); - select into v_revision_id latest_revision - from cr_items - where item_id=v_item_id; + select into v_revision_id latest_revision + from cr_items + where item_id=v_item_id; - insert into general_comments - ( - comment_id, - related_object_id - ) - values - ( - v_item_id, - p_object_id - ); + insert into general_comments + ( + comment_id, + related_object_id + ) + values + ( + v_item_id, + p_object_id + ); - if p_is_live then - perform content_item__set_live_revision(v_revision_id); - end if; + if p_is_live then + perform content_item__set_live_revision(v_revision_id); + end if; return p_comment_id; end;' language 'plpgsql'; create or replace function general_comment__del( - integer - ) returns integer as ' + integer + ) returns integer as ' declare - p_comment_id alias for $1; + p_comment_id alias for $1; begin - -- remove permssions from the object - delete from acs_permissions where object_id=:p_comment_id; - -- handle attachments and child comments for threaded comments? + -- remove permssions from the object + delete from acs_permissions where object_id=:p_comment_id; + -- handle attachments and child comments for threaded comments? - -- do we need to remove live_revision and latest_revision first? - perform content_item__delete(p_comment_id); + -- do we need to remove live_revision and latest_revision first? + perform content_item__delete(p_comment_id); - delete from general_comments where comment_id=:p_comment_id; + delete from general_comments where comment_id=:p_comment_id; return NULL; end;' language 'plpgsql'; +-- create a new revision of a comment create or replace function general_comment__revise( - integer - ) returns integer as ' + integer, + varchar, + varchar, + varchar, + integer, + timestamptz, + varchar, + boolean + ) returns integer as ' declare - p_comment_id alias for $1 + p_comment_id alias for $1; + p_title alias for $2; + p_content alias for $3; + p_mime_type alias for $4; + p_creation_user alias for $5; + p_creation_date alias for $6; + p_creation_ip alias for $7; + p_is_live alias for $8; + v_revision_id cr_revisions.revision_id%TYPE; begin - -- create a new revision of a comment - -- does the UI even offer this option? -return NULL; -end;' language 'plpgsql'; + v_revision_id := content_revision__new ( + p_title, + NULL, + current_timestamp, + p_mime_type, + NULL, + p_content, + p_comment_id, + NULL, + p_creation_date, + p_creation_user, + p_creation_ip + ); + if p_is_live then + perform content_item__set_live_revision ( + p_comment_id, + v_revision_id + ); + end if; + return v_revision_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 -r1.3 -r1.4 --- openacs-4/contrib/packages/general-comments/tcl/general-comments-procs-postgresql.xql 5 Jun 2003 00:50:27 -0000 1.3 +++ openacs-4/contrib/packages/general-comments/tcl/general-comments-procs-postgresql.xql 7 Jul 2003 01:51:04 -0000 1.4 @@ -14,7 +14,7 @@ :title, :description, :content, - :user_id, + :creation_user, now(), :creation_ip, :comment_mime_type, 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.4 -r1.5 --- openacs-4/contrib/packages/general-comments/tcl/general-comments-procs.tcl 5 Jun 2003 00:50:27 -0000 1.4 +++ openacs-4/contrib/packages/general-comments/tcl/general-comments-procs.tcl 7 Jul 2003 01:51:04 -0000 1.5 @@ -30,7 +30,7 @@ -title -comment_mime_type -context_id - {-user_id ""} + {-creation_user ""} {-creation_ip ""} {-parent_id ""} -package_id @@ -59,13 +59,13 @@ # 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]} { + if {![empty_string_p $creation_id]} { permission::grant -object_id $comment_id \ - -party_id $user_id \ + -party_id $creation_user \ -privilege "read" permission::grant -object_id $comment_id \ - -party_id $user_id \ + -party_id $creation_user \ -privilege "write" } Index: openacs-4/contrib/packages/general-comments/www/comment-add-edit.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/www/Attic/comment-add-edit.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/general-comments/www/comment-add-edit.xql 7 Jul 2003 01:51:04 -0000 1.1 @@ -0,0 +1,20 @@ + + + + + + + select g.object_id, + r.title, + r.content, + r.mime_type as comment_mime_type + from general_comments g, + cr_revisions r + where g.comment_id = :comment_id and + r.revision_id = :revision_id + + + + + +