aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem.moulin@fripost.org>2012-04-19 00:12:57 +0200
committerGuilhem Moulin <guilhem.moulin@fripost.org>2012-04-19 00:12:57 +0200
commit47135d7827c75073278089d43220df48f250b118 (patch)
treeb32e0ee5a3a70eff8836b719928a0c08bad65572 /lib
parent5f15ee93f79af5af0ee064ffdb5c03f2af14ee3a (diff)
Search tools.
Diffstat (limited to 'lib')
-rw-r--r--lib/Fripost/Schema/Search.pm10
-rw-r--r--lib/Fripost/Schema/Type/Domain.pm11
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/Fripost/Schema/Search.pm b/lib/Fripost/Schema/Search.pm
index 7c0ece6..3dc2efa 100644
--- a/lib/Fripost/Schema/Search.pm
+++ b/lib/Fripost/Schema/Search.pm
@@ -53,6 +53,12 @@ sub _domainEntry {
&_get_values( $entry, \%domain, 'domain', 'dc');
map { &_get_values($entry, \%domain, $_) }
qw /isActive owner/;
+ if (defined $domain{owner}) {
+ $domain{owner} = [ $domain{owner} ]
+ unless (ref $domain{owner}) eq 'ARRAY';
+ $domain{owner} = [ map { (split /=/, (split /,/, $_, 2)[0], 2)[1] }
+ @{$domain{owner}} ];
+ }
return \%domain;
}
@@ -60,6 +66,10 @@ sub _aliasEntry {
my $entry = shift;
my %alias;
&_get_values( $entry, \%alias, 'address', 'mailLocalAddress');
+ if (defined $alias{address}) {
+ $alias{address} = [ $alias{address} ]
+ unless (ref $alias{address}) eq 'ARRAY';
+ }
&_get_values( $entry, \%alias, 'goto', 'mailTarget');
&_get_values( $entry, \%alias, 'isActive');
return \%alias;
diff --git a/lib/Fripost/Schema/Type/Domain.pm b/lib/Fripost/Schema/Type/Domain.pm
index f85ea87..0d2be17 100644
--- a/lib/Fripost/Schema/Type/Domain.pm
+++ b/lib/Fripost/Schema/Type/Domain.pm
@@ -14,6 +14,8 @@ our $VERSION = '0.01';
# domain is given, returns all domains.
# Filters on values of both keys `domain' and `owner' (unless they are
# undefined).
+# If `owner' is the empty string, serch for non self-managed domains
+# only.
sub search {
my $self = shift;
@@ -26,7 +28,14 @@ sub search {
my @filters = ('(ObjectClass=virtualDomain)');
push @filters, "(dc=" .$_[0]->{domain}. ")" if defined $_[0]->{domain};
- push @filters, "(owner=" .$owner. ")" if defined $_[0]->{owner};
+ if (defined $_[0]->{owner}) {
+ if ($_[0]->{owner} eq '') {
+ push @filters, "(!(owner=*))";
+ }
+ else {
+ push @filters, "(owner=" .$owner. ")";
+ }
+ }
my $filter;
if ($#filters == 0) {
$filter = $filters[0];