Fix SyncML preferences

This commit is contained in:
Jörg Lehrke 2010-03-24 11:37:22 +00:00
parent de947ef466
commit 0dfb44228c
4 changed files with 72 additions and 40 deletions

View File

@ -117,7 +117,7 @@ class addressbook_sif extends addressbook_bo
$this->sifData .= $_data; $this->sifData .= $_data;
} }
function siftoegw($sifData, $_abID=null) function siftoegw($sifData)
{ {
#$tmpfname = tempnam('/tmp/sync/contents','sifc_'); #$tmpfname = tempnam('/tmp/sync/contents','sifc_');
@ -152,12 +152,7 @@ class addressbook_sif extends addressbook_bo
{ {
$categories1 = explode(',', $value); $categories1 = explode(',', $value);
$categories2 = explode(';', $value); $categories2 = explode(';', $value);
$categories = count($categories1) > count($categories2) ? $categories1 : $categories2; $finalContact[$key] = count($categories1) > count($categories2) ? $categories1 : $categories2;
$finalContact[$key] = implode(',', $this->find_or_add_categories($categories, $_abID));
}
else
{
$finalContact[$key] = '';
} }
break; break;
@ -186,7 +181,7 @@ class addressbook_sif extends addressbook_bo
{ {
$result = array(); $result = array();
if (($contact = $this->siftoegw($_sifdata, $contentID))) if (($contact = $this->siftoegw($_sifdata)))
{ {
if ($contentID) if ($contentID)
{ {
@ -207,7 +202,7 @@ class addressbook_sif extends addressbook_bo
*/ */
function addSIF($_sifdata, $_abID=null, $merge=false) function addSIF($_sifdata, $_abID=null, $merge=false)
{ {
if (!$contact = $this->siftoegw($_sifdata, $_abID)) if (!$contact = $this->siftoegw($_sifdata))
{ {
return false; return false;
} }
@ -232,17 +227,41 @@ class addressbook_sif extends addressbook_bo
{ {
$contact['account_id'] = $old_contact['account_id']; $contact['account_id'] = $old_contact['account_id'];
} }
if (is_array($contact['cat_id']))
{
$contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], $_abID));
}
else
{
// restore from orignal
$contact['cat_id'] = $old_contact['cat_id'];
}
} }
} }
// update entry // update entry
$contact['id'] = $_abID; $contact['id'] = $_abID;
} }
elseif (array_key_exists('filter_addressbook', $GLOBALS['egw_info']['user']['preferences']['syncml'])) else
{ {
$contact['owner'] = (int) $GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']; if (is_array($contact['cat_id']))
if ($contact['owner'] == -1)
{ {
$contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1));
}
if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']))
{
$owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook'];
switch ($owner)
{
case 'G':
$contact['owner'] = $GLOBALS['egw_info']['user']['account_primary_group']; $contact['owner'] = $GLOBALS['egw_info']['user']['account_primary_group'];
break;
case 'P':
case 0:
$contact['owner'] = $this->user;
break;
default:
$contact['owner'] = (int)$owner;
}
} }
} }
return $this->save($contact); return $this->save($contact);

View File

@ -147,32 +147,47 @@ class addressbook_vcal extends addressbook_bo
{ {
$contact['account_id'] = $old_contact['account_id']; $contact['account_id'] = $old_contact['account_id'];
} }
if (is_array($contact['category'])) if (is_array($contact['cat_id']))
{ {
$contact['category'] = implode(',',$this->find_or_add_categories($contact['category'], $_abID)); $contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], $_abID));
} }
else else
{ {
// restore from orignal // restore from orignal
$contact['category'] = $old_contact['category']; $contact['cat_id'] = $old_contact['cat_id'];
} }
} }
} }
// update entry // update entry
$contact['id'] = $_abID; $contact['id'] = $_abID;
} }
elseif (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']) && else
(int)$GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook'])
{ {
$contact['owner'] = (int)$GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']; if (is_array($contact['cat_id']))
if ($contact['owner'] == -1)
{ {
$contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1));
}
if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']))
{
$owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook'];
switch ($owner)
{
case 'G':
$contact['owner'] = $GLOBALS['egw_info']['user']['account_primary_group']; $contact['owner'] = $GLOBALS['egw_info']['user']['account_primary_group'];
break;
case 'P':
case 0:
$contact['owner'] = $this->user;
break;
default:
$contact['owner'] = (int)$owner;
} }
if (is_array($contact['category'])) }
}
if ($this->log)
{ {
$contact['category'] = implode(',',$this->find_or_add_categories($contact['category'], -1)); error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
} array2string($contact)."\n",3,$this->logfile);
} }
return $this->save($contact); return $this->save($contact);
} }
@ -875,7 +890,6 @@ class addressbook_vcal extends addressbook_bo
} }
} }
if ($this->log) if ($this->log)
{ {
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" . error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
@ -938,11 +952,6 @@ class addressbook_vcal extends addressbook_bo
} }
} }
if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook']))
{
$contact['owner'] = $GLOBALS['egw_info']['user']['preferences']['syncml']['filter_addressbook'];
}
$this->fixup_contact($contact); $this->fixup_contact($contact);
if ($this->log) if ($this->log)

View File

@ -1778,11 +1778,13 @@ class calendar_ical extends calendar_boupdate
if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner'])) if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner']))
{ {
$owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner']; $owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner'];
if ($owner == 0) switch ($owner)
{ {
$owner = $GLOBALS['egw_info']['user']['account_primary_group']; case 'G':
case 'P':
$owner = $this->user;
} }
if (0 < (int)$owner && $this->check_perms(EGW_ACL_EDIT,0,$owner)) if (0 < (int)$owner && $this->check_perms(EGW_ACL_EDIT, 0, $owner))
{ {
$this->calendarOwner = $owner; $this->calendarOwner = $owner;
} }
@ -2006,7 +2008,7 @@ class calendar_ical extends calendar_boupdate
'(' . $this->productManufacturer . '(' . $this->productManufacturer .
', '. $this->productName .', ' . ', '. $this->productName .', ' .
($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) . ($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) .
")\n" , 3, $this->logfile); ', ' . $this->calendarOwner . ")\n" , 3, $this->logfile);
} }
//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', ' //Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '

View File

@ -1213,11 +1213,13 @@ class calendar_sif extends calendar_boupdate
if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner'])) if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner']))
{ {
$owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner']; $owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner'];
if ($owner == 0) switch ($owner)
{ {
$owner = $GLOBALS['egw_info']['user']['account_primary_group']; case 'G':
case 'P':
$owner = $this->user;
} }
if (0 < (int)$owner && $this->check_perms(EGW_ACL_EDIT,0,$owner)) if (0 < (int)$owner && $this->check_perms(EGW_ACL_EDIT, 0, $owner))
{ {
$this->calendarOwner = $owner; $this->calendarOwner = $owner;
} }