PHP Класс Turba_Api, horde

This file defines Turba's external API interface. Other applications can interact with Turba through this API. Copyright 2009-2015 Horde LLC (http://www.horde.org/) See the enclosed file LICENSE for license information (ASL). If you did did not receive this file, see http://www.horde.org/licenses/apache.
Автор: Michael Slusarz ([email protected])
Наследование: extends Horde_Registry_Api
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$_links array Links.
$_noPerms array The listing of API calls that do not require permissions checking.

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

Метод Описание
addAddressbook ( string $name, array $params = [] ) : string Create a new addressbook
addClient ( array $attributes = [] ) : boolean Adds a client to the client source.
addField ( string | array $address = '', string $name = '', string $field = '', string $value = '', string $source = '' ) Sets the value of the specified attribute of a contact
addGroup ( string $name, array $members, array $opts = [] ) : array Adds a group (and its members) to the source provided.
browse ( string $path = '', array $properties = ['name', 'icon', 'browseable'] ) : array Browses through Turba's object tree.
clientFields ( ) : array Returns the available client fields.
commentCallback ( integer $id ) : mixed Callback for comment API.
delete ( string | array $uid, string | array $sources = null ) : boolean Deletes a contact identified by UID.
deleteAddressbook ( string $id ) Delete the specified addressbook.
deleteClient ( string $objectId = '' ) : boolean Deletes a client
deleteField ( string $address = '', string $field = '', array $sources = [] ) Deletes a field value.
export ( string $uid, mixed $contentType, string | array $sources = null, array $fields = null, array $options = [] ) : mixed Export a contact, identified by UID, in the requested contentType.
fields ( string $source = null ) : array Returns a list of fields avaiable in a source.
getActionTimestamp ( string $uid, string $action, string | array $sources = null, boolean $modSeq = false ) : integer Returns the timestamp of an operation for a given UID and action.
getAllAttributeValues ( string $field = '', array $sources = [] ) : array Retrieves a list of all possible values of a field in specified source(s).
getChanges ( integer $start, integer $end, boolean $isModSeq = false, string | array $sources = null ) : array Method for obtaining all server changes between two timestamps.
getChangesByModSeq ( integer $start, integer $end, string | array $sources = null ) : array Return all changes occuring between the specified modification sequences.
getClient ( string $objectId = '' ) : array Returns a contact from the client source.
getClientSource ( ) : string Returns the client source name.
getClients ( array $objectIds = [] ) : array Returns mulitple contacts from the client source.
getContact ( string $source = null, string $objectId = '' ) : array Retrieves a contact.
getContacts ( string $source = '', array $objectIds = [] ) : array Retrieves a set of contacts from a single source.
getDefaultShare ( ) : string Retrieve the UID for the current user's default Turba share.
getField ( string $address = '', string $field = '', array $sources = [], boolean $strict = false, boolean $multiple = false ) : array Returns a field value.
getGalUid ( ) : string | boolean Retrieve the UID for the Global Address List source.
getGroupMembers ( string $gid, boolean $subGroups = false ) : array Returns a list of all members belonging to a contact group.
getGroupMemberships ( string $user, boolean $parentGroups = false ) : array Returns all contact groups that the specified user is a member of.
getGroupObject ( string $gid ) : array Returns a contact group hash.
getGroupObjects ( ) : array Returns all contact groups.
getHighestModSeq ( string $id = null ) : integer Return the largest modification sequence from the history backend.
getOwnContactObject ( ) : array Helper function to return the user's own contact object
getSourcesConfig ( type $filter = [] ) : array Obtain an array of $cfgSource entries matching the filter criteria.
hasComments ( ) : boolean Does this API allow comments?
import ( string $content, string $contentType = 'array', string $source = null, array $options = [] ) : string Import a contact represented in the specified contentType.
listBy ( string $action, integer $timestamp, string | array $sources = null, integer $end = null, boolean $isModSeq = false ) : array Returns an array of UIDs for contacts that have had a given action since a certain time.
listShares ( integer $perms = Horde_Perms::READ ) : array Lists all shares the current user has access to.
listTagInfo ( array $tags = null, $user = null ) : array Retrieve the list of used tag_names, tag_ids and the total number of resources that are linked to that tag.
listTimeObjectCategories ( ) : array Retrieves a list of available time objects categories.
listTimeObjects ( array $time_categories, mixed $start, mixed $end ) : array Lists birthdays and/or anniversaries as time objects.
listUids ( string | array $sources = null ) : array Returns an array of UIDs for all contacts that the current user is authorized to see.
listUserGroupObjects ( ) : array GroupObject API - Lists all turba lists for the current user that can be treated as Horde_Group objects.
ownContact ( ) : array Export the user's own contact as a hash.
ownVCard ( ) : string Exports the user's own contact as a vCard string.
path_delete ( string $path ) : string Deletes a file from the Turba tree.
replace ( string $uid, mixed $content, string $contentType, string | array $sources = null ) : boolean Replaces the contact identified by UID with the content represented in the specified contentType.
search ( mixed $names = null, array $opts = [] ) : mixed Returns a contact search result.
searchClients ( array $names = [], array $fields = [], boolean $matchBegin = false ) : array Search for clients.
searchTags ( array $names, integer $max = 10, integer $from, string $resource_type = '', string $user = null, boolean $raw = false ) : array SearchTags API: Returns an application-agnostic array (useful for when doing a tag search across multiple applications)
sources ( boolean $writeable = false, boolean $sync_only = false ) : array Returns a list of available sources.
updateAddressbook ( string $id, array $info ) Update an existing addressbook's name or description.
updateClient ( string $objectId = '', array $attributes = [] ) : boolean Updates client data.

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

Метод Описание
_encodeContent ( $content )
_getContactImageUrl ( $obj )
_getGroupObject ( $source, $key )
_getSource ( $source )
_getSources ( $sources, $synchronize = false, $end = false )
_modified ( $uid, $sources )

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

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

protected _encodeContent ( $content )

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

protected _getContactImageUrl ( $obj )

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

protected _getGroupObject ( $source, $key )

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

protected _getSource ( $source )

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

protected _getSources ( $sources, $synchronize = false, $end = false )

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

protected _modified ( $uid, $sources )

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

Create a new addressbook
С версии: 4.2.0
public addAddressbook ( string $name, array $params = [] ) : string
$name string The display name for the addressbook.
$params array Any addtional parameters needed. - synchronize: (boolean) If true, add address book to the list of address books to syncronize. DEFAULT: false (do not add to the list). @since 4.2.1
Результат string The new addressbook's id (share name).

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

Adds a client to the client source.
public addClient ( array $attributes = [] ) : boolean
$attributes array Array containing the client attributes.
Результат boolean

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

Sets the value of the specified attribute of a contact
public addField ( string | array $address = '', string $name = '', string $field = '', string $value = '', string $source = '' )
$address string | array Contact email address(es).
$name string Contact name.
$field string Field to update.
$value string Field value to set.
$source string Contact source.

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

Adds a group (and its members) to the source provided.
public addGroup ( string $name, array $members, array $opts = [] ) : array
$name string Group name.
$members array An array of members to add to the group. Format is the same as the 'array' argument to the import() API function.
$opts array Additional options:
  - attr: (array) Additional attributes to add to group.
  - source: (string) Source to import contacts to.
Результат array An array with the following keys:
  - added: (integer) The number of addresses added to the group.
  - uid: (string) The uid of the group object.

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

Browses through Turba's object tree.
public browse ( string $path = '', array $properties = ['name', 'icon', 'browseable'] ) : array
$path string The path of the tree to browse.
$properties array The item properties to return. Defaults to 'name', 'icon', and 'browseable'.
Результат array Content of the specified path.

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

Returns the available client fields.
public clientFields ( ) : array
Результат array An array describing the fields.

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

