PHP Класс Horde_SyncMl_Backend_Horde, horde

Copyright 2005-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Автор: Karsten Fourmont ([email protected])
Наследование: extends Horde_SyncMl_Backend
Показать файл Открыть проект

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

Свойство Тип Описание
$_db Horde_Db_Adapter_Base A database instance.
$_sessionId string The session ID used in the Horde session.

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

Метод Описание
__construct ( array $params ) Constructor.
addEntry ( string $databaseURI, string $content, string $contentType, string $cuid = null ) : array Adds an entry into the server database.
close ( )
createUidMap ( string $databaseURI, string $cuid, string $suid, integer $timestamp ) Creates a map entry to map between server and client IDs.
deleteEntry ( string $databaseURI, string $cuid ) : boolean Deletes an entry from the server database.
eraseMap ( string $databaseURI ) Erases all mapping entries for one combination of user, device ID.
getServerChanges ( string $databaseURI, integer $from_ts, integer $to_ts, &$adds, &$mods, &$dels ) : boolean Returns entries that have been modified in the server database.
getUserAnchors ( string $user ) : array Returns all previously written sync anchors for a user.
logMessage ( mixed $message, string $priority = 'INFO' ) Logs a message in the backend.
readSyncAnchors ( string $databaseURI ) : mixed Reads the previously written sync anchors from the database.
removeAnchor ( string $user, string $device = null, string $database = null ) : array Deletes previously written sync anchors for a user.
removeMaps ( string $user, string $device = null, string $database = null ) : array Deletes previously written sync maps for a user.
replaceEntry ( string $databaseURI, string $content, string $contentType, string $cuid ) : string Replaces an entry in the server database.
retrieveEntry ( string $databaseURI, string $suid, string $contentType, array $fields ) : mixed Retrieves an entry from the backend.
sessionStart ( string $syncDeviceID, $sessionId, integer $backendMode = Horde_SyncMl_Backend::MODE_SERVER ) Starts a PHP session.
setUser ( string $user ) Sets the user used for this session.
testSetup ( string $user, string $pwd ) Creates a clean test environment in the backend.
testStart ( string $user ) Prepares the test start.
testTearDown ( ) Tears down the test environment after the test is run.
writeSyncAnchors ( string $databaseURI, string $clientAnchorNext, string $serverAnchorNext ) Stores Sync anchors after a successful synchronization to allow two-way synchronization next time.

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

Метод Описание
_checkAuthentication ( string $username, string $password ) : boolean | string Authenticates the user at the backend.
_fastsync ( $databaseURI, $from_ts, $to_ts )
_getChangeTS ( string $databaseURI, string $suid ) : mixed Returns a timestamp stored in the map for a given Server ID.
_getCuid ( string $databaseURI, string $suid ) : mixed Retrieves the Client ID for a given Server ID from the map.
_getSuid ( string $databaseURI, string $cuid ) : mixed Retrieves the Server ID for a given Client ID from the map.
_setAuthenticated ( string $username, string $credData ) : string Sets a user as being authenticated at the backend.
_slowsync ( $databaseURI, $from_ts, $to_ts )

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

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

Initializes the logger.
public __construct ( array $params )
$params array Any parameters the backend might need.

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

Authenticates the user at the backend.
protected _checkAuthentication ( string $username, string $password ) : boolean | string
$username string A user name.
$password string A password.
Результат boolean | string The user name if authentication succeeded, false otherwise.

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

protected _fastsync ( $databaseURI, $from_ts, $to_ts )

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

The timestamp is the timestamp of the last change to this server ID that was done inside a sync session (as a result of a change received by the server). It's important to distinguish changes in the backend a) made by the user during normal operation and b) changes made by SyncML to reflect client updates. When the server is sending its changes it is only allowed to send type a). However the history feature in the backend my not know if a change is of type a) or type b). So the timestamp is used to differentiate between the two.
protected _getChangeTS ( string $databaseURI, string $suid ) : mixed
$databaseURI string URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
$suid string The server ID.
Результат mixed The previously stored timestamp or false if no entry is found.

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

Retrieves the Client ID for a given Server ID from the map.
protected _getCuid ( string $databaseURI, string $suid ) : mixed
$databaseURI string URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
$suid string The server ID.
Результат mixed The client ID string or false if no entry is found.

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

Retrieves the Server ID for a given Client ID from the map.
protected _getSuid ( string $databaseURI, string $cuid ) : mixed
$databaseURI string URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
$cuid string The client ID.
Результат mixed The server ID string or false if no entry is found.

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

Sets a user as being authenticated at the backend.
protected _setAuthenticated ( string $username, string $credData ) : string
$username string A user name.
$credData string Authentication data provided by in the .
Результат string The user name.

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

protected _slowsync ( $databaseURI, $from_ts, $to_ts )

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

Adds an entry into the server database.
public addEntry ( string $databaseURI, string $content, string $contentType, string $cuid = null ) : array
$databaseURI string URI of Database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
$content string The actual data.
$contentType string MIME type of the content.
$cuid string Client ID of this entry.
Результат array PEAR_Error or suid (Horde guid) of new entry

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

public close ( )

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

If an entry already exists, it is overwritten.
public createUidMap ( string $databaseURI, string $cuid, string $suid, integer $timestamp )
$databaseURI string URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
$cuid string Client ID of the entry.
$suid string Server ID of the entry.
$timestamp integer Optional timestamp. This can be used to 'tag' changes made in the backend during the sync process. This allows to identify these, and ensure that these changes are not replicated back to the client (and thus duplicated). See key concept "Changes and timestamps".

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

Deletes an entry from the server database.
public deleteEntry ( string $databaseURI, string $cuid ) : boolean
$databaseURI string URI of Database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
$cuid string Client ID of the entry.
Результат boolean True on success or false on failed (item not found).

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

This is used during SlowSync so that we really sync everything properly and no old mapping entries remain.
public eraseMap ( string $databaseURI )
$databaseURI string URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.

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

Returns entries that have been modified in the server database.
public getServerChanges ( string $databaseURI, integer $from_ts, integer $to_ts, &$adds, &$mods, &$dels ) : boolean
$databaseURI string URI of Database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
$from_ts integer Start timestamp.
$to_ts integer Exclusive end timestamp. Not yet implemented.
Результат boolean true

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

Returns all previously written sync anchors for a user.
public getUserAnchors ( string $user ) : array
$user string A user name.
Результат array A hash tree with all devices, databases and sync anchors from the specified user.

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

Logs a message in the backend.
public logMessage ( mixed $message, string $priority = 'INFO' )
$message mixed Either a string or a PEAR_Error object.
$priority string The priority of the message. One of: - EMERG - ALERT - CRIT - ERR - WARN - NOTICE - INFO - DEBUG

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

Reads the previously written sync anchors from the database.
public readSyncAnchors ( string $databaseURI ) : mixed
$databaseURI string URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
Результат mixed Two-element array with client anchor and server anchor as stored in previous writeSyncAnchor() calls. False if no data found.

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

If no device or database are specified, anchors for all devices and/or databases will be deleted.
public removeAnchor ( string $user, string $device = null, string $database = null ) : array
$user string A user name.
$device string The ID of the client device.
$database string Normalized URI of database to delete. Like calendar, tasks, contacts or notes.
Результат array

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

If no device or database are specified, maps for all devices and/or databases will be deleted.
public removeMaps ( string $user, string $device = null, string $database = null ) : array
$user string A user name.
$device string The ID of the client device.
$database string Normalized URI of database to delete. Like calendar, tasks, contacts or notes.
Результат array

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

Replaces an entry in the server database.
public replaceEntry ( string $databaseURI, string $content, string $contentType, string $cuid ) : string
$databaseURI string URI of Database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
$content string The actual data.
$contentType string MIME type of the content.
$cuid string Client ID of this entry.
Результат string PEAR_Error or server ID (Horde GUID) of modified entry.

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

Retrieves an entry from the backend.
public retrieveEntry ( string $databaseURI, string $suid, string $contentType, array $fields ) : mixed
$databaseURI string URI of Database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
$suid string Server unique id of the entry: for horde this is the guid.
$contentType string Content-Type: the MIME type in which the public function should return the data.
$fields array Hash of field names and Horde_SyncMl_Property properties with the requested fields.
Результат mixed A string with the data entry or a PEAR_Error object.

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

Starts a PHP session.
public sessionStart ( string $syncDeviceID, $sessionId, integer $backendMode = Horde_SyncMl_Backend::MODE_SERVER )
$syncDeviceID string The device ID.
$backendMode integer The backend mode, one of the Horde_SyncMl_Backend::MODE_* constants.

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

Sets the user used for this session.
public setUser ( string $user )
$user string A user name.

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

Ensures there's a user with the given credentials and an empty data store.
public testSetup ( string $user, string $pwd )
$user string This user accout has to be created in the backend.
$pwd string The password for user $user.

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

Prepares the test start.
public testStart ( string $user )
$user string This user accout has to be created in the backend.

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

Should remove the testuser created during testSetup and all its data.
public testTearDown ( )

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

The backend has to store the parameters in its persistence engine where user, syncDeviceID and database are the keys while client and server anchor ar the payload. See readSyncAnchors() for retrieval.
public writeSyncAnchors ( string $databaseURI, string $clientAnchorNext, string $serverAnchorNext )
$databaseURI string URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
$clientAnchorNext string The client anchor as sent by the client.
$serverAnchorNext string The anchor as used internally by the server.

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

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

A database instance.
protected Horde_Db_Adapter_Base $_db
Результат Horde_Db_Adapter_Base

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

The session ID used in the Horde session.
protected string $_sessionId
Результат string