save => [\&html_start, \&action_save, \&html_end],
search => [\&html_start, \&action_search, \&html_end],
verify => [\&html_start, \&action_verify, \&html_end],
+ delete => [\&html_start, \&action_ask_del, \&html_end],
+ expunge => [\&html_start, \&action_do_del, \&html_end],
vcard => \&action_vcard
);
[<a href="$MySelf?action=verify&cn=$cn_esc">Verify</a>]
[<a href="$MySelf?action=vcard&cn=$cn_esc">vCard</a>]
[<a href="$MySelf?action=edit&cn=$cn_esc">Edit</a>]
+ [<a href="$MySelf?action=delete&cn=$cn_esc">Delete</a>]
</div>
EOF
return (1);
}
+sub action_ask_del
+{
+ my $cn = param ('cn');
+ $cn or die;
+
+ my $person = LiCoM::Person->load ($cn);
+ $person or die;
+
+ my $cn_esc = uri_escape ($cn);
+
+ print <<EOF;
+ <h2>Really delete $cn?</h2>
+
+ <div>
+ You are about to delete <strong>$cn</strong>. Are you
+ totally, absolutely sure you want to do this?
+ </div>
+
+ <div class="menu">
+ [<a href="$MySelf?action=expunge&cn=$cn_esc">Yes, delete</a>]
+ [<a href="$MySelf?action=detail&cn=$cn_esc">No, keep</a>]
+ </div>
+
+EOF
+}
+
+sub action_do_del
+{
+ my $cn = param ('cn');
+ $cn or die;
+
+ my $person = LiCoM::Person->load ($cn);
+ $person or die;
+
+ $person->delete ();
+
+ print <<EOF;
+ <div>$cn has been deleted.</div>
+
+EOF
+ action_browse ();
+}
+
sub html_start
{
my $title = shift;
my $number = $_;
next unless ($number);
- if ($number !~ m/^\+/)
+ if ($number !~ m/^\+[0-9 \-]+$/)
{
- push (@errors, 'Telephone numbers have to begin with the country code, e.g. "+49 911 123456"');
+ push (@errors, 'Telephone numbers have to begin with the country code and only numbers, spaces and dashes are allowed, e.g. "+49 911-123456"');
last;
}
}
{
for (@values)
{
- $_ =~ s/\D//g;
- $_ = '+' . $_;
+ $_ =~ s/[^0-9 \-]//g;
+ $_ = '+' . $_ if ($_);
}
}