PHP Class Turba_Driver, horde

Author: Chuck Hagenbuch ([email protected])
Author: Jon Parise ([email protected])
Inheritance: implements Countable
Afficher le fichier Open project: horde/horde Class Usage Examples

Méthodes publiques

Свойство Type Description
$alternativeName string The name of a field to use as an alternative to the name field if that one is empty.
$approximate array Array of fields to search "approximately" (@see config/backends.php).
$fields array List of all fields that can be accessed in the backend (excludes composite attributes, etc.).
$listNameField string The name of a field to store contact list names in if not the default.
$map array Hash describing the mapping between Turba attributes and driver-specific fields.
$strict array Array of fields that must match exactly.
$tabs array Hash with all tabs and their fields.
$title string The symbolic title of this source.

Protected Properties

Свойство Type Description
$_asMap array Mapping of Turba attributes to ActiveSync fields.
$_capabilities array What can this backend do?
$_contact_owner string Hold the value for the owner of this address book.
$_count integer Number of contacts in this source.
$_name string The internal name of this source.
$_objectOptions array Any additional options passed to Turba_Object constructors.
$_params array Hash holding the driver's additional parameters.

Méthodes publiques

Méthode Description
__construct ( string $name = '', array $params = [] ) Constructs a new Turba_Driver object.
add ( array $attributes ) : string Adds a new entry to the contact source.
canAdd ( ) : boolean Returns ability of the backend to add new contacts.
checkDefaultShare ( Horde_Share_Object $share, array $srcconfig ) : boolean Check if the passed in share is the default share for this source.
count ( ) : integer Returns the number of contacts of the current user in this address book.
createShare ( string $share_name, array $params ) : Horde_Share Creates a new Horde_Share for this source type.
delete ( string $object_id, boolean $remove_tags = true ) Deletes the specified entry from the contact source.
deleteAll ( string $sourceName = null ) Deletes all contacts from an address book.
fromASContact ( Horde_ActiveSync_Message_Contact $message ) : array Convert an ActiveSync contact message into a hash suitable for importing via self::add().
getBlobs ( ) : array Returns the attributes that are blob types.
getContactOwner ( ) : string Return the owner to use when searching or creating contacts in this address book.
getCriteria ( ) : array Returns the criteria available for this source except '__key'.
getDateFields ( ) : array Returns the attributes that represent dates.
getFields ( ) : array Returns all non-composite fields for this source. Useful for importing and exporting data, etc.
getName ( ) Return the name of this address book.
getObject ( string $objectId ) : Turba_Object Retrieves one object from the source.
getObjects ( array $objectIds ) : array Retrieves a set of objects from the source.
getParams ( ) : array Returns the current driver's additional parameters.
getTimeObjectTurbaList ( Horde_Date $start, Horde_Date $end, string $field ) : Turba_List Default implementation for obtaining a Turba_List to get TimeObjects out of.
hasCapability ( string $capability ) : boolean Checks if this backend has a certain capability.
hasPermission ( integer $perm ) : boolean Checks if the current user has the requested permissions on this address book.
listTimeObjects ( Horde_Date $start, Horde_Date $end, string $category ) : array Returns a list of birthday or anniversary hashes from this source for a certain period.
makeSearch ( array $criteria, string $search_type, array $strict, boolean $match_begin = false, array $custom_strict = [] ) : array Takes a hash of Turba key => search value and return a (possibly nested) array, using backend attribute names, that can be turned into a search by the driver. The translation is based on the contents of $this->map, and includes nested OR searches for composite fields.
removeUserData ( string $user ) Remove all entries owned by the specified user.
save ( Turba_Object $object ) : string Modifies an existing entry in the contact source.
search ( array $search_criteria, string $sort_order = null, string $search_type = 'AND', array $return_fields = [], array $custom_strict = [], boolean $match_begin = false, boolean $count_only = false ) : mixed Searches the source based on the provided criteria.
searchDuplicates ( ) : array Searches the current address book for duplicate entries.
setContactOwner ( string $owner ) Override the contactOwner setting for this driver.
setDefaultShare ( string $share ) Runs any actions after setting a new default tasklist.
setSourceName ( string $name ) Override the name setting for this driver.
synchronize ( mixed $token = false ) Synchronize, if needed.
toASContact ( Turba_Object $object, array $options = [] ) : Horde_ActiveSync_Message_Contact Convert the contact to an ActiveSync contact message
toDriver ( string $attribute ) : string Translates a single Turba attribute to the driver-specific counterpart. The translation is based on the contents of $this->map. This ignores composite fields.
toDriverKeys ( array $hash ) : array Translates the keys of the first hash from the generalized Turba attributes to the driver-specific fields. The translation is based on the contents of $this->map.
toHash ( Horde_Icalendar_Vcard $vcard ) : array Function to convert a Horde_Icalendar_Vcard object into a Turba Object Hash with Turba attributes suitable as a parameter for add().
toTurbaKeys ( array $entry ) : array Translates a hash from being keyed on driver-specific fields to being keyed on the generalized Turba attributes. The translation is based on the contents of $this->map.
tovCard ( Turba_Object $object, string $version = '2.1', array $fields = null, boolean $skipEmpty = false ) : Horde_Icalendar_Vcard Exports a given Turba_Object as an iCalendar vCard.

Méthodes protégées

Méthode Description
_add ( array $attributes, array $blob_fields = [], array $date_fields = [] ) Adds the specified contact to the addressbook.
_canAdd ( ) : boolean Returns ability of the backend to add new contacts.
_delete ( string $object_key, string $object_id ) Deletes the specified contact from the addressbook.
_deleteAll ( ) : array Deletes all contacts from an address book.
_filterTags ( array $objects, array $tags, Array $sort_order = null ) : Turba_List Returns a Turba_List object containing $objects filtered by $tags.
_getContactOwner ( ) : string Return the owner to use when searching or creating contacts in this address book.
_getTimeObjectTurbaListFallback ( Horde_Date $start, Horde_Date $end, string $field ) : Turba_List Default implementation for obtaining a Turba_List to get TimeObjects out of.
_guessName ( array &$hash ) Helper function for guessing name parts from a single name string.
_hasValEnum ( array $valEnum, string $type ) : boolean Returns whether a ValEnum entry from a DevInf object contains a certain type.
_init ( ) Initialize the driver.
_makeKey ( array $attributes ) : string Creates an object key for a new object.
_makeUid ( ) : string Creates an object UID for a new object.
_read ( string $key, mixed $ids, string $owner, array $fields, array $blobFields = [], array $dateFields = [] ) : array Reads the given data from the address book and returns the results.
_save ( Turba_Object $object ) : string Saves the specified object in the SQL database.
_search ( array $criteria, array $fields, array $blobFields = [], boolean $count_only = false ) : array Searches the address book with the given criteria and returns a filtered list of results. If the criteria parameter is an empty array, all records will be returned.
_toTurbaObjects ( array $objects, array $sort_order = null ) : Turba_List Takes an array of object hashes and returns a Turba_List containing the correct Turba_Objects

Method Details

__construct() public méthode

Constructs a new Turba_Driver object.
public __construct ( string $name = '', array $params = [] )
$name string Source name
$params array Hash containing additional configuration parameters.

_add() protected méthode

Adds the specified contact to the addressbook.
protected _add ( array $attributes, array $blob_fields = [], array $date_fields = [] )
$attributes array The attribute values of the contact.
$blob_fields array Fields that represent binary data.
$date_fields array Fields that represent dates. @since 4.2.0

_canAdd() protected méthode

Returns ability of the backend to add new contacts.
protected _canAdd ( ) : boolean
Résultat boolean Can backend add?

_delete() protected méthode

Deletes the specified contact from the addressbook.
protected _delete ( string $object_key, string $object_id )
$object_key string TODO
$object_id string TODO

_deleteAll() protected méthode

Deletes all contacts from an address book.
protected _deleteAll ( ) : array
Résultat array An array of UIDs that have been deleted.

_filterTags() protected méthode

Returns a Turba_List object containing $objects filtered by $tags.
protected _filterTags ( array $objects, array $tags, Array $sort_order = null ) : Turba_List
$objects array A hash of objects, as returned by self::_search.
$tags array An array of tags to filter by.
$sort_order Array The sort order to pass to Turba_List::sort.
Résultat Turba_List The filtered Turba_List object.

_getContactOwner() protected méthode

Return the owner to use when searching or creating contacts in this address book.
protected _getContactOwner ( ) : string
Résultat string Contact owner.

_getTimeObjectTurbaListFallback() protected méthode

Default implementation for obtaining a Turba_List to get TimeObjects out of.
protected _getTimeObjectTurbaListFallback ( Horde_Date $start, Horde_Date $end, string $field ) : Turba_List
$start Horde_Date The starting date.
$end Horde_Date The ending date.
$field string The address book field containing the timeObject information (birthday, anniversary).
Résultat Turba_List A list of objects.

_guessName() protected méthode

Helper function for guessing name parts from a single name string.
protected _guessName ( array &$hash )
$hash array The attributes array.

_hasValEnum() protected méthode

Returns whether a ValEnum entry from a DevInf object contains a certain type.
protected _hasValEnum ( array $valEnum, string $type ) : boolean
$valEnum array A ValEnum hash.
$type string A requested attribute type.
Résultat boolean True if $type exists in $valEnum.

_init() protected méthode

Initialize the driver.
protected _init ( )

_makeKey() protected méthode

Creates an object key for a new object.
protected _makeKey ( array $attributes ) : string
$attributes array The attributes (in driver keys) of the object being added.
Résultat string A unique ID for the new object.

_makeUid() protected méthode

Creates an object UID for a new object.
protected _makeUid ( ) : string
Résultat string A unique ID for the new object.

_read() protected méthode

Reads the given data from the address book and returns the results.
protected _read ( string $key, mixed $ids, string $owner, array $fields, array $blobFields = [], array $dateFields = [] ) : array
$key string The primary key field to use.
$ids mixed The ids of the contacts to load.
$owner string Only return contacts owned by this user.
$fields array List of fields to return.
$blobFields array Array of fields containing binary data.
$dateFields array Array of fields containing date data. @since 4.2.0
Résultat array Hash containing the search results.

_save() protected méthode

Saves the specified object in the SQL database.
protected _save ( Turba_Object $object ) : string
$object Turba_Object The object to save
Résultat string The object id, possibly updated.

_toTurbaObjects() protected méthode

Takes an array of object hashes and returns a Turba_List containing the correct Turba_Objects
protected _toTurbaObjects ( array $objects, array $sort_order = null ) : Turba_List
$objects array An array of object hashes (keyed to backend).
$sort_order array Array of hashes describing sort fields. Each hash has the following fields:
ascending - (boolean) Indicating sort direction.
field - (string) Sort field.
Résultat Turba_List A list object.

add() public méthode

Adds a new entry to the contact source.
public add ( array $attributes ) : string
$attributes array The attributes of the new object to add.
Résultat string The new __key value on success.

canAdd() public méthode

Returns ability of the backend to add new contacts.
public canAdd ( ) : boolean
Résultat boolean Can backend add?

checkDefaultShare() public méthode

Check if the passed in share is the default share for this source.
public checkDefaultShare ( Horde_Share_Object $share, array $srcconfig ) : boolean
$share Horde_Share_Object The share object.
$srcconfig array The cfgSource entry for the share.
Résultat boolean TODO

count() public méthode

Returns the number of contacts of the current user in this address book.
public count ( ) : integer
Résultat integer The number of contacts that the user owns.

createShare() public méthode

Creates a new Horde_Share for this source type.
public createShare ( string $share_name, array $params ) : Horde_Share
$share_name string The share name
$params array The params for the share.
Résultat Horde_Share The share object.

delete() public méthode

Deletes the specified entry from the contact source.
public delete ( string $object_id, boolean $remove_tags = true )
$object_id string The ID of the object to delete.
$remove_tags boolean Remove tags if true.

deleteAll() public méthode

Deletes all contacts from an address book.
public deleteAll ( string $sourceName = null )
$sourceName string The identifier of the address book to delete. If omitted, will clear the current user's 'default' address book for this source type.

fromASContact() public méthode

Convert an ActiveSync contact message into a hash suitable for importing via self::add().
public fromASContact ( Horde_ActiveSync_Message_Contact $message ) : array
$message Horde_ActiveSync_Message_Contact The contact message object.
Résultat array A contact hash.

