Add site configuration setting for which fields to copy when copying an address. (egw.stylite.de bug #8168)

This commit is contained in:
Nathan Gray 2010-08-25 16:47:25 +00:00
parent 2d616fe2bb
commit 989011fe69
3 changed files with 65 additions and 3 deletions

View File

@ -1379,11 +1379,18 @@ class addressbook_ui extends addressbook_bo
$GLOBALS['egw_info']['user']['account_firstname'],$GLOBALS['egw_info']['user']['account_lastname']), $GLOBALS['egw_info']['user']['account_firstname'],$GLOBALS['egw_info']['user']['account_lastname']),
$content['id'])); $content['id']));
// create a new contact with the content of the old // create a new contact with the content of the old
foreach(array('id','modified','modifier','account_id','uid','cat_id','etag') as $key) $copy_fields = unserialize($this->config['copy_fields']);
foreach($content as $key => $value)
{ {
unset($content[$key]); if(!in_array($key, $copy_fields) || in_array($key, array('etag')))
{
unset($content[$key]);
}
}
if(!isset($content['owner']))
{
$this->default_private ? $this->user.'p' : $this->default_addressbook;
} }
$content['owner'] = $this->default_private ? $this->user.'p' : $this->default_addressbook;
$content['creator'] = $this->user; $content['creator'] = $this->user;
$content['created'] = $this->now_su; $content['created'] = $this->now_su;
$content['msg'] = lang('Contact copied'); $content['msg'] = lang('Contact copied');

View File

@ -110,3 +110,52 @@ function org_fileds_to_update($config)
return html::checkbox_multiselect('newsettings[org_fileds_to_update]', return html::checkbox_multiselect('newsettings[org_fileds_to_update]',
$config['org_fileds_to_update'] ? $config['org_fileds_to_update'] : $bocontacts->org_fields,$fields,true,'',4); $config['org_fileds_to_update'] ? $config['org_fileds_to_update'] : $bocontacts->org_fields,$fields,true,'',4);
} }
/**
* Hook to get a multiselect box with all fieleds of fields used for copying for addressbook config
*
* @param array $config
* @return string html
*/
function copy_fields($config)
{
$bocontacts = new addressbook_bo();
$supported_fields = $bocontacts->get_fields('supported',null,0); // fields supported by the backend (ldap schemas!)
// get the list of account fields
$fields = array();
foreach($bocontacts->contact_fields as $field => $label)
{
// some fields the user should never be allowed to copy or are coverted by an other attribute (n_fn for all n_*)
if (!in_array($field,array('id','tid','created','creator','modified','modifier','n_prefix','n_given','n_middle','n_family','n_suffix', 'account_id', 'uid')))
{
$fields[$field] = $label;
}
}
$fields['link_to'] = 'Links';
if ($config['account_repository'] != 'ldap') // no custom-fields in ldap
{
foreach(config::get_customfields('addressbook') as $name => $data)
{
$fields['#'.$name] = $data['label'];
}
}
$default = array(
'company',
'department',
'adr_one_street',
'adr_one_street2',
'adr_one_locality',
'adr_one_region',
'adr_one_postalcode',
'adr_one_countryname',
'email',
'url',
'tel_work',
'cat_id'
);
return html::checkbox_multiselect('newsettings[copy_fields]',
$config['copy_fields'] ? $config['copy_fields'] : $default,
$fields,true,'',4
);
}

View File

@ -54,6 +54,12 @@
</td> </td>
</tr> </tr>
<tr class="row_on"> <tr class="row_on">
<td>&nbsp;{lang_Fields_to_copy_when_copying_an_address?}</td>
<td>
{hook_copy_fields}
</td>
</tr>
<tr class="row_off">
<td>&nbsp;{lang_Use_an_extra_tab_for_private_custom_fields?}</td> <td>&nbsp;{lang_Use_an_extra_tab_for_private_custom_fields?}</td>
<td> <td>
<select name="newsettings[private_cf_tab]"> <select name="newsettings[private_cf_tab]">