diff options
author | Guilhem Moulin <guilhem.moulin@fripost.org> | 2013-01-18 21:44:37 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem.moulin@fripost.org> | 2013-01-18 22:06:23 +0100 |
commit | 1f35ed5ce38525af78508b46eea67a4f41c74a4a (patch) | |
tree | 7b427071baf28eee056c05cad26c3fcb03f5cf9a /lib/Fripost/Schema | |
parent | 68484bbbde92a7b5ccb0da16d29afda31aec0370 (diff) |
Fripost::Schema::Misc → Fripost::Schema::Util
Diffstat (limited to 'lib/Fripost/Schema')
-rw-r--r-- | lib/Fripost/Schema/Alias.pm | 11 | ||||
-rw-r--r-- | lib/Fripost/Schema/Domain.pm | 5 | ||||
-rw-r--r-- | lib/Fripost/Schema/List.pm | 15 | ||||
-rw-r--r-- | lib/Fripost/Schema/Local.pm | 6 | ||||
-rw-r--r-- | lib/Fripost/Schema/User.pm | 13 | ||||
-rw-r--r-- | lib/Fripost/Schema/Util.pm (renamed from lib/Fripost/Schema/Misc.pm) | 13 |
6 files changed, 30 insertions, 33 deletions
diff --git a/lib/Fripost/Schema/Alias.pm b/lib/Fripost/Schema/Alias.pm index d121929..817f4a6 100644 --- a/lib/Fripost/Schema/Alias.pm +++ b/lib/Fripost/Schema/Alias.pm @@ -17,10 +17,9 @@ use warnings; use utf8; use parent 'Fripost::Schema'; -use Fripost::Schema::Misc qw/concat explode must_attrs email_valid +use Fripost::Schema::Util qw/concat explode must_attrs email_valid split_addr canonical_dn/; -use Net::IDN::Encode qw/domain_to_ascii - email_to_ascii email_to_unicode/; +use Net::IDN::Encode qw/domain_to_ascii email_to_ascii email_to_unicode/; =head1 METHODS @@ -80,7 +79,7 @@ sub replace { } eval { - my ($l,$d) = split_addr( $a->{alias}, -encoding => 'ascii' ); + my ($l,$d) = split_addr( $a->{alias}, -encode => 'ascii' ); &_is_valid($a); my $mesg = $self->ldap->modify( canonical_dn({fva => $l}, {fvd => $d}, @{$self->suffix}), @@ -113,7 +112,7 @@ sub add { eval { die "Missing alias name\n" unless $a->{alias} =~ /^.+\@.+$/; - my ($l,$d) = split_addr( $a->{alias}, -encoding => 'ascii' ); + my ($l,$d) = split_addr( $a->{alias}, -encode => 'ascii' ); &_is_valid($a); die "‘".$a->{alias}."’ already exists\n" if $self->local->exists($a->{alias},%options); @@ -145,7 +144,7 @@ Delete the given alias. sub delete { my $self = shift; - my ($l,$d) = split_addr( shift, -encoding => 'ascii' ); + my ($l,$d) = split_addr( shift, -encode => 'ascii' ); my %options = @_; my $mesg = $self->ldap->delete( canonical_dn( {fva => $l}, {fvd => $d}, diff --git a/lib/Fripost/Schema/Domain.pm b/lib/Fripost/Schema/Domain.pm index c36cea8..fc80b4c 100644 --- a/lib/Fripost/Schema/Domain.pm +++ b/lib/Fripost/Schema/Domain.pm @@ -17,9 +17,8 @@ use warnings; use utf8; use parent 'Fripost::Schema'; -use Fripost::Schema::Misc qw/concat get_perms explode - must_attrs email_valid - canonical_dn/; +use Fripost::Schema::Util qw/concat get_perms explode must_attrs + email_valid canonical_dn/; use Net::IDN::Encode qw/domain_to_ascii domain_to_unicode email_to_ascii email_to_unicode/; diff --git a/lib/Fripost/Schema/List.pm b/lib/Fripost/Schema/List.pm index 58d198c..7753bd1 100644 --- a/lib/Fripost/Schema/List.pm +++ b/lib/Fripost/Schema/List.pm @@ -17,10 +17,9 @@ use warnings; use utf8; use parent 'Fripost::Schema'; -use Fripost::Schema::Misc qw/concat explode must_attrs email_valid +use Fripost::Schema::Util qw/concat explode must_attrs email_valid split_addr canonical_dn ldap_explode_dn/; -use Net::IDN::Encode qw/domain_to_ascii - email_to_ascii email_to_unicode/; +use Net::IDN::Encode qw/domain_to_ascii email_to_ascii email_to_unicode/; use Mail::GnuPG; use MIME::Entity; @@ -85,7 +84,7 @@ sub replace { if defined $l->{description}; eval { - my ($l2,$d) = split_addr( $l->{list}, -encoding => 'ascii' ); + my ($l2,$d) = split_addr( $l->{list}, -encode => 'ascii' ); &_is_valid($l); my $l3 = { fripostIsStatusActive => $l->{isactive} ? 'TRUE' : 'FALSE' , description => $l->{description} }; @@ -117,7 +116,7 @@ sub add { eval { die "Missing list name\n" unless $l->{list} =~ /^.+\@.+$/; - my ($l2,$d) = split_addr ( $l->{list}, -encoding => 'ascii' ); + my ($l2,$d) = split_addr ( $l->{list}, -encode => 'ascii' ); must_attrs( $l, 'transport' ); &_is_valid($l); die "‘".$l->{list}."’ already exists\n" @@ -177,7 +176,7 @@ the ListCreator entity, and the list is not known by the list manager. sub is_pending { my $self = shift; - my ($l,$d) = split_addr( shift, -encoding => 'ascii' ); + my ($l,$d) = split_addr( shift, -encode => 'ascii' ); my %options = @_; my $dn = canonical_dn({fvl => $l}, {fvd => $d}, @{$self->suffix}); @@ -209,7 +208,7 @@ Add the lists commands, and remove the pending status. sub add_commands { my $self = shift; - my ($l,$d) = split_addr( shift, -encoding => 'ascii' ); + my ($l,$d) = split_addr( shift, -encode => 'ascii' ); my $cmds = shift; my %options = @_; @@ -243,7 +242,7 @@ disk, but merely delete the list entry in the LDAP directory. sub delete { my $self = shift; - my ($l,$d) = split_addr( shift, -encoding => 'ascii' ); + my ($l,$d) = split_addr( shift, -encode => 'ascii' ); my %options = @_; my $dn = canonical_dn( {fvl => $l}, {fvd => $d}, @{$self->suffix} ); diff --git a/lib/Fripost/Schema/Local.pm b/lib/Fripost/Schema/Local.pm index d8a71ef..5ca833c 100644 --- a/lib/Fripost/Schema/Local.pm +++ b/lib/Fripost/Schema/Local.pm @@ -17,7 +17,7 @@ use warnings; use utf8; use parent 'Fripost::Schema'; -use Fripost::Schema::Misc qw/concat split_addr canonical_dn/; +use Fripost::Schema::Util qw/concat split_addr canonical_dn/; use Net::IDN::Encode qw/email_to_ascii email_to_unicode/; use Net::LDAP::Util 'escape_filter_value'; @@ -40,7 +40,7 @@ sub get { my %options = @_; my $concat = $options{'-concat'}; - my ($l,$d) = split_addr( $loc, -encoding => 'ascii' ); + my ($l,$d) = split_addr( $loc, -encode => 'ascii' ); $l = escape_filter_value($l); my $locals = $self->ldap->search( base => canonical_dn({fvd => $d}, @{$self->suffix}), @@ -110,7 +110,7 @@ attribute. sub exists { my $self = shift; - my ($l,$d) = split_addr( shift, -encoding => 'ascii' ); + my ($l,$d) = split_addr( shift, -encode => 'ascii' ); my %options = @_; # We may not have read access to the list commands diff --git a/lib/Fripost/Schema/User.pm b/lib/Fripost/Schema/User.pm index ff8691f..7d79e69 100644 --- a/lib/Fripost/Schema/User.pm +++ b/lib/Fripost/Schema/User.pm @@ -17,10 +17,9 @@ use warnings; use utf8; use parent 'Fripost::Schema'; -use Fripost::Schema::Misc qw/concat explode must_attrs email_valid +use Fripost::Schema::Util qw/concat explode must_attrs email_valid split_addr canonical_dn/; -use Net::IDN::Encode qw/domain_to_ascii - email_to_ascii email_to_unicode/; +use Net::IDN::Encode qw/domain_to_ascii email_to_ascii email_to_unicode/; =head1 METHODS @@ -82,7 +81,7 @@ sub replace { } eval { - my ($l,$d) = split_addr( $m->{user}, -encoding => 'ascii' ); + my ($l,$d) = split_addr( $m->{user}, -encode => 'ascii' ); &_is_valid($m); my $mesg = $self->ldap->modify( canonical_dn( {fvu => $l}, {fvd => $d}, @{$self->suffix} ), @@ -106,7 +105,7 @@ may want to hash it before hand. sub passwd { my $self = shift; - my ($l,$d) = split_addr( shift, -encoding => 'ascii' ); + my ($l,$d) = split_addr( shift, -encode => 'ascii' ); my $pw = shift; my %options = @_; @@ -137,7 +136,7 @@ sub add { eval { die "Missing user name\n" unless $m->{user} =~ /^.+\@.+$/; - my ($l,$d) = split_addr( $m->{user}, -encoding => 'ascii' ); + my ($l,$d) = split_addr( $m->{user}, -encode => 'ascii' ); &_is_valid($m); die "‘".$m->{user}."’ already exists\n" if $self->local->exists($m->{user},%options); @@ -174,7 +173,7 @@ but merely delete its entry in the LDAP directory. sub delete { my $self = shift; - my ($l,$d) = split_addr( shift, -encoding => 'ascii' ); + my ($l,$d) = split_addr( shift, -encode => 'ascii' ); my %options = @_; my $mesg = $self->ldap->delete( canonical_dn( {fvu => $l}, {fvd => $d}, diff --git a/lib/Fripost/Schema/Misc.pm b/lib/Fripost/Schema/Util.pm index aec2618..8d75a3a 100644 --- a/lib/Fripost/Schema/Misc.pm +++ b/lib/Fripost/Schema/Util.pm @@ -1,8 +1,8 @@ -package Fripost::Schema::Misc; +package Fripost::Schema::Util; =head1 NAME -Misc.pm - +Util.pm - =cut @@ -136,15 +136,16 @@ sub split_addr { my $addr = shift; my %options = @_; - if (defined $options{'-encoding'}) { - if ($options{'-encoding'} eq 'ascii') { + if (defined $options{'-encode'}) { + my $e = $options{'-encode'}; + if ($e eq 'ascii') { $addr = Net::IDN::Encode::email_to_ascii($addr); } - elsif ($options{'-encoding'} eq 'unicode') { + elsif ($e eq 'unicode') { $addr = Net::IDN::Encode::email_to_unicode($addr); } else { - die "Unknown encoding: ". $options{'-encoding'}; + die "Unknown encoding: ". $e; } } |