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/Schema/Domain.pm | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'lib/Fripost/Schema/Domain.pm') 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}; -- cgit v1.2.3