3 # LiCoM - Lightweight contact manager
4 # Copyright (c) 2005-2006 Florian octo Forster <octo at verplant.org>
6 # This program is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free Software
8 # Foundation; only version 2 of the License is applicable.
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 # You should have received a copy of the GNU General Public License along with
16 # this program; if not, write to the Free Software # Foundation, Inc.,
17 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 use CGI::Carp (qw(fatalsToBrowser));
26 use HTML::Entities (qw(encode_entities));
28 use LiCoM::Config (qw(get_config set_config read_config));
29 use LiCoM::Connection ();
35 our @MultiFields = (qw(address homephone cellphone officephone fax mail uri));
40 homephone => 'Home Phone',
41 cellphone => 'Cell Phone',
42 officephone => 'Office Phone',
45 uri => 'URI (Homepage)',
49 our $MySelf = $ENV{'SCRIPT_NAME'};
51 our $Action = param ('action');
52 $Action ||= 'default';
56 browse => [\&html_start, \&action_browse, \&html_end],
57 default => [\&html_start, \&action_browse, \&html_end],
58 detail => [\&html_start, \&action_detail, \&html_end],
59 edit => [\&html_start, \&action_edit, \&html_end],
60 list => [\&html_start, \&action_list, \&html_end],
61 save => [\&html_start, \&action_save, \&html_end],
62 search => [\&html_start, \&action_search, \&html_end],
63 verify => [\&html_start, \&action_verify, \&html_end],
64 delete => [\&html_start, \&action_ask_del, \&html_end],
65 expunge => [\&html_start, \&action_do_del, \&html_end],
66 vcard => \&action_vcard,
67 edit_group => [\&html_start, \&action_edit_group, \&html_end],
68 save_group => [\&html_start, \&action_save_group, \&html_end]
73 # make sure AuthLDAPRemoteUserIsDN is enabled.
74 die unless ($ENV{'REMOTE_USER'});
75 set_config ('base_dn', $ENV{'REMOTE_USER'});
77 die unless (defined (get_config ('uri'))
78 and defined (get_config ('base_dn'))
79 and defined (get_config ('bind_dn'))
80 and defined (get_config ('password')));
82 LiCoM::Connection->connect
84 uri => get_config ('uri'),
85 bind_dn => get_config ('bind_dn'),
86 password => get_config ('password')
89 our ($UserCN, $UserID) = LiCoM::Person->get_user ($ENV{'REMOTE_USER'});
91 if (!$UserID and $Action ne 'save')
101 if (!defined ($Actions{$Action}))
103 die ("No such action: $Action");
106 if (ref ($Actions{$Action}) eq 'CODE')
108 $Actions{$Action}->();
110 elsif (ref ($Actions{$Action}) eq 'ARRAY')
112 for (@{$Actions{$Action}})
118 LiCoM::Connection->disconnect ();
126 my $group = param ('group');
127 $group = shift if (@_);
132 my @groups = LiCoM::Group->all ();
134 print qq(\t\t<h2>Contact groups</h2>\n\t\t<ul class="groups">\n);
138 my @members = $group->get_members ();
139 my $members = scalar (@members);
140 my $group_name = $group->name ();
141 my $group_uri = uri_escape ($group_name);
142 my $desc = $group->description ();
144 print qq#\t\t\t<li><a href="$MySelf?action=browse&group=$group_uri">#,
145 encode_entities ($group_name),
146 qq#</a> ($members Member#, ($members == 1 ? ')' : 's)');
147 print qq(<br />\n\t\t\t\t<span class="description">),
148 encode_entities ($desc) . '</span>' if ($desc);
153 print qq(\t\t\t<li class="empty">There are no groups yet.</li>\n);
158 [<a href="$MySelf?action=list">List all</a>]
164 my $group_obj = LiCoM::Group->load ($group);
165 my $group_uri = uri_escape ($group_obj->name ());
166 my $group_html = encode_entities ($group_obj->name ());
167 my @member_names = $group_obj->get_members ();
168 my $desc = $group_obj->description ();
169 my $desc_html = encode_entities ($desc || '');
171 print qq(\t\t<h2>Contact group "$group_html"</h2>\n);
172 print qq(\t\t<div>$desc_html</div>\n) if ($desc);
173 print qq(\t\t<ul class="results">\n);
174 for (sort (@member_names))
177 my $cn_uri = uri_escape ($cn);
178 my $cn_html = encode_entities ($cn);
180 print qq(\t\t\t<li><a href="$MySelf?action=detail&cn=$cn_uri">$cn_html</a></li>\n);
186 [<a href="$MySelf?action=list&group=$group_uri">List</a>]
187 [<a href="$MySelf?action=browse">Back</a>]
188 [<a href="$MySelf?action=edit_group&group=$group_uri">Edit</a>]
196 my $group_name = param ('group');
197 $group_name = shift if (@_);
200 my $group_name_html = encode_entities ($group_name || '');
202 my $title = $group_name
203 ? "List of group "$group_name_html""
204 : 'List of all addresses';
205 my @fields = (qw(address homephone cellphone officephone fax mail));
210 my $group_obj = LiCoM::Group->load ($group_name);
215 Unable to load group "$group_name_html".
220 for ($group_obj->get_members ())
223 my $person_obj = LiCoM::Person->load ($cn);
227 print STDERR "Unable to load cn = $cn;\n";
230 push (@all, $person_obj);
235 @all = LiCoM::Person->search ([[group => $group_name]]);
247 print "\t\t\t\t<th>" . (defined ($FieldNames{$_}) ? $FieldNames{$_} : $_) . "</th>\n";
249 print "\t\t\t</tr>\n";
251 for (sort { $a->name () cmp $b->name () } (@all))
254 my $cn = $person->name ();
255 my $sn = $person->lastname ();
256 my $gn = $person->firstname ();
258 my $cn_uri = uri_escape ($cn);
259 my $cn_html = encode_entities ("$sn, $gn");
261 print "\t\t\t<tr>\n",
262 qq(\t\t\t\t<td><a href="$MySelf?action=detail&cn=$cn_uri">$cn_html</a></td>\n);
267 my @values = $person->get ($field);
268 print "\t\t\t\t<td>" . join ('<br />', map { markup_field ($field, $_) } (@values)) . "</td>\n";
271 print "\t\t\t</tr>\n";
273 print "\t\t</table>\n\n";
277 my $group_esc = uri_escape ($group_name);
278 print qq(\t\t<div class="menu">[<a href="$MySelf?action=browse&group=$group_esc">Back</a>]</div>\n);
282 print qq(\t\t<div class="menu">[<a href="$MySelf?action=browse">Back</a>]</div>\n);
288 my $cn = param ('cn');
292 my $cn_html = encode_entities ($cn);
293 my $cn_uri = uri_escape ($cn);
295 my $person = LiCoM::Person->load ($cn);
298 print qq(\t<div>Entry "$cn_html" could not be loaded from DB.</div>\n);
302 print qq(\t\t<h2>Details for $cn_html</h2>\n);
305 <table class="detail">
314 my $values = $person->get ($field);
315 my $num = scalar (@$values);
316 my $field_name = defined ($FieldNames{$field}) ? $FieldNames{$field} : $field;
320 $field_name = encode_entities ($field_name);
322 print "\t\t\t<tr>\n";
325 print qq(\t\t\t\t<th rowspan="$num">$field_name</th>\n);
329 print qq(\t\t\t\t<th>$field_name</th>\n);
332 for (my $i = 0; $i < $num; $i++)
334 my $val = markup_field ($field, $values->[$i]);
336 print "\t\t\t<tr>\n" if ($i);
337 print "\t\t\t\t<td>$val</td>\n",
342 my @groups = LiCoM::Group->load_by_member ($cn);
345 my $num = scalar (@groups);
346 print "\t\t\t<tr>\n",
347 "\t\t\t\t<th", ($num == 1 ? '' : qq( rowspan="$num")), ">Group", ($num == 1 ? '' : 's'), "</th>\n";
348 for (my $i = 0; $i < $num; $i++)
350 my $group = $groups[$i];
351 my $group_name = $group->name ();
352 my $group_uri = uri_escape ($group_name);
353 my $group_html = encode_entities ($group_name);
355 print "\t\t\t<tr>\n" if ($i != 0);
356 print qq(\t\t\t\t<td><a href="$MySelf?action=browse&group=$group_uri">$group_html</a></td>\n),
365 [<a href="$MySelf?action=verify&cn=$cn_uri">Verify</a>]
366 [<a href="$MySelf?action=vcard&cn=$cn_uri">vCard</a>]
367 [<a href="$MySelf?action=edit&cn=$cn_uri">Edit</a>]
368 [<a href="$MySelf?action=delete&cn=$cn_uri">Delete</a>]
376 my $search = param ('search');
379 $search =~ s/[^\s\w]//g;
383 print qq(\t<div class="error">Sorry, the empty search is not allowed.</div>\n);
388 my @patterns = split (m/\s+/, $search);
394 push (@filter, [[lastname => $pattern], [firstname => $pattern]]);
397 my @matches = LiCoM::Person->search (@filter);
401 print qq(\t<div>No entries matched your search.</div>\n);
405 if (scalar (@matches) == 1)
407 my $person = shift (@matches);
408 my $cn = $person->name ();
413 print qq(\t<ul class="result">\n);
414 for (sort { $a->name () cmp $b->name () } (@matches))
417 my $cn = $person->name ();
418 my $cn_uri = uri_escape ($cn);
419 my $cn_html = encode_entities ($cn);
421 print qq(\t\t<li><a href="$MySelf?action=detail&cn=$cn_uri">$cn_html</a></li>\n);
430 my $cn = param ('cn');
432 $cn = $opts{'cn'} if (defined ($opts{'cn'}));
435 my $cn_html = encode_entities ($cn);
448 $contacts->{$_} = [] for (@MultiFields);
452 $person = LiCoM::Person->load ($cn);
456 print qq(\t<div class="error">Unable to load CN "$cn". Sorry.</div>\n);
460 $lastname = $person->lastname ();
461 $firstname = $person->firstname ();
465 $contacts->{$_} = $person->get ($_);
469 $lastname = param ('lastname') if (param ('lastname') and $UserID);
470 $firstname = param ('firstname') if (param ('firstname') and $UserID);
472 get_contacts ($contacts);
474 $lastname = $opts{'lastname'} if (defined ($opts{'lastname'}));
475 $firstname = $opts{'firstname'} if (defined ($opts{'firstname'}));
479 @{$contacts->{$field}} = @{$opts{$field}} if (defined ($opts{$field}));
484 print "\t\t<h2>Edit contact $cn_html</h2>\n";
488 print "\t\t<h2>Create new contact</h2>\n";
492 <form action="$MySelf" method="post">
493 <input type="hidden" name="action" value="save" />
494 <input type="hidden" name="cn" value="$cn_html" />
501 print qq(\t\t\t\t<td><input type="text" name="lastname" value="$lastname" /></td>\n);
505 print qq(\t\t\t\t<td>$lastname</td>\n);
514 print qq(\t\t\t\t<td><input type="text" name="firstname" value="$firstname" /></td>\n);
518 print qq(\t\t\t\t<td>$firstname</td>\n);
521 print "\t\t\t</tr>\n";
526 my $print = defined ($FieldNames{$field}) ? $FieldNames{$field} : $field;
527 my @values = @{$contacts->{$field}};
529 next if ($field eq 'group');
533 $field = encode_entities ($field);
534 $print = encode_entities ($print);
538 my $value = encode_entities ($_);
543 <td><input type="text" name="$field" value="$value" /></td>
551 my @all_groups = LiCoM::Group->all ();
555 print "\t\t\t<tr>\n",
556 "\t\t\t\t<th>Group(s)</th>\n",
557 qq(\t\t\t\t<td><select name="group" multiple="multiple" size="5">\n);
562 my $group_name = encode_entities ($group->name ());
565 if (grep { $cn eq $_ } ($group->get_members ()))
567 $selected = ' selected="selected"';
570 print qq(\t\t\t\t\t<option value="$group_name"$selected>$group_name</option>\n);
572 print "\t\t\t\t</select></td>\n",
576 print "\t\t\t<tr>\n",
577 "\t\t\t\t<th>New Group</th>\n",
578 qq(\t\t\t\t<td><input type="text" name="newgroup" value="" /></td>\n),
584 <th colspan="2" class="menu">
589 <input type="submit" name="button" value="Cancel" />
590 <input type="submit" name="button" value="Apply" />
594 <input type="submit" name="button" value="Save" />
604 my $cn = $UserID ? param ('cn') : $UserCN;
606 if (verify_fields ())
608 action_edit (cn => $cn);
618 die unless ($UserID);
620 my $button = lc (param ('button'));
623 if ($button eq 'cancel')
629 if (!param ('lastname') or !param ('firstname'))
631 print qq(\t<div class="error">You have to give both, first and lastname, to identify this record.</div>\n);
632 action_edit (cn => '');
636 my $lastname = param ('lastname');
637 my $firstname = param ('firstname');
639 my $contacts = get_contacts ();
641 my $person = LiCoM::Person->create (lastname => $lastname, firstname => $firstname, %$contacts);
645 print qq(\t<div class="error">Unable to save entry. Sorry.</div>\n);
649 $cn = $person->name ();
651 for (param ('group'))
654 my $group = LiCoM::Group->load ($group_name);
658 $group->add_members ($cn);
662 my $group_html = encode_entities ($group_name);
663 print qq(\t<div class="error">Group "$group_html" does not exist or could not be loaded.</div>\n);
667 if (param ('newgroup'))
669 # FIXME add error handling
670 my $group_name = param ('newgroup');
671 LiCoM::Group->create ($group_name, '', $cn);
674 if ($button eq 'apply')
676 action_edit (cn => $cn);
686 my $cn = $UserID ? param ('cn') : $UserCN;
687 my $person = LiCoM::Person->load ($cn);
689 die unless ($person);
691 my $button = lc (param ('button'));
694 if ($UserID and $button eq 'cancel')
702 my $lastname = param ('lastname');
703 my $firstname = param ('firstname');
705 $person->lastname ($lastname) if ($lastname and $lastname ne $person->lastname ());
706 $person->firstname ($firstname) if ($firstname and $firstname ne $person->firstname ());
708 $cn = $person->name ();
710 # Each group is one entry of type (objectClass=groupOfNames)
711 # with one or more `member' attributes. These attributes are
712 # the `dn' (distinguished name) of the member entries.
715 my $contacts = get_contacts ();
721 next if (!$UserID and $field eq 'group');
723 if (defined ($contacts->{$field}))
725 my $values = $contacts->{$field};
726 $person->set ($field, $values);
730 $person->set ($field, []);
734 # only `authorized' users may see and change groups
737 my %changed_groups = map { $_ => 1 } (param ('group'));
738 my @current_groups = LiCoM::Group->load_by_member ($cn);
740 for (@current_groups)
743 my $group_name = $group_obj->name ();
745 if (!defined ($changed_groups{$group_name}))
747 $group_obj->del_members ($cn);
751 delete ($changed_groups{$group_name});
754 for (keys %changed_groups)
757 my $group_obj = LiCoM::Group->load ($group_name) or die;
759 $group_obj->add_members ($cn);
762 if (param ('newgroup'))
764 # FIXME add error handling
765 my $group_name = param ('newgroup');
766 LiCoM::Group->create ($group_name, '', $cn);
773 <h3>Your changes have been saved.</h3>
774 <p>Thank you very much for taking the time to keep this record up to date.</p>
779 if ($button eq 'apply' or !$UserID)
781 action_edit (cn => $cn);
791 my $cn = param ('cn');
795 my $person = LiCoM::Person->load ($cn);
796 die unless ($person);
800 homephone => 'TEL;TYPE=home,voice',
801 cellphone => 'TEL;TYPE=cell',
802 officephone => 'TEL;TYPE=work,voice',
803 fax => 'TEL;TYPE=fax',
809 my $sn = $person->lastname ();
810 my $gn = $person->firstname ();
811 my $cn_esc = uri_escape ($cn);
814 Content-Type: text/x-vcard
815 Content-Disposition: attachment; filename="$cn.vcf"
826 my $vc_fld = $vcard_types{$field};
827 my $values = $person->get ($field);
829 next unless ($vc_fld);
834 print "$vc_fld:$value\n";
842 my $cn = param ('cn');
846 my $cn_html = encode_entities ($cn);
848 my $person = LiCoM::Person->load ($cn);
849 die unless ($person);
851 my ($mail) = $person->get ('mail');
855 my ($password) = $person->get ('password');
860 $password = pwgen ();
861 $person->set ('password', [$password]);
863 $password_html = encode_entities ($password);
865 $message = qq(The password for the record "$cn_html" is "$password_html".);
869 if (action_verify_send_mail ($person))
871 my $mail_html = encode_entities ($mail);
872 $message .= qq( A request for verification has been sent to $mail_html.);
877 $message .= q( There was no e-mail address, thus no verification request could be sent.);
880 print qq(\t\t<div class="message">$message</div>\n);
885 sub action_verify_send_mail
888 my $owner = LiCoM::Person->load ($UserCN);
891 my ($owner_mail) = $owner->get ('mail');
894 my $cn_uri = uri_escape ($UserCN);
895 print qq(\t\t<div class="error">You have no email set in your own profile. <a href="$MySelf?action=edit&cn=$cn_uri">Edit it now</a>!</div>\n);
900 for (keys %FieldNames)
902 $max_width = length $FieldNames{$_} if ($max_width < length $FieldNames{$_});
906 my $person_name = $person->name ();
907 my ($person_mail) = $person->get ('mail');
908 my $person_gn = $person->firstname ();
909 my ($password) = $person->get ('password');
911 my $host = $ENV{'HTTP_HOST'};
912 my $url = (defined ($ENV{'HTTPS'}) ? 'https://' : 'http://') . $host . $MySelf;
914 open ($smh, '|-', '/usr/sbin/sendmail', '-t', '-f', $owner_mail) or die ("open (sendmail): $!");
916 To: $person_name <$person_mail>
917 From: $UserCN <$owner_mail>
918 Subject: Please verify our entry in my address book
922 the following is your entry in my address book:
927 my $print = defined ($FieldNames{$field}) ? $FieldNames{$field} : $field;
928 my @values = $person->get ($field);
932 printf $smh ('%'.$max_width."s: %-s\n", $print, $_);
937 If this entry is outdated or incomplete, please take a minute and correct it.
939 Username: $person_name
942 Thank you very much :)
947 This message was automatically generated by LiCoM,
948 http://verplant.org/licom/
957 my $cn = param ('cn');
960 my $person = LiCoM::Person->load ($cn);
963 my $cn_uri = uri_escape ($cn);
964 my $cn_html = encode_entities ($cn);
967 <h2>Really delete $cn_html?</h2>
970 You are about to delete <strong>$cn_html</strong>.
971 Are you totally, absolutely sure you want to do this?
975 [<a href="$MySelf?action=expunge&cn=$cn_uri">Yes, delete</a>]
976 [<a href="$MySelf?action=detail&cn=$cn_uri">No, keep</a>]
984 my $cn = param ('cn');
987 my $cn_html = encode_entities ($cn);
989 my $person = LiCoM::Person->load ($cn);
995 <div>$cn_html has been deleted.</div>
1001 sub action_edit_group
1003 my $group_name = param ('group') or die;
1005 my $group_name_html = encode_entities ($group_name);
1007 my $group_obj = LiCoM::Group->load ($group_name);
1011 print qq(\t<div class="error">Group "$group_name_html" does not exist or could not be loaded.</div>\n);
1015 $group_name_html = encode_entities ($group_obj->name ());
1017 my $desc_html = encode_entities ($group_obj->description () || '');
1020 <h2>Edit contact group "$group_name_html"</h2>
1021 <form action="$MySelf" method="post">
1022 <input type="hidden" name="action" value="save_group" />
1023 <input type="hidden" name="group" value="$group_name_html" />
1027 <td>$group_name_html</td>
1030 <th>Description</th>
1031 <td><input type="text" name="description" value="$desc_html" /></td>
1034 <th colspan="2"><input type="submit" name="button" value="Save" /></th>
1041 sub action_save_group
1043 my $group_name = param ('group') or die;
1045 my $group_name_html = encode_entities ($group_name);
1047 my $group_obj = LiCoM::Group->load ($group_name);
1051 print qq(\t<div class="error">Group "$group_name_html" does not exist or could not be loaded.</div>\n);
1055 my $desc = param ('description');
1056 $group_obj->description ($desc);
1065 $title = q(Lightweight Contact Manager) unless ($title);
1067 $title = encode_entities ($title);
1070 Content-Type: text/html; charset=UTF-8
1074 <title>$title</title>
1075 <style type="text/css">
1082 background-color: inherit;
1083 text-decoration: none;
1088 text-decoration: underline;
1094 background-color: inherit;
1100 background-color: white;
1106 background-color: yellow;
1110 border: 2px solid red;
1116 background-color: white;
1126 border-top: 1px solid black;
1133 background-color: inherit;
1134 text-decoration: none;
1139 text-decoration: underline;
1144 border-top: 1px solid black;
1152 background-color: transparent;
1158 padding-bottom: 1ex;
1159 border-bottom: 1px solid black;
1188 border: 2px solid #d0d0d0;
1199 background-color: #e8e8e8;
1200 vertical-align: top;
1206 background-color: #d0d0d0;
1209 vertical-align: top;
1223 background-color: inherit;
1224 text-decoration: underline;
1227 div.topmenu, div.menu
1250 border-collapse: collapse;
1265 border-bottom-width: 2px;
1270 border: 1px solid black;
1271 vertical-align: top;
1289 my $search = param ('search') || '';
1290 $search = encode_entities ($search);
1292 <div class="topmenu">
1293 <form action="$MySelf" method="post">
1294 <input type="hidden" name="action" value="browse" />
1295 <input type="submit" name="button" value="Browse" />
1297 <form action="$MySelf" method="post">
1298 <input type="hidden" name="action" value="search" />
1299 <input type="text" name="search" value="$search" />
1300 <input type="submit" name="button" value="Search" />
1302 <form action="$MySelf" method="post">
1303 <input type="hidden" name="action" value="edit" />
1304 <input type="hidden" name="dn" value="" />
1305 <input type="submit" name="button" value="Add New" />
1310 print "\t\t<h1>$title</h1>\n";
1317 "Lightweight Contact Manager",
1318 written 2005-2006 by <a href="http://verplant.org/">Florian octo Forster</a>
1319 <octo at verplant.org>
1328 my $len = @_ ? shift : 6;
1337 while (length ($retval) < $len)
1339 my $chr = int (rand (128));
1341 if ($chr >= 48 and $chr < 58)
1345 elsif ($chr >= 65 and $chr < 91)
1349 elsif ($chr >= 97 and $chr < 123)
1357 $retval .= chr ($chr);
1360 $retval = '' if (!$numbers or !$lchars or !$uchars);
1374 if ($val !~ m#^[a-zA-Z]+://#)
1376 push (@errors, 'URIs have to begin with a protocol, e.g. "http://", "ftp://" etc.');
1381 for (param ('homephone'), param ('cellphone'), param ('officephone'), param ('fax'))
1384 next unless ($number);
1386 if ($number !~ m/^\+[0-9 \-]+$/)
1388 push (@errors, 'Telephone numbers have to begin with the country code and only numbers, spaces and dashes are allowed, e.g. "+49 911-123456"');
1393 print qq(\t\t<div class="error">\n) if (@errors);
1394 for (my $i = 0; $i < scalar (@errors); $i++)
1396 my $e = $errors[$i];
1398 print "<br />\n" if ($i);
1401 print qq(\n\t\t</div>\n\n) if (@errors);
1403 return (scalar (@errors));
1411 my $value_uri = uri_escape ($value);
1412 my $value_html = encode_entities ($value);
1414 if ($field eq 'group')
1416 return (qq(<a href="$MySelf?action=browse&group=$value_uri">$value_html</a>));
1418 elsif ($field eq 'uri')
1420 if ($value =~ m#^([a-z]+)://(.+)$#)
1422 $value_uri = $1 . '://' . uri_escape ($2);
1426 $value_uri = 'http://' . uri_escape ($value);
1428 return (qq(<a href="$value_uri" class="extern">$value_html</a>));
1430 elsif ($field eq 'mail')
1432 return (qq(<a href="mailto:$value_uri" class="mail">$value_html</a>));
1434 return ($value_html);
1439 my $contacts = @_ ? shift : {};
1444 my @values = grep { $_ } (param ($field));
1446 next unless (@values);
1448 if ($field eq 'homephone' or $field eq 'cellphone' or $field eq 'officephone' or $field eq 'fax')
1452 $_ =~ s/[^0-9 \-]//g;
1453 $_ = '+' . $_ if ($_);
1457 $contacts->{$field} = [@values] if (@values);