Google Shared Contacts Manager  1.0
Semestral project for BI-ZNF
ContactService Class Reference

Class provides CRUD functionality for Contacts. More...

Public Member Functions

 __construct (APIService $apis, OAuthService $oa, User $user)
 ContactService constructor. More...
 
 get ($id, $purge=false)
 Get single contact. More...
 
 getAll ($filter, $order, $purge=false)
 Get filtered & ordered list of contacts. More...
 
 create (Contact $c)
 Save new contact to Google Contacts. More...
 
 update (Contact $cn)
 Update the contact in Google Contacts. More...
 
 delete (Contact $cn, $recache=true)
 Delete the contact from Google Contacts. More...
 
 deleteBatch (array $ids)
 Delete a group of contacts from Google Contacts. More...
 
 saveProfilePhoto (Contact $c, SerializableImage $img)
 Save uploaded image as Contact's profile photo and send it to Google Contacts. More...
 
 getDomain ()
 Get domain of currently logged in administrator. More...
 
 getBaseTarget ()
 Get URL that is target for most of the requests. More...
 

Data Fields

const XMLNS_ATOM = "http://www.w3.org/2005/Atom"
 
const XMLNS_GD = "http://schemas.google.com/g/2005"
 
const XML_SCHEMA = "http://schemas.google.com/g/2005#kind"
 
const XML_TERM = "http://schemas.google.com/contact/2008#contact"
 
const DEFAULT_CONTACT_DESCRIPTION = "Domain Shared Contact created with http://gshared-contacts.appspot.com/"
 
const CACHE_EXPIRATION = "10 minutes"
 

Private Member Functions

 getNewPhotoURL (\SimpleXMLElement &$xml)
 Get target url for profile photo upload from the XML response. More...
 
 singleContactFromXML (\SimpleXMLElement &$xml)
 Parse XML response as a single contact. More...
 
 parseContact (\SimpleXMLElement &$xc, Contact &$c)
 Parse contact attributes to contact object representation. More...
 
 contactToXML (Contact &$contact)
 Convert contact to XML. More...
 
 setPhoto (\SimpleXMLElement &$xc, Contact &$c)
 Parse contact and get its profile photo. More...
 
 getProfilePhoto ($target)
 Receive profile photo from Google. More...
 
 prepareContacts ($filter, $order, &$contacts)
 Filter & order the list of contacts according to criteria. More...
 
 filterContacts (array $filters, &$contacts)
 Apply filters to the list of Contacts. More...
 
 isMatch (Contact $c, array &$f)
 Determine whether the contact matches filter criteria or not. More...
 
 isEmailMatch ($emails, $query)
 Determine whether any of the emails match the filter criteria. More...
 
 isPhoneMatch ($phones, $query)
 Determine whether any of the phone numbers match the filter criteria. More...
 

Private Attributes

 $apis
 
 $oauth
 
 $cache
 
 $user
 

Detailed Description

Class provides CRUD functionality for Contacts.

Constructor & Destructor Documentation

◆ __construct()

__construct ( APIService  $apis,
OAuthService  $oa,
User  $user 
)

ContactService constructor.

Parameters
APIService$apis
OAuthService$oa
User$user

Member Function Documentation

◆ contactToXML()

contactToXML ( Contact $contact)
private

Convert contact to XML.

Parameters
Contact$contact
Returns

◆ create()

create ( Contact  $c)

Save new contact to Google Contacts.

Parameters
Contact$c
Returns
Contact

◆ delete()

delete ( Contact  $cn,
  $recache = true 
)

Delete the contact from Google Contacts.

Parameters
Contact$cn
bool$recacheWhether removed contact should be removed from cache

◆ deleteBatch()

deleteBatch ( array  $ids)

Delete a group of contacts from Google Contacts.

Parameters
array$ids

◆ filterContacts()

filterContacts ( array  $filters,
$contacts 
)
private

Apply filters to the list of Contacts.

Parameters
array$filters
Contact[]$contacts

◆ get()

get (   $id,
  $purge = false 
)

Get single contact.

Parameters
string$idID of an existing Contact
bool$purgeWhether cache should be updated
Returns
Contact|null

◆ getAll()

getAll (   $filter,
  $order,
  $purge = false 
)

Get filtered & ordered list of contacts.

Parameters
array$filterRules to filter the contacts
array$orderRules to order the contacts
bool$purgeWhether cache should be updated
Returns
array|null

◆ getBaseTarget()

getBaseTarget ( )

Get URL that is target for most of the requests.

Returns
string

◆ getDomain()

getDomain ( )

Get domain of currently logged in administrator.

Returns
string

◆ getNewPhotoURL()

getNewPhotoURL ( \SimpleXMLElement &  $xml)
private

Get target url for profile photo upload from the XML response.

Parameters
\SimpleXMLElement$xml
Returns
string

◆ getProfilePhoto()

getProfilePhoto (   $target)
private

Receive profile photo from Google.

Parameters
$target
Returns
SerializableImage

◆ isEmailMatch()

isEmailMatch (   $emails,
  $query 
)
private

Determine whether any of the emails match the filter criteria.

Parameters
EmailAttribute[]$emails
string$query
Returns
bool

◆ isMatch()

isMatch ( Contact  $c,
array &  $f 
)
private

Determine whether the contact matches filter criteria or not.

Parameters
Contact$c
array$f
Returns
bool

◆ isPhoneMatch()

isPhoneMatch (   $phones,
  $query 
)
private

Determine whether any of the phone numbers match the filter criteria.

Parameters
PhoneAttribute[]$phones
string$query
Returns
bool

◆ parseContact()

parseContact ( \SimpleXMLElement &  $xc,
Contact $c 
)
private

Parse contact attributes to contact object representation.

Parameters
\SimpleXMLElement$xc
Contact$c

◆ prepareContacts()

prepareContacts (   $filter,
  $order,
$contacts 
)
private

Filter & order the list of contacts according to criteria.

Parameters
array$filterFilter rules
array$orderOrder rule
Contact[]$contacts
Returns
Contact[]|null

◆ saveProfilePhoto()

saveProfilePhoto ( Contact  $c,
SerializableImage  $img 
)

Save uploaded image as Contact's profile photo and send it to Google Contacts.

Parameters
Contact$c
SerializableImage$img

◆ setPhoto()

setPhoto ( \SimpleXMLElement &  $xc,
Contact $c 
)
private

Parse contact and get its profile photo.

Parameters
\SimpleXMLElement$xc
Contact$c

◆ singleContactFromXML()

singleContactFromXML ( \SimpleXMLElement &  $xml)
private

Parse XML response as a single contact.

Parameters
\SimpleXMLElement$xml
Returns
Contact

◆ update()

update ( Contact  $cn)

Update the contact in Google Contacts.

Parameters
Contact$cn

Field Documentation

◆ $apis

$apis
private

◆ $cache

$cache
private

◆ $oauth

$oauth
private

◆ $user

$user
private

◆ CACHE_EXPIRATION

const CACHE_EXPIRATION = "10 minutes"

◆ DEFAULT_CONTACT_DESCRIPTION

const DEFAULT_CONTACT_DESCRIPTION = "Domain Shared Contact created with http://gshared-contacts.appspot.com/"

◆ XML_SCHEMA

const XML_SCHEMA = "http://schemas.google.com/g/2005#kind"

◆ XML_TERM

const XML_TERM = "http://schemas.google.com/contact/2008#contact"

◆ XMLNS_ATOM

const XMLNS_ATOM = "http://www.w3.org/2005/Atom"

◆ XMLNS_GD

const XMLNS_GD = "http://schemas.google.com/g/2005"

The documentation for this class was generated from the following file: