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. If 'forum_id' is not passed, check only if the attachments package is mounted as a child of the current forums package instance. Otherwise, check also if a particular forum's 'attachments_allowed_p' option is true. In case the package is mounted and the option enabled, return 1.

Switches:
-forum_id (optional)
Returns:
1 if the attachments are enabled in the forums, 0 otherwise.

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
    }

    #
    # See if an instance of the attachments package is mounted
    # underneath this forums instance.
    #
    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

[ hide source ] | [ make this the default ]
Show another procedure: