Index: openacs-4/packages/general-comments/tcl/general-comments-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/tcl/general-comments-procs.tcl,v diff -u -N -r1.21 -r1.22 --- openacs-4/packages/general-comments/tcl/general-comments-procs.tcl 27 Oct 2014 16:41:42 -0000 1.21 +++ openacs-4/packages/general-comments/tcl/general-comments-procs.tcl 27 Jun 2015 21:10:12 -0000 1.22 @@ -36,41 +36,39 @@ } { db_transaction { - db_exec_plsql insert_comment { } + + db_exec_plsql insert_comment { } + db_dml add_entry { } + db_1row get_revision {} + db_dml set_content {} -blobs [list $content] - db_dml add_entry { } + # 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 {$user_id ne ""} { + permission::grant -object_id $comment_id \ + -party_id $user_id \ + -privilege "read" - db_1row get_revision {} + permission::grant -object_id $comment_id \ + -party_id $user_id \ + -privilege "write" - db_dml set_content {} -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 {$user_id ne ""} { - permission::grant -object_id $comment_id \ - -party_id $user_id \ - -privilege "read" - - permission::grant -object_id $comment_id \ - -party_id $user_id \ - -privilege "write" - - } + } } # Convert the comment to HTML if {$comment_mime_type ne "text/html"} { - set content [ad_convert_to_html $content] + set content [ad_convert_to_html $content] } # Start notifications callback general_comments::notify_objects \ - -object_id $object_id \ - -comment $content \ - -title $title \ - -object_type [acs_object_type $object_id] + -object_id $object_id \ + -comment $content \ + -title $title \ + -object_type [acs_object_type $object_id] return $revision_id } @@ -88,7 +86,7 @@ @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, - only works if print_content_p is 1. + only works if print_content_p is 1. @param context_id Show only comments with given context_id @param object_id The object_id to retrieve the comments for. @param return_url A url for the user to return to after viewing a comment. @@ -124,7 +122,7 @@ if {[string is true $my_comments_only_p] && [string is true $allow_my_comments_only_p]} { - set user_id [ad_conn user_id] + set user_id [ad_conn user_id] set my_comments_clause "and o.creation_user = :user_id " } else { set my_comments_clause "" @@ -150,8 +148,8 @@ set pretty_date2 [lc_time_fmt $creation_date "%q %X"] # call on helper proc to print out comment append html [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 $print_user_info_p] + $creation_user $author $pretty_date $pretty_date2 $content \ + $print_content_p $print_attachments_p $package_url $return_url $print_user_info_p] } return $html } @@ -203,37 +201,46 @@ 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 + 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 eq "image_gif" || $mime_type eq "image/jpeg" } { - append attachments_html "($name)\n" - } else { - append attachments_html "($name)\n" - } - } + append attachments_html "
  • $title " + if { $mime_type eq "image_gif" || $mime_type eq "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" - } + 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 { $attachments_html ne "" } { append html "
    [_ general-comments.Attachments]
    \n\n" } } - append html "

    -- $author [_ general-comments.on] $pretty_date2 ([_ general-comments.view_details])

    \n" + append html [subst {

    -- + $author + [_ general-comments.on] $pretty_date2 + ([_ general-comments.view_details])

    + }] } else { - append html "
  • $title" - if {$print_user_info_p} { - append html " [_ general-comments.by] $author [_ general-comments.on] $pretty_date
    \n" - } else { - append html "
    \n" - } + append html [subst { +
  • $title + }] + if {$print_user_info_p} { + append html [subst { + [_ general-comments.by] $author + [_ general-comments.on] $pretty_date
    + }] + } else { + append html "
    \n" + } } return $html @@ -258,8 +265,8 @@ @param context_id The context_id for the comment. @param category A category to associate comment to. @param link_attributes Some additional parameters for the link. Could be used - to set the link title and other things like that. Ex. -link_attributes - { title="My link title" } + to set the link title and other things like that. Ex. -link_attributes + { title="My link title" } } { # get the package url set package_url [general_comments_package_url] @@ -271,7 +278,8 @@ if { ![info exists object_name] } { set object_name [acs_object_name $object_id] } if { ![info exists context_id] } { set context_id $object_id } - set html "$link_text" + set html [subst {$link_text}] return $html } @@ -286,20 +294,20 @@ # these are being replaced with the above procs namespace eval general_comments { -ad_proc -deprecated get_comments {object_id return_url} { - Generates a line item list of comments for the object_id. + ad_proc -deprecated get_comments {object_id return_url} { + Generates a line item list of comments for the object_id. - @param object_id The object_id to retrieve the comments for. - @param return_url A url for the user to return to after viewing a comment. - - @see general_comments_get_comments -} { + @param object_id The object_id to retrieve the comments for. + @param return_url A url for the user to return to after viewing a comment. + + @see general_comments_get_comments + } { - # get the package url - set package_url [general_comments_package_url] + # get the package url + set package_url [general_comments_package_url] - set html "" - db_foreach get_comments_deprecated " + set html "" + db_foreach get_comments_deprecated " select g.comment_id, r.title, r.content, @@ -318,26 +326,38 @@ o.object_id = g.comment_id and p.person_id = o.creation_user order by creation_date" { - append html "
  • $title by $author, $creation_date
    \n" + append html [subst { +
  • $title + by $author, $creation_date
    + }] + } + return "$html" } - return "$html" -} -ad_proc -deprecated create_link {object_id object_name return_url link_text {context_id ""} {category ""}} { - Generates an html link to add a comment to an object. - @param object_id The object to comment on. - @param object_name The name of the object. - @param return_url A url for the user to return to after viewing a comment. - @param link_text The text to display for the link. - @param category A category to associate comment to. + ad_proc -deprecated create_link {object_id object_name return_url link_text {context_id ""} {category ""}} { + Generates an html link to add a comment to an object. + @param object_id The object to comment on. + @param object_name The name of the object. + @param return_url A url for the user to return to after viewing a comment. + @param link_text The text to display for the link. + @param category A category to associate comment to. - @see general_comments_create_link -} { - # get the package url - set package_url [general_comments_package_url] + @see general_comments_create_link + } { + # get the package url + set package_url [general_comments_package_url] - set html "$link_text" - return $html -} + set html [subst {$link_text + }] + return $html + } } + +# +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: Index: openacs-4/packages/general-comments/www/comment-add-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/comment-add-3.tcl,v diff -u -N -r1.11 -r1.12 --- openacs-4/packages/general-comments/www/comment-add-3.tcl 14 Jun 2015 00:37:34 -0000 1.11 +++ openacs-4/packages/general-comments/www/comment-add-3.tcl 27 Jun 2015 21:10:12 -0000 1.12 @@ -50,5 +50,5 @@ if { $attach_p == "f" && $return_url ne "" } { ad_returnredirect $return_url } else { - ad_returnredirect "view-comment?[export_vars { comment_id return_url }]" + ad_returnredirect [export_vars -base view-comment { comment_id return_url }] } Index: openacs-4/packages/general-comments/www/comment-edit-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/comment-edit-3.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/general-comments/www/comment-edit-3.tcl 27 Oct 2014 16:41:42 -0000 1.5 +++ openacs-4/packages/general-comments/www/comment-edit-3.tcl 27 Jun 2015 21:10:12 -0000 1.6 @@ -53,5 +53,5 @@ } -ad_returnredirect "view-comment?[export_vars -url {comment_id return_url}]" +ad_returnredirect [export_vars -base view-comment {comment_id return_url}] Index: openacs-4/packages/general-comments/www/delete-attachment-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/delete-attachment-2.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/general-comments/www/delete-attachment-2.tcl 27 Oct 2014 16:41:43 -0000 1.6 +++ openacs-4/packages/general-comments/www/delete-attachment-2.tcl 27 Jun 2015 21:10:12 -0000 1.7 @@ -73,7 +73,7 @@ #/ i18n #} -ad_returnredirect "view-comment?comment_id=$parent_id&[export_vars -url {return_url}]" +ad_returnredirect [export_vars -base view-comment {{comment_id $parent_id} return_url}] Index: openacs-4/packages/general-comments/www/file-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/file-add-2.tcl,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/general-comments/www/file-add-2.tcl 27 Oct 2014 16:41:43 -0000 1.7 +++ openacs-4/packages/general-comments/www/file-add-2.tcl 27 Jun 2015 21:10:12 -0000 1.8 @@ -140,5 +140,5 @@ } -ad_returnredirect "view-comment?comment_id=$parent_id&[export_vars -url {return_url}]" +ad_returnredirect [export_vars -base view-comment {{comment_id $parent_id} return_url}] Index: openacs-4/packages/general-comments/www/file-edit-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/file-edit-2.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/general-comments/www/file-edit-2.tcl 27 Oct 2014 16:41:43 -0000 1.3 +++ openacs-4/packages/general-comments/www/file-edit-2.tcl 27 Jun 2015 21:10:12 -0000 1.4 @@ -30,7 +30,7 @@ where revision_id = :revision_id } -ad_returnredirect "view-comment?comment_id=$parent_id&[export_vars -url {return_url}]" +ad_returnredirect [export_vars -base view-comment {{comment_id $parent_id} return_url}] Index: openacs-4/packages/general-comments/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/index.tcl,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/general-comments/www/index.tcl 27 Oct 2014 16:41:43 -0000 1.8 +++ openacs-4/packages/general-comments/www/index.tcl 27 Jun 2015 21:10:12 -0000 1.9 @@ -48,7 +48,7 @@ template::list::create -name comments_list \ -multirow comments \ -no_data "#general-comments.lt_No_comments_available#" \ - -html {align center} \ + -html {style "margin: 0 auto"} \ -elements { counter { label "#general-comments.Num#" Index: openacs-4/packages/general-comments/www/url-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/url-add-2.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/general-comments/www/url-add-2.tcl 27 Oct 2014 16:41:44 -0000 1.5 +++ openacs-4/packages/general-comments/www/url-add-2.tcl 27 Jun 2015 21:10:12 -0000 1.6 @@ -45,7 +45,7 @@ end; } -ad_returnredirect "view-comment?comment_id=$parent_id&[export_vars -url {return_url}]" +ad_returnredirect [export_vars -base view-comment {{comment_id $parent_id} return_url}] Index: openacs-4/packages/general-comments/www/url-edit-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/url-edit-2.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/general-comments/www/url-edit-2.tcl 27 Oct 2014 16:41:44 -0000 1.4 +++ openacs-4/packages/general-comments/www/url-edit-2.tcl 27 Jun 2015 21:10:12 -0000 1.5 @@ -28,7 +28,7 @@ where extlink_id = :attach_id } -ad_returnredirect "view-comment?comment_id=$parent_id&[export_vars -url {return_url}]" +ad_returnredirect [export_vars -base view-comment {{comment_id $parent_id} return_url}] Index: openacs-4/packages/general-comments/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/general-comments/www/admin/index.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/general-comments/www/admin/index.tcl 27 Oct 2014 16:41:44 -0000 1.5 +++ openacs-4/packages/general-comments/www/admin/index.tcl 27 Jun 2015 21:10:12 -0000 1.6 @@ -41,7 +41,7 @@ template::list::create -name comments_list \ -multirow comments \ -no_data "#general-comments.lt_No_comments_available#" \ - -html {align center} \ + -html {style "margin: 0 auto"} \ -elements { counter { label "#general-comments.Num#"