@@ -50,9 +54,11 @@
* Returns an array of GUIDs for all notes that the current user is
* authorized to see.
*
+ * @param string $filter The filter expression the client provided.
+ *
* @return array An array of GUIDs for all notes the user can access.
*/
-function _egwcontactssync_list()
+function _egwcontactssync_list($filter='')
{
$guids = array();
@@ -62,8 +68,7 @@
$criteria = array();
$filter = array();
- if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
- {
+ if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) {
$filter['account_id'] = null;
}
@@ -80,7 +85,7 @@
#Horde::logMessage("SymcML: egwcontactssync list generate id for: ". print_r($contact, true), __FILE__, __LINE__, PEAR_LOG_DEBUG);
$guids[] = "contacts-".$contact['id'];
-
+
}
#Horde::logMessage("SymcML: egwcontactssync list found ids: ". print_r($guids, true), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -94,20 +99,22 @@
*
* @param string $action The action to check for - add, modify, or delete.
* @param integer $timestamp The time to start the search.
+ * @param string $type The type of the content.
+ * @param string $filter The filter expression the client provided.
*
* @return array An array of GUIDs matching the action and time criteria.
*/
-function &_egwcontactssync_listBy($action, $timestamp) {
+function &_egwcontactssync_listBy($action, $timestamp, $type, $filter='') {
$allChangedItems = (array)$state->getHistory('contacts', $action, $timestamp);
- #Horde::logMessage('SymcML: egwcontactssync listBy $allChangedItems: '. print_r($allChangedItems,true), __FILE__, __LINE__, PEAR_LOG_DEBUG);
+ #Horde::logMessage('SymcML: egwcontactssync listBy $allChangedItems: '. count($allChangedItems), __FILE__, __LINE__, PEAR_LOG_DEBUG);
$allReadAbleItems = (array)_egwcontactssync_list();
- #Horde::logMessage('SymcML: egwcontactssync listBy $allReadAbleItems: '. print_r($allReadAbleItems,true), __FILE__, __LINE__, PEAR_LOG_DEBUG);
- $allClientItems = (array)$state->_getClientItems($state->_currentTargetURI);
- #Horde::logMessage('SymcML: egwcontactssync listBy $allClientItems: '. print_r($allClientItems,true), __FILE__, __LINE__, PEAR_LOG_DEBUG);
+ #Horde::logMessage('SymcML: egwcontactssync listBy $allReadAbleItems: '. count($allReadAbleItems), __FILE__, __LINE__, PEAR_LOG_DEBUG);
+ $allClientItems = (array)$state->getClientItems();
+ #Horde::logMessage('SymcML: egwcontactssync listBy $allClientItems: '. count($allClientItems), __FILE__, __LINE__, PEAR_LOG_DEBUG);
switch ($action) {
case 'delete' :
// filters may have changed, so we need to calculate which
@@ -138,27 +145,56 @@
* @param string $contentType What format is the data in? Currently supports:
* text/plain
* text/x-vnote
- * @param string $notepad (optional) The notepad to save the memo on.
+ * @param string $guid (optional) The guid of a collision entry.
*
* @return string The new GUID, or false on failure.
*/
-function _egwcontactssync_import($content, $contentType, $notepad = null)
+function _egwcontactssync_import($content, $contentType, $guid = null)
{
//error_log("_egwcontactssync_import");
#error_log("SymcML: egwcontactssync import content: ".base64_decode($ccontent)." contentType: $contentType");
- Horde::logMessage("SymcML: egwcontactssync import content: $content contenttype: $contentType", __FILE__, __LINE__, PEAR_LOG_DEBUG);
-
- $state = $_SESSION['SyncML.state'];
+ #Horde::logMessage("SymcML: egwcontactssync import content: $content contenttype:\n" . print_r($contentType,true), __FILE__, __LINE__, PEAR_LOG_DEBUG);
+
+ if (is_array($contentType)) {
+ $contentType = $contentType['ContentType'];
+ }
+
+ $contactId = null; //default for new entry
+
+ if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['addressbook_conflict_category'])) {
+ if (!$guid) {
+ $guid = _egwcontactssync_search($content, $contentType, null, true);
+ }
+ if (preg_match('/contacts-(\d+)/', $guid, $matches)) {
+ Horde::logMessage("SymcML: egwcontactssync import conflict found for " . $matches[1], __FILE__, __LINE__, PEAR_LOG_DEBUG);
+ // We found a conflicting entry on the server, let's make it a duplicate
+ if ($conflict = ExecMethod2('addressbook.addressbook_bo.read', $matches[1])) {
+ $cat_ids = explode(",", $conflict['cat_id']); //existing categories
+ $conflict_cat = $GLOBALS['egw_info']['user']['preferences']['syncml']['addressbook_conflict_category'];
+ if (!in_array($conflict_cat, $cat_ids)) {
+ $cat_ids[] = $conflict_cat;
+ $conflict['cat_id'] = implode(",", $cat_ids);
+ }
+ if (!empty($conflict['uid'])) {
+ $conflict['uid'] = 'DUP-' . $conflict['uid'];
+ }
+ ExecMethod2('addressbook.addressbook_bo.save', $conflict);
+ }
+ }
+ }
+
+ $state = &$_SESSION['SyncML.state'];
$deviceInfo = $state->getClientDeviceInfo();
#error_log(print_r($deviceInfo, true));
switch ($contentType) {
case 'text/x-vcard':
+ case 'text/vcard':
$vcaladdressbook = new addressbook_vcal();
$vcaladdressbook->setSupportedFields($deviceInfo['manufacturer'],$deviceInfo['model']);
case 'text/x-s4j-sife':
@@ -167,7 +203,7 @@
error_log("[_egwcontactssync_import] Treating bad contact content-type '".$contentType."' as if is was 'text/x-s4j-sifc'");
case 'text/x-s4j-sifc':
$sifaddressbook = new addressbook_sif();
- $contactId = $sifaddressbook->addSIF($content);
+ $contactId = $sifaddressbook->addSIF($content, $contactId);
break;
/**
* Search a memo represented in the specified contentType,
* used for SlowSync to check / rebuild content_map.
*
- * @param string $content The content of the memo.
- * @param string $contentType What format is the data in? Currently supports:
- * text/plain
- * text/x-vnote
- * @param string $contentid the contentid read from contentmap we are expecting the content to be
+ * @param string $content The content of the memo.
+ * @param string $contentType What format is the data in? Currently supports:
+ * text/plain
+ * text/x-vnote
+ * @param string $contentid the contentid read from contentmap we are expecting the content to be
+ * @param boolean $relax=false relaxed matching (lesser fields)
*
*
* @return string The new GUID, or false on failure.
*/
-function _egwcontactssync_search($content, $contentType, $contentid)
-{
- Horde::logMessage("SymcML: egwcontactssync search content: $content contenttype: $contentType contentid: $contentid", __FILE__, __LINE__, PEAR_LOG_DEBUG);
-
- $state = $_SESSION['SyncML.state'];
+function _egwcontactssync_search($content, $contentType, $contentid, $relax=false)
+{
+ #Horde::logMessage("SymcML: egwcontactssync search content: $content contentid: $contentid contenttype:\n" . print_r($contentType, true), __FILE__, __LINE__, PEAR_LOG_DEBUG);
+
+ $state = &$_SESSION['SyncML.state'];
$deviceInfo = $state->getClientDeviceInfo();
+ if (is_array($contentType)) {
+ $contentType = $contentType['ContentType'];
+ }
switch ($contentType) {
case 'text/x-vcard':
+ case 'text/vcard':
$vcaladdressbook = new addressbook_vcal();
$vcaladdressbook->setSupportedFields($deviceInfo['manufacturer'],$deviceInfo['model']);
case 'text/x-s4j-sife':
@@ -222,7 +264,7 @@
#Horde::logMessage("SymcML: egwcontactssync search content: Treating bad contact content-type '$contentType' as if it was 'text/x-s4j-sifc'", __FILE__, __LINE__, PEAR_LOG_DEBUG);
case 'text/x-s4j-sifc':
$sifaddressbook = new addressbook_sif();
- $contactId = $sifaddressbook->search($content,$state->get_egwID($contentid));
+ $contactId = $sifaddressbook->search($content, $state->get_egwID($contentid), $relax);
break;
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge _______________________________________________
eGroupWare-cvs mailing list
eGroupWare-cvs@... https://lists.sourceforge.net/lists/listinfo/egroupware-cvs