/** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $principalBackend = new Principal($this->config, $this->userManager); $this->backend = new CardDavBackend($this->dbConnection, $principalBackend); // ensure system addressbook exists $systemAddressBook = $this->ensureSystemAddressBookExists(); $converter = new Converter(); $output->writeln('Syncing users ...'); $progress = new ProgressBar($output); $progress->start(); $this->userManager->callForAllUsers(function ($user) use($systemAddressBook, $converter, $progress) { /** @var IUser $user */ $name = $user->getBackendClassName(); $userId = $user->getUID(); $cardId = "{$name}:{$userId}.vcf"; $card = $this->backend->getCard($systemAddressBook['id'], $cardId); if ($card === false) { $vCard = $converter->createCardFromUser($user); $this->backend->createCard($systemAddressBook['id'], $cardId, $vCard->serialize()); } else { $vCard = Reader::read($card['carddata']); if ($converter->updateCard($vCard, $user)) { $this->backend->updateCard($systemAddressBook['id'], $cardId, $vCard->serialize()); } } $progress->advance(); }); $progress->finish(); $output->writeln(''); }
/** * @inheritdoc */ public function run(IOutput $output) { $output->startProgress(); $this->userManager->callForAllUsers(function ($user) use($output) { /** @var IUser $user */ $output->advance(1, $user->getDisplayName()); $this->birthdayService->syncUser($user->getUID()); }); $output->finishProgress(); }
protected function run($argument) { $maxAge = $this->expiration->getMaxAgeAsTimestamp(); if (!$maxAge) { return; } $this->userManager->callForAllUsers(function (IUser $user) { $uid = $user->getUID(); if (!$this->setupFS($uid)) { return; } Storage::expireOlderThanMaxForUser($uid); }); }
/** * @param $argument * @throws \Exception */ protected function run($argument) { $maxAge = $this->expiration->getMaxAgeAsTimestamp(); if (!$maxAge) { return; } $this->userManager->callForAllUsers(function (IUser $user) { $uid = $user->getUID(); if (!$this->setupFS($uid)) { return; } $dirContent = Helper::getTrashFiles('/', $uid, 'mtime'); Trashbin::deleteExpiredFiles($dirContent, $uid); }); \OC_Util::tearDownFS(); }
/** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $user = $input->getArgument('user'); if (!is_null($user)) { if (!$this->userManager->userExists($user)) { throw new \InvalidArgumentException("User <{$user}> in unknown."); } $output->writeln("Start birthday calendar sync for {$user}"); $this->birthdayService->syncUser($user); return; } $output->writeln("Start birthday calendar sync for all users ..."); $p = new ProgressBar($output); $p->start(); $this->userManager->callForAllUsers(function ($user) use($p) { $p->advance(); /** @var IUser $user */ $this->birthdayService->syncUser($user->getUID()); }); $p->finish(); $output->writeln(''); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->service->setup(); if ($input->hasArgument('user')) { $user = $input->getArgument('user'); if (!$this->userManager->userExists($user)) { throw new \InvalidArgumentException("User <{$user}> in unknown."); } $output->writeln("Start migration for {$user}"); $this->service->migrateForUser($user); return; } $output->writeln("Start migration of all known users ..."); $p = new ProgressBar($output); $p->start(); $this->userManager->callForAllUsers(function ($user) use($p) { $p->advance(); /** @var IUser $user */ $this->service->migrateForUser($user->getUID()); }); $p->finish(); $output->writeln(''); }
/** * @param IOutput $output */ private function removeRootShares(IOutput $output) { $function = function (IUser $user) use($output) { $userFolder = $this->rootFolder->getUserFolder($user->getUID()); $fileId = $userFolder->getId(); $qb = $this->connection->getQueryBuilder(); $qb->delete('share')->where($qb->expr()->eq('file_source', $qb->createNamedParameter($fileId)))->andWhere($qb->expr()->orX($qb->expr()->eq('item_type', $qb->expr()->literal('file')), $qb->expr()->eq('item_type', $qb->expr()->literal('folder')))); $qb->execute(); $output->advance(); }; $userCount = $this->countUsers(); $output->startProgress($userCount); $this->userManager->callForAllUsers($function); $output->finishProgress(); }
public function run(IOutput $output) { $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); if (version_compare($ocVersionFromBeforeUpdate, '9.2.0.1', '<')) { // this situation was only possible between 9.0.0 and 9.0.3 included $function = function (IUser $user) use($output) { $this->fixUnmergedShares($output, $user); $output->advance(); }; $this->buildPreparedQueries(); $userCount = $this->countUsers(); $output->startProgress($userCount); $this->userManager->callForAllUsers($function); $output->finishProgress(); } }
public function syncInstance(\Closure $progressCallback) { $systemAddressBook = $this->getLocalSystemAddressBook(); $this->userManager->callForAllUsers(function ($user) use($systemAddressBook, $progressCallback) { $this->updateUser($user); $progressCallback(); }); // 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->deleteUser($card['uri']); } } }