getBlobs() public méthode

Returns the attributes that are blob types.
public getBlobs ( ) : array
Résultat array List of blob attributes in the array keys.

getContactOwner() public méthode

Return the owner to use when searching or creating contacts in this address book.
public getContactOwner ( ) : string
Résultat string Contact owner.

getCriteria() public méthode

Returns the criteria available for this source except '__key'.
public getCriteria ( ) : array
Résultat array An array containing the criteria.

getDateFields() public méthode

Returns the attributes that represent dates.
Since: 4.2.0
public getDateFields ( ) : array
Résultat array List of date attributes in the array keys.

getFields() public méthode

Returns all non-composite fields for this source. Useful for importing and exporting data, etc.
public getFields ( ) : array
Résultat array The field list.

getName() public méthode

(This is the key into the cfgSources array)
public getName ( )

getObject() public méthode

Retrieves one object from the source.
public getObject ( string $objectId ) : Turba_Object
$objectId string The unique id of the object to retrieve.
Résultat Turba_Object The retrieved object.

getObjects() public méthode

Retrieves a set of objects from the source.
public getObjects ( array $objectIds ) : array
$objectIds array The unique ids of the objects to retrieve.
Résultat array The array of retrieved objects (Turba_Objects).

getParams() public méthode

Returns the current driver's additional parameters.
public getParams ( ) : array
Résultat array Hash containing the driver's additional parameters.

getTimeObjectTurbaList() public méthode

Default implementation for obtaining a Turba_List to get TimeObjects out of.
public getTimeObjectTurbaList ( Horde_Date $start, Horde_Date $end, string $field ) : Turba_List
$start Horde_Date The starting date.
$end Horde_Date The ending date.
$field string The address book field containing the timeObject information (birthday, anniversary).
Résultat Turba_List A list of objects.

hasCapability() public méthode

Checks if this backend has a certain capability.
public hasCapability ( string $capability ) : boolean
$capability string The capability to check for.
Résultat boolean Supported or not.

hasPermission() public méthode

Checks if the current user has the requested permissions on this address book.
public hasPermission ( integer $perm ) : boolean
$perm integer The permission to check for.
Résultat boolean True if the user has permission, otherwise false.

listTimeObjects() public méthode

Returns a list of birthday or anniversary hashes from this source for a certain period.
public listTimeObjects ( Horde_Date $start, Horde_Date $end, string $category ) : array
$start Horde_Date The start date of the valid period.
$end Horde_Date The end date of the valid period.
$category string The timeObjects category to return.
Résultat array A list of timeObject hashes.

makeSearch() public méthode

Takes a hash of Turba key => search value and return a (possibly nested) array, using backend attribute names, that can be turned into a search by the driver. The translation is based on the contents of $this->map, and includes nested OR searches for composite fields.
public makeSearch ( array $criteria, string $search_type, array $strict, boolean $match_begin = false, array $custom_strict = [] ) : array
$criteria array Hash of criteria using Turba keys.
$search_type string OR search or AND search?
$strict array Fields that must be matched exactly.
$match_begin boolean Whether to match only at beginning of words.
$custom_strict array Custom set of fields that are to matched exactly, but are glued using $search_type and 'AND' together with $strict fields. Allows an 'OR' search pm a custom set of $strict fields.
Résultat array An array of search criteria.

removeUserData() public méthode

Remove all entries owned by the specified user.
public removeUserData ( string $user )
$user string The user's data to remove.

save() public méthode

Modifies an existing entry in the contact source.
public save ( Turba_Object $object ) : string
$object Turba_Object The object to update.
Résultat string The object id, possibly updated.

searchDuplicates() public méthode

Duplicates are determined by comparing email and name or last name and first name values.
public searchDuplicates ( ) : array
Résultat array A hash with the following format: array('name' => array('John Doe' => Turba_List, ...), ...)

setContactOwner() public méthode

Override the contactOwner setting for this driver.
public setContactOwner ( string $owner )
$owner string The contact owner.

setDefaultShare() public méthode

Runs any actions after setting a new default tasklist.
public setDefaultShare ( string $share )
$share string The default share ID.

setSourceName() public méthode

Override the name setting for this driver.
public setSourceName ( string $name )
$name string The source name. This is the key into the $cfgSources array.

synchronize() public méthode

Synchronize, if needed.
public synchronize ( mixed $token = false )
$token mixed A value indicating the last synchronization point, if available.

toASContact() public méthode

Convert the contact to an ActiveSync contact message
public toASContact ( Turba_Object $object, array $options = [] ) : Horde_ActiveSync_Message_Contact
$object Turba_Object The turba object to convert
$options array Options: - protocolversion: (float) The EAS version to support DEFAULT: 2.5 - bodyprefs: (array) A BODYPREFERENCE array. DEFAULT: none (No body prefs enforced). - truncation: (integer) Truncate event body to this length DEFAULT: none (No truncation). - device: (Horde_ActiveSync_Device) The device object.
Résultat Horde_ActiveSync_Message_Contact

toDriver() public méthode

Translates a single Turba attribute to the driver-specific counterpart. The translation is based on the contents of $this->map. This ignores composite fields.
public toDriver ( string $attribute ) : string
$attribute string The Turba attribute to translate.
Résultat string The driver name for this attribute.

toDriverKeys() public méthode

Translates the keys of the first hash from the generalized Turba attributes to the driver-specific fields. The translation is based on the contents of $this->map.
public toDriverKeys ( array $hash ) : array
$hash array Hash using Turba keys.
Résultat array Translated version of $hash.

toHash() public méthode

Function to convert a Horde_Icalendar_Vcard object into a Turba Object Hash with Turba attributes suitable as a parameter for add().
See also: add()
public toHash ( Horde_Icalendar_Vcard $vcard ) : array
$vcard Horde_Icalendar_Vcard The Horde_Icalendar_Vcard object to parse.
Résultat array A Turba attribute hash.

toTurbaKeys() public méthode

Translates a hash from being keyed on driver-specific fields to being keyed on the generalized Turba attributes. The translation is based on the contents of $this->map.
public toTurbaKeys ( array $entry ) : array
$entry array A hash using driver-specific keys.
Résultat array Translated version of $entry.

tovCard() public méthode

Exports a given Turba_Object as an iCalendar vCard.
public tovCard ( Turba_Object $object, string $version = '2.1', array $fields = null, boolean $skipEmpty = false ) : Horde_Icalendar_Vcard
$object Turba_Object Turba_Object.
$version string The vcard version to produce.
$fields array Hash of field names and Horde_SyncMl_Property properties with the requested fields.
$skipEmpty boolean Whether to skip empty fields.
Résultat Horde_Icalendar_Vcard A vcard object.

Property Details

$_asMap protected_oe static_oe property

Mapping of Turba attributes to ActiveSync fields.
protected static array $_asMap
Résultat array

$_capabilities protected_oe property

What can this backend do?
protected array $_capabilities
Résultat array

$_contact_owner protected_oe property

Hold the value for the owner of this address book.
protected string $_contact_owner
Résultat string

$_count protected_oe property

Number of contacts in this source.
protected int $_count
Résultat integer

$_name protected_oe property

The internal name of this source.
protected string $_name
Résultat string

$_objectOptions protected_oe property

Any additional options passed to Turba_Object constructors.
protected array $_objectOptions
Résultat array

$_params protected_oe property

Hash holding the driver's additional parameters.
protected array $_params
Résultat array

$alternativeName public_oe property

The name of a field to use as an alternative to the name field if that one is empty.
public string $alternativeName
Résultat string

$approximate public_oe property

Array of fields to search "approximately" (@see config/backends.php).
public array $approximate
Résultat array

$fields public_oe property

List of all fields that can be accessed in the backend (excludes composite attributes, etc.).
public array $fields
Résultat array

$listNameField public_oe property

The name of a field to store contact list names in if not the default.
public string $listNameField
Résultat string

$map public_oe property

Hash describing the mapping between Turba attributes and driver-specific fields.
public array $map
Résultat array

$strict public_oe property

Array of fields that must match exactly.
public array $strict
Résultat array

$tabs public_oe property

Hash with all tabs and their fields.
public array $tabs
Résultat array

$title public_oe property

The symbolic title of this source.
public string $title
Résultat string