Index: openacs-4/contrib/packages/general-comments/www/comment-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/general-comments/www/Attic/comment-add-edit.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/general-comments/www/comment-add-edit.tcl 6 Jul 2003 12:56:35 -0000 1.3 +++ openacs-4/contrib/packages/general-comments/www/comment-add-edit.tcl 13 Jul 2003 19:05:39 -0000 1.4 @@ -11,13 +11,15 @@ @creation-date 2000-10-12 @cvs-id $Id$ } { - object_id:integer,optional comment_id:integer,optional + { object_id "" } { context_id "" } { title "" } { content "" } { object_name "" } { return_url "" } + { revision_id "" } + { comment_mime_type "" } } -properties { page_title:onevalue context:onevalue @@ -30,6 +32,12 @@ context_id:onevalue category:onevalue return_url:onevalue +} -validate { + comment_id_or_object_id { + if {![exists_and_not_null comment_id] && [empty_string_p $object_id]} { + ad_complain "Must specify object_id for new comment" + } + } } # check to see if the user can create comments on this object @@ -54,11 +62,12 @@ # ad_page_contract does not set object_name to # [acs_object_name $object_id] if object_name is passed # in as an empty string. -if { [empty_string_p $object_name] } { - set object_name [acs_object_name $object_id] -} -ad_form -name comment -export { object_id object_name context_id return_url} -confirm_template comment-confirm -form { +#if { [empty_string_p $object_name] } { +# set object_name [acs_object_name $object_id] +#} + +ad_form -name comment -form { comment_id:key {title:text {label "[_ general_comments.Title]"} @@ -73,6 +82,12 @@ {submit:text(submit) {value "[_ general_comments.Proceed]"} } + + {object_id:text(hidden) {value $object_id}} + {object_name:text(hidden) {value $object_name}} + {context_id:text(hidden) {value $context_id}} + {return_url:text(hidden) {value $return_url}} + {comment_mime_type:text(hidden) {value $comment_mime_type}} } -new_data { set comment_mime_type [template::util::richtext::get_property format $content] set content [template::util::richtext::get_property contents $content] @@ -90,26 +105,27 @@ if {[exists_and_not_null return_url]} { ad_returnredirect $return_url } else { - ad_returnredirect "comment?[export_vars $object_id]" + ad_returnredirect "view-comment?[export_vars comment_id]" } ad_script_abort +} -edit_request { + + db_1row get_comment "" + } -edit_data { - general_comments::general_comment::set - general_comments::general_comment::create \ - -object_id $object_id \ + general_comments::general_comment::edit \ -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]} { + -creation_ip $creation_ip + + if {[exists_and_not_null return_url]} { ad_returnredirect $return_url } else { - ad_returnredirect "comment?[export_vars $object_id]" + ad_returnredirect "view-comment?[export_vars comment_id]" } ad_script_abort }