From 28b534d7eb4542a8de5ff7e4eaf3d366db4b3c0c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 6 May 2016 16:17:05 +0000 Subject: [PATCH] implement birthday as fileas option --- api/src/Contacts.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/api/src/Contacts.php b/api/src/Contacts.php index 794a6c6872..51790d637e 100755 --- a/api/src/Contacts.php +++ b/api/src/Contacts.php @@ -57,6 +57,7 @@ class Contacts extends Contacts\Storage 'n_family, n_given', 'n_family, n_prefix', 'n_fn', + 'n_family, n_given (bday)', ); /** @@ -416,7 +417,7 @@ class Contacts extends Contacts\Storage if($isUpdate) { - $fileas_fields = array('n_prefix','n_given','n_middle','n_family','n_suffix','n_fn','org_name','org_unit','adr_one_locality'); + $fileas_fields = array('n_prefix','n_given','n_middle','n_family','n_suffix','n_fn','org_name','org_unit','adr_one_locality','bday'); $old = null; foreach($fileas_fields as $field) { @@ -432,9 +433,18 @@ class Contacts extends Contacts\Storage // removing empty delimiters, caused by empty contact fields $fileas = str_replace(array(', , : ',', : ',': , ',', , ',': : ',' ()'), array(': ',': ',': ',', ',': ',''), - str_replace(array('n_prefix','n_given','n_middle','n_family','n_suffix','n_fn','org_name','org_unit','adr_one_locality'), - array($contact['n_prefix'],$contact['n_given'],$contact['n_middle'],$contact['n_family'],$contact['n_suffix'], - $contact['n_fn'], $contact['org_name'], $contact['org_unit'], $contact['adr_one_locality']), $type)); + strtr($type, array( + 'n_prefix' => $contact['n_prefix'], + 'n_given' => $contact['n_given'], + 'n_middle' => $contact['n_middle'], + 'n_family' => $contact['n_family'], + 'n_suffix' => $contact['n_suffix'], + 'n_fn' => $contact['n_fn'], + 'org_name' => $contact['org_name'], + 'org_unit' => $contact['org_unit'], + 'adr_one_locality' => $contact['adr_one_locality'], + 'bday' => (int)$contact['bday'] ? DateTime::to($contact['bday'], true) : $contact['bday'], + ))); while ($fileas[0] == ':' || $fileas[0] == ',') { @@ -505,6 +515,7 @@ class Contacts extends Contacts\Storage 'org_name' => lang('company'), 'org_unit' => lang('department'), 'adr_one_locality' => lang('city'), + 'bday' => lang('Birthday'), ); foreach(array_keys($labels) as $name) {