]> source.dussan.org Git - nextcloud-server.git/commitdiff
Delete no longer existing users from system addressbook
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 4 Dec 2015 10:50:11 +0000 (11:50 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Fri, 4 Dec 2015 10:51:45 +0000 (11:51 +0100)
apps/dav/command/syncsystemaddressbook.php

index bb2896abc60facfab2bc6de9fc8b60a254a53a6d..162ab36289200bbc9fca24c884abbdc5323fc8b8 100644 (file)
@@ -88,6 +88,18 @@ class SyncSystemAddressBook extends Command {
                        }
                        $progress->advance();
                });
+
+               // remove no longer existing
+               $allCards = $this->backend->getCards($systemAddressBook['id']);
+               foreach($allCards as $card) {
+                       $vCard = Reader::read($card['carddata']);
+                       $uid = $vCard->UID->getValue();
+                       // load backend and see if user exists
+                       if (!$this->userManager->userExists($uid)) {
+                               $this->backend->deleteCard($systemAddressBook['id'], $card['uri']);
+                       }
+               }
+
                $progress->finish();
                $output->writeln('');
        }