tree-map-2.tcl

Asks whether users will be allowed to assign multiple categories of this subtree to objects and if users have to categorize an object in this subtree. Then assigns this subtree to the passed object (usually a package_id).

Location:
/packages/categories/www/cadmin/tree-map-2.tcl
Author:
Timo Hentschel <timo@timohentschel.de>
CVS ID:
$Id: tree-map-2.tcl,v 1.12.2.2 2023/10/22 16:37:51 gustafn Exp $

Related Files

[ hide source ] | [ make this the default ]

File Contents

ad_page_contract {

    Asks whether users will be allowed to assign multiple
    categories of this subtree to objects and if users
    have to categorize an object in this subtree.

    Then assigns this subtree to the passed object (usually a package_id).

    @author Timo Hentschel (timo@timohentschel.de)
    @cvs-id $Id: tree-map-2.tcl,v 1.12.2.2 2023/10/22 16:37:51 gustafn Exp $
} {
    tree_id:naturalnum,notnull
    {category_id:naturalnum,optional ""}
    {locale:word ""}
    object_id:naturalnum,notnull
    {edit_p:boolean,notnull 0}
    ctx_id:naturalnum,optional
}

set user_id [auth::require_login]
permission::require_permission -object_id $object_id -privilege admin

array set tree [category_tree::get_data $tree_id $locale]
set tree_name $tree(tree_name)
if {$tree(site_wide_p) == "f"} {
    permission::require_permission -object_id $tree_id -privilege category_tree_read
}

set context_bar [list [category::get_object_context $object_id] [list "[export_vars -no_empty -base object-map {locale object_id ctx_id}]" [_ categories.cadmin]] [_ categories.Mapping_parameters]]

if {$edit_p} {
    # parameters are edited, so get old data
    db_1row get_mapped_subtree_id ""
}

if {$category_id eq ""} {
    set page_title [_ categories.Mapping_parameters_tree_title]
} else {
    set category_name [category::get_name $category_id $locale]
    set page_title [_ categories.Mapping_parameters_subtree_title]
}

ad_form -name tree_map_form -action tree-map-2 -export { tree_id category_id locale object_id edit_p ctx_id} -form {
    {widget:text(radio) {label "#categories.Widget#"} {options {
        {"#categories.Widget_select#" select}
        {"#categories.Widget_multiselect#" multiselect}
        {"#categories.Widget_radio#" radio}
        {"#categories.Widget_checkbox#" checkbox}
    }}}
    {require_category_p:text(radio) {label "#categories.Widget_required_category#"} {options {{"#acs-admin.Yes#" t} {"#acs-admin.No#" f}}}}
} -on_request {
    if {$edit_p} {
        db_1row get_mapping_parameters ""
        if { $widget eq "" } {
            # this is pre-widget selection and we default to the same
            # look and feel as before
            if { $assign_single_p } {
                set widget "select"
            } else {
                set widget "multiselect"
            }
        }
    } else {
    # we default to the default before widgets could be selected
        set widget multiselect
        set require_category_p f
    }
} -on_submit {
    if { $widget eq "select" || $widget eq "radio" } {
        set assign_single_p t
    } else {
        set assign_single_p f
    }
    if {$edit_p} {
        category_tree::edit_mapping -tree_id $tree_id -object_id $object_id -assign_single_p $assign_single_p -require_category_p $require_category_p -widget $widget
    } else {
        category_tree::map -tree_id $tree_id -subtree_category_id $category_id -object_id $object_id -assign_single_p $assign_single_p -require_category_p $require_category_p -widget $widget
    }
} -after_submit {
    ad_returnredirect [export_vars -no_empty -base object-map {locale object_id ctx_id}]
    ad_script_abort
}

ad_return_template

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