• Publicity: Public Only All

forums-procs.tcl

Forums Library

Location:
packages/forums/tcl/forums-procs.tcl
Created:
2002-05-17
Author:
Ben Adida
CVS Identification:
$Id: forums-procs.tcl,v 1.38.2.9 2024/08/06 10:16:11 gustafn Exp $

Procedures in this file

Detailed information

forum::attachments_enabled_p (public)

 forum::attachments_enabled_p [ -forum_id forum_id ]

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

forum::delete (public)

 forum::delete [ -forum_id forum_id ]

delete a forum

Switches:
-forum_id (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 test_web_forum_edit web_forum_edit (test forums) forum::delete forum::delete test_web_forum_edit->forum::delete test_web_forum_new web_forum_new (test forums) test_web_forum_new->forum::delete test_web_forum_view web_forum_view (test forums) test_web_forum_view->forum::delete test_web_forums_message_and_reply web_forums_message_and_reply (test forums) test_web_forums_message_and_reply->forum::delete db_exec_plsql db_exec_plsql (public) forum::delete->db_exec_plsql forum::install::before-uninstantiate forum::install::before-uninstantiate (private) forum::install::before-uninstantiate->forum::delete

Testcases:
web_forum_new, web_forum_view, web_forum_edit, web_forums_message_and_reply

forum::disable (public)

 forum::disable -forum_id forum_id

Disable a forum

Switches:
-forum_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_forum_enable_disable forum_enable_disable (test forums) forum::disable forum::disable test_forum_enable_disable->forum::disable db_dml db_dml (public) forum::disable->db_dml packages/forums/www/admin/forum-disable.tcl packages/forums/ www/admin/forum-disable.tcl packages/forums/www/admin/forum-disable.tcl->forum::disable

Testcases:
forum_enable_disable

forum::edit (public)

 forum::edit -forum_id forum_id [ -name name ] [ -charter charter ] \
    [ -presentation_type presentation_type ] \
    [ -posting_policy posting_policy ] \
    [ -new_questions_allowed_p new_questions_allowed_p ] \
    [ -anonymous_allowed_p anonymous_allowed_p ] \
    [ -attachments_allowed_p attachments_allowed_p ] [ -no_callback ]

Edit a forum

Switches:
-forum_id (required)
-name (optional)
-charter (optional)
-presentation_type (optional)
-posting_policy (optional)
-new_questions_allowed_p (optional)
-anonymous_allowed_p (optional)
-attachments_allowed_p (optional)
-no_callback (optional, boolean)

Partial Call Graph (max 5 caller/called nodes):
%3 test_web_forum_edit web_forum_edit (test forums) forum::edit forum::edit test_web_forum_edit->forum::edit test_web_forums_message_and_reply web_forums_message_and_reply (test forums) test_web_forums_message_and_reply->forum::edit ad_conn ad_conn (public) forum::edit->ad_conn callback callback (public) forum::edit->callback db_dml db_dml (public) forum::edit->db_dml forum::flush_cache forum::flush_cache (public) forum::edit->forum::flush_cache forum::get forum::get (public) forum::edit->forum::get forum::posting_policy_set forum::posting_policy_set (public, deprecated) forum::posting_policy_set->forum::edit packages/forums/lib/forums/edit.tcl packages/forums/ lib/forums/edit.tcl packages/forums/lib/forums/edit.tcl->forum::edit

Testcases:
web_forum_edit, web_forums_message_and_reply

forum::enable (public)

 forum::enable -forum_id forum_id

Enable a forum

Switches:
-forum_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_forum_enable_disable forum_enable_disable (test forums) forum::enable forum::enable test_forum_enable_disable->forum::enable db_dml db_dml (public) forum::enable->db_dml packages/forums/www/admin/forum-enable.tcl packages/forums/ www/admin/forum-enable.tcl packages/forums/www/admin/forum-enable.tcl->forum::enable

Testcases:
forum_enable_disable

forum::flush_cache (public)

 forum::flush_cache -forum_id forum_id

Flushes all the forum caches.

Switches:
-forum_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_forum_count_test forum_count_test (test forums) forum::flush_cache forum::flush_cache test_forum_count_test->forum::flush_cache forum::flush_namespaced_cache forum::flush_namespaced_cache (public) forum::flush_cache->forum::flush_namespaced_cache forum::flush_templating_cache forum::flush_templating_cache (public) forum::flush_cache->forum::flush_templating_cache forum::edit forum::edit (public) forum::edit->forum::flush_cache forum::message::delete forum::message::delete (public) forum::message::delete->forum::flush_cache forum::message::new forum::message::new (public) forum::message::new->forum::flush_cache forum::message::set_state forum::message::set_state (private) forum::message::set_state->forum::flush_cache

Testcases:
forum_count_test

forum::flush_namespaced_cache (public)

 forum::flush_namespaced_cache -forum_id forum_id

Unsets namespaced thread variable holding the forum cache

Switches:
-forum_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_forum_count_test forum_count_test (test forums) forum::flush_namespaced_cache forum::flush_namespaced_cache test_forum_count_test->forum::flush_namespaced_cache forum::flush_cache forum::flush_cache (public) forum::flush_cache->forum::flush_namespaced_cache

Testcases:
forum_count_test

forum::flush_templating_cache (public)

 forum::flush_templating_cache -forum_id forum_id

Flushes forum templating cache, created by template::paginator

Switches:
-forum_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_forum_new forum_new (test forums) forum::flush_templating_cache forum::flush_templating_cache test_forum_new->forum::flush_templating_cache template::cache template::cache (public) forum::flush_templating_cache->template::cache forum::flush_cache forum::flush_cache (public) forum::flush_cache->forum::flush_templating_cache forum::new forum::new (public) forum::new->forum::flush_templating_cache packages/forums/www/moderate/message-approve.tcl packages/forums/ www/moderate/message-approve.tcl packages/forums/www/moderate/message-approve.tcl->forum::flush_templating_cache

Testcases:
forum_new

forum::get (public)

 forum::get -forum_id forum_id -array array

get the fields for a forum

Switches:
-forum_id (required)
-array (required)
Returns:

Partial Call Graph (max 5 caller/called nodes):
%3 test_forum_count_test forum_count_test (test forums) forum::get forum::get test_forum_count_test->forum::get test_web_forum_edit web_forum_edit (test forums) test_web_forum_edit->forum::get test_web_forum_view web_forum_view (test forums) test_web_forum_view->forum::get test_web_forums_message_and_reply web_forums_message_and_reply (test forums) test_web_forums_message_and_reply->forum::get db_0or1row db_0or1row (public) forum::get->db_0or1row callback::search::datasource::impl::forums_message callback::search::datasource::impl::forums_message (private) callback::search::datasource::impl::forums_message->forum::get forum::attachments_enabled_p forum::attachments_enabled_p (public) forum::attachments_enabled_p->forum::get forum::edit forum::edit (public) forum::edit->forum::get forum::new_questions_allowed_p forum::new_questions_allowed_p (public, deprecated) forum::new_questions_allowed_p->forum::get forum::security::can_post_forum_p forum::security::can_post_forum_p (public) forum::security::can_post_forum_p->forum::get

Testcases:
forum_count_test, web_forum_view, web_forum_edit, web_forums_message_and_reply

forum::list_forums (public)

 forum::list_forums -package_id package_id

List all forums in a package

Switches:
-package_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_forum_new forum_new (test forums) forum::list_forums forum::list_forums test_forum_new->forum::list_forums db_list_of_ns_sets db_list_of_ns_sets (public) forum::list_forums->db_list_of_ns_sets

Testcases:
forum_new

forum::new (public)

 forum::new [ -forum_id forum_id ] -name name [ -charter charter ] \
    [ -presentation_type presentation_type ] \
    [ -posting_policy posting_policy ] -package_id package_id \
    [ -new_questions_allowed_p new_questions_allowed_p ] \
    [ -anonymous_allowed_p anonymous_allowed_p ] \
    [ -attachments_allowed_p attachments_allowed_p ] [ -no_callback ]

create a new forum

Switches:
-forum_id (optional)
-name (required)
-charter (optional)
-presentation_type (optional, defaults to "flat")
-posting_policy (optional, defaults to "open")
-package_id (required)
-new_questions_allowed_p (optional, defaults to "t")
-anonymous_allowed_p (optional, defaults to "f")
-attachments_allowed_p (optional, defaults to "t")
-no_callback (optional, boolean)

Partial Call Graph (max 5 caller/called nodes):
%3 test_forum_count_test forum_count_test (test forums) forum::new forum::new test_forum_count_test->forum::new test_forum_enable_disable forum_enable_disable (test forums) test_forum_enable_disable->forum::new test_forum_message_new forum_message_new (test forums) test_forum_message_new->forum::new test_forum_new forum_new (test forums) test_forum_new->forum::new test_web_forum_edit web_forum_edit (test forums) test_web_forum_edit->forum::new callback callback (public) forum::new->callback db_dml db_dml (public) forum::new->db_dml forum::flush_templating_cache forum::flush_templating_cache (public) forum::new->forum::flush_templating_cache package_instantiate_object package_instantiate_object (public) forum::new->package_instantiate_object callback::pm::project_new::impl::forums callback::pm::project_new::impl::forums (private) callback::pm::project_new::impl::forums->forum::new install::xml::action::forum-create install::xml::action::forum-create (private) install::xml::action::forum-create->forum::new packages/forums/lib/forums/new.tcl packages/forums/ lib/forums/new.tcl packages/forums/lib/forums/new.tcl->forum::new

Testcases:
forum_new, forum_message_new, forum_count_test, web_forum_new, web_forum_view, web_forum_edit, web_forums_message_and_reply, forum_enable_disable

forum::new_questions_allow (public, deprecated)

 forum::new_questions_allow -forum_id forum_id [ -party_id party_id ]
Deprecated. Invoking this procedure generates a warning.

Allow the users to create new threads in the forum DEPRECATED: either use forum::edit or inline this trivial query.

Switches:
-forum_id (required)
-party_id (optional)
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log ad_log (public) ad_log_deprecated ad_log_deprecated (public) db_dml db_dml (public) forum::new_questions_allow forum::new_questions_allow forum::new_questions_allow->ad_log forum::new_questions_allow->ad_log_deprecated forum::new_questions_allow->db_dml

Testcases:
No testcase defined.

forum::new_questions_allowed_p (public, deprecated)

 forum::new_questions_allowed_p -forum_id forum_id \
    [ -party_id party_id ]
Deprecated. Invoking this procedure generates a warning.

Check if the users can create new threads in the forum DEPRECATED: the forum::get api already retrieves this information and there is normally no need to invoke this API specifically.

Switches:
-forum_id (required)
-party_id (optional)
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log ad_log (public) ad_log_deprecated ad_log_deprecated (public) forum::get forum::get (public) forum::new_questions_allowed_p forum::new_questions_allowed_p forum::new_questions_allowed_p->ad_log forum::new_questions_allowed_p->ad_log_deprecated forum::new_questions_allowed_p->forum::get

Testcases:
No testcase defined.

forum::new_questions_deny (public, deprecated)

 forum::new_questions_deny -forum_id forum_id [ -party_id party_id ]
Deprecated. Invoking this procedure generates a warning.

Deny the users to create new threads in the forum DEPRECATED: either use forum::edit or inline this trivial query.

Switches:
-forum_id (required)
-party_id (optional)
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log ad_log (public) ad_log_deprecated ad_log_deprecated (public) db_dml db_dml (public) forum::new_questions_deny forum::new_questions_deny forum::new_questions_deny->ad_log forum::new_questions_deny->ad_log_deprecated forum::new_questions_deny->db_dml

Testcases:
No testcase defined.

forum::posting_policy_set (public, deprecated)

 forum::posting_policy_set -posting_policy posting_policy \
    -forum_id forum_id
Deprecated. Invoking this procedure generates a warning.

Set the posting policy. This used to happen by setting permissions on the registered_users group, but was reformed to be just a flag on the forum itself in order to support subsite installation. Please use forum::edit instead.

Switches:
-posting_policy (required)
-forum_id (required)
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log_deprecated ad_log_deprecated (public) forum::edit forum::edit (public) forum::posting_policy_set forum::posting_policy_set forum::posting_policy_set->ad_log_deprecated forum::posting_policy_set->forum::edit

Testcases:
No testcase defined.

forum::use_ReadingInfo_p (public)

 forum::use_ReadingInfo_p [ -package_id package_id ]
Switches:
-package_id (optional)
Returns:
1 if the UseReadingInfo package parameter is true, 0 otherwise.

Partial Call Graph (max 5 caller/called nodes):
%3 test_web_forums_message_and_reply web_forums_message_and_reply (test forums) forum::use_ReadingInfo_p forum::use_ReadingInfo_p test_web_forums_message_and_reply->forum::use_ReadingInfo_p ad_conn ad_conn (public) forum::use_ReadingInfo_p->ad_conn apm_package_ids_from_key apm_package_ids_from_key (public) forum::use_ReadingInfo_p->apm_package_ids_from_key parameter::get parameter::get (public) forum::use_ReadingInfo_p->parameter::get packages/forums/lib/forums/forums-chunk.tcl packages/forums/ lib/forums/forums-chunk.tcl packages/forums/lib/forums/forums-chunk.tcl->forum::use_ReadingInfo_p packages/forums/lib/message/post.tcl packages/forums/ lib/message/post.tcl packages/forums/lib/message/post.tcl->forum::use_ReadingInfo_p packages/forums/lib/message/threads-chunk.tcl packages/forums/ lib/message/threads-chunk.tcl packages/forums/lib/message/threads-chunk.tcl->forum::use_ReadingInfo_p packages/forums/www/message-view.tcl packages/forums/ www/message-view.tcl packages/forums/www/message-view.tcl->forum::use_ReadingInfo_p packages/forums/www/moderate/move-thread.tcl packages/forums/ www/moderate/move-thread.tcl packages/forums/www/moderate/move-thread.tcl->forum::use_ReadingInfo_p

Testcases:
web_forums_message_and_reply

forum::valid_forum_id_p (public)

 forum::valid_forum_id_p -forum_id forum_id [ -package_id package_id ]

checks forum_id

Switches:
-forum_id (required)
-package_id (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 test_forum_new forum_new (test forums) forum::valid_forum_id_p forum::valid_forum_id_p test_forum_new->forum::valid_forum_id_p test_web_forums_message_and_reply web_forums_message_and_reply (test forums) test_web_forums_message_and_reply->forum::valid_forum_id_p db_0or1row db_0or1row (public) forum::valid_forum_id_p->db_0or1row

Testcases:
forum_new, web_forums_message_and_reply
[ hide source ] | [ make this the default ]

Content File Source

ad_library {

    Forums Library

    @creation-date 2002-05-17
    @author Ben Adida <ben@openforce.biz>
    @cvs-id $Id: forums-procs.tcl,v 1.38.2.9 2024/08/06 10:16:11 gustafn Exp $

}

namespace eval forum {}


d_proc -public forum::new {
    {-forum_id ""}
    {-name:required}
    {-charter ""}
    {-presentation_type flat}
    {-posting_policy open}
    {-package_id:required}
    {-new_questions_allowed_p t}
    {-anonymous_allowed_p f}
    {-attachments_allowed_p t}
    -no_callback:boolean
} {
    create a new forum
} {
    set var_list [list \
        [list forum_id $forum_id] \
        [list name $name] \
        [list charter $charter] \
        [list presentation_type $presentation_type] \
        [list posting_policy $posting_policy] \
        [list package_id $package_id]]

    set forum_id [package_instantiate_object -var_list $var_list forums_forum]

    db_dml update_extra_cols {
        update forums_forums
       set new_questions_allowed_p = :new_questions_allowed_p,
           anonymous_allowed_p     = :anonymous_allowed_p,
           attachments_allowed_p   = :attachments_allowed_p
        where forum_id = :forum_id
    }

    if {!$no_callback_p} {
        callback forum::forum_new -package_id $package_id -forum_id $forum_id
    }

    forum::flush_templating_cache \
        -forum_id $forum_id

    return $forum_id
}

d_proc -public forum::delete {
    {-forum_id ""}
} {
    delete a forum
} {
    db_exec_plsql forum_delete {}
}

d_proc -public forum::edit {
    {-forum_id:required}
    -name
    -charter
    -presentation_type
    -posting_policy
    -new_questions_allowed_p
    -anonymous_allowed_p
    -attachments_allowed_p
    -no_callback:boolean
} {
    Edit a forum
} {
    forum::get -forum_id $forum_id -array forum
    foreach var {
        name charter presentation_type posting_policy new_questions_allowed_p anonymous_allowed_p attachments_allowed_p} {
        if {![info exists $var]} {
            set $var $forum($var)
        }
    }

    # This is a straight DB update
    db_dml update_forum {}
    db_dml update_forum_object {}

    if {!$no_callback_p} {
        callback forum::forum_edit -package_id [ad_conn package_id] -forum_id $forum_id
    }

    forum::flush_cache \
        -forum_id $forum_id
}

d_proc -public forum::attachments_enabled_p {
    {-forum_id ""}
} {
    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.

    @return 1 if the attachments are enabled in the forums, 0 otherwise.
} {
    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}]
}

