Bric::Biz::Contact(3p)User Contributed Perl DocumentatioBric::Biz::Contact(3p)



NAME
       Bric::Biz::Contact - Interface to Contacts

VERSION
       $LastChangedRevision$

DATE
       $LastChangedDate: 2006-03-18 01:26:34 +0100 (Sat, 18 Mar 2006) $

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
       my $c = Bric::Biz::Contact->new()
       my $c = Bric::Biz::Contact->new($init)
           Instantiates a Bric::Biz::Contact object. An anonymous hash of
           initial values may be passed. The supported initial value keys are:

           o   type

           o   value

           The active property will be set to true by default. Call $c->save()
           to save the new object.

           Throws:

           o   Incorrect number of args to Bric::_set().

           o   Bric::set() - Problems setting fields.

           Side Effects: NONE.

           Notes: NONE.

       my $c = Bric::Biz::Contact->lookup({ id => $id })
           Looks up and instantiates a new Bric::Biz::Contact object based on
           the Bric::Biz::Contact object ID passed. If $id is not found in the
           database, lookup() returns undef.

           Throws:

           o   Too many Bric::Biz::Contact objects found.

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           Side Effects: If $id is found, populates the new Bric::Biz::Contact
           object with data from the database before returning it.

           Notes: NONE.

       my (@contacts || $contact_aref) = Bric::Biz::Contact->list($params)
           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:

           id  Contact ID. May use "ANY" for a list of possible values.

           type
               Contact type. May use "ANY" for a list of possible values.

           description
               Contact description. May use "ANY" for a list of possible
               values.

           value
               Contact value. May use "ANY" for a list of possible values.

           person_id
               ID of person object associated with contacts. May use "ANY" for
               a list of possible values.

           alertable
               Boolean indicating whether or not alerts can be sent to
               contacts of this type.

           Throws:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   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.

       my $contacts_href = Bric::Biz::Contact->href($params)
           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:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   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
       my (@c_ids || $c_ids_aref) = Bric::Biz::Contact->list_ids($params)
           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:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           Side Effects: NONE.

           Notes: NONE.

       $meths = Bric::Biz::Conatact->my_meths
       (@meths || $meths_aref) = Bric::Biz::Contact->my_meths(TRUE)
       my (@meths || $meths_aref) = Bric::Biz:::Contact->my_meths(0, TRUE)
           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 "id", 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.

       my (@types || $type_aref) = Bric::Biz::Contact->list_types
           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
           $c->set_type().

           Throws:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           Side Effects: NONE.

           Notes: NONE.

       my $type_href = Bric::Biz::Contact->href_types
           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:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           Side Effects: NONE.

           Notes: NONE.

       my (@types || $type_aref) = Bric::Biz::Contact->list_alertable_types
           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:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           Side Effects: NONE.

           Notes: NONE.

       my $types_aref = Bric::Biz::Contact->href_alertable_types
           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:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           Side Effects: NONE.

           Notes: NONE.

       my $types_aref = Bric::Biz::Contact->href_alertable_type_ids
           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:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           Side Effects: NONE.

           Notes: NONE.

       my $success = Bric::Biz::Contact->edit_type($type, $description)
           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:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to execute SQL statement.

           Side Effects: NONE.

           Notes: NONE.

       my $success = Bric::Biz::Contact->deactivate_type($type)
           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:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to execute SQL statement.

           Side Effects: NONE.

           Notes: NONE.

   Public Instance Methods
       my $id = $c->get_id
           Returns the ID of the Bric::Biz::Contact object.

           Throws:

           o   Bad AUTOLOAD method format.

           o   Cannot AUTOLOAD private methods.

           o   Access denied: READ access for field 'id' required.

           o   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 "save"d, the object will
           not yet have an ID, so this method call will return undef.

       my $type = $c->get_type
           Returns the type of the Bric::Biz::Contact object.

           Throws:

           o   Bad AUTOLOAD method format.

           o   Cannot AUTOLOAD private methods.

           o   Access denied: READ access for field 'type' required.

           o   No AUTOLOAD method.

           Side Effects: NONE.

           Notes: NONE.

       $self = $c->set_type($type)
           Sets the type type of the contact. The type type must be a valid
           type as returned by get_types().

           Throws:

           o   Incorrect number of args to Bric::_set().

           o   Bric::set() - Problems setting fields.

           Side Effects: NONE.

           Notes: NONE.

       my $description = $c->get_description
           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:

           o   Bad AUTOLOAD method format.

           o   Cannot AUTOLOAD private methods.

           o   Access denied: READ access for field 'description' required.

           o   No AUTOLOAD method.

           Side Effects: NONE.

           Notes: NONE.

       my $value =  $c->get_value
           Returns the value of the Bric::Biz::Contact object.

           Throws:

           o   Bad AUTOLOAD method format.

           o   Cannot AUTOLOAD private methods.

           o   Access denied: READ access for field 'value' required.

           o   No AUTOLOAD method.

           Side Effects: NONE.

           Notes: NONE.

       $self = $c->set_value($value)
           Sets the value of the Bric::Biz::Contact object. Returns $self on
           success and undef on failure.

           Throws:

           o   Bad AUTOLOAD method format.

           o   Cannot AUTOLOAD private methods.

           o   Access denied: WRITE access for field 'value' required.

           o   No AUTOLOAD method.

           Side Effects: NONE.

           Notes: NONE.

       $self = $c->activate
           Activates the Bric::Biz::Contact object. Call $p->save to make the
           change persistent. Bric::Biz::Contact objects instantiated by new()
           are active by default.

           Throws:

           o   Incorrect number of args to Bric::_set().

           o   Bric::set() - Problems setting fields.

           Side Effects: NONE.

           Notes: NONE.

       $self = $c->deactivate
           Deactivates (deletes) the Bric::Biz::Contact object. Call $p->save
           to make the change persistent.

           Throws:

           o   Incorrect number of args to Bric::_set().

           o   Bric::set() - Problems setting fields.

           Side Effects: NONE.

           Notes: NONE.

       $self = $c->is_active
           Returns $self if the Bric::Biz::Contact object is active, and undef
           if it is not.

           Throws:

           o   Bric::_get() - Problems retrieving fields.

           Side Effects: NONE.

           Notes: NONE.

       $self = $p->save
           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 $self on success
           and undef on failure.

           Throws:

           o   Bric::_get() - Problems retrieving fields.

           o   Unable to connect to database.

           o   Unable to prepare SQL statement.

           o   Unable to execute SQL statement.

           o   Unable to select row.

           o   Incorrect number of args to _set.

           o   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
       my $contacts_aref = &$get_em( $pkg, $search_href )
       my $contacts_ids_aref = &$get_em( $pkg, $search_href, 1 )
           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:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to select column into arrayref.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           Side Effects: NONE.

           Notes: NONE.

       my (@types || $types_aref) = &$get_types()
       my (%types || $types_href) = &$get_types(1)
       my (@alertable_types || $alertable_types_aref) = &$get_types(undef, 1)
       my (%alertable_types || $alertable_types_href) = &$get_types(1, 1)
       my (%alertable_type_ids || $alertable_type_ids_href) = &$get_types(1,
       1, 1)
           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:

           o   If no arguments are passed, a simple list of contact type names
               is returned.

           o   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.

           o   The second argument specifies that the values returned by the
               the method reflect only those contact types that are alertable.

           o   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:

           o   Unable to prepare SQL statement.

           o   Unable to connect to database.

           o   Unable to execute SQL statement.

           o   Unable to bind to columns to statement handle.

           o   Unable to fetch row from statement handle.

           Side Effects: NONE.

           Notes: NONE.

NOTES
       NONE.

AUTHOR
       David Wheeler <david@justatheory.com>

SEE ALSO
       Bric



perl v5.12.2                      2006-03-17            Bric::Biz::Contact(3p)
