PHP Класс Turba_Driver, horde

Автор: Chuck Hagenbuch ([email protected])
Автор: Jon Parise ([email protected])
Наследование: implements Countable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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)

Свойство Тип Описание
$_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.

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
_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

Описание методов

__construct() публичный Метод

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

_add() защищенный Метод

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() защищенный Метод

Returns ability of the backend to add new contacts.
protected _canAdd ( ) : boolean
Результат boolean Can backend add?

_delete() защищенный Метод

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

_deleteAll() защищенный Метод

Deletes all contacts from an address book.
protected _deleteAll ( ) : array
Результат array An array of UIDs that have been deleted.

_filterTags() защищенный Метод

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.
Результат Turba_List The filtered Turba_List object.

_getContactOwner() защищенный Метод

Return the owner to use when searching or creating contacts in this address book.
protected _getContactOwner ( ) : string
Результат string Contact owner.

_getTimeObjectTurbaListFallback() защищенный Метод

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).
Результат Turba_List A list of objects.

_guessName() защищенный Метод

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

_hasValEnum() защищенный Метод

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.
Результат boolean True if $type exists in $valEnum.

_init() защищенный Метод

Initialize the driver.
protected _init ( )

_makeKey() защищенный Метод

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.
Результат string A unique ID for the new object.

_makeUid() защищенный Метод

Creates an object UID for a new object.
protected _makeUid ( ) : string
Результат string A unique ID for the new object.

_read() защищенный Метод

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
Результат array Hash containing the search results.

_save() защищенный Метод

Saves the specified object in the SQL database.
protected _save ( Turba_Object $object ) : string
$object Turba_Object The object to save
Результат string The object id, possibly updated.

_toTurbaObjects() защищенный Метод

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.
Результат Turba_List A list object.

add() публичный Метод

Adds a new entry to the contact source.
public add ( array $attributes ) : string
$attributes array The attributes of the new object to add.
Результат string The new __key value on success.

canAdd() публичный Метод

Returns ability of the backend to add new contacts.
public canAdd ( ) : boolean
Результат boolean Can backend add?

checkDefaultShare() публичный Метод

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.
Результат boolean TODO

count() публичный Метод

Returns the number of contacts of the current user in this address book.
public count ( ) : integer
Результат integer The number of contacts that the user owns.

createShare() публичный Метод

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.
Результат Horde_Share The share object.

delete() публичный Метод

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() публичный Метод

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() публичный Метод

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.
Результат array A contact hash.

getBlobs() публичный Метод

Returns the attributes that are blob types.
public getBlobs ( ) : array
Результат array List of blob attributes in the array keys.

getContactOwner() публичный Метод

Return the owner to use when searching or creating contacts in this address book.
public getContactOwner ( ) : string
Результат string Contact owner.

getCriteria() публичный Метод

Returns the criteria available for this source except '__key'.
public getCriteria ( ) : array
Результат array An array containing the criteria.

getDateFields() публичный Метод

Returns the attributes that represent dates.
С версии: 4.2.0
public getDateFields ( ) : array
Результат array List of date attributes in the array keys.

getFields() публичный Метод

Returns all non-composite fields for this source. Useful for importing and exporting data, etc.
public getFields ( ) : array
Результат array The field list.

getName() публичный Метод

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

getObject() публичный Метод

Retrieves one object from the source.
public getObject ( string $objectId ) : Turba_Object
$objectId string The unique id of the object to retrieve.
Результат Turba_Object The retrieved object.

getObjects() публичный Метод

Retrieves a set of objects from the source.
public getObjects ( array $objectIds ) : array
$objectIds array The unique ids of the objects to retrieve.
Результат array The array of retrieved objects (Turba_Objects).

getParams() публичный Метод

Returns the current driver's additional parameters.
public getParams ( ) : array
Результат array Hash containing the driver's additional parameters.

getTimeObjectTurbaList() публичный Метод

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).
Результат Turba_List A list of objects.

hasCapability() публичный Метод

Checks if this backend has a certain capability.
public hasCapability ( string $capability ) : boolean
$capability string The capability to check for.
Результат boolean Supported or not.

hasPermission() публичный Метод

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.
Результат boolean True if the user has permission, otherwise false.

listTimeObjects() публичный Метод

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.
Результат array A list of timeObject hashes.

makeSearch() публичный Метод

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.
Результат array An array of search criteria.

removeUserData() публичный Метод

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

save() публичный Метод

Modifies an existing entry in the contact source.
public save ( Turba_Object $object ) : string
$object Turba_Object The object to update.
Результат string The object id, possibly updated.

searchDuplicates() публичный Метод

Duplicates are determined by comparing email and name or last name and first name values.
public searchDuplicates ( ) : array
Результат array A hash with the following format: array('name' => array('John Doe' => Turba_List, ...), ...)

setContactOwner() публичный Метод

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

setDefaultShare() публичный Метод

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

setSourceName() публичный Метод

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() публичный Метод

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

toASContact() публичный Метод

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.
Результат Horde_ActiveSync_Message_Contact

toDriver() публичный Метод

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.
Результат string The driver name for this attribute.

toDriverKeys() публичный Метод

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.
Результат array Translated version of $hash.

toHash() публичный Метод

Function to convert a Horde_Icalendar_Vcard object into a Turba Object Hash with Turba attributes suitable as a parameter for add().
См. также: add()
public toHash ( Horde_Icalendar_Vcard $vcard ) : array
$vcard Horde_Icalendar_Vcard The Horde_Icalendar_Vcard object to parse.
Результат array A Turba attribute hash.

toTurbaKeys() публичный Метод

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.
Результат array Translated version of $entry.

tovCard() публичный Метод

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.
Результат Horde_Icalendar_Vcard A vcard object.

Описание свойств

$_asMap защищенное статическое свойство

Mapping of Turba attributes to ActiveSync fields.
protected static array $_asMap
Результат array

$_capabilities защищенное свойство

What can this backend do?
protected array $_capabilities
Результат array

$_contact_owner защищенное свойство

Hold the value for the owner of this address book.
protected string $_contact_owner
Результат string

$_count защищенное свойство

Number of contacts in this source.
protected int $_count
Результат integer

$_name защищенное свойство

The internal name of this source.
protected string $_name
Результат string

$_objectOptions защищенное свойство

Any additional options passed to Turba_Object constructors.
protected array $_objectOptions
Результат array

$_params защищенное свойство

Hash holding the driver's additional parameters.
protected array $_params
Результат array

$alternativeName публичное свойство

The name of a field to use as an alternative to the name field if that one is empty.
public string $alternativeName
Результат string

$approximate публичное свойство

Array of fields to search "approximately" (@see config/backends.php).
public array $approximate
Результат array

$fields публичное свойство

List of all fields that can be accessed in the backend (excludes composite attributes, etc.).
public array $fields
Результат array

$listNameField публичное свойство

The name of a field to store contact list names in if not the default.
public string $listNameField
Результат string

$map публичное свойство

Hash describing the mapping between Turba attributes and driver-specific fields.
public array $map
Результат array

$strict публичное свойство

Array of fields that must match exactly.
public array $strict
Результат array

$tabs публичное свойство

Hash with all tabs and their fields.
public array $tabs
Результат array

$title публичное свойство

The symbolic title of this source.
public string $title
Результат string