Index: openacs-4/packages/forums/tcl/forums-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/forums-procs.tcl,v diff -u -r1.38.2.2 -r1.38.2.3 --- openacs-4/packages/forums/tcl/forums-procs.tcl 19 Jun 2019 16:41:38 -0000 1.38.2.2 +++ openacs-4/packages/forums/tcl/forums-procs.tcl 24 Feb 2023 13:19:57 -0000 1.38.2.3 @@ -108,20 +108,45 @@ @return 1 if the attachments are enabled in the forums, 0 otherwise. } { - if {"forums" eq [ad_conn package_key]} { - set return_value [site_node_apm_integration::child_package_exists_p \ - -package_id [ad_conn package_id] -package_key attachments] - } else { - set return_value 0 - } - - if {$return_value && $forum_id ne ""} { + if {$forum_id ne ""} { + # + # A forum was provided + # forum::get -forum_id $forum_id -array forum - if {! $forum(attachments_allowed_p)} { - set return_value 0 + + if {!$forum(attachments_allowed_p)} { + # + # Forum does not allow attachments. Exit immediately. + # + return 0 } + + # + # We get the package from the forum + # + set package_id $forum(package_id) + + } elseif {"forums" eq [ad_conn package_key]} { + # + # No forum provided, but the connection context tells us this + # is a forum package. We use the connection package_id. + # + set package_id [ad_conn package_id] + } else { + # + # No forum and no connection context to help us determine the + # package. Exit immediately. + # + ad_log warning "Cannot determine package_id. Returning 0" + return 0 } - return $return_value + + # + # See if an instance of the attachments package is mounted + # underneath this forums instance. + # + return [site_node_apm_integration::child_package_exists_p \ + -package_id $package_id -package_key attachments] } ad_proc -public forum::list_forums {