[pmg-devel] [PATCH pmg-api 3/3] add optional list parameter to quarusers api call
Dominik Csapak
d.csapak at proxmox.com
Tue Feb 26 09:12:36 CET 2019
so that we can get the list of users of white or blacklist only
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PMG/API2/Quarantine.pm | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/PMG/API2/Quarantine.pm b/PMG/API2/Quarantine.pm
index 3572c41..81ba379 100644
--- a/PMG/API2/Quarantine.pm
+++ b/PMG/API2/Quarantine.pm
@@ -477,7 +477,14 @@ __PACKAGE__->register_method ({
description => "Get a list of users with whitelist/blacklist setttings.",
parameters => {
additionalProperties => 0,
- properties => {},
+ properties => {
+ list => {
+ type => 'string',
+ description => 'If set, limits the result to the given list.',
+ enum => ['BL', 'WL'],
+ optional => 1,
+ },
+ },
},
returns => {
type => 'array',
@@ -501,10 +508,14 @@ __PACKAGE__->register_method ({
my $dbh = PMG::DBTools::open_ruledb();
- my $sth = $dbh->prepare(
- "SELECT DISTINCT pmail FROM UserPrefs ORDER BY pmail");
-
- $sth->execute();
+ my $sth;
+ if ($param->{list}) {
+ $sth = $dbh->prepare("SELECT DISTINCT pmail FROM UserPrefs WHERE name = ? ORDER BY pmail");
+ $sth->execute($param->{list});
+ } else {
+ $sth = $dbh->prepare("SELECT DISTINCT pmail FROM UserPrefs ORDER BY pmail");
+ $sth->execute();
+ }
while (my $ref = $sth->fetchrow_hashref()) {
push @$res, { mail => $ref->{pmail} };
--
2.11.0
More information about the pmg-devel
mailing list