]> git.proxmox.com Git - pmg-api.git/commitdiff
add optional list parameter to quarusers api call
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 26 Feb 2019 08:12:36 +0000 (09:12 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 26 Feb 2019 09:50:59 +0000 (10:50 +0100)
so that we can get the list of users of white or blacklist only

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PMG/API2/Quarantine.pm

index 157a51e8a628cbd749fe5ee924f9ba1467b08d59..158247b14dc7303eab38b3738188189599675554 100644 (file)
@@ -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} };