2006-06-17 20:50:07 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2009-05-09 09:58:16 +02:00
|
|
|
* eGroupware - Addressbook configuration
|
2006-06-17 20:50:07 +02:00
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
|
|
|
* @package addressbook
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
2008-05-10 14:02:49 +02:00
|
|
|
* @version $Id$
|
2006-06-17 20:50:07 +02:00
|
|
|
*/
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2009-05-09 09:58:16 +02:00
|
|
|
/**
|
|
|
|
* Hook to query available contact repositories for addressbook config
|
|
|
|
*
|
|
|
|
* @param array $config
|
|
|
|
* @return string with options
|
|
|
|
*/
|
2006-06-17 20:50:07 +02:00
|
|
|
function contact_repositories($config)
|
|
|
|
{
|
|
|
|
$repositories = array('sql' => 'SQL');
|
|
|
|
// check account-repository, contact-repository LDAP is only availible for account-repository == ldap
|
|
|
|
if ($config['account_repository'] == 'ldap' || !$config['account_repository'] && $config['auth_type'] == 'ldap')
|
|
|
|
{
|
|
|
|
$repositories['ldap'] = 'LDAP';
|
|
|
|
$repositories['sql-ldap'] = 'SQL --> LDAP ('.lang('read only').')';
|
|
|
|
}
|
|
|
|
$options = '';
|
|
|
|
foreach($repositories as $repo => $label)
|
|
|
|
{
|
|
|
|
$options .= '<option value="'.$repo.'"'.($config['contact_repository'] == $repo ? ' selected="1">' : '>').
|
|
|
|
$label."</option>\n";
|
|
|
|
}
|
|
|
|
return $options;
|
|
|
|
}
|
2006-09-15 09:16:07 +02:00
|
|
|
|
2009-05-09 09:58:16 +02:00
|
|
|
/**
|
|
|
|
* Hook to get available fileas types selectbox for addressbook config
|
|
|
|
*
|
|
|
|
* @param array $config
|
|
|
|
* @return string html
|
|
|
|
*/
|
|
|
|
function select_fileas($config)
|
|
|
|
{
|
|
|
|
$bocontacts = new addressbook_bo();
|
|
|
|
|
|
|
|
return html::select('fileas','',array('' => lang('Set only full name'))+$bocontacts->fileas_options(),true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hook to get a multiselect box with all fieleds of onw-account-acl for addressbook config
|
|
|
|
*
|
|
|
|
* @param array $config
|
|
|
|
* @return string html
|
|
|
|
*/
|
2006-09-15 09:16:07 +02:00
|
|
|
function own_account_acl($config)
|
|
|
|
{
|
2008-05-10 14:02:49 +02:00
|
|
|
$bocontacts = new addressbook_bo();
|
2006-09-15 09:16:07 +02:00
|
|
|
$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 edit or are covert by an other attribute (n_fn for all n_*)
|
|
|
|
if (!in_array($field,array('id','tid','owner','created','creator','modified','modifier','private','n_prefix','n_given','n_middle','n_family','n_suffix')))
|
|
|
|
{
|
|
|
|
$fields[$field] = $label;
|
|
|
|
}
|
|
|
|
}
|
2007-06-03 14:24:49 +02:00
|
|
|
$fields['link_to'] = 'Links';
|
|
|
|
|
2006-09-15 09:16:07 +02:00
|
|
|
if ($config['account_repository'] != 'ldap') // no custom-fields in ldap
|
|
|
|
{
|
2008-05-10 14:02:49 +02:00
|
|
|
foreach(config::get_customfields('addressbook') as $name => $data)
|
2006-09-15 09:16:07 +02:00
|
|
|
{
|
|
|
|
$fields['#'.$name] = $data['label'];
|
|
|
|
}
|
|
|
|
}
|
2008-03-25 16:25:01 +01:00
|
|
|
return html::checkbox_multiselect('newsettings[own_account_acl]',$config['own_account_acl'],$fields,true,'',4);
|
2008-03-05 11:31:26 +01:00
|
|
|
}
|
|
|
|
|
2009-05-09 09:58:16 +02:00
|
|
|
/**
|
|
|
|
* Hook to get a multiselect box with all fields of org-fields-to-update for addressbook config
|
|
|
|
*
|
|
|
|
* @param array $config
|
|
|
|
* @return string html
|
|
|
|
*/
|
2008-03-05 11:31:26 +01:00
|
|
|
function org_fileds_to_update($config)
|
|
|
|
{
|
2008-05-10 14:02:49 +02:00
|
|
|
$bocontacts = new addressbook_bo();
|
2008-03-05 11:31:26 +01:00
|
|
|
$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 never making sense for an organisation
|
|
|
|
if (!in_array($field,array('id','tid','owner','created','creator','modified','modifier','private','n_prefix','n_given','n_middle','n_family','n_suffix','n_fn')))
|
|
|
|
{
|
|
|
|
$fields[$field] = $label;
|
|
|
|
}
|
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2008-03-05 11:31:26 +01:00
|
|
|
if ($config['account_repository'] != 'ldap') // no custom-fields in ldap
|
|
|
|
{
|
2008-05-10 14:02:49 +02:00
|
|
|
foreach(config::get_customfields('addressbook') as $name => $data)
|
2008-03-05 11:31:26 +01:00
|
|
|
{
|
|
|
|
$fields['#'.$name] = $data['label'];
|
|
|
|
}
|
|
|
|
}
|
2008-03-25 16:25:01 +01:00
|
|
|
return html::checkbox_multiselect('newsettings[org_fileds_to_update]',
|
2008-03-05 11:31:26 +01:00
|
|
|
$config['org_fileds_to_update'] ? $config['org_fileds_to_update'] : $bocontacts->org_fields,$fields,true,'',4);
|
2006-09-15 09:16:07 +02:00
|
|
|
}
|
2010-08-25 18:47:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
);
|
|
|
|
}
|