Callback for comment API.
public commentCallback ( integer $id ) : mixed
$id integer Internal data identifier.
Результат mixed Name of object on success, false on failure.

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

Deletes a contact identified by UID.
public delete ( string | array $uid, string | array $sources = null ) : boolean
$uid string | array Identify the contact to delete, either a single UID or an array.
$sources string | array The source(s) from which the contact will be deleted.
Результат boolean Success or failure.

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

Delete the specified addressbook.
С версии: 4.2.0
public deleteAddressbook ( string $id )
$id string The addressbook id.

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

Deletes a client
public deleteClient ( string $objectId = '' ) : boolean
$objectId string The unique id of the client
Результат boolean

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

Deletes a field value.
public deleteField ( string $address = '', string $field = '', array $sources = [] )
$address string Contact email address.
$field string Field to delete value for.
$sources array Sources to delete value from.

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

Export a contact, identified by UID, in the requested contentType.
public export ( string $uid, mixed $contentType, string | array $sources = null, array $fields = null, array $options = [] ) : mixed
$uid string Identify the contact to export.
$contentType mixed What format should the data be in? - text/directory: Returns RFC2426 vcard3.0 - text/vcard: Returns RFC2426 vcard3.0 - text/x-vcard: Returns imc.org vcard 2.1 format. - array: Returns a raw array - activesync: Returns a Horde_ActiveSync_Message_Contact:: object
$sources string | array The source(s) from which the contact will be exported.
$fields array Hash of field names and Horde_SyncMl_Property properties with the requested fields.
$options array Any additional options to be passed to the exporter. Currently supported: - skip_empty: (boolean) {text/vcard or text/x-vcard} Set to true to not output empty properties. DEFAULT: false. - protocolversion: (float) {activesync} The EAS version to support DEFAULT: 2.5 - bodyprefs: (array) {activesync} A BODYPREFERENCE array. DEFAULT: none (No body prefs enforced). - truncation: (integer) {activesync} Truncate event body to this length. DEFAULT: none (No truncation).
Результат mixed The requested data.

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

Returns a list of fields avaiable in a source.
public fields ( string $source = null ) : array
$source string The source name.
Результат array An array describing the fields. Keys are the field name, values are arrays with these keys: - name: (string) Field name. - label: (string) Field label. - search: (boolean) Can this field be searched? - type: (string) See turba/config/attributes.php.

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

Returns the timestamp of an operation for a given UID and action.
public getActionTimestamp ( string $uid, string $action, string | array $sources = null, boolean $modSeq = false ) : integer
$uid string The UID to look for.
$action string The action to check for - add, modify, or delete.
$sources string | array The source(s) for which to retrieve the history.
$modSeq boolean Request a modification sequence instead of timestamp. @since 4.1.1
Результат integer The timestamp for this action.

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

Retrieves a list of all possible values of a field in specified source(s).
public getAllAttributeValues ( string $field = '', array $sources = [] ) : array
$field string Field name to check.
$sources array Array containing the sources to look in.
Результат array An array of fields and possible values.

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

Essentially a wrapper around listBy(), but returns an array containing all adds, edits, and deletions.
public getChanges ( integer $start, integer $end, boolean $isModSeq = false, string | array $sources = null ) : array
$start integer The starting timestamp
$end integer The ending timestamp.
$isModSeq boolean If true, $start and $end are modification sequences and not timestamps. @since 4.1.1
$sources string | array The sources to check. @since 4.2.0
Результат array A hash with 'add', 'modify' and 'delete' arrays.

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

Return all changes occuring between the specified modification sequences.
С версии: 4.1.1
public getChangesByModSeq ( integer $start, integer $end, string | array $sources = null ) : array
$start integer The starting modseq.
$end integer The ending modseq.
$sources string | array The sources to check. @since 4.2.0
Результат array The changes @see getChanges()

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

