one.tcl

Shows information about one relationship type

Location:
/packages/acs-subsite/www/admin/rel-types/one.tcl
Author:
mbryzek@arsdigita.com
Created:
Sun Dec 10 17:24:21 2000
CVS ID:
$Id: one.tcl,v 1.6.2.1 2021/10/04 13:56:55 antoniop Exp $

Related Files

[ hide source ] | [ make this the default ]

File Contents

# /packages/mbryzek-subsite/www/admin/rel-types/one.tcl

ad_page_contract {

    Shows information about one relationship type

    @author mbryzek@arsdigita.com
    @creation-date Sun Dec 10 17:24:21 2000
    @cvs-id $Id: one.tcl,v 1.6.2.1 2021/10/04 13:56:55 antoniop Exp $

} {
    rel_type:notnull
} -properties {
    context:onevalue
    rel_type:onevalue
    rel_type_enc:onevalue
    rel_type_pretty_name:onevalue
    dynamic_p:onevalue
    rels:multirow
    attributes:multirow
    properties:onerow
    return_url_enc:onevalue
}

set return_url [ad_conn url]?[ad_conn query] 
set return_url_enc [ad_urlencode $return_url]
set rel_type_enc [ad_urlencode $rel_type]

set package_id [ad_conn package_id]

set context [list [list "./" "Relationship types""One type"]

if { ![db_0or1row select_pretty_name {
    select t.pretty_name as rel_type_pretty_name, t.table_name, t.id_column, t.dynamic_p
      from acs_object_types t
     where t.object_type = :rel_type
}] } {
    ad_return_error \
        "Relationship type doesn't exist" \
        "Relationship type \"$rel_type\" doesn't exist"
    ad_script_abort
}

db_1row select_rel_type_properties {
    select t1.pretty_name as object_type_one_pretty_name,
           r.object_type_one,
           (select pretty_name from acs_rel_roles
            where role = r.role_one) as role_one_pretty_name,
           r.role_one,
           r.min_n_rels_one,
           r.max_n_rels_one,
           t2.pretty_name as object_type_two_pretty_name,
           r.object_type_two,
           (select pretty_name from acs_rel_roles
             where role = r.role_two) as role_two_pretty_name,
           r.role_two,
           r.min_n_rels_two,
           r.max_n_rels_two
      from acs_rel_types r, acs_object_types t1, acs_object_types t2
     where r.rel_type = :rel_type
       and r.object_type_one = t1.object_type
       and r.object_type_two = t2.object_type
} -column_array properties


set user_id [ad_conn user_id]

# We display up to 25 relations, and then offer a link for the rest.

# Pull out all the relations of this type 
db_multirow rels rels_select {
    select v_inner.*
    from (select r.rel_id,
                 acs_object.name(r.object_id_one) || ' and ' || acs_object.name(r.object_id_two) as name
              from acs_rels r, app_group_distinct_rel_map m
             where acs_permission.permission_p(r.rel_id, :user_id, 'read')
               and r.rel_type = :rel_type
               and m.rel_id = r.rel_id
               and m.package_id = :package_id
             order by lower(acs_object.name(r.object_id_one)),
                      lower(acs_object.name(r.object_id_two))
          ) v_inner
    fetch first 26 rows only
}


db_multirow attributes attributes_select {
    select a.attribute_id, a.pretty_name
      from acs_attributes a
     where a.object_type = :rel_type
}

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