package Fripost::Schema::Utils; use 5.010_000; use warnings; use strict; our $VERSION = '0.01'; ####################################################################### sub mkDN { my $config = shift; my ($user, $domain) = split /\@/, $_[0], 2; my $dn; if (defined $domain) { $dn = join ',', ( 'uid='. $user , 'dc='. $domain , $config->{base_dn} ); } elsif (defined $user) { $dn = join ',', ( 'dc='. $user , $config->{base_dn} ); } else { $dn = $config->{base_dn}; } return $dn; } sub fromDN { my ($u,$d) = split /,/, $_[0], 3; join '@', ( map { (split /=/, $_, 2)[1] } ($u,$d) ); } sub mkAndFilter { my @filters = @_; my $filter; if ($#filters == 0) { $filter = $filters[0]; } elsif ($#filters > 0) { $filter = "(&" . (join '', @filters) . ")"; } } ####################################################################### 1; =head1 NAME Fripost::Schema::Type::User - =head1 AUTHOR Guilhem Moulin C<< >> =head1 COPYRIGHT Copyright 2012 Guilhem Moulin, all rights reserved. =head1 LICENSE This program is free software; you can redistribute it and/or modify it under the same terms as perl itself. =cut 1; # End of Utils.pm __END__