LOGFILE_CLIENTMESSAGE
LOGFILE_CLIENTMESSAGE
Types of logfiles. See logFile() method.
SyncML Backend for the Horde Application framework.
Copyright 2005-2017 Horde LLC (http://www.horde.org/)
See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
$state : \Horde_SyncMl_State
The State object.
factory(string $driver, array $params = null) : \Horde_SyncMl_Backend
Attempts to return a concrete Horde_SyncMl_Backend instance based on $driver.
string | $driver | The type of concrete Backend subclass to return. The code is dynamically included from Backend/$driver.php if no path is given or directly with "include_once $driver . '.php'" if a path is included. So make sure this parameter is "safe" and not directly taken from web input. The class in the file must be named 'Horde_SyncMlBackend' . basename($driver) and extend Horde_SyncMl_Backend. |
array | $params | A hash containing any additional configuration or connection parameters a subclass might need. |
The newly created concrete Horde_SyncMl_Backend instance, or false on an error.
setUser(string $user)
Sets the user used for this session.
This method is called by SyncML right after sessionStart() when either authentication is accepted via checkAuthentication() or a valid user has been retrieved from the state. $this->_user together with $this->_syncDeviceID is used as an additional key for all persistence operations. This method may have to force a "login", when the backend doesn't keep auth state within a session or when in test mode.
string | $user | A user name. |
isValidDatabaseURI(string $databaseURI) : boolean
Returns whether a database URI is valid to be synced with this backend.
This default implementation accepts "tasks", "calendar", "notes" and "contacts". However individual backends may offer replication of different or completly other databases (like browser bookmarks or cooking recipes).
string | $databaseURI | URI of a database. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
True if a valid URI.
getServerChanges(string $databaseURI, integer $from_ts, integer $to_ts, $adds, $mods, $dels) : boolean
Returns entries that have been modified in the server database.
string | $databaseURI | URI of Database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
integer | $from_ts | Start timestamp. |
integer | $to_ts | Exclusive end timestamp. Not yet implemented. |
$adds | ||
$mods | ||
$dels |
true
retrieveEntry(string $databaseURI, string $suid, string $contentType, array $fields) : mixed
Retrieves an entry from the backend.
string | $databaseURI | URI of Database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
string | $suid | Server unique id of the entry: for horde this is the guid. |
string | $contentType | Content-Type: the MIME type in which the public function should return the data. |
array | $fields | Hash of field names and Horde_SyncMl_Property properties with the requested fields. |
A string with the data entry or a PEAR_Error object.
addEntry(string $databaseURI, string $content, string $contentType, string $cuid = null) : array
Adds an entry into the server database.
string | $databaseURI | URI of Database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
string | $content | The actual data. |
string | $contentType | MIME type of the content. |
string | $cuid | Client ID of this entry. |
PEAR_Error or suid (Horde guid) of new entry
replaceEntry(string $databaseURI, string $content, string $contentType, string $cuid) : string
Replaces an entry in the server database.
string | $databaseURI | URI of Database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
string | $content | The actual data. |
string | $contentType | MIME type of the content. |
string | $cuid | Client ID of this entry. |
PEAR_Error or server ID (Horde GUID) of modified entry.
deleteEntry(string $databaseURI, string $cuid) : boolean
Deletes an entry from the server database.
string | $databaseURI | URI of Database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
string | $cuid | Client ID of the entry. |
True on success or false on failed (item not found).
checkAuthentication(string $username, string $credData, string $credFormat, string $credType) : boolean|string
Authenticates the user at the backend.
For some types of authentications (notably auth:basic) the username
gets extracted from the authentication data and is then stored in
username. For security reasons the caller must ensure that this is the
username that is used for the session, overriding any username
specified in
string | $username | Username as provided in the |
string | $credData | Authentication data provided by |
string | $credFormat | Format of data as |
string | $credType | Auth type as provided by |
The user name if authentication succeeded, false otherwise.
writeSyncAnchors(string $databaseURI, string $clientAnchorNext, string $serverAnchorNext)
Stores Sync anchors after a successful synchronization to allow two-way synchronization next time.
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.
string | $databaseURI | URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
string | $clientAnchorNext | The client anchor as sent by the client. |
string | $serverAnchorNext | The anchor as used internally by the server. |
readSyncAnchors(string $databaseURI) : mixed
Reads the previously written sync anchors from the database.
string | $databaseURI | URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
Two-element array with client anchor and server anchor as stored in previous writeSyncAnchor() calls. False if no data found.
createUidMap(string $databaseURI, string $cuid, string $suid, integer $timestamp)
Creates a map entry to map between server and client IDs.
If an entry already exists, it is overwritten.
string | $databaseURI | URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
string | $cuid | Client ID of the entry. |
string | $suid | Server ID of the entry. |
integer | $timestamp | 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". |
eraseMap(string $databaseURI)
Erases all mapping entries for one combination of user, device ID.
This is used during SlowSync so that we really sync everything properly and no old mapping entries remain.
string | $databaseURI | URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
logMessage(mixed $message, string $priority = 'INFO')
Logs a message in the backend.
TODO: This should be done via Horde_Log or the equivalent.
mixed | $message | Either a string or a PEAR_Error object. |
string | $priority | The priority of the message. One of:
|
logFile(integer $type, string $content, boolean $wbxml = false, boolean $sessionClose = false)
Logs data to a file in the debug directory.
integer | $type | The data type. One of the Horde_SyncMlBackend::LOGFILE* constants. |
string | $content | The data content. |
boolean | $wbxml | Whether the data is wbxml encoded. |
boolean | $sessionClose | Whether this is the last SyncML message in a session. Bump the file number. |
testSetup(string $user, string $pwd)
Creates a clean test environment in the backend.
Ensures there's a user with the given credentials and an empty data store.
string | $user | This user accout has to be created in the backend. |
string | $pwd | The password for user $user. |
normalize(string $databaseURI) : string
Normalizes a databaseURI to a database name, so that _normalize('tasks?ignorecompleted') should return just 'tasks'.
string | $databaseURI | URI of a database. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
The normalized database name.
getParameter(string $url, string $parameter, string $default = null)
Extracts an HTTP GET like parameter from an URL.
Example: getParameter('test?q=1', 'q') == 1
string | $url | The complete URL. |
string | $parameter | The parameter name to extract. |
string | $default | A default value to return if none has been provided in the URL. |
removeAnchor(string $user, string $device = null, string $database = null) : array
Deletes previously written sync anchors for a user.
If no device or database are specified, anchors for all devices and/or databases will be deleted.
string | $user | A user name. |
string | $device | The ID of the client device. |
string | $database | Normalized URI of database to delete. Like calendar, tasks, contacts or notes. |
removeMaps(string $user, string $device = null, string $database = null) : array
Deletes previously written sync maps for a user.
If no device or database are specified, maps for all devices and/or databases will be deleted.
string | $user | A user name. |
string | $device | The ID of the client device. |
string | $database | Normalized URI of database to delete. Like calendar, tasks, contacts or notes. |
_getSuid(string $databaseURI, string $cuid) : mixed
Retrieves the Server ID for a given Client ID from the map.
string | $databaseURI | URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
string | $cuid | The client ID. |
The server ID string or false if no entry is found.
_getCuid(string $databaseURI, string $suid) : mixed
Retrieves the Client ID for a given Server ID from the map.
string | $databaseURI | URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
string | $suid | The server ID. |
The client ID string or false if no entry is found.
_getChangeTS(string $databaseURI, string $suid) : mixed
Returns a timestamp stored in the map for a given Server ID.
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.
string | $databaseURI | URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted. |
string | $suid | The server ID. |
The previously stored timestamp or false if no entry is found.