Returns a contact from the client source.
public getClient ( string $objectId = '' ) : array
$objectId string Client unique ID.
Результат array Array of client data.

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

Returns the client source name.
public getClientSource ( ) : string
Результат string The name of the source to use with the clients api.

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

Returns mulitple contacts from the client source.
public getClients ( array $objectIds = [] ) : array
$objectIds array client unique ids.
Результат array An array of clients data.

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

Retrieves a contact.
public getContact ( string $source = null, string $objectId = '' ) : array
$source string The source name where the contact is stored
$objectId string The unique id of the contact to retrieve
Результат array The retrieved contact.

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

Retrieves a set of contacts from a single source.
public getContacts ( string $source = '', array $objectIds = [] ) : array
$source string The source name where the contact is stored
$objectIds array The unique ids of the contact to retrieve.
Результат array The retrieved contact.

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

Retrieve the UID for the current user's default Turba share.
public getDefaultShare ( ) : string
Результат string UID.

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

Returns a field value.
public getField ( string $address = '', string $field = '', array $sources = [], boolean $strict = false, boolean $multiple = false ) : array
$address string Contact email address.
$field string Field to get.
$sources array Sources to check.
$strict boolean Match the email address strictly.
$multiple boolean Return more than one entry if found and true, return an error if this is false.
Результат array An array of field value(s).

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

Retrieve the UID for the Global Address List source.
public getGalUid ( ) : string | boolean
Результат string | boolean The UID or false if none configured.

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

Returns a list of all members belonging to a contact group.
public getGroupMembers ( string $gid, boolean $subGroups = false ) : array
$gid string The group identifier
$subGroups boolean Also include members of any subgroups?
Результат array An array of group members (identified by email address).

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

Returns all contact groups that the specified user is a member of.
public getGroupMemberships ( string $user, boolean $parentGroups = false ) : array
$user string The user.
$parentGroups boolean Include user as a member of the any parent group as well.
Результат array An array of group identifiers that the specified user is a member of.

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

Returns a contact group hash.
public getGroupObject ( string $gid ) : array
$gid string The group identifier.
Результат array A hash defining the group.

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

Returns all contact groups.
public getGroupObjects ( ) : array
Результат array A list of group hashes.

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

Return the largest modification sequence from the history backend.
С версии: 4.1.1
public getHighestModSeq ( string $id = null ) : integer
$id string Addressbook id to return highest MODSEQ for. If null, the highest MODSEQ across all addressbooks is returned. @since 4.2.0
Результат integer The modseq.

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

Helper function to return the user's own contact object
public getOwnContactObject ( ) : array
Результат array An array containing the following keys: - contact: (Turba_Object) Object representing the user's own contact. - source: (string) The source of the user's own contact.

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

Obtain an array of $cfgSource entries matching the filter criteria.
public getSourcesConfig ( type $filter = [] ) : array
$filter type A single key -> value hash to filter the sources.
Результат array

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

Does this API allow comments?
public hasComments ( ) : boolean
Результат boolean True if API allows comments.

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

Import a contact represented in the specified contentType.
public import ( string $content, string $contentType = 'array', string $source = null, array $options = [] ) : string
$content string The content of the contact.
$contentType string What format is the data in? Currently supports array, text/directory, text/vcard, text/x-vcard, and activesync.
$source string The source into which the contact will be imported.
$options array Additional options: - match_on_email: (boolean) If true, will detect entry as duplicate if ANY email field matches. Useful for automatically adding contacts from an email application, such as IMP. @since 4.2.9
Результат string The new UID.

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

Returns an array of UIDs for contacts that have had a given action since a certain time.
public listBy ( string $action, integer $timestamp, string | array $sources = null, integer $end = null, boolean $isModSeq = false ) : array
$action string The action to check for - add, modify, or delete.
$timestamp integer The time to start the search.
$sources string | array The source(s) for which to retrieve the history.
$end integer The optional ending timestamp.
$isModSeq boolean If true, $timestamp and $end are modification sequences and not timestamps. @since 4.1.1
Результат array An array of UIDs matching the action and time criteria.

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

Lists all shares the current user has access to.
public listShares ( integer $perms = Horde_Perms::READ ) : array
$perms integer
Результат array of Turba_Share objects.

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

Retrieve the list of used tag_names, tag_ids and the total number of resources that are linked to that tag.
public listTagInfo ( array $tags = null, $user = null ) : array
$tags array An optional array of tag_ids. If omitted, all tags will be included.
Результат array An array containing tag_name, and total

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

Retrieves a list of available time objects categories.
public listTimeObjectCategories ( ) : array
Результат array An array of all configured time object categories.

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

Lists birthdays and/or anniversaries as time objects.
public listTimeObjects ( array $time_categories, mixed $start, mixed $end ) : array
$time_categories array The time categories (from listTimeObjectCategories) to list.
$start mixed The start date of the period.
$end mixed The end date of the period.
Результат array An array of timeObject results.

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

Returns an array of UIDs for all contacts that the current user is authorized to see.
public listUids ( string | array $sources = null ) : array
$sources string | array The name(s) of the source(s) to return contacts of. If empty, the current user's sync sources or default source are used.
Результат array An array of UIDs for all contacts the user can access.

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

GroupObject API - Lists all turba lists for the current user that can be treated as Horde_Group objects.
public listUserGroupObjects ( ) : array
Результат array A hash of all visible groups in the form of group_id => group_name

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

Export the user's own contact as a hash.
public ownContact ( ) : array
Результат array The contact hash.

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

Exports the user's own contact as a vCard string.
public ownVCard ( ) : string
Результат string The requested vCard data.

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

Deletes a file from the Turba tree.
public path_delete ( string $path ) : string
$path string The path to the file.
Результат string The event's UID.

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

Replaces the contact identified by UID with the content represented in the specified contentType.
public replace ( string $uid, mixed $content, string $contentType, string | array $sources = null ) : boolean
$uid string Idenfity the contact to replace.
$content mixed The content of the contact.
$contentType string What format is the data in? Currently supports array, text/directory, text/vcard, text/x-vcard and activesync.
$sources string | array The source(s) where the contact will be replaced.
Результат boolean Success or failure.

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

Search for clients.
public searchClients ( array $names = [], array $fields = [], boolean $matchBegin = false ) : array
$names array The search filter values.
$fields array The fields to search in.
$matchBegin boolean Match word boundaries only.
Результат array A hash containing the search results.

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

The 'raw' results array can be returned instead by setting $raw = true.
public searchTags ( array $names, integer $max = 10, integer $from, string $resource_type = '', string $user = null, boolean $raw = false ) : array
$names array An array of tag_names to search for.
$max integer The maximum number of resources to return.
$from integer The number of the resource to start with.
$resource_type string The resource type [bookmark, '']
$user string Restrict results to resources owned by $user.
$raw boolean Return the raw data?
Результат array An array of results:
 'title'    - The title for this resource.
 'desc'     - A terse description of this resource.
 'view_url' - The URL to view this resource.
 'app'      - The Horde application this resource belongs to.
 'icon'     - URL to an image.

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

Returns a list of available sources.
public sources ( boolean $writeable = false, boolean $sync_only = false ) : array
$writeable boolean If true, limits to writeable sources.
$sync_only boolean Only include synchable address books.
Результат array An array of the available sources. Keys are source IDs, values are source titles.

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

Update an existing addressbook's name or description.
С версии: 4.2.0
public updateAddressbook ( string $id, array $info )
$id string The addressbook id.
$info array The info to change: - name: The addressbook's display name. - desc: The addressbook's description.

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

Updates client data.
public updateClient ( string $objectId = '', array $attributes = [] ) : boolean
$objectId string The unique id of the client.
$attributes array An array of client attributes.
Результат boolean

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

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

The listing of API calls that do not require permissions checking.
protected array $_noPerms
Результат array