d_proc -public forum::list_forums {
    {-package_id:required}
} {
    List all forums in a package
} {
    return [db_list_of_ns_sets select_forums {}]
}

d_proc -public forum::get {
    {-forum_id:required}
    {-array:required}
} {
    get the fields for a forum

    @return
} {
    # Select the info into the upvar'ed Tcl Array
    upvar $array row

    set global_varname ::forum_${forum_id}

    if {[info exists $global_varname]} {
        array set row [array get $global_varname]
    } else {
        if {![db_0or1row select_forum {} -column_array row]} {
            error "Forum $forum_id not found" {} NOT_FOUND
        }
        array set $global_varname [array get row]
    }
}

d_proc -public forum::flush_cache {
    {-forum_id:required}
} {
    Flushes all the forum caches.
} {
    forum::flush_templating_cache -forum_id $forum_id
    forum::flush_namespaced_cache -forum_id $forum_id
}

d_proc -public forum::flush_templating_cache {
    {-forum_id:required}
} {
    Flushes forum templating cache, created by template::paginator
} {
    # DRB: Black magic cache flush call which will disappear when list builder is
    # rewritten to paginate internally rather than use the template paginator.
    template::cache flush "messages,forum_id=$forum_id*"
}

d_proc -public forum::flush_namespaced_cache {
    {-forum_id:required}
} {
    Unsets namespaced thread variable holding the forum cache
} {
    unset -nocomplain ::forum_${forum_id}
}

