Version 4 > Developer's Guide > Plugins and Frameworks > Contact Management

Contact Management

There are significant differences in the structure of address cards in v4. The contact record itself contains no contact information; the content information is in the attribute-like contact_info records. That makes it more extensible, and more flexible for security (access can be granted field-by-field rather than for whole cards.

The individual contact_info fields each have their own privacy settings (numeric, equivalent to access level), which supersede the privacy setting of the contact record itself.

However, it will complicate contact queries, especially on multiple fields. To get multiple contact fields as separate rows, do something like this:

select c.contact_id,c.name,i.name,i.value 
   from contact c, contact_info i 
   where i.contact_id=c.contact id and ...

To get multiple contact fields on a single row, do something like this:

select c.contact_id,c.name,phone.value,email.value
   from contact c
   left join contact_info email on email.contact_id=c.contact_id
   left join contact_info phone on phone.contact_id=c.contact id
   where email.name="email" and phone.name="phone" and ...

 To quickly get the contact fields for a particular contact record, use:

my %contact_info = $contact->get_info();

The v3 phone1 and phone2 fields have been replaced with phone and cell fields.

Address cards auto-validate their provstate settings, based on which country was selected.

Contact records can be attached to accounts or to contact records. The latter is used for things like:

  • location addresses
  • profile/directory addresses

This allows you to keep your accounting contacts and directory contacts more cleanly separated.

Contact Lists

V4 content objects can declare their own contact lists. By default, this is just the list of contact records connected to the content object - eg. the address(es) of a location.

Some content classes may want to overload this to get more comprehensive contact list handling. For example membership lists or event rosters can generate detailed contact lists for their memberships or attendees.

To fetch a contact list for a particular content object, use the following syntax:

my ($contact_list,$merge) = $content->contact_list(%option);

$contact_list will return as a ContactList object, containing a list of address cards. $merge will return with a hash of relevant data data that can can be used as merge codes, for example

'foo@bar.com' => {
    first_name=>"Boo",
    last_name=>"Jones",
    organization=>"Acme, Inc."
},
...etc.

If the contact list is for a particular email blast, you can pass the email object to contact_list(), ie.

my ($contact_list,$merge) = $content->contact_list(email=>$email_obj);

 

Then your contact_list method can make contextual decisions about who to include in the contact list based on the particulars of that blast.