From 5002c89470b511dea3bb8eb64c81a71b7788fa0f Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sat, 26 Jan 2013 20:32:10 +0100 Subject: wibble --- lib/Fripost/Panel/Interface.pm | 2 +- lib/Fripost/Schema/Domain.pm | 23 ++++++++++++----------- lib/Fripost/Schema/Util.pm | 4 ++-- templates/add-domain-1.html | 2 +- templates/add-domain-2.html | 2 +- templates/edit-domain.html | 2 +- templates/list-domains.html | 4 ++-- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/Fripost/Panel/Interface.pm b/lib/Fripost/Panel/Interface.pm index 79b77aa..fc27158 100644 --- a/lib/Fripost/Panel/Interface.pm +++ b/lib/Fripost/Panel/Interface.pm @@ -560,7 +560,7 @@ sub mkDesc { } my @single_valued_keys = qw/isActive/; -my @multi_valued_keys = qw/description catchAlls +my @multi_valued_keys = qw/description catchAll canAddAlias canAddList/; sub fill_HTML_template_from_entry { diff --git a/lib/Fripost/Schema/Domain.pm b/lib/Fripost/Schema/Domain.pm index 44ad84e..950484b 100644 --- a/lib/Fripost/Schema/Domain.pm +++ b/lib/Fripost/Schema/Domain.pm @@ -73,7 +73,7 @@ addresses of the domain owners (other than postmasters). An optional array reference containing the (internationalized) e-mails addresses of the domain postmasters. -=item B +=item B An optional array reference containing the (internationalized) catch-alls for that domain. Localparts may be left empty for domain @@ -213,9 +213,10 @@ sub search { ); ldap_error($domains, %options) // return; + return unless defined wantarray; return $domains->count if $options{'-count'}; - &_entries_to_domains( $self->whoami, $options{'-keys'} // [], + &_entries_to_domains( $self->whoami, $options{'-keys'}, wantarray ? ( $options{'-sort'} ? $domains->sorted('fvd') : $domains->entries ) : $domains->pop_entry @@ -229,7 +230,7 @@ sub _entries_to_domains { my @dn = @{ldap_explode_dn $user}; shift @dn; my $parent = lc (canonical_dn @dn); - my $keys = shift; + my $keys = shift // []; my @domains; foreach my $entry (@_) { @@ -270,8 +271,8 @@ sub _entries_to_domains { if not @$keys or grep { $_ eq 'postmaster' } @$keys; } elsif ($attr eq 'fripostOptionalMaildrop') { - $domain{catchAlls} = [ map { &_email_to_unicode($_) } @$val ] - if not @$keys or grep { $_ eq 'catchAlls' } @$keys; + $domain{catchAll} = [ map { &_email_to_unicode($_) } @$val ] + if not @$keys or grep { $_ eq 'catchAll' } @$keys; } elsif ($attr eq 'description') { $domain{description} = [ map { Encode::_utf8_on($_); $_ } @$val ] @@ -320,7 +321,7 @@ sub _keys_to_attrs { , canAddList => 'fripostCanAddList' , owner => 'fripostOwner' , postmaster => 'fripostPostmaster' - , catchAlls => 'fripostOptionalMaildrop' + , catchAll => 'fripostOptionalMaildrop' , description => 'description' , permissions => [ qw/fripostCanAddAlias fripostCanAddList fripostOwner fripostPostmaster/ ] @@ -574,8 +575,8 @@ sub _domain_to_entry { elsif ($key eq 'description') { $entry{description} = $domain{description}; } - elsif ($key eq 'catchAlls') { - $entry{fripostOptionalMaildrop} = $domain{catchAlls}; + elsif ($key eq 'catchAll') { + $entry{fripostOptionalMaildrop} = $domain{catchAll}; } elsif ($key eq 'canAddAlias') { $entry{fripostCanAddAlias} = @@ -699,9 +700,9 @@ sub _is_valid { eval { Fripost::Schema::Util::must_attrs( $d, qw/name isActive/ ); $d->{name} = domain_valid( $d->{name} ); - $d->{catchAlls} = [ map { email_valid($_, -prefix => 'fake') } - @{$d->{catchAlls}} ] - if $d->{catchAlls}; + $d->{catchAll} = [ map { email_valid($_, -prefix => 'fake') } + @{$d->{catchAll}} ] + if $d->{catchAll}; $d->{canAddAlias} = [ map { email_valid($_, -prefix => 'fake') } @{$d->{canAddAlias}} ] if $d->{canAddAlias}; diff --git a/lib/Fripost/Schema/Util.pm b/lib/Fripost/Schema/Util.pm index 6fb84dc..2d1a60f 100644 --- a/lib/Fripost/Schema/Util.pm +++ b/lib/Fripost/Schema/Util.pm @@ -157,7 +157,7 @@ sub split_addr { my $addr = shift; my %options = @_; - $addr =~ /^(.*)\@([^@]+)$/s; + $addr =~ /^(.*)\@([^\@]+)$/s; my ($l,$d) = ($1, $2); if (defined $options{'-encode'}) { @@ -246,7 +246,7 @@ sub ldap_and_filter { return $filters[0]; } else { - @filters = map {'('.$_.')'} @filters; + @filters = map { /^\(.*\)$/ ? $_ : '('.$_.')' } @filters; return '(&'.(join '', @filters).')'; } } diff --git a/templates/add-domain-1.html b/templates/add-domain-1.html index 9b7de76..a7afc6f 100644 --- a/templates/add-domain-1.html +++ b/templates/add-domain-1.html @@ -70,7 +70,7 @@

Catch-All aliases

- +
An optional list of destinations (one e-mail address per line) that will receive mail sent to non existing recipients. diff --git a/templates/add-domain-2.html b/templates/add-domain-2.html index 72bc0d8..9565d8a 100644 --- a/templates/add-domain-2.html +++ b/templates/add-domain-2.html @@ -25,7 +25,7 @@ - +
diff --git a/templates/edit-domain.html b/templates/edit-domain.html index 9acd52f..d95c8fb 100644 --- a/templates/edit-domain.html +++ b/templates/edit-domain.html @@ -60,7 +60,7 @@

Catch-All aliases

- +
An optional list of destinations (one e-mail address per line) that will receive mail sent to non existing recipients. diff --git a/templates/list-domains.html b/templates/list-domains.html index c5c662b..e0fe52e 100644 --- a/templates/list-domains.html +++ b/templates/list-domains.html @@ -36,9 +36,9 @@
(none)