From 909609ebbc01c54a327b678f37b5db9c9e5754ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20Wei=C3=9F?= Date: Wed, 4 Jul 2007 19:14:35 +0000 Subject: [PATCH] backport syncML fixes --- .../inc/horde/Horde/SyncML/Command/Map.php | 3 +- phpgwapi/inc/horde/Horde/SyncML/State_egw.php | 35 +++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/phpgwapi/inc/horde/Horde/SyncML/Command/Map.php b/phpgwapi/inc/horde/Horde/SyncML/Command/Map.php index 1c2d4c8200..264682de77 100644 --- a/phpgwapi/inc/horde/Horde/SyncML/Command/Map.php +++ b/phpgwapi/inc/horde/Horde/SyncML/Command/Map.php @@ -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; diff --git a/phpgwapi/inc/horde/Horde/SyncML/State_egw.php b/phpgwapi/inc/horde/Horde/SyncML/State_egw.php index 60c95d40af..4490fb0c22 100644 --- a/phpgwapi/inc/horde/Horde/SyncML/State_egw.php +++ b/phpgwapi/inc/horde/Horde/SyncML/State_egw.php @@ -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) {