+
-
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 -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
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
--- /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 -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
+
+
+
Fisheye: Tag 1.3 refers to a dead (removed) revision in file `openacs-4/contrib/packages/general-comments/www/comment-ae.adp'.
Fisheye: No comparison available. Pass `N' to diff?