man Bric::Biz::Contact () - Interface to Contacts

NAME

Bric::Biz::Contact - Interface to Contacts

VERSION

$LastChangedRevision$

DATE

$LastChangedDate: 2004-08-12 17:13:34 -0700 (Thu, 12 Aug 2004) $

SYNOPSIS

  use Bric::Biz::Contact

  # Constructors.
  my $c = Bric::Biz::Contact->new($init);
  my $c = Bric::Biz::Contact->lookup({ id => $id });
  my @c = Bric::Biz::Contact->list($params);

  # Class Methods.
  my @cids = Bric::Biz::Contact->list_ids($params);
  my $methods = Bric::Biz::Contact->my_meths;

  # Contact Type managment.
  my @types = Bric::Biz::Contact->list_types;
  my $types_href = Bric::Biz::Contact->href_types;
  my @types = Bric::Biz::Contact->list_alertable_types;
  my $types_href = Bric::Biz::Contact->href_alertable_types;
  my $type_ids_href = Bric::Biz::Contact->href_alertable_type_ids;
  my $bool = Bric::Biz::Contact->edit_type($type, $description);
  my $bool = Bric::Biz::Contact->deactivate_type($type);

  # Instance Methods.
  my $id = $c->get_id;
  my $type = $c->get_type;
  $c = $c->set_type($type);
  my $desc = $c->get_description;
  my $value = $c->get_value;
  $c = $c->set_value($value);

  $c = $c->activate;
  $c = $c->deactivate;
  $c = $c->is_active;

  $c = $c->save;

DESCRIPTION

This class manages contacts. Currently, contacts are only associated with Bric::Biz::Person objects, but they could conceivably be associated with other objects, e.g., Bric::Biz::Org.

A contact is a method (other than snail mail) to contact a person. Default contact types include Primary Email, Secondary Email, Office Phone, Mobile Phone, AOL Instant Messenger, etc. These types can be modified and new contact types can be added via this class' class methods. Each individual Bric::Biz::Contact object has an associated type, the type's description, and a value. Each is also associated with another object, so they will often be accessed from that object (see Bric::Biz::Person for an example).

INTERFACE

Constructors

Instantiates a Bric::Biz::Contact object. An anonymous hash of initial values may be passed. The supported initial value keys are:

*
type
*
value The active property will be set to true by default. Call CW$c->save() to save the new object. Throws:
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Looks up and instantiates a new Bric::Biz::Contact object based on the Bric::Biz::Contact object ID passed. If CW$id is not found in the database, lookup() returns undef. Throws:
*
Too many Bric::Biz::Contact objects found.
*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to select column into arrayref.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle. Side Effects: If CW$id is found, populates the new Bric::Biz::Contact object with data from the database before returning it. Notes: NONE. Returns a list or anonymous array of Bric::Biz::Contact objects based on the search parameters passed via an anonymous hash. The supported lookup keys are:
*
type
*
value
*
description Throws:
*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to select column into arrayref.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle. Side Effects: Populates each Bric::Biz::Contact object with data from the database before returning them all. Notes: NONE. Works the same as list(), with the same arguments, except it returns a hash or hashref of Bric::Biz::Contact objects, where the keys are the contact IDs, and the values are the contact objects. Throws:
*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to select column into arrayref.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle. Side Effects: Populates each Bric::Biz::Contact object with data from the database before returning them all. Notes: NONE.

Destructors

$p->DESTROY
Dummy method to prevent wasting time trying to AUTOLOAD DESTROY. Throws: NONE. Side Effects: NONE. Notes: NONE.

Public Class Methods

Returns a list or anonymous array of Bric::Biz::Contact object IDs based on the search parameters passed via an anonymous hash. The supported lookup keys are the same as those for list(). Throws:

