n_fn issue backport to epl9.1

This commit is contained in:
Klaus Leithoff 2010-03-08 11:18:10 +00:00
parent 9fcd55ed87
commit 0b3377534f
2 changed files with 13 additions and 2 deletions

View File

@ -441,8 +441,13 @@ class addressbook_bo extends addressbook_so
*/
function fullname($contact)
{
if (empty($contact['n_family']) && empty($contact['n_given'])) {
$cpart = array('org_name');
} else {
$cpart = array('n_prefix','n_given','n_middle','n_family','n_suffix');
}
$parts = array();
foreach(array('n_prefix','n_given','n_middle','n_family','n_suffix') as $n)
foreach($cpart as $n)
{
if ($contact[$n]) $parts[] = $contact[$n];
}
@ -611,7 +616,7 @@ class addressbook_bo extends addressbook_so
$contact['modifier'] = $this->user;
$contact['modified'] = $this->now_su;
// set full name and fileas from the content
if (isset($contact['n_family']) && isset($contact['n_given']))
if (!isset($contact['n_fn']) )
{
$contact['n_fn'] = $this->fullname($contact);
if (isset($contact['org_name'])) $contact['n_fileas'] = $this->fileas($contact);

View File

@ -1213,9 +1213,15 @@ class addressbook_ui extends addressbook_bo
{
$links = $content['link_to']['to_id'];
}
$fullname = $old_fullname = parent::fullname($content);
if ($content['id'] && $content['org_name'] && $content['change_org'])
{
$old_org_entry = $this->read($content['id']);
$old_fullname = ($old_org_entry['n_fn'] ? $old_org_entry['n_fn'] : parent::fullname($old_org_entry));
}
if ( $content['n_fn'] != $fullname || $fullname != $old_fullname)
{
unset($content['n_fn']);
}
if ($this->save($content))
{