+
+sub verify_fields
+{
+ my @errors = ();
+ for (param ('uri'))
+ {
+ my $val = $_;
+ next unless ($val);
+
+ if ($val !~ m#^[a-zA-Z]+://#)
+ {
+ push (@errors, 'URIs have to begin with a protocol, e.g. "http://", "ftp://" etc.');
+ last;
+ }
+ }
+
+ for (param ('homephone'), param ('cellphone'), param ('officephone'), param ('fax'))
+ {
+ my $number = $_;
+ next unless ($number);
+
+ if ($number !~ m/^\+/)
+ {
+ push (@errors, 'Telephone numbers have to begin with the country code, e.g. "+49 911 123456"');
+ last;
+ }
+ }
+
+ print qq(\t\t<div class="error">\n) if (@errors);
+ for (my $i = 0; $i < scalar (@errors); $i++)
+ {
+ my $e = $errors[$i];
+
+ print "<br />\n" if ($i);
+ print "\t\t\t$e";
+ }
+ print qq(\n\t\t</div>\n\n) if (@errors);
+
+ return (scalar (@errors));
+}
+
+sub get_contacts
+{
+ my $contacts = @_ ? shift : {};
+
+ for (@MultiFields)
+ {
+ my $field = $_;
+ my @values = grep { $_ } (param ($field));
+
+ next unless (@values);
+
+ if ($field eq 'homephone' or $field eq 'cellphone' or $field eq 'officephone' or $field eq 'fax')
+ {
+ for (@values)
+ {
+ $_ =~ s/\D//g;
+ $_ = '+' . $_;
+ }
+ }
+
+ $contacts->{$field} = [@values] if (@values);
+ }
+
+ return ($contacts);
+}