X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=licom.cgi;h=59eddd66fb65a04bcd2e978a6bb5adf4601cadaa;hb=17b661b0d5e8f9927a7f7785779ff15244dd0d52;hp=5abb2e6f09d430ff122519fa3bfb99825faaf5e0;hpb=fb2741ec9a3da3376994f3f70f8d0c17bbe70931;p=licom.git diff --git a/licom.cgi b/licom.cgi index 5abb2e6..59eddd6 100755 --- a/licom.cgi +++ b/licom.cgi @@ -44,6 +44,8 @@ our %Actions = 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 ); @@ -322,6 +324,7 @@ EOF [Verify] [vCard] [Edit] + [Delete] EOF @@ -479,6 +482,8 @@ EOF my $print = defined ($FieldNames{$field}) ? $FieldNames{$field} : $field; my @values = @{$contacts->{$field}}; + next if ($field eq 'group'); + push (@values, ''); for (@values) @@ -494,6 +499,31 @@ EOF } } + if ($UserID) + { + my %c_groups = map { $_ => 1 } (@{$contacts->{'group'}}); + my %a_groups = (); + my @a_persons = LiCoM::Person->search (); + + for (@a_persons) + { + $a_groups{$_} = 1 for ($_->get ('group')); + } + + print "\t\t\t\n", + "\t\t\t\t", $FieldNames{'group'}, "\n", + qq(\t\t\t\t\n", + "\t\t\t\n"; + } + print < @@ -606,6 +636,8 @@ sub action_update { my $field = $_; + next if (!$UserID and $field eq 'group'); + if (defined ($contacts->{$field})) { my $values = $contacts->{$field}; @@ -667,6 +699,8 @@ EOF my $vc_fld = $vcard_types{$field}; my $values = $person->get ($field); + next unless ($vc_fld); + for (@$values) { my $value = $_; @@ -689,12 +723,12 @@ sub action_verify $mail ||= ''; my $message; - my $password = $person->password (); + my $password = $person->get ('password'); if (!$password) { $password = pwgen (); - $person->password ($password); + $person->set ('password', $password); } $message = qq(The password for the record "$cn" is "$password".); @@ -740,10 +774,10 @@ sub action_verify_send_mail my $person_name = $person->name (); my ($person_mail) = $person->get ('mail'); my $person_gn = $person->firstname (); - my $password = $person->password (); + my $password = $person->get ('password'); my $host = $ENV{'HTTP_HOST'}; - my $url = 'http://' . $host . $MySelf; + my $url = (defined ($ENV{'HTTPS'}) ? 'https://' : 'http://') . $host . $MySelf; open ($smh, "| /usr/sbin/sendmail -t -f $owner_mail") or die ("open pipe to sendmail: $!"); print $smh <load ($cn); + $person or die; + + my $cn_esc = uri_escape ($cn); + + print <Really delete $cn? + +
+ You are about to delete $cn. Are you + totally, absolutely sure you want to do this? +
+ + + +EOF +} + +sub action_do_del +{ + my $cn = param ('cn'); + $cn or die; + + my $person = LiCoM::Person->load ($cn); + $person or die; + + $person->delete (); + + print <$cn has been deleted. + +EOF + action_browse (); +} + sub html_start { my $title = shift; @@ -997,6 +1079,7 @@ Content-Type: text/html; charset=UTF-8 EOF + if ($UserID) { my $search = param ('search') || ''; @@ -1095,9 +1178,9 @@ sub verify_fields 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; } } @@ -1130,8 +1213,8 @@ sub get_contacts { for (@values) { - $_ =~ s/\D//g; - $_ = '+' . $_; + $_ =~ s/[^0-9 \-]//g; + $_ = '+' . $_ if ($_); } }