backport syncML fixes

This commit is contained in:
Cornelius Weiß 2007-07-04 19:14:35 +00:00
parent b6cd1ee9e6
commit 909609ebbc
2 changed files with 35 additions and 3 deletions

View File

@ -137,7 +137,8 @@ class Horde_SyncML_Command_Map extends Horde_SyncML_Command {
Horde::logMessage("SyncML: creating Map for source=" .
$this->_mapSource . " and target=" . $this->_mapTarget, __FILE__, __LINE__, PEAR_LOG_DEBUG);
// Overwrite existing data by removing it first:
$r = $state->setUID($this->_targetLocURI, $this->_mapSource, $this->_mapTarget);
$ts = $state->getServerAnchorNext($this->_targetLocURI);
$r = $state->setUID($this->_targetLocURI, $this->_mapSource, $this->_mapTarget, $ts);
if (is_a($r, 'PEAR_Error')) {
Horde::logMessage('SyncML: PEAR Error: ' . $r->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
return false;

View File

@ -111,6 +111,34 @@ class EGW_SyncML_State extends Horde_SyncML_State
return false;
}
/**
* returns GUIDs of all client items
*/
function _getClientItems($type)
{
$mapID = $this->_locName . $this->_sourceURI . $type;
$db = clone($GLOBALS['egw']->db);
$cols = array('map_guid');
$where = array
(
'map_id' => $mapID,
'map_expired' => 0,
);
$db->select('egw_contentmap', $cols, $where, __LINE__, __FILE__, false, '', 'syncml');
$guids = array();
while($db->next_record())
{
$guids[] = $db->f('map_guid');
}
return empty($guids) ? false : $guids;
}
/**
* Retrieves the Horde server guid (like
* kronolith:0d1b415fc124d3427722e95f0e926b75) for a given client
@ -338,11 +366,14 @@ class EGW_SyncML_State extends Horde_SyncML_State
#if(count($guidParts) == 3) {
# $guid = $GLOBALS['egw']->common->generate_uid($guidParts[0],$guidParts[1]);
#}
// problem: entries created from client, come here with the (long) server guid,
// but getUIDMapping does not know them and can not map server-guid <--> client guid
$guid = $this->getUIDMapping($_guid);
if($guid === false) {
Horde::logMessage("SyncML: setUID $type, $locid, $guid something went wrong!!! Mapping not found.", __FILE__, __LINE__, PEAR_LOG_INFO);
return false;
$guid = $_guid;
//return false;
}
Horde::logMessage("SyncML: setUID $_guid => $guid", __FILE__, __LINE__, PEAR_LOG_DEBUG);
if($ts == 0) {