mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
* Addressbook/CardDAV: fix contacts created with "Copy instead of move" checked in "Move to addressbook" context menu sync not correctly (already created ones need to be deleted!)
Using now behavior like interactive "copy", but copying all fields, but ones never to copy like uid etc. This includes creating a link to the copied contact
This commit is contained in:
parent
69df935fb1
commit
1fa25b0e6a
@ -1054,7 +1054,7 @@ class addressbook_ui extends addressbook_bo
|
|||||||
$action_msg = lang('moved');
|
$action_msg = lang('moved');
|
||||||
if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_DELETE,$contact)))
|
if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_DELETE,$contact)))
|
||||||
{
|
{
|
||||||
if (!$contact['owner']) // no mass-change of accounts
|
if (!$contact['owner']) // no (mass-)move of accounts
|
||||||
{
|
{
|
||||||
$Ok = false;
|
$Ok = false;
|
||||||
}
|
}
|
||||||
@ -1069,20 +1069,19 @@ class addressbook_ui extends addressbook_bo
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$action_msg = lang('copied');
|
$action_msg = lang('copied');
|
||||||
if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_DELETE,$contact)))
|
if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_READ,$contact)))
|
||||||
{
|
{
|
||||||
if (!$contact['owner']) // no mass-change of accounts
|
if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p'))
|
||||||
{
|
{
|
||||||
$Ok = false;
|
$this->copy_contact($contact, false); // do NOT use self::$copy_fields, copy everything but uid etc.
|
||||||
}
|
$links = $contact['link_to']['to_id'];
|
||||||
elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p'))
|
|
||||||
{
|
|
||||||
unset($contact['id']);
|
|
||||||
unset($contact['uid']);
|
|
||||||
unset($contact['etag']);
|
|
||||||
$contact['owner'] = (int) $action;
|
$contact['owner'] = (int) $action;
|
||||||
$contact['private'] = (int)(substr($action,-1) == 'p');
|
$contact['private'] = (int)(substr($action,-1) == 'p');
|
||||||
$Ok = $this->save($contact);
|
$Ok = $this->save($contact);
|
||||||
|
if ($Ok && is_array($links))
|
||||||
|
{
|
||||||
|
egw_link::link('addressbook', $contact['id'], $links);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1100,6 +1099,38 @@ class addressbook_ui extends addressbook_bo
|
|||||||
return !$failed;
|
return !$failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy a given contact (not storing it!)
|
||||||
|
*
|
||||||
|
* Taken care only configured fields get copied and certain fields never to copy (uid etc.).
|
||||||
|
*
|
||||||
|
* @param array& $content
|
||||||
|
* @param boolean $only_copy_fields =true true: only copy fields configured for copying (eg. no name),
|
||||||
|
* false: copy everything, but never to copy fields
|
||||||
|
*/
|
||||||
|
function copy_contact(array &$content, $only_copy_fields=true)
|
||||||
|
{
|
||||||
|
$content['link_to']['to_id'] = 0;
|
||||||
|
egw_link::link('addressbook',$content['link_to']['to_id'],'addressbook',$content['id'],
|
||||||
|
lang('Copied by %1, from record #%2.',common::display_fullname('',
|
||||||
|
$GLOBALS['egw_info']['user']['account_firstname'],$GLOBALS['egw_info']['user']['account_lastname']),
|
||||||
|
$content['id']));
|
||||||
|
// create a new contact with the content of the old
|
||||||
|
foreach(array_keys($content) as $key)
|
||||||
|
{
|
||||||
|
if($only_copy_fields && !in_array($key, self::$copy_fields) || in_array($key, array('id','etag','carddav_name','uid')))
|
||||||
|
{
|
||||||
|
unset($content[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!isset($content['owner']))
|
||||||
|
{
|
||||||
|
$content['owner'] = $this->default_private ? $this->user.'p' : $this->default_addressbook;
|
||||||
|
}
|
||||||
|
$content['creator'] = $this->user;
|
||||||
|
$content['created'] = $this->now_su;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rows callback for index nextmatch
|
* rows callback for index nextmatch
|
||||||
*
|
*
|
||||||
@ -1791,25 +1822,7 @@ class addressbook_ui extends addressbook_bo
|
|||||||
|
|
||||||
if($content && $_GET['makecp']) // copy the contact
|
if($content && $_GET['makecp']) // copy the contact
|
||||||
{
|
{
|
||||||
$content['link_to']['to_id'] = 0;
|
$this->copy_contact($content);
|
||||||
egw_link::link('addressbook',$content['link_to']['to_id'],'addressbook',$content['id'],
|
|
||||||
lang('Copied by %1, from record #%2.',common::display_fullname('',
|
|
||||||
$GLOBALS['egw_info']['user']['account_firstname'],$GLOBALS['egw_info']['user']['account_lastname']),
|
|
||||||
$content['id']));
|
|
||||||
// create a new contact with the content of the old
|
|
||||||
foreach($content as $key => $value)
|
|
||||||
{
|
|
||||||
if(!in_array($key, self::$copy_fields) || in_array($key, array('etag','carddav_name','uid')))
|
|
||||||
{
|
|
||||||
unset($content[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!isset($content['owner']))
|
|
||||||
{
|
|
||||||
$content['owner'] = $this->default_private ? $this->user.'p' : $this->default_addressbook;
|
|
||||||
}
|
|
||||||
$content['creator'] = $this->user;
|
|
||||||
$content['created'] = $this->now_su;
|
|
||||||
$content['msg'] = lang('Contact copied');
|
$content['msg'] = lang('Contact copied');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user