From: Jakob Haufe Date: Fri, 14 Dec 2012 16:47:56 +0000 (+0100) Subject: Make phone multivalue aware X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=refs%2Fheads%2Fmultivalue;p=contagged Make phone multivalue aware This makes it possible to have an arbitrary number of (office) phone values. CSV export will only use the first one, as before. VCF importer should also correctly recognize multiple TEL;WORK;VOICE fields. --- diff --git a/import.php b/import.php index d369b1c..eac6b0f 100644 --- a/import.php +++ b/import.php @@ -87,7 +87,7 @@ function vcard_entry($vcf){ my_array_search('VOICE',(array) $tel['param']['TYPE']) != false)) { // Work phone - $entry['phone'] = $tel['value'][0][0]; + $entry['phone'][] = $tel['value'][0][0]; }elseif(empty($entry['fax']) && my_array_search('FAX',(array) $tel['param']['TYPE']) !== false){ $entry['fax'] = $tel['value'][0][0]; diff --git a/inc/fields.php b/inc/fields.php index f7e4162..ec8ed88 100644 --- a/inc/fields.php +++ b/inc/fields.php @@ -30,7 +30,7 @@ $FIELDS = array( 'street' => 'postalAddress', 'zip' => 'postalCode', 'location' => 'l', // aka. city - 'phone' => 'telephoneNumber', + '_phone' => 'telephoneNumber', 'fax' => 'facsimileTelephoneNumber', 'mobile' => 'mobile', // aka. cell phone 'pager' => 'pager', diff --git a/templates/entry_edit.tpl b/templates/entry_edit.tpl index 043f531..98aeb90 100644 --- a/templates/entry_edit.tpl +++ b/templates/entry_edit.tpl @@ -102,10 +102,16 @@ {/if} -{if $fields.phone} +{if $fields._phone} + {foreach from=$entry.phone|smarty:nodefaults item=phone} - {$lang.phone}: - + {$lang.phone} {counter name=phone}: + + + {/foreach} + + {$lang.phone} {counter name=phone}: + {/if} {if $fields.switchboard} diff --git a/templates/entry_show.tpl b/templates/entry_show.tpl index 4fbe17b..f340caa 100644 --- a/templates/entry_show.tpl +++ b/templates/entry_show.tpl @@ -47,7 +47,11 @@ {if $entry.phone} {$lang.phone}: - {$entry.phone|h} + + {foreach from=$entry.phone item=phone} + {$phone|h}
+ {/foreach} + {/if} {if $entry.switchboard} diff --git a/templates/entry_vcf.tpl b/templates/entry_vcf.tpl index 5ce4e5c..1814d53 100644 --- a/templates/entry_vcf.tpl +++ b/templates/entry_vcf.tpl @@ -4,7 +4,9 @@ N:{$entry.name};{$entry.givenname};;{$entry.title} FN:{$entry.givenname} {$entry.name} ORG;ENCODING=QUOTED-PRINTABLE:{$entry.organisation|escape:qp};{$entry.office|escape:qp} NOTE;ENCODING=QUOTED-PRINTABLE:{$entry.note|escape:qp} -TEL;WORK;VOICE;ENCODING=QUOTED-PRINTABLE:{$entry.phone|escape:qp} +{foreach from=$entry.phone item=phone} +TEL;WORK;VOICE;ENCODING=QUOTED-PRINTABLE:{$phone|escape:qp} +{/foreach} {foreach from=$entry.homephone item=homephone} TEL;HOME;VOICE;ENCODING=QUOTED-PRINTABLE:{$homephone|escape:qp} {/foreach} diff --git a/templates/import_entry.tpl b/templates/import_entry.tpl index bde612c..be96fd2 100644 --- a/templates/import_entry.tpl +++ b/templates/import_entry.tpl @@ -16,7 +16,9 @@ - + {foreach from=$entry.phone item=phone} + + {/foreach} diff --git a/templates/list_csv_entry.tpl b/templates/list_csv_entry.tpl index 15b07c6..c74989c 100644 --- a/templates/list_csv_entry.tpl +++ b/templates/list_csv_entry.tpl @@ -1,2 +1,2 @@ -{$entry.name|csv};{$entry.givenname|csv};{$entry.title|csv};{$entry.organization|csv};{$entry.office|csv};{$entry.street|csv};{$entry.zip|csv};{$entry.location|csv};{$entry.country|csv};{$entry.phone|csv};{$entry.fax|csv};{$entry.pager|csv};{$entry.homestreet|csv};{$entry.homephone[0]|csv};{$entry.mobile|csv};{$lang.url|csv};{$entry.note|csv};{$entry.mail[0]|csv};{$entry.mail[1]|csv};{$entry.mail[2]|csv};{$entry.markers|csv} +{$entry.name|csv};{$entry.givenname|csv};{$entry.title|csv};{$entry.organization|csv};{$entry.office|csv};{$entry.street|csv};{$entry.zip|csv};{$entry.location|csv};{$entry.country|csv};{$entry.phone[0]|csv};{$entry.fax|csv};{$entry.pager|csv};{$entry.homestreet|csv};{$entry.homephone[0]|csv};{$entry.mobile|csv};{$lang.url|csv};{$entry.note|csv};{$entry.mail[0]|csv};{$entry.mail[1]|csv};{$entry.mail[2]|csv};{$entry.markers|csv} diff --git a/templates/list_entry.tpl b/templates/list_entry.tpl index 05bcd7a..6c2b871 100644 --- a/templates/list_entry.tpl +++ b/templates/list_entry.tpl @@ -11,7 +11,7 @@ {$entry.organization|h}  - {$entry.phone|h}  + {$entry.phone[0]|h}  {$entry.mail[0]|h}