*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to select column into arrayref.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle. Side Effects: NONE. Notes: NONE.
$meths = Bric::Biz::Conatact->my_meths
Returns an anonymous hash of introspection data for this object. If called with a true argument, it will return an ordered list or anonymous array of introspection data. If a second true argument is passed instead of a first, then a list or anonymous array of introspection data will be returned for properties that uniquely identify an object (excluding CWid, which is assumed). Each hash key is the name of a property or attribute of the object. The value for a hash key is another anonymous hash containing the following keys:
name
The name of the property or attribute. Is the same as the hash key when an anonymous hash is returned.
disp
The display name of the property or attribute.
get_meth
A reference to the method that will retrieve the value of the property or attribute.
get_args
An anonymous array of arguments to pass to a call to get_meth in order to retrieve the value of the property or attribute.
set_meth
A reference to the method that will set the value of the property or attribute.
set_args
An anonymous array of arguments to pass to a call to set_meth in order to set the value of the property or attribute.
type
The type of value the property or attribute contains. There are only three types:
short
date
blob
len
If the value is a 'short' value, this hash key contains the length of the field.
search
The property is searchable via the list() and list_ids() methods.
req
The property or attribute is required.
props
An anonymous hash of properties used to display the property or attribute. Possible keys include:
type
The display field type. Possible values are
text
textarea
password
hidden
radio
checkbox
select
length
The Length, in letters, to display a text or password field.
maxlength
The maximum length of the property or value - usually defined by the SQL DDL.
rows
The number of rows to format in a textarea field.
cols
The number of columns to format in a textarea field.
vals
An anonymous hash of key/value pairs reprsenting the values and display names to use in a select list. Throws: NONE. Side Effects: NONE. Notes: NONE. Returns a list or anonymous array of all the possible types (names) of contacts. Use these types to set the type of a contact via CW$c->set_type(). Throws:
*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle. Side Effects: NONE. Notes: NONE. Returns a hash list or anonymous hash of all the possible types of contacts. The hash keys are the type names, and the hash values are the descriptions. Throws:
*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle. Side Effects: NONE. Notes: NONE. Returns a list or anonymous array of contact types that are alertable, that is, contacts of these types may be used for sending alerts. Throws:
*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle. Side Effects: NONE. Notes: NONE. Returns a hash list or anonymous hash of contact types that are alertable, that is, contacts of these types may be used for sending alerts. The hash keys are the type names and the values are their descriptions. Throws:
*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle. Side Effects: NONE. Notes: NONE. Returns a hash list or anonymous hash of contact types that are alertable, that is, contacts of these types may be used for sending alerts. The hash keys are they type names and the values are theiry IDs. Used by Bric::Util::Alert. Throws:
*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle. Side Effects: NONE. Notes: NONE. Adds or alters a contact type. If the type exists, its description will be updated and it will be activated. If it does not exist, it will be created. Throws:
*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to execute SQL statement. Side Effects: NONE. Notes: NONE. Deletes a type. All contacts of this type will be automatically deactivated. To reactivate a type, use edit_type(); all existing contacts of that type will then be available again. Throws:
*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to execute SQL statement. Side Effects: NONE. Notes: NONE.

Public Instance Methods

Returns the ID of the Bric::Biz::Contact object. Throws:

*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'id' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: If the Bric::Biz::Contact object has been instantiated via the new() constructor and has not yet been CWsaved, the object will not yet have an ID, so this method call will return undef. Returns the type of the Bric::Biz::Contact object. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'type' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the type type of the contact. The type type must be a valid type as returned by get_types(). Throws:
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Returns the description of the Bric::Biz::Contact object. If the contact has not been looked up from the database or if it's type has changed, description will be undef. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'description' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Returns the value of the Bric::Biz::Contact object. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: READ access for field 'value' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Sets the value of the Bric::Biz::Contact object. Returns CW$self on success and undef on failure. Throws:
*
Bad AUTOLOAD method format.
*
Cannot AUTOLOAD private methods.
*
Access denied: WRITE access for field 'value' required.
*
No AUTOLOAD method. Side Effects: NONE. Notes: NONE. Activates the Bric::Biz::Contact object. Call CW$p->save to make the change persistent. Bric::Biz::Contact objects instantiated by new() are active by default. Throws:
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Deactivates (deletes) the Bric::Biz::Contact object. Call CW$p->save to make the change persistent. Throws:
*
Incorrect number of args to Bric::_set().
*
Bric::set() - Problems setting fields. Side Effects: NONE. Notes: NONE. Returns CW$self if the Bric::Biz::Contact object is active, and undef if it is not. Throws:
*
Bric::_get() - Problems retrieving fields. Side Effects: NONE. Notes: NONE. Saves any changes to the Bric::Biz::Contact object, including changes to associated contacts (Bric::Biz::Attribute::Contact::Contact objects) and attributes (Bric::Biz::Attribute::Contact objects). Returns CW$self on success and undef on failure. Throws:
*
Bric::_get() - Problems retrieving fields.
*
Unable to connect to database.
*
Unable to prepare SQL statement.
*
Unable to execute SQL statement.
*
Unable to select row.
*
Incorrect number of args to _set.
*
Bric::_set() - Problems setting fields. Side Effects: Cleans out internal cache of Bric::Biz::Attr::Contact::Contact and Bric::Biz::Attribute::Contact objects to reflect what is in the database. Notes: NONE.

PRIVATE

Private Class Methods

NONE.

Private Instance Methods

NONE.

Private Functions

Function used by lookup() and list() to return a list of Bric::Biz::Contact objects or, if called with an optional third argument, returns a listof Bric::Biz::Contact object IDs (used by list_ids()). Throws:

*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to select column into arrayref.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle. Side Effects: NONE. Notes: NONE. Function used by list_types(), href_types(), list_alertable_types(), href_alertable_types(), and href_alertable_type_ids() to return an anonymous array or anonymous hash of contact types. The arguments are as follows:
*
If no arguments are passed, a simple list of contact type names is returned.
*
The first argument requires that a hash list or anonymous hash be returned, where the hash keys are the contact type names and the values are the contact type descriptions.
*
The second argument specifies that the values returned by the the method reflect only those contact types that are alertable.
*
The third argument specifies that the hash values returned by the inclusion of the second argument be the contact type IDs, rather than their descriptions. Throws:
*
Unable to prepare SQL statement.
*
Unable to connect to database.
*
Unable to execute SQL statement.
*
Unable to bind to columns to statement handle.
*
Unable to fetch row from statement handle. Side Effects: NONE. Notes: NONE.

NOTES

NONE.

AUTHOR

David Wheeler <david@wheeler.net>

SEE ALSO

Bric