forum::attachments_enabled_p (public)
forum::attachments_enabled_p [ -forum_id forum_id ]
Defined in packages/forums/tcl/forums-procs.tcl
Check if attachments are enabled in forums. Simple attachment style uses the enabled shared attachments service. Complex style requires an attachments instance mounted beneath Forums. When forum_id is supplied, also require that forum's attachments_allowed_p option. Otherwise, determine the Forums instance from the current request.
- Switches:
- -forum_id (optional)
- Returns:
- 1 if the attachments are enabled in the forums, 0 otherwise.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- forum_message_new
Source code: if {$forum_id ne ""} { # # A forum was provided # forum::get -forum_id $forum_id -array forum 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 {![ns_conn isconnected]} { # # All the next tests require an active connection. The # messages with "ad_log warning" are not helpful and might be # overwhelming, especially when called via the search # callback. So, provide a shorter message. ns_log notice "forum::attachments_enabled_p must receive a" "valid -forum_id when called in the background" return 0 } 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 "forum::attachments: Cannot determine package_id. Returning 0" return 0 } # # Simple attachments use the shared singleton service directly. They do # not require the legacy per-Forums child mount. # if {[parameter::get -package_id $package_id -parameter AttachmentStyle -default simple] eq "simple"} { return [expr {[apm_package_enabled_p attachments] && [namespace which ::attachments::attach] ne ""}] } # # The complex workflow still uses its child-mounted attachment pages. # set node_id [site_node::get_node_id_from_object_id -object_id $package_id] set nodes [site_node::get_children -package_key attachments -node_id $node_id] return [expr {[llength $nodes] > 0}]Generic XQL file: packages/forums/tcl/forums-procs.xql
PostgreSQL XQL file: packages/forums/tcl/forums-procs-postgresql.xql
Oracle XQL file: packages/forums/tcl/forums-procs-oracle.xql