* Addressbook/Active Directory: got prefix, middle name and suffix working for AD account, file as got disabled (as well as not supported history tab)

This commit is contained in:
Ralf Becker 2013-07-11 15:33:59 +00:00
parent 92e0ee86a5
commit 3060d95322
3 changed files with 14 additions and 9 deletions

View File

@ -115,6 +115,9 @@ class addressbook_ads extends addressbook_ldap
'n_fn' => 'displayname', // leave CN used in DN untouched 'n_fn' => 'displayname', // leave CN used in DN untouched
'accountexpires', 'useraccountcontrol', // needed to exclude deactivated or expired accounts 'accountexpires', 'useraccountcontrol', // needed to exclude deactivated or expired accounts
)); ));
unset($this->schema2egw['user']['n_fileas']);
unset($this->schema2egw['inetorgperson']);
foreach($this->schema2egw as $schema => $attributes) foreach($this->schema2egw as $schema => $attributes)
{ {
$this->all_attributes = array_merge($this->all_attributes,array_values($attributes)); $this->all_attributes = array_merge($this->all_attributes,array_values($attributes));
@ -195,7 +198,7 @@ class addressbook_ads extends addressbook_ldap
// ignore deactivated or expired accounts // ignore deactivated or expired accounts
if (!$this->accounts_ads->user_active($data)) return false; if (!$this->accounts_ads->user_active($data)) return false;
$this->_inetorgperson2egw($contact, $data); $this->_inetorgperson2egw($contact, $data, 'displayname');
} }
/** /**

View File

@ -1227,24 +1227,25 @@ class addressbook_ldap
* @param array &$contact already copied fields according to the mapping * @param array &$contact already copied fields according to the mapping
* @param array $data eGW contact data * @param array $data eGW contact data
*/ */
function _inetorgperson2egw(&$contact,$data) function _inetorgperson2egw(&$contact, $data, $cn='cn')
{ {
if(empty($data['givenname'][0])) if(empty($data['givenname'][0]))
{ {
$parts = explode($data['sn'][0], $data['cn'][0]); $parts = explode($data['sn'][0], $data[$cn][0]);
$contact['n_prefix'] = trim($parts[0]); $contact['n_prefix'] = trim($parts[0]);
$contact['n_suffix'] = trim($parts[1]); $contact['n_suffix'] = trim($parts[1]);
} }
else else
{ {
$parts = preg_split('/'. preg_quote($data['givenname'][0],'/') .'.*'. preg_quote($data['sn'][0],'/') .'/', $data['cn'][0]); $parts = preg_split('/'. preg_quote($data['givenname'][0],'/') .'.*'. preg_quote($data['sn'][0],'/') .'/', $data[$cn][0]);
$contact['n_prefix'] = trim($parts[0]); $contact['n_prefix'] = trim($parts[0]);
$contact['n_suffix'] = trim($parts[1]); $contact['n_suffix'] = trim($parts[1]);
if(preg_match('/'. preg_quote($data['givenname'][0],'/') .' (.*) '. preg_quote($data['sn'][0],'/') .'/',$data['cn'][0], $matches)) if(preg_match('/'. preg_quote($data['givenname'][0],'/') .' (.*) '. preg_quote($data['sn'][0],'/') .'/',$data[$cn][0], $matches))
{ {
$contact['n_middle'] = $matches[1]; $contact['n_middle'] = $matches[1];
} }
} }
//error_log(__METHOD__."(, data=array($cn=>{$data[$cn][0]}, sn=>{$data['sn'][0]}, givenName=>{$data['givenname'][0]}), cn='$cn') returning with contact=array(n_prefix={$contact['n_prefix']}, n_middle={$contact['n_middle']}, n_suffix={$contact['n_suffix']}) ".function_backtrace());
} }
/** /**

View File

@ -1868,13 +1868,14 @@ class addressbook_ui extends addressbook_bo
{ {
$readonlys[$field] = true; $readonlys[$field] = true;
} }
if ($readonlys['n_fileas']) $readonlys['fileas_type'] = true;
// disable not needed tabs // disable not needed tabs
$readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']); $readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
$readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts; $readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts;
$readonlys['tabs']['custom_private'] = $readonlys['tabs']['custom'] || !$this->config['private_cf_tab']; $readonlys['tabs']['custom_private'] = $readonlys['tabs']['custom'] || !$this->config['private_cf_tab'];
$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
$readonlys['tabs']['history'] = $this->contact_repository == 'ldap' || !$content['id'] || $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
$this->account_repository == 'ldap' && $content['account_id']; $this->account_repository != 'sql' && $content['account_id'];
$readonlys['button[delete]'] = !$content['id']; $readonlys['button[delete]'] = !$content['id'];
if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
$readonlys['change_org'] = empty($content['org_name']) || $view; $readonlys['change_org'] = empty($content['org_name']) || $view;
@ -2157,8 +2158,8 @@ class addressbook_ui extends addressbook_bo
$readonlys['tabs']['custom'] = !$this->customfields; $readonlys['tabs']['custom'] = !$this->customfields;
$readonlys['tabs']['custom_private'] = !$this->customfields || !$this->config['private_cf_tab']; $readonlys['tabs']['custom_private'] = !$this->customfields || !$this->config['private_cf_tab'];
$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
$readonlys['tabs']['history'] = $this->contact_repository == 'ldap' || !$content['id'] || $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
$this->account_repository == 'ldap' && $content['account_id']; $this->account_repository != 'sql' && $content['account_id'];
if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
// last and next calendar date // last and next calendar date