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 ++-- 3 files changed, 15 insertions(+), 14 deletions(-) (limited to 'lib') 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).')'; } } -- cgit v1.2.3