# packages/address-book/tcl/address-book-procs.tcl
ad_library {
Procs related to the address-book package
@author John Mileham (jmileham@arsdigita.com)
@cvs-id $Id: address-book-procs.tcl,v 1.1 2001/04/20 20:51:12 donb Exp $
}
namespace eval ab {
namespace eval contact {}
namespace eval contact_attr {}
namespace eval contact_attr_type {}
}
ad_proc ab::contact::1row {
contact_id
{out_datasource_name "contact"}
} {
Creates a 1row datasource for a contact and stores it to the datasource described by
out_datasource_name
. This doesn't include attributes, just basic elements.
@param contact_id The contact_id
of the contact we want the info on
@param out_datasource_name The name of the datasource we're storing to
@author John Mileham (jmileham@arsdigita.com)
} {
upvar $out_datasource_name my_contact
db_1row get_contact_info {
select last_name,
first_names,
title,
organization
from ab_contacts
where contact_id = :contact_id
} -column_array my_contact
}
ad_proc ab::contact_attr::multirow {
contact_id
{out_datasource_name "contact_attrs"}
} {
Creates a multirow datasource containing all attributes asssociated with a contact
in sort order.
@param contact_id The contact_id
of the contact we want the attributes of
@param out_datasource_name The name of the datasource we're storing to
@author John Mileham (jmileham@arsdigita.com)
} {
uplevel [list db_multirow $out_datasource_name get_contact_attrs "
select attr_id,
type_name,
value
from ab_contact_attr_types acat,
ab_contact_attrs aca
where acat.type_key = aca.type_key
and aca.contact_id = :contact_id
order by sort_key"]
}
ad_proc ab::contact::displaywidget {
contact_id
} {
Returns a display widget for a contact
@param contact_id The contact_id
of the widget to be displayed
@author John Mileham (jmileham@arsdigita.com)
} {
ab::contact::1row $contact_id contact
set widget "
First Name: | $contact(first_names) |
Last Name: | $contact(last_name) |
Title: | $contact(title) |
Organization: | $contact(organization) |
$type_name: | $value |
No Attributes Found | |
Address #$n: | [place::address::displaywidget -in_datasource_name address] |
type_key
of the type to be selected by default
@param field_name Name carried by the HTML select
widget generated
@author John Mileham (jmileham@arsdigita.com)
} {
return [ad_db_select_widget -default $default ab_contact_attr_list {select type_name, type_key from ab_contact_attr_types order by type_id} $field_name]
}