From 17b515f76c5774e3bc45906d3e679edcfe2b529b Mon Sep 17 00:00:00 2001 From: Jon Robertson Date: Thu, 7 Jan 2010 08:02:26 -0800 Subject: Added ability to list only ACLs with no members Added new option to the 'wallet-admin list acls' command, 'empty', which will only return those ACLs which have no members. This will help maintenance in the long term by pointing out ACLs in error or no longer needed. --- perl/Wallet/Admin.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'perl/Wallet/Admin.pm') diff --git a/perl/Wallet/Admin.pm b/perl/Wallet/Admin.pm index 91f1bfb..0e437ec 100644 --- a/perl/Wallet/Admin.pm +++ b/perl/Wallet/Admin.pm @@ -261,6 +261,15 @@ sub list_acls_all { return ($sql); } +# Returns the SQL statement required to find and returned all empty ACLs in +# the db. +sub list_acls_empty { + my ($self) = @_; + my $sql = 'select ac_id, ac_name from acls left join acl_entries ' + .'on (acls.ac_id=acl_entries.ae_id) where ae_id is null;'; + return ($sql); +} + # Returns the SQL statement and the field required to search the ACLs and # return only those entries which contain a entries with identifiers # matching a particular given string. @@ -289,10 +298,14 @@ sub list_acls { if (!defined $type || $type eq '') { ($sql) = $self->list_acls_all (); } else { - if (@args == 0) { - $self->error ("acl searches require an argument to search"); - } elsif ($type eq 'entry') { - ($sql, @search) = $self->list_acls_entry (@args); + if ($type eq 'entry') { + if (@args == 0) { + $self->error ("acl searches require an argument to search"); + } else { + ($sql, @search) = $self->list_acls_entry (@args); + } + } elsif ($type eq 'empty') { + ($sql) = $self->list_acls_empty (); } else { $self->error ("do not know search type: $type"); } -- cgit v1.2.3