\CGContactscontact

A contact has numerous properties (full name, nickname, title, company, division, role can belong to zero or more categories (which can be nested) and can have one or more objects some objects (name) can only exist once other objects can exist multiple times these objects each have a label and can be preferred names: if a fullname is set, it is used as the display name.

else if nickname is set, it is used as the display name else if a name object exists, it is formatted and used as the display name preferred: if no object of a certain type is set as 'preferred' then the first object of that type is returned. Multiple objects of a certain type can be preferred but only the first one will be returned when asking for the preferred object of a type. labels user defiend, but system may create numerous standard labels (i.e: home/work) labels cannot be empty.

Note: This class (and it's dependent classes) use heavy use of exceptions.

Summary

Methods
Properties
Constants
add_object()
count_objects()
get_object()
remove_object()
get_preferred_object()
set_preferred()
get_id()
get_feu_uid()
set_feu_uid()
get_guid()
set_guid()
get_fullname()
set_fullname()
get_image()
set_image()
get_logo()
set_logo()
get_nickname()
set_nickname()
get_company()
set_company()
get_title()
set_title()
get_role()
set_role()
set_name()
get_name()
remove_name()
get_display_name()
get_uuid()
get_status()
disable()
is_enabled()
set_note()
get_note()
add_email()
insert_add_email()
get_email()
get_preferred_email_obj()
get_preferred_email()
get_email_objects()
remove_email()
add_url()
insert_set_url()
get_url()
get_preferred_url()
get_url_objects()
remove_url()
add_im()
get_im()
get_preferred_im()
remove_im()
add_phone()
insert_add_phone()
get_phone_object()
get_phone_object_by_type()
get_phone()
get_phone_by_type()
get_phone_type()
get_preferred_phone_obj()
get_preferred_phone()
get_phone_objects()
remove_phone()
add_address()
insert_add_address()
get_address()
get_preferred_address()
get_address_objects()
remove_address()
add_coords()
get_coords()
get_preferred_coords()
remove_coords()
add_date()
get_date()
get_preferred_date()
get_date_objects()
remove_date()
add_category()
get_categories()
get_categories_full()
remove_category()
get_modified()
load()
load_by_guid()
exists()
validate()
save()
delete()
get_cge_address()
No public properties found
LABEL_NAME
STATUS_DISABLED
get_objects_by_type()
_update()
_insert()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

LABEL_NAME

LABEL_NAME

STATUS_DISABLED

STATUS_DISABLED

Methods

add_object()

add_object(\CGContacts\contact_sub $object) : void

Add an object to the contact

Parameters

\CGContacts\contact_sub $object

The object to add (must be a valid object)

count_objects()

count_objects(string $class_name) : int

Count the number of objects of a certain class

Parameters

string $class_name

Returns

int

get_object()

get_object(string $class_name, string $label) : \CGContacts\contact_sub

Get an object of a specific class with a specific label

Parameters

string $class_name
string $label

Returns

\CGContacts\contact_sub

remove_object()

remove_object(string $class_name, string $label) : void

Remove an object from the list

Parameters

string $class_name
string $label

get_preferred_object()

get_preferred_object(string $class_name) : \CGContacts\contact_sub

Get the preferred object of a certain class

Multiple objects of a class can be preferred. Or none. If no objects of the specified class are preferred, the first object of the specified class will be returned.

Parameters

string $class_name

Returns

\CGContacts\contact_sub

set_preferred()

set_preferred(string $class_name, string $label) : void

Set the preferred flag on an object (identified by class and label) to true automatically sets all other objects of that class to be non-preferred

Parameters

string $class_name
string $label

get_id()

get_id() : int

Return the id of thsi contact The id of a new (unsaved) object is null

Returns

int

get_feu_uid()

get_feu_uid() : int

Return the FEU uid attached to this contact (if any)

Returns

int

set_feu_uid()

set_feu_uid(int $uid)

Associate an FEU uid with this contact.

A 0 or negative value will remove the association.

Parameters

int $uid

get_guid()

get_guid() : string

Return the guid for this contact The guid is a unique, randomly generated string representing this contact.

Typically the guid is used in export formats like vcard

Returns

string

set_guid()

set_guid(string $str)

Set the GUID for this contact.

The GUID must be unique to all users. If none is specified, on save a uniqe GUID will be generated.

Parameters

string $str

get_fullname()

get_fullname() : string

Get the full name (if any) associated with this contact The full name may not be set.

Returns

string

set_fullname()

set_fullname(string $val) : void

Set the full name for this contact

Parameters

string $val

get_image()

get_image() : string

Get the image (if any) associated with this contact The image is stored as a data uri

Returns

string

set_image()

set_image(string $val) : void

Set the image for this contact

Parameters

string $val

A data uri to an image... the data uri must fit within 64k

get_logo()

get_logo() : string

Get the logo (if any) associated with this contact The image is stored as a data uri.

. maximum 64k

Returns

string

set_logo()

set_logo(string $val)

Get the logo (if any) associated with this contact The logo is stored as a data uri.

. maximum 64k

Parameters

string $val

get_nickname()

get_nickname() : string

Return the nickname (if any) associated with this contact

Returns

string

set_nickname()

set_nickname(string $val) : void

Set the nickname (or erase it) for this contact

Parameters

string $val

get_company()

get_company() : string

Return the company name (if any) associated with this contact

Returns

string

set_company()

set_company(string $val) : void

Set (or erase) the company name for this contact

Parameters

string $val

get_title()

get_title() : string

Return the title (if any) associated with this contact

Returns

string

set_title()

set_title(string $val) : void

Set (or erase) the title associated with this contact

Parameters

string $val

get_role()

get_role() : string

Get the role (if any) associated with this contact

Returns

string

set_role()

set_role(string $val)

Set (or erase) the role associated with this contact

Parameters

string $val

set_name()

set_name(string $prefix, string $first, string $middle, string $last, string $suffix) : void

Set the name associated with this contact

Parameters

string $prefix

The prefix (i.e: Mr, Mrs. Dr, etc)

string $first

The first name

string $middle

The middle name (optional)

string $last

The surname (optional)

string $suffix

The suffix (i.e: PHD, B.S., P.Geo)

get_name()

get_name() : \CGContacts\contact_sub

Return the name object (if any) associated with this contact

Returns

\CGContacts\contact_sub

remove_name()

remove_name() : void

Erase the name object (if any) associated with this contact

get_display_name()

get_display_name() : string

Get a displayable name If a name object exists, it's formatted value is returned otherwise, the full name, or nickname is returned whichever occurred first

Returns

string

get_uuid()

get_uuid() : string

alias for get_guid()

Returns

string

get_status()

get_status() : string

Get the status (if any) for this contact a non empty status indicates that the contact is disabled

Returns

string

disable()

disable() : void

Sets this contact to disabled.

is_enabled()

is_enabled() : bool

Test if the contact is disabled

Returns

bool

set_note()

set_note(string $val) : void

Set (or erase) the note associated with this contact Maximum size is 64k

Parameters

string $val

get_note()

get_note() : string

Return the note (if any) associated with this contact

Returns

string

add_email()

add_email(string $email, string $label, bool $preferred) : void

Add an email address to this contact

Multiple email objects with the same label are permitted. and multiple preferred are permitted in the database.

Parameters

string $email

The email address

string $label

The label

bool $preferred

Wether this is the preferred email address

insert_add_email()

insert_add_email(string $value, string $label, bool $preferred)

Set an email object with the specifiede label.

This method will first search email objects for the same label. if a match is found, it's value and preferred flag are updated. if no match is found, a new object is created.

Parameters

string $value
string $label
bool $preferred

get_email()

get_email(string $label) : string

Get an email address associated with the specified label.

Parameters

string $label

Returns

string

get_preferred_email_obj()

get_preferred_email_obj() : \CGContacts\contact_email

Return the preferred email object (if any)

Returns

\CGContacts\contact_email

get_preferred_email()

get_preferred_email() : string

Return the preferred email address (if any)

Returns

string

get_email_objects()

get_email_objects() : \CGContacts\contact_email[]

Return all of the email objects (if any)

Returns

\CGContacts\contact_email[]

remove_email()

remove_email(string $label) : void

Remove all the email addresses with the specified label

Parameters

string $label

add_url()

add_url(string $url, string $label, bool $preferred) : void

Add a url to the contact

Parameters

string $url
string $label
bool $preferred

insert_set_url()

insert_set_url(string $value) : void

Set the first URL object in the list to the specified value.

If no URL objects are found, insert one as a preferred URL.

Parameters

string $value

get_url()

get_url(string $label) : string

Get the first url with the specified label (if any)

Parameters

string $label

Returns

string

get_preferred_url()

get_preferred_url() : string

Get the preferred url (if any) with the specified label

Returns

string

get_url_objects()

get_url_objects() : \CGContacts\contact_url[]

Get the URL objects associated with this contact

Returns

\CGContacts\contact_url[]

remove_url()

remove_url(string $label) : void

Remove all of the url objects with the specified label

Parameters

string $label

add_im()

add_im(string $im, string $label, bool $preferred) : bool

Add an IM object to the contact

Parameters

string $im

(the IM value (i.e: facebook username))

string $label
bool $preferred

Returns

bool

get_im()

get_im(string $label) : string

Return the (first) IM with the specified label (if any)

Parameters

string $label

Returns

string

get_preferred_im()

get_preferred_im() : string

Get the preferred IM object (if any)

Returns

string

remove_im()

remove_im(string $label) : void

Remove all IM objects with the specified label

Parameters

string $label

add_phone()

add_phone(string $type, string $value, string $label, bool $preferred)

Add a phone number object of the specified type

Parameters

string $type

The type (one of voice,msg,fax,mobile,pager,video,satellite)

string $value
string $label
bool $preferred

insert_add_phone()

insert_add_phone(string $type, string $value, string $label, bool $preferred)

Set a phone object with the specifiede label and type.

This method will first search phone objects for the same label and type if a match is found, it's value and preferred flag are updated. if no match is found, a new object is created.

Parameters

string $type

The type (one of voice,msg,fax,mobile,pager,video,satellite)

string $value
string $label
bool $preferred

get_phone_object()

get_phone_object(string $label) : \CGContacts\contact_sub

Get the first phone object with the specified label (if any)

Parameters

string $label

Returns

\CGContacts\contact_sub

get_phone_object_by_type()

get_phone_object_by_type(string $type) : \CGContacts\contact_sub

Get first phone object of the specified type

Parameters

string $type

Returns

\CGContacts\contact_sub

get_phone()

get_phone(string $label) : string

Get the first phone number with the specified label This is useful for getting a number, note the type is not returned

Parameters

string $label

Returns

string

get_phone_by_type()

get_phone_by_type(string $type) : string

Get the first phone number of the specified type.

Parameters

string $type

Returns

string

get_phone_type()

get_phone_type(string $label) : string

Get the type of the first phone object with the specified label.

Parameters

string $label

Returns

string

get_preferred_phone_obj()

get_preferred_phone_obj() : \CGContacts\contact_sub

Get the first preferred phone object (if any)

Returns

\CGContacts\contact_sub

get_preferred_phone()

get_preferred_phone() : string

Get the preferred phone number (if any)

Returns

string

get_phone_objects()

get_phone_objects()

Get all of the phone objects associated with this contact.

remove_phone()

remove_phone(string $label) : void

Remove all phone numbers with the specified label

Parameters

string $label

add_address()

add_address(string $street, string $pobox, string $city, string $state, string $zip, string $country, string $label, bool $preferred)

Add an address object manually.

Any of the values may be empty (except label). However, at least one value must be specified.

Parameters

string $street
string $pobox
string $city
string $state
string $zip
string $country
string $label
bool $preferred

insert_add_address()

insert_add_address(string $street, string $pobox, string $city, string $state, string $zip, string $country, string $label, bool $preferred)

Update an address object with the specified label.

If no address object with that label exists, create a new address record.

Parameters

string $street
string $pobox
string $city
string $state
string $zip
string $country
string $label
bool $preferred

get_address()

get_address(string $label) : \CGContacts\contact_sub

Get an address with the specified label

Parameters

string $label

Returns

\CGContacts\contact_sub

get_preferred_address()

get_preferred_address() : \CGContacts\contact_sub

Return the preferred address

Returns

\CGContacts\contact_sub

get_address_objects()

get_address_objects() : \CGContacts\contact_address[]

Get all of the address objects associated with this contact.

Returns

\CGContacts\contact_address[]

remove_address()

remove_address(string $label) : void

Return all addresses with the specified label

Parameters

string $label

add_coords()

add_coords(float $lat, float $long, string $label, bool $preferred) : void

Add a coordinate set to the contact object

Parameters

float $lat

Latitude (must be between -180 and 180)

float $long

Longitude (must be between -180 and 180)

string $label
bool $preferred

get_coords()

get_coords(string $label) : \CGContacts\contact_sub

Get the coordinates with the specified label (if any)

Parameters

string $label

Returns

\CGContacts\contact_sub

get_preferred_coords()

get_preferred_coords() : \CGContacts\contact_sub

Get the preferred coordinates object (if any)

Returns

\CGContacts\contact_sub

remove_coords()

remove_coords(string $label) : void

Remove any coordinate objects wth the specified label

Parameters

string $label

add_date()

add_date(string $date, string $label, bool $preferred) : void

Add a date object (birthday, or anniversary) to the contact object

Parameters

string $date
string $label
bool $preferred

get_date()

get_date(string $label) : string

Get the date with the specified label (if any)

Parameters

string $label

Returns

string

get_preferred_date()

get_preferred_date() : string

Get the preferred date (if any)

Returns

string

get_date_objects()

get_date_objects() : \CGContacts\contact_date[]

Get all of the date objects associated with this contact.

Returns

\CGContacts\contact_date[]

remove_date()

remove_date(string $label) : void

Remove any date objects with the specified label

Parameters

string $label

add_category()

add_category(mixed $cat) : void

Add the the specified category to the contact object

Parameters

mixed $cat

(Either an integer category id, or \CGContacts\cateogry object)

get_categories()

get_categories() : int[]

Get the list of category ids that this contact belongs to (if any)

Returns

int[]

get_categories_full()

get_categories_full() : \CGContacts\contact[]

Get the list of category objects that this contact belongs to (if any)

Returns

\CGContacts\contact[]

remove_category()

remove_category(mixed $cat) : void

De-associate the specified category from the contact

Parameters

mixed $cat

(Either an integer category id, or \CGContacts\cateogry object)

get_modified()

get_modified() : int

Return the timestamp of the time this contact was last modified.

Returns

int

load()

load(int $id) : \CGcontacts\contact

Load the specified contact object.

The loaded object is cached so that subsequent requests for that contact will not hit the database

Parameters

int $id

The contact id

Returns

\CGcontacts\contact

load_by_guid()

load_by_guid(string $uid) : \CGContacts\contact

Load the specified content object (by unique id)

The loaded object is cached so that subsequent requests for that contact will not hit the database

Parameters

string $uid

The contact uid

Returns

\CGContacts\contact

exists()

exists(int $id)

A quick (lightweight) convenience method to test if a contact with the specified id exists

This method first checks the cache to see if the object exists, otherwise it does a simle query to the database.

Parameters

int $id

validate()

validate() : void

A method to validate the contact object (typically used before saving the object to the database)

This method validates that there is some sort of displayable name, and that there is at least one valid object exceptions are thrown on errors

save()

save() : void

Save this object to the database

First a validation check is performed, then depending upon if there is a valid contact id either an update, or an insert is performed. All static contact caches are cleared

delete()

delete() : void

Delete this contact object from the database

The contact object is completely removed from the database, and the contact id is erased, so that a subsequent save will result in a new insert Additionally, all caches are cleared

get_cge_address()

get_cge_address() : \CGContacts\cge_address

Get as much information as possible from the contact into a cge_address object

Returns

\CGContacts\cge_address

get_objects_by_type()

get_objects_by_type(string $class_name) : \CGContacts\contact_sub[]

Retrieve all of the objects of a certain type

Parameters

string $class_name

Returns

\CGContacts\contact_sub[]

_update()

_update() : void

A method to save an existing contact object to the database

_insert()

_insert() : void

A method to save a new contact object to the database