d_proc -deprecated -public forum::posting_policy_set {
    {-posting_policy:required}
    {-forum_id:required}
} {
    Set the posting policy. This used to happen by setting permissions
    on the registered_users group, but was reformed to be just a flag
    on the forum itself in order to support subsite
    installation. Please use forum::edit instead.

    @see forum::edit
} {
    forum::edit -forum_id $forum_id \
        -posting_policy $posting_policy
    # # JCD: this is potentially bad since we are
    # # just assuming registered_users is the
    # # right group to be granting write to.

    # if {"closed" ne $posting_policy } {
    #     permission::grant -object_id $forum_id \
    #         -party_id [acs_magic_object registered_users] \
    #         -privilege write
    # } else {
    #     permission::revoke -object_id $forum_id \
    #         -party_id [acs_magic_object registered_users] \
    #         -privilege write
    # }
}

d_proc -deprecated forum::new_questions_allow {
    {-forum_id:required}
    {-party_id ""}
} {
    Allow the users to create new threads in the forum

    DEPRECATED: either use forum::edit or inline this trivial query.

    @see forum::edit
} {
    if { $party_id ne "" } {
        ad_log warning "Attribute party_id is deprecated and was ignored."
    }

    db_dml query {
        update forums_forums set new_questions_allowed_p = true
        where forum_id = :forum_id
    }
}

