Class SyncML_Backend_Sql

Description

Located in /SyncML/SyncML/Backend/Sql.php (line 76)

SyncML_Backend
   |
   --SyncML_Backend_Sql
Variable Summary
 MDB2 $_db
Method Summary
 SyncML_Backend_Sql SyncML_Backend_Sql (array $params)
 array addEntry (string $databaseURI, string $content, string $contentType, [string $cuid = null])
 array addEntry_backend (string $user, string $databaseURI, string $content, string $contentType)
 void close ()
 void createUidMap (string $databaseURI, string $cuid, string $suid, [integer $timestamp = 0])
 boolean deleteEntry (string $databaseURI, string $cuid)
 boolean deleteEntry_backend (string $user, string $databaseURI, string $suid)
 void eraseMap (string $databaseURI)
 mixed getServerChanges (string $databaseURI, integer $from_ts, integer $to_ts, array &$adds, array &$mods, array &$dels)
 boolean isValidDatabaseURI (string $databaseURI)
 mixed readSyncAnchors (string $databaseURI)
 string replaceEntry (string $databaseURI, string $content, string $contentType, string $cuid)
 string replaceEntry_backend (string $user, string $databaseURI, string $content, string $contentType, string $suid)
 mixed retrieveEntry (string $databaseURI, string $suid, string $contentType, array $fields)
 string setAuthenticated (string $username, string $credData)
 void testSetup (string $user, string $pwd)
 void testStart (string $user)
 void testTearDown ()
 void writeSyncAnchors (string $databaseURI, string $clientAnchorNext, string $serverAnchorNext)
 boolean|string _checkAuthentication (string $username, string $password)
 mixed _checkForError (mixed $o)
 void _cleanUser ( $user)
 string _generateID ()
 mixed _getChangeTS (string $databaseURI, string $suid)
 mixed _getCuid (string $databaseURI, string $suid)
 mixed _getSuid (string $databaseURI, string $cuid)
 void _removeFromSuidList (string $databaseURI, array $suid)
 array _trackDeletes (string $databaseURI, array $currentSuids)
Variables
Methods
Constructor SyncML_Backend_Sql (line 93)

Constructor.

SyncML_Backend_Sql SyncML_Backend_Sql (array $params)
  • array $params: A hash with parameters. In addition to those supported by the SyncML_Backend class one more parameter is required for the database connection: 'dsn' => connection DSN.
addEntry (line 308)

Adds an entry into the server database.

  • return: PEAR_Error or suid (Horde guid) of new entry
array addEntry (string $databaseURI, string $content, string $contentType, [string $cuid = null])
  • 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.

Redefinition of:
SyncML_Backend::addEntry()
Adds an entry into the server database.
addEntry_backend (line 1048)

Adds an entry into the server database.

  • return: PEAR_Error or suid of new entry.
array addEntry_backend (string $user, string $databaseURI, string $content, string $contentType)
  • string $user: The username to use. Not strictly necessery to store this, but it helps for the test environment to clean up all entries for a test user.
  • 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.
close (line 805)

Cleanup function called after all message processing is finished.

Allows for things like closing databases or flushing logs. When running in test mode, tearDown() must be called rather than close.

void close ()

Redefinition of:
SyncML_Backend::close()
Cleanup function called after all message processing is finished.
createUidMap (line 605)

Creates a map entry to map between server and client IDs.

If an entry already exists, it is overwritten.

void createUidMap (string $databaseURI, string $cuid, string $suid, [integer $timestamp = 0])
  • 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".

Redefinition of:
SyncML_Backend::createUidMap()
Creates a map entry to map between server and client IDs.
deleteEntry (line 405)

Deletes an entry from the server database.

  • return: True on success or false on failed (item not found).
boolean deleteEntry (string $databaseURI, string $cuid)
  • 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.

Redefinition of:
SyncML_Backend::deleteEntry()
Deletes an entry from the server database.
deleteEntry_backend (line 1136)

Deletes an entry from the server database.

  • return: True on success or false on failed (item not found).
boolean deleteEntry_backend (string $user, string $databaseURI, string $suid)
  • string $user: The username to use. Not strictly necessery to store this, but it helps for the test environment to clean up all entries for a test user.
  • string $databaseURI: URI of Database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
  • string $suid: Server ID of the entry.
eraseMap (line 768)

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.

void eraseMap (string $databaseURI)
  • string $databaseURI: URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.

Redefinition of:
SyncML_Backend::eraseMap()
Erases all mapping entries for one combination of user, device ID.
getServerChanges (line 152)

Returns entries that have been modified in the server database.

  • return: True on success or a PEAR_Error object.
mixed getServerChanges (string $databaseURI, integer $from_ts, integer $to_ts, array &$adds, array &$mods, array &$dels)
  • 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.
  • array &$adds: Output array: hash of adds suid => 0
  • array &$mods: Output array: hash of modifications suid => cuid
  • array &$dels: Output array: hash of deletions suid => cuid

Redefinition of:
SyncML_Backend::getServerChanges()
Returns entries that have been modified in the server database.
isValidDatabaseURI (line 114)

Returns whether a database URI is valid to be synced with this backend.

  • return: True if a valid URI.
boolean isValidDatabaseURI (string $databaseURI)
  • string $databaseURI: URI of a database. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.

Redefinition of:
SyncML_Backend::isValidDatabaseURI()
Returns whether a database URI is valid to be synced with this backend.
readSyncAnchors (line 565)

Reads the previously written sync anchors from the database.

  • return: Two-element array with client anchor and server anchor as stored in previous writeSyncAnchor() calls. False if no data found.
mixed readSyncAnchors (string $databaseURI)
  • string $databaseURI: URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.

Redefinition of:
SyncML_Backend::readSyncAnchors()
Reads the previously written sync anchors from the database.
replaceEntry (line 352)

Replaces an entry in the server database.

  • return: PEAR_Error or server ID (Horde GUID) of modified entry.
string replaceEntry (string $databaseURI, string $content, string $contentType, string $cuid)
  • 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.

Redefinition of:
SyncML_Backend::replaceEntry()
Replaces an entry in the server database.
replaceEntry_backend (line 1093)

Replaces an entry in the server database.

  • return: PEAR_Error or suid of modified entry.
string replaceEntry_backend (string $user, string $databaseURI, string $content, string $contentType, string $suid)
  • string $user: The username to use. Not strictly necessery to store this but, it helps for the test environment to clean up all entries for a test user.
  • 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 $suid: Server ID of this entry.
retrieveEntry (line 281)

Retrieves an entry from the backend.

  • return: A string with the data entry or a PEAR_Error object.
mixed retrieveEntry (string $databaseURI, string $suid, string $contentType, array $fields)
  • 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 function should return the data.
  • array $fields: Hash of field names and SyncML_Property properties with the requested fields.

Redefinition of:
SyncML_Backend::retrieveEntry()
Retrieves an entry from the backend.
setAuthenticated (line 493)

Sets a user as being authenticated at the backend.

  • return: The user name.
  • abstract:
string setAuthenticated (string $username, string $credData)
  • string $username: A user name.
  • string $credData: Authentication data provided by <Cred><Data> in the <SyncHdr>.

Redefinition of:
SyncML_Backend::setAuthenticated()
Sets a user as being authenticated at the backend.
testSetup (line 988)

Creates a clean test environment in the backend.

Ensures there's a user with the given credentials and an empty data store.

void testSetup (string $user, string $pwd)
  • string $user: This user accout has to be created in the backend.
  • string $pwd: The password for user $user.

Redefinition of:
SyncML_Backend::testSetup()
Creates a clean test environment in the backend.
testStart (line 1007)

Prepares the test start.

void testStart (string $user)
  • string $user: This user accout has to be created in the backend.

Redefinition of:
SyncML_Backend::testStart()
Prepares the test start.
testTearDown (line 1018)

Tears down the test environment after the test is run.

Should remove the testuser created during testSetup and all its data.

void testTearDown ()

Redefinition of:
SyncML_Backend::testTearDown()
Tears down the test environment after the test is run.
writeSyncAnchors (line 515)

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.

void writeSyncAnchors (string $databaseURI, string $clientAnchorNext, string $serverAnchorNext)
  • 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.

Redefinition of:
SyncML_Backend::writeSyncAnchors()
Stores Sync anchors after a successful synchronization to allow two-way synchronization next time.
_checkAuthentication (line 461)

Authenticates the user at the backend.

  • return: The user name if authentication succeeded, false otherwise.
boolean|string _checkAuthentication (string $username, string $password)
  • string $username: A user name.
  • string $password: A password.

Redefinition of:
SyncML_Backend::_checkAuthentication()
Authenticates the user at the backend.
_checkForError (line 839)

Checks if the parameter is a PEAR_Error object and if so logs the error.

  • return: The error object if an error has been passed or false if no error has been passed.
mixed _checkForError (mixed $o)
  • mixed $o: An object or value to check.
_cleanUser (line 1155)
void _cleanUser ( $user)
  • $user
_generateID (line 816)

Generates a unique ID used as suid

  • return: A unique ID.
string _generateID ()
_getChangeTS (line 734)

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.

  • return: The previously stored timestamp or false if no entry is found.
mixed _getChangeTS (string $databaseURI, string $suid)
  • 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.
_getCuid (line 689)

Retrieves the Client ID for a given Server ID from the map.

  • return: The client ID string or false if no entry is found.
mixed _getCuid (string $databaseURI, string $suid)
  • 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.
_getSuid (line 655)

Retrieves the Server ID for a given Client ID from the map.

  • return: The server ID string or false if no entry is found.
mixed _getSuid (string $databaseURI, string $cuid)
  • 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.
_removeFromSuidList (line 953)

Removes a suid from the suidlist.

Called by _trackDeletes() when updating the suidlist and deleteEntry() when removing an entry due to a client request.

void _removeFromSuidList (string $databaseURI, array $suid)
  • string $databaseURI: URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
  • array $suid: The suid to remove from the list.
_trackDeletes (line 870)

Returns a list of item IDs that have been deleted since the last sync run and stores a complete list of IDs for next sync run.

Some backend datastores don't keep information about deleted entries. So we have to create a workaround that finds out what entries have been deleted since the last sync run. This method provides this functionality: it is called with a list of all IDs currently in the database. It then compares this list with its own previously stored list of IDs to identify those missing (and thus deleted). The passed list is then stored for the next invocation.

  • return: Array of all entries that have been deleted since the last call.
array _trackDeletes (string $databaseURI, array $currentSuids)
  • string $databaseURI: URI of database to sync. Like calendar, tasks, contacts or notes. May include optional parameters: tasks?options=ignorecompleted.
  • array $currentSuids: Array of all SUIDs (primary keys) currently in the server datastore.

Inherited Methods

Inherited From SyncML_Backend

 SyncML_Backend::SyncML_Backend()
 SyncML_Backend::addEntry()
 SyncML_Backend::checkAuthentication()
 SyncML_Backend::close()
 SyncML_Backend::createUidMap()
 SyncML_Backend::deleteEntry()
 SyncML_Backend::eraseMap()
 SyncML_Backend::factory()
 SyncML_Backend::getCharset()
 SyncML_Backend::getCurrentTimeStamp()
 SyncML_Backend::getParameter()
 SyncML_Backend::getServerChanges()
 SyncML_Backend::getSyncDeviceID()
 SyncML_Backend::getUser()
 SyncML_Backend::isValidDatabaseURI()
 SyncML_Backend::logFile()
 SyncML_Backend::logMessage()
 SyncML_Backend::readSyncAnchors()
 SyncML_Backend::replaceEntry()
 SyncML_Backend::retrieveEntry()
 SyncML_Backend::sessionClose()
 SyncML_Backend::sessionStart()
 SyncML_Backend::setAuthenticated()
 SyncML_Backend::setCharset()
 SyncML_Backend::setupState()
 SyncML_Backend::setUser()
 SyncML_Backend::testSetup()
 SyncML_Backend::testStart()
 SyncML_Backend::testTearDown()
 SyncML_Backend::writeSyncAnchors()
 SyncML_Backend::_checkAuthentication()
 SyncML_Backend::_normalize()

Documentation generated on Sun, 30 Jan 2011 05:22:02 +0000 by phpDocumentor 1.4.3