Add \"copy\" feature for copying contact(s) to addressbook

This commit is contained in:
Hadi Nategh 2013-11-08 18:51:37 +00:00
parent 75a26eed0c
commit 1943b35303

View File

@ -141,7 +141,7 @@ class addressbook_ui extends addressbook_bo
else
{
if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
$success,$failed,$action_msg,$content['do_email'] ? 'email' : 'index',$msg))
$success,$failed,$action_msg,$content['do_email'] ? 'email' : 'index',$msg,$content['nm']['checkboxes']))
{
$msg .= lang('%1 contact(s) %2',$success,$action_msg);
}
@ -501,6 +501,13 @@ class addressbook_ui extends addressbook_bo
'caption' => $label,
);
}
// copy checkbox
$move2addressbooks= array(
'copy' =>array(
'id' => 'move_to_copy',
'caption' => 'Copy instead of move',
'checkbox' => true,
)) + $move2addressbooks;
$actions['move_to'] = array(
'caption' => 'Move to addressbook',
'children' => $move2addressbooks,
@ -787,7 +794,7 @@ window.egw_LAB.wait(function() {
* @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
* @return boolean true if all actions succeded, false otherwise
*/
function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg)
function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg, $checkboxes = NULL)
{
//echo "<p>uicontacts::action('$action',".print_r($checked,true).','.(int)$use_all.",...)</p>\n";
$success = $failed = 0;
@ -1056,6 +1063,8 @@ window.egw_LAB.wait(function() {
{
return false;
}
if (!$checkboxes['move_to_copy'])
{
$action_msg = lang('moved');
if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_DELETE,$contact)))
{
@ -1070,6 +1079,27 @@ window.egw_LAB.wait(function() {
$Ok = $this->save($contact);
}
}
}
else
{
$action_msg = lang('copied');
if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_DELETE,$contact)))
{
if (!$contact['owner']) // no mass-change of accounts
{
$Ok = false;
}
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['private'] = (int)(substr($action,-1) == 'p');
$Ok = $this->save($contact);
}
}
}
break;
}
if ($Ok)