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.

Partial Call Graph (max 5 caller/called nodes):
%3 test_forum_message_new forum_message_new (test forums) forum::attachments_enabled_p forum::attachments_enabled_p test_forum_message_new->forum::attachments_enabled_p ad_conn ad_conn (public) forum::attachments_enabled_p->ad_conn ad_log ad_log (public) forum::attachments_enabled_p->ad_log forum::get forum::get (public) forum::attachments_enabled_p->forum::get site_node::get_children site_node::get_children (public) forum::attachments_enabled_p->site_node::get_children site_node::get_node_id_from_object_id site_node::get_node_id_from_object_id (public) forum::attachments_enabled_p->site_node::get_node_id_from_object_id forum::message::get forum::message::get (public) forum::message::get->forum::attachments_enabled_p forum::message::get_attachments forum::message::get_attachments (public, deprecated) forum::message::get_attachments->forum::attachments_enabled_p forums::form::forum forums::form::forum (public) forums::form::forum->forum::attachments_enabled_p packages/forums/lib/forums/edit.tcl packages/forums/ lib/forums/edit.tcl packages/forums/lib/forums/edit.tcl->forum::attachments_enabled_p packages/forums/lib/forums/new.tcl packages/forums/ lib/forums/new.tcl packages/forums/lib/forums/new.tcl->forum::attachments_enabled_p

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 {"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
    }

    #
    # 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: