/**
* Creates a map entry to map between server and client IDs.
*
* If an entry already exists, it is overwritten.
*
* @param string $databaseURI URI of database to sync. Like calendar,
* tasks, contacts or notes. May include
* optional parameters:
* tasks?options=ignorecompleted.
* @param string $cuid Client ID of the entry.
* @param string $suid Server ID of the entry.
* @param 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".
*/
public function createUidMap($databaseURI, $cuid, $suid, $timestamp = 0)
{
$database = $this->normalize($databaseURI);
$values = array($suid, (int) $timestamp, $this->_syncDeviceID, $database, $this->_user, $cuid);
// Check if entry exists. If not insert, otherwise update.
if (!$this->_getSuid($databaseURI, $cuid)) {
$query = 'INSERT INTO horde_syncml_map ' . '(syncml_suid, syncml_timestamp, syncml_syncpartner, ' . 'syncml_db, syncml_uid, syncml_cuid) ' . 'VALUES (?, ?, ?, ?, ?, ?)';
$this->_db->insert($query, $values);
} else {
$query = 'UPDATE horde_syncml_map ' . 'SET syncml_suid = ?, syncml_timestamp = ? ' . 'WHERE syncml_syncpartner = ? AND syncml_db = ? AND ' . 'syncml_uid = ? AND syncml_cuid = ?';
$this->_db->update($query, $values);
}
}