aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Fripost/Schema/Search.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Fripost/Schema/Search.pm')
-rw-r--r--lib/Fripost/Schema/Search.pm28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/Fripost/Schema/Search.pm b/lib/Fripost/Schema/Search.pm
index a9eb2ea..1051a21 100644
--- a/lib/Fripost/Schema/Search.pm
+++ b/lib/Fripost/Schema/Search.pm
@@ -11,7 +11,20 @@ use base qw/Net::LDAP::Search/;
our $VERSION = '0.01';
# Count the entries got out from the query.
-sub count { $_[0]->{_res}->count }
+sub count {
+ my $self = shift;
+
+ if (ref $self->{_res} eq 'ARRAY') {
+ my $count;
+ foreach (@{$self->{_res}}) {
+ $count += $_->count;
+ }
+ return $count;
+ }
+ else {
+ return $self->{_res}->count;
+ }
+}
# Create a hash out of the LDAP entry. Keys depend on the context
# of the object.
@@ -31,11 +44,20 @@ sub entries {
$dumpEntry = "_aliasEntry";
}
else {
- die "Something weird happened. Please report."
+ die "Something weird happened. Please report.";
}
+ my @entries;
+ if (ref $self->{_res} eq 'ARRAY') {
+ foreach (@{$self->{_res}}) {
+ push @entries, $_->entries;
+ }
+ }
+ else {
+ @entries = ($self->{_res}->entries);
+ }
no strict "refs";
- return (map {&$dumpEntry($_)} $self->{_res}->entries);
+ return (map {&$dumpEntry($_)} @entries);
}