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]
72 my @files = (qw(/etc/licom/licom.conf));
73 push (@files, './licom.conf') if (-r './licom.conf');
77 # make sure AuthLDAPRemoteUserIsDN is enabled.
78 die unless ($ENV{'REMOTE_USER'});
79 #set_config ('base_dn', $ENV{'REMOTE_USER'});
81 die unless (defined (get_config ('uri'))
82 and defined (get_config ('base_dn'))
83 and defined (get_config ('bind_dn'))
84 and defined (get_config ('password')));
86 LiCoM::Connection->connect
88 uri => get_config ('uri'),
89 bind_dn => get_config ('bind_dn'),
90 password => get_config ('password')
91 ) or die ("LiCoM::Connection->connect failed.");
93 our ($UserCN, $UserID) = LiCoM::Person->get_user ($ENV{'REMOTE_USER'});
95 if (!$UserID and $Action ne 'save')
102 die ("UserCN is not set. Make sure `AuthLDAPRemoteUserIsDN' in enabled.");
105 if (!defined ($Actions{$Action}))
107 die ("No such action: $Action");
110 if (ref ($Actions{$Action}) eq 'CODE')
112 $Actions{$Action}->();
114 elsif (ref ($Actions{$Action}) eq 'ARRAY')
116 for (@{$Actions{$Action}})
122 LiCoM::Connection->disconnect ();
130 my $group = param ('group');
131 $group = shift if (@_);
136 my @groups = LiCoM::Group->all ();
138 print qq(\t\t<h2>Contact groups</h2>\n\t\t<ul class="groups">\n);
142 my @members = $group->get_members ();
143 my $members = scalar (@members);
144 my $group_name = $group->name ();
145 my $group_uri = uri_escape ($group_name);
146 my $desc = $group->description ();
148 print qq#\t\t\t<li><a href="$MySelf?action=browse&group=$group_uri">#,
149 encode_entities ($group_name),
150 qq#</a> ($members Member#, ($members == 1 ? ')' : 's)');
151 print qq(<br />\n\t\t\t\t<span class="description">),
152 encode_entities ($desc) . '</span>' if ($desc);
157 print qq(\t\t\t<li class="empty">There are no groups yet.</li>\n);
162 [<a href="$MySelf?action=list">List all</a>]
168 my $group_obj = LiCoM::Group->load ($group);
169 my $group_uri = uri_escape ($group_obj->name ());
170 my $group_html = encode_entities ($group_obj->name ());
171 my @member_names = $group_obj->get_members ();
172 my $desc = $group_obj->description ();
173 my $desc_html = encode_entities ($desc || '');
175 print qq(\t\t<h2>Contact group "$group_html"</h2>\n);
176 print qq(\t\t<div>$desc_html</div>\n) if ($desc);
177 print qq(\t\t<ul class="results">\n);
178 for (sort (@member_names))
181 my $cn_uri = uri_escape ($cn);
182 my $cn_html = encode_entities ($cn);
184 print qq(\t\t\t<li><a href="$MySelf?action=detail&cn=$cn_uri">$cn_html</a></li>\n);
190 [<a href="$MySelf?action=list&group=$group_uri">List</a>]
191 [<a href="$MySelf?action=browse">Back</a>]
192 [<a href="$MySelf?action=edit_group&group=$group_uri">Edit</a>]
200 my $group_name = param ('group');
201 $group_name = shift if (@_);
204 my $group_name_html = encode_entities ($group_name || '');
206 my $title = $group_name
207 ? "List of group "$group_name_html""
208 : 'List of all addresses';
209 my @fields = (qw(address homephone cellphone officephone fax mail));
214 my $group_obj = LiCoM::Group->load ($group_name);
219 Unable to load group "$group_name_html".
224 for ($group_obj->get_members ())
227 my $person_obj = LiCoM::Person->load ($cn);
231 print STDERR "Unable to load cn = $cn;\n";
234 push (@all, $person_obj);
239 @all = LiCoM::Person->search ([[group => $group_name]]);
251 print "\t\t\t\t<th>" . (defined ($FieldNames{$_}) ? $FieldNames{$_} : $_) . "</th>\n";
253 print "\t\t\t</tr>\n";
255 for (sort { $a->name () cmp $b->name () } (@all))
258 my $cn = $person->name ();
259 my $sn = $person->lastname ();
260 my $gn = $person->firstname ();
262 my $cn_uri = uri_escape ($cn);
263 my $cn_html = encode_entities ("$sn, $gn");
265 print "\t\t\t<tr>\n",
266 qq(\t\t\t\t<td><a href="$MySelf?action=detail&cn=$cn_uri">$cn_html</a></td>\n);
271 my @values = $person->get ($field);
272 print "\t\t\t\t<td>" . join ('<br />', map { markup_field ($field, $_) } (@values)) . "</td>\n";
275 print "\t\t\t</tr>\n";
277 print "\t\t</table>\n\n";
281 my $group_esc = uri_escape ($group_name);
282 print qq(\t\t<div class="menu">[<a href="$MySelf?action=browse&group=$group_esc">Back</a>]</div>\n);
286 print qq(\t\t<div class="menu">[<a href="$MySelf?action=browse">Back</a>]</div>\n);
292 my $cn = param ('cn');
296 my $cn_html = encode_entities ($cn);
297 my $cn_uri = uri_escape ($cn);
299 my $person = LiCoM::Person->load ($cn);
302 print qq(\t<div>Entry "$cn_html" could not be loaded from DB.</div>\n);
306 print qq(\t\t<h2>Details for $cn_html</h2>\n);
309 <table class="detail">
318 my $values = $person->get ($field);
319 my $num = scalar (@$values);
320 my $field_name = defined ($FieldNames{$field}) ? $FieldNames{$field} : $field;
324 $field_name = encode_entities ($field_name);
326 print "\t\t\t<tr>\n";
329 print qq(\t\t\t\t<th rowspan="$num">$field_name</th>\n);
333 print qq(\t\t\t\t<th>$field_name</th>\n);
336 for (my $i = 0; $i < $num; $i++)
338 my $val = markup_field ($field, $values->[$i]);
340 print "\t\t\t<tr>\n" if ($i);
341 print "\t\t\t\t<td>$val</td>\n",
346 my @groups = LiCoM::Group->load_by_member ($cn);
349 my $num = scalar (@groups);
350 print "\t\t\t<tr>\n",
351 "\t\t\t\t<th", ($num == 1 ? '' : qq( rowspan="$num")), ">Group", ($num == 1 ? '' : 's'), "</th>\n";
352 for (my $i = 0; $i < $num; $i++)
354 my $group = $groups[$i];
355 my $group_name = $group->name ();
356 my $group_uri = uri_escape ($group_name);
357 my $group_html = encode_entities ($group_name);
359 print "\t\t\t<tr>\n" if ($i != 0);
360 print qq(\t\t\t\t<td><a href="$MySelf?action=browse&group=$group_uri">$group_html</a></td>\n),
369 [<a href="$MySelf?action=verify&cn=$cn_uri">Verify</a>]
370 [<a href="$MySelf?action=vcard&cn=$cn_uri">vCard</a>]
371 [<a href="$MySelf?action=edit&cn=$cn_uri">Edit</a>]
372 [<a href="$MySelf?action=delete&cn=$cn_uri">Delete</a>]
380 my $search = param ('search');
383 $search =~ s/[^\s\w]//g;
387 print qq(\t<div class="error">Sorry, the empty search is not allowed.</div>\n);
392 my @patterns = split (m/\s+/, $search);
398 push (@filter, [[lastname => $pattern], [firstname => $pattern]]);
401 my @matches = LiCoM::Person->search (@filter);
405 print qq(\t<div>No entries matched your search.</div>\n);
409 if (scalar (@matches) == 1)
411 my $person = shift (@matches);
412 my $cn = $person->name ();
417 print qq(\t<ul class="result">\n);
418 for (sort { $a->name () cmp $b->name () } (@matches))
421 my $cn = $person->name ();
422 my $cn_uri = uri_escape ($cn);
423 my $cn_html = encode_entities ($cn);
425 print qq(\t\t<li><a href="$MySelf?action=detail&cn=$cn_uri">$cn_html</a></li>\n);
434 my $cn = param ('cn');
436 $cn = $opts{'cn'} if (defined ($opts{'cn'}));
439 my $cn_html = encode_entities ($cn);
452 $contacts->{$_} = [] for (@MultiFields);
456 $person = LiCoM::Person->load ($cn);
460 print qq(\t<div class="error">Unable to load CN "$cn". Sorry.</div>\n);
464 $lastname = $person->lastname ();
465 $firstname = $person->firstname ();
469 $contacts->{$_} = $person->get ($_);
473 $lastname = param ('lastname') if (param ('lastname') and $UserID);
474 $firstname = param ('firstname') if (param ('firstname') and $UserID);
476 get_contacts ($contacts);
478 $lastname = $opts{'lastname'} if (defined ($opts{'lastname'}));
479 $firstname = $opts{'firstname'} if (defined ($opts{'firstname'}));
483 @{$contacts->{$field}} = @{$opts{$field}} if (defined ($opts{$field}));
488 print "\t\t<h2>Edit contact $cn_html</h2>\n";
492 print "\t\t<h2>Create new contact</h2>\n";
496 <form action="$MySelf" method="post">
497 <input type="hidden" name="action" value="save" />
498 <input type="hidden" name="cn" value="$cn_html" />
505 print qq(\t\t\t\t<td><input type="text" name="lastname" value="$lastname" /></td>\n);
509 print qq(\t\t\t\t<td>$lastname</td>\n);
518 print qq(\t\t\t\t<td><input type="text" name="firstname" value="$firstname" /></td>\n);
522 print qq(\t\t\t\t<td>$firstname</td>\n);
525 print "\t\t\t</tr>\n";
530 my $print = defined ($FieldNames{$field}) ? $FieldNames{$field} : $field;
531 my @values = @{$contacts->{$field}};
533 next if ($field eq 'group');
537 $field = encode_entities ($field);
538 $print = encode_entities ($print);
542 my $value = encode_entities ($_);
547 <td><input type="text" name="$field" value="$value" /></td>
555 my @all_groups = LiCoM::Group->all ();
559 print "\t\t\t<tr>\n",
560 "\t\t\t\t<th>Group(s)</th>\n",
561 qq(\t\t\t\t<td><select name="group" multiple="multiple" size="5">\n);
566 my $group_name = encode_entities ($group->name ());
569 if (grep { $cn eq $_ } ($group->get_members ()))
571 $selected = ' selected="selected"';
574 print qq(\t\t\t\t\t<option value="$group_name"$selected>$group_name</option>\n);
576 print "\t\t\t\t</select></td>\n",
580 print "\t\t\t<tr>\n",
581 "\t\t\t\t<th>New Group</th>\n",
582 qq(\t\t\t\t<td><input type="text" name="newgroup" value="" /></td>\n),
588 <th colspan="2" class="menu">
593 <input type="submit" name="button" value="Cancel" />
594 <input type="submit" name="button" value="Apply" />
598 <input type="submit" name="button" value="Save" />
608 my $cn = $UserID ? param ('cn') : $UserCN;
610 if (verify_fields ())
612 action_edit (cn => $cn);
622 die unless ($UserID);
624 my $button = lc (param ('button'));
627 if ($button eq 'cancel')
633 if (!param ('lastname') or !param ('firstname'))
635 print qq(\t<div class="error">You have to give both, first and lastname, to identify this record.</div>\n);
636 action_edit (cn => '');
640 my $lastname = param ('lastname');
641 my $firstname = param ('firstname');
643 my $contacts = get_contacts ();
645 my $person = LiCoM::Person->create (lastname => $lastname, firstname => $firstname, %$contacts);
649 print qq(\t<div class="error">Unable to save entry. Sorry.</div>\n);
653 $cn = $person->name ();
655 for (param ('group'))
658 my $group = LiCoM::Group->load ($group_name);
662 $group->add_members ($cn);
666 my $group_html = encode_entities ($group_name);
667 print qq(\t<div class="error">Group "$group_html" does not exist or could not be loaded.</div>\n);
671 if (param ('newgroup'))
673 # FIXME add error handling
674 my $group_name = param ('newgroup');
675 LiCoM::Group->create ($group_name, '', $cn);
678 if ($button eq 'apply')
680 action_edit (cn => $cn);
690 my $cn = $UserID ? param ('cn') : $UserCN;
691 my $person = LiCoM::Person->load ($cn);
693 die unless ($person);
695 my $button = lc (param ('button'));
698 if ($UserID and $button eq 'cancel')
706 my $lastname = param ('lastname');
707 my $firstname = param ('firstname');
709 $person->lastname ($lastname) if ($lastname and $lastname ne $person->lastname ());
710 $person->firstname ($firstname) if ($firstname and $firstname ne $person->firstname ());
712 $cn = $person->name ();
714 # Each group is one entry of type (objectClass=groupOfNames)
715 # with one or more `member' attributes. These attributes are
716 # the `dn' (distinguished name) of the member entries.
719 my $contacts = get_contacts ();
725 next if (!$UserID and $field eq 'group');
727 if (defined ($contacts->{$field}))
729 my $values = $contacts->{$field};
730 $person->set ($field, $values);
734 $person->set ($field, []);
738 # only `authorized' users may see and change groups
741 my %changed_groups = map { $_ => 1 } (param ('group'));
742 my @current_groups = LiCoM::Group->load_by_member ($cn);
744 for (@current_groups)
747 my $group_name = $group_obj->name ();
749 if (!defined ($changed_groups{$group_name}))
751 $group_obj->del_members ($cn);
755 delete ($changed_groups{$group_name});
758 for (keys %changed_groups)
761 my $group_obj = LiCoM::Group->load ($group_name) or die;
763 $group_obj->add_members ($cn);
766 if (param ('newgroup'))
768 # FIXME add error handling
769 my $group_name = param ('newgroup');
770 LiCoM::Group->create ($group_name, '', $cn);
777 <h3>Your changes have been saved.</h3>
778 <p>Thank you very much for taking the time to keep this record up to date.</p>
783 if ($button eq 'apply' or !$UserID)
785 action_edit (cn => $cn);
795 my $cn = param ('cn');
799 my $person = LiCoM::Person->load ($cn);
800 die unless ($person);
804 homephone => 'TEL;TYPE=home,voice',
805 cellphone => 'TEL;TYPE=cell',
806 officephone => 'TEL;TYPE=work,voice',
807 fax => 'TEL;TYPE=fax',
813 my $sn = $person->lastname ();
814 my $gn = $person->firstname ();
815 my $cn_esc = uri_escape ($cn);
818 Content-Type: text/x-vcard
819 Content-Disposition: attachment; filename="$cn.vcf"
830 my $vc_fld = $vcard_types{$field};
831 my $values = $person->get ($field);
833 next unless ($vc_fld);
838 print "$vc_fld:$value\n";
846 my $cn = param ('cn');
850 my $cn_html = encode_entities ($cn);
852 my $person = LiCoM::Person->load ($cn);
853 die unless ($person);
855 my ($mail) = $person->get ('mail');
859 my ($password) = $person->get ('password');
864 $password = pwgen ();
865 $person->set ('password', [$password]);
867 $password_html = encode_entities ($password);
869 $message = qq(The password for the record "$cn_html" is "$password_html".);
873 if (action_verify_send_mail ($person))
875 my $mail_html = encode_entities ($mail);
876 $message .= qq( A request for verification has been sent to $mail_html.);
881 $message .= q( There was no e-mail address, thus no verification request could be sent.);
884 print qq(\t\t<div class="message">$message</div>\n);
889 sub action_verify_send_mail
892 my $owner = LiCoM::Person->load ($UserCN);
895 my ($owner_mail) = $owner->get ('mail');
898 my $cn_uri = uri_escape ($UserCN);
899 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);
904 for (keys %FieldNames)
906 $max_width = length $FieldNames{$_} if ($max_width < length $FieldNames{$_});
910 my $person_name = $person->name ();
911 my ($person_mail) = $person->get ('mail');
912 my $person_gn = $person->firstname ();
913 my ($password) = $person->get ('password');
915 my $host = $ENV{'HTTP_HOST'};
916 my $url = (defined ($ENV{'HTTPS'}) ? 'https://' : 'http://') . $host . $MySelf;
918 open ($smh, '|-', '/usr/sbin/sendmail', '-t', '-f', $owner_mail) or die ("open (sendmail): $!");
920 To: $person_name <$person_mail>
921 From: $UserCN <$owner_mail>
922 Subject: Please verify our entry in my address book
926 the following is your entry in my address book:
931 my $print = defined ($FieldNames{$field}) ? $FieldNames{$field} : $field;
932 my @values = $person->get ($field);
936 printf $smh ('%'.$max_width."s: %-s\n", $print, $_);
941 If this entry is outdated or incomplete, please take a minute and correct it.
943 Username: $person_name
946 Thank you very much :)
951 This message was automatically generated by LiCoM,
952 http://verplant.org/licom/
961 my $cn = param ('cn');
964 my $person = LiCoM::Person->load ($cn);
967 my $cn_uri = uri_escape ($cn);
968 my $cn_html = encode_entities ($cn);
971 <h2>Really delete $cn_html?</h2>
974 You are about to delete <strong>$cn_html</strong>.
975 Are you totally, absolutely sure you want to do this?
979 [<a href="$MySelf?action=expunge&cn=$cn_uri">Yes, delete</a>]
980 [<a href="$MySelf?action=detail&cn=$cn_uri">No, keep</a>]
988 my $cn = param ('cn');
991 my $cn_html = encode_entities ($cn);
993 my $person = LiCoM::Person->load ($cn);
999 <div>$cn_html has been deleted.</div>
1005 sub action_edit_group
1007 my $group_name = param ('group') or die;
1009 my $group_name_html = encode_entities ($group_name);
1011 my $group_obj = LiCoM::Group->load ($group_name);
1015 print qq(\t<div class="error">Group "$group_name_html" does not exist or could not be loaded.</div>\n);
1019 $group_name_html = encode_entities ($group_obj->name ());
1021 my $desc_html = encode_entities ($group_obj->description () || '');
1024 <h2>Edit contact group "$group_name_html"</h2>
1025 <form action="$MySelf" method="post">
1026 <input type="hidden" name="action" value="save_group" />
1027 <input type="hidden" name="group" value="$group_name_html" />
1031 <td>$group_name_html</td>
1034 <th>Description</th>
1035 <td><input type="text" name="description" value="$desc_html" /></td>
1038 <th colspan="2"><input type="submit" name="button" value="Save" /></th>
1045 sub action_save_group
1047 my $group_name = param ('group') or die;
1049 my $group_name_html = encode_entities ($group_name);
1051 my $group_obj = LiCoM::Group->load ($group_name);
1055 print qq(\t<div class="error">Group "$group_name_html" does not exist or could not be loaded.</div>\n);
1059 my $desc = param ('description');
1060 $group_obj->description ($desc);
1069 $title = q(Lightweight Contact Manager) unless ($title);
1071 $title = encode_entities ($title);
1074 Content-Type: text/html; charset=UTF-8
1078 <title>$title</title>
1079 <style type="text/css">
1086 background-color: inherit;
1087 text-decoration: none;
1092 text-decoration: underline;
1098 background-color: inherit;
1104 background-color: white;
1110 background-color: yellow;
1114 border: 2px solid red;
1120 background-color: white;
1130 border-top: 1px solid black;
1137 background-color: inherit;
1138 text-decoration: none;
1143 text-decoration: underline;
1148 border-top: 1px solid black;
1156 background-color: transparent;
1162 padding-bottom: 1ex;
1163 border-bottom: 1px solid black;
1192 border: 2px solid #d0d0d0;
1203 background-color: #e8e8e8;
1204 vertical-align: top;
1210 background-color: #d0d0d0;
1213 vertical-align: top;
1227 background-color: inherit;
1228 text-decoration: underline;
1231 div.topmenu, div.menu
1254 border-collapse: collapse;
1269 border-bottom-width: 2px;
1274 border: 1px solid black;
1275 vertical-align: top;
1293 my $search = param ('search') || '';
1294 $search = encode_entities ($search);
1296 <div class="topmenu">
1297 <form action="$MySelf" method="post">
1298 <input type="hidden" name="action" value="browse" />
1299 <input type="submit" name="button" value="Browse" />
1301 <form action="$MySelf" method="post">
1302 <input type="hidden" name="action" value="search" />
1303 <input type="text" name="search" value="$search" />
1304 <input type="submit" name="button" value="Search" />
1306 <form action="$MySelf" method="post">
1307 <input type="hidden" name="action" value="edit" />
1308 <input type="hidden" name="dn" value="" />
1309 <input type="submit" name="button" value="Add New" />
1314 print "\t\t<h1>$title</h1>\n";
1321 "Lightweight Contact Manager",
1322 written 2005-2006 by <a href="http://verplant.org/">Florian octo Forster</a>
1323 <octo at verplant.org>
1332 my $len = @_ ? shift : 6;
1341 while (length ($retval) < $len)
1343 my $chr = int (rand (128));
1345 if ($chr >= 48 and $chr < 58)
1349 elsif ($chr >= 65 and $chr < 91)
1353 elsif ($chr >= 97 and $chr < 123)
1361 $retval .= chr ($chr);
1364 $retval = '' if (!$numbers or !$lchars or !$uchars);
1378 if ($val !~ m#^[a-zA-Z]+://#)
1380 push (@errors, 'URIs have to begin with a protocol, e.g. "http://", "ftp://" etc.');
1385 for (param ('homephone'), param ('cellphone'), param ('officephone'), param ('fax'))
1388 next unless ($number);
1390 if ($number !~ m/^\+[0-9 \-]+$/)
1392 push (@errors, 'Telephone numbers have to begin with the country code and only numbers, spaces and dashes are allowed, e.g. "+49 911-123456"');
1397 print qq(\t\t<div class="error">\n) if (@errors);
1398 for (my $i = 0; $i < scalar (@errors); $i++)
1400 my $e = $errors[$i];
1402 print "<br />\n" if ($i);
1405 print qq(\n\t\t</div>\n\n) if (@errors);
1407 return (scalar (@errors));
1415 my $value_uri = uri_escape ($value);
1416 my $value_html = encode_entities ($value);
1418 if ($field eq 'group')
1420 return (qq(<a href="$MySelf?action=browse&group=$value_uri">$value_html</a>));
1422 elsif ($field eq 'uri')
1424 if ($value =~ m#^([a-z]+)://(.+)$#)
1426 $value_uri = $1 . '://' . uri_escape ($2);
1430 $value_uri = 'http://' . uri_escape ($value);
1432 return (qq(<a href="$value_uri" class="extern">$value_html</a>));
1434 elsif ($field eq 'mail')
1436 return (qq(<a href="mailto:$value_uri" class="mail">$value_html</a>));
1438 return ($value_html);
1443 my $contacts = @_ ? shift : {};
1448 my @values = grep { $_ } (param ($field));
1450 next unless (@values);
1452 if ($field eq 'homephone' or $field eq 'cellphone' or $field eq 'officephone' or $field eq 'fax')
1456 $_ =~ s/[^0-9 \-]//g;
1457 $_ = '+' . $_ if ($_);
1461 $contacts->{$field} = [@values] if (@values);