d_proc -deprecated forum::new_questions_deny {
    {-forum_id:required}
    {-party_id ""}
} {
    Deny the users to create new threads in the forum

    DEPRECATED: either use forum::edit or inline this trivial query.

    @see forum::edit
} {
    if { $party_id ne "" } {
        ad_log warning "Attribute party_id is deprecated and was ignored."
    }

    db_dml query {
        update forums_forums set new_questions_allowed_p = false
        where forum_id = :forum_id
    }
}

d_proc -deprecated forum::new_questions_allowed_p {
    {-forum_id:required}
    {-party_id ""}
} {
    Check if the users can create new threads in the forum

    DEPRECATED: the forum::get api already retrieves this information
                and there is normally no need to invoke this API
                specifically.

    @see forum::get
} {
    if { $party_id ne "" } {
        ad_log warning "Attribute party_id is deprecated and was ignored."
    }

    forum::get -forum_id $forum_id -array forum
    return $forum(new_questions_allowed_p)
}

d_proc -public forum::enable {
    {-forum_id:required}
} {
    Enable a forum
} {
    # Enable the forum, no big deal
    db_dml update_forum_enabled_p {}
}

d_proc -public forum::disable {
    {-forum_id:required}
} {
    Disable a forum
} {
    db_dml update_forum_disabled_p {}
}

ad_proc -public forum::use_ReadingInfo_p {{-package_id ""}} {
    @return 1 if the UseReadingInfo package parameter is true, 0 otherwise.
} {
    if {$package_id eq ""} {
        if {[ns_conn isconnected]} {
            set package_id [ad_conn package_id]
        } else {
            set package_id [lindex [apm_package_ids_from_key -package_key forums -mounted] 0]
        }
    }
    return [string is true -strict [parameter::get \
                                        -package_id $package_id \
                                        -parameter UseReadingInfo \
                                        -default f]]
}

d_proc forum::valid_forum_id_p {
    {-forum_id:required}
    {-package_id}
} {
    checks forum_id
} {
    if {[info exists package_id] && [db_0or1row check_forum_id {
        select forum_id from forums_forums where forum_id = :forum_id and package_id = :package_id
    }]} {
        set result true
    } elseif {![info exists package_id] && [db_0or1row check_forum_id {
        select forum_id from forums_forums where forum_id = :forum_id
    }]} {
        set result true
    } else {
        set result false
    }

    return $result
}

# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: