AlterPingChanges / ctag for all-in-one addressbook

This commit is contained in:
Ralf Becker 2011-04-07 19:37:37 +00:00
parent 6361ee4f4b
commit 0e56e1b7b6
2 changed files with 28 additions and 5 deletions

View File

@ -376,7 +376,7 @@ class addressbook_activesync implements activesync_plugin_write, activesync_plug
break;
case 'email':
case 'email_home':
if (!empty($contact[$attr]))
if (!empty($contact[$attr]))
{
$message->$key = ('"'.$emailname.'"'." <$contact[$attr]>");
}
@ -515,7 +515,7 @@ class addressbook_activesync implements activesync_plugin_write, activesync_plug
break;
case 'email':
case 'email_home':
if (function_exists ('imap_rfc822_parse_adrlist'))
if (function_exists ('imap_rfc822_parse_adrlist'))
{
$email_array = array_shift(imap_rfc822_parse_adrlist($message->$key,""));
if (!empty($email_array->mailbox) && $email_array->mailbox != 'INVALID_ADDRESS' && !empty($email_array->host))
@ -646,6 +646,29 @@ class addressbook_activesync implements activesync_plugin_write, activesync_plug
if ($type != 'addressbook') return false;
if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo();
// handle all-in-one addressbook
if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] &&
$owner == $GLOBALS['egw_info']['user']['account_id'])
{
if (strpos($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs'],'A') !== false)
{
$owner = null; // all AB's
}
else
{
$owner = array_keys($this->get_addressbooks(null,false)); // false = return all selected abs
// translate AS private AB ID to current user
if (($key == array_search(self::PRIVATE_AB, $owner)) !== false)
{
unset($owner[$key]);
if (!in_array($GLOBALS['egw_info']['user']['account_id'],$owner))
{
$owner[] = $GLOBALS['egw_info']['user']['account_id'];
}
}
}
}
$ctag = $this->addressbook->get_ctag($owner);
$changes = array(); // no change

View File

@ -1660,10 +1660,10 @@ class addressbook_bo extends addressbook_so
// info_from and info_link_id (main link)
$newlinkID = egw_link::link('addressbook',$target['id'],$data['app'],$data['id'],$data['remark'],$target['owner']);
//_debug_array(array('newLinkID'=>$newlinkID));
if ($newlinkID)
if ($newlinkID)
{
// update egw_infolog set info_link_id=$newlinkID where info_id=$data['id'] and info_link_id=$data['link_id']
if ($data['app']=='infolog')
if ($data['app']=='infolog')
{
$this->db->update('egw_infolog',array(
'info_link_id' => $newlinkID
@ -2181,7 +2181,7 @@ class addressbook_bo extends addressbook_so
* We have to include deleted entries, as otherwise the ctag will not change if an entry gets deleted!
* (Only works if tracking of deleted entries / history is switched on!)
*
* @param int $owner=null 0=accounts, null=all addressbooks or integer account_id of user or group
* @param int|array $owner=null 0=accounts, null=all addressbooks or integer account_id of user or group
* @return string
*/
public function get_ctag($owner=null)