2015-11-24 23:53:27 +01:00
|
|
|
<?php
|
2024-05-27 17:39:07 +02:00
|
|
|
|
2016-01-12 15:02:16 +01:00
|
|
|
/**
|
2024-05-27 17:39:07 +02:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2016-01-12 15:02:16 +01:00
|
|
|
*/
|
2015-11-24 23:53:27 +01:00
|
|
|
namespace OCA\DAV\Command;
|
|
|
|
|
2016-01-13 20:56:25 +01:00
|
|
|
use OCA\DAV\CardDAV\SyncService;
|
2023-08-17 10:19:10 +02:00
|
|
|
use OCP\IConfig;
|
2015-11-24 23:53:27 +01:00
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
use Symfony\Component\Console\Helper\ProgressBar;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
class SyncSystemAddressBook extends Command {
|
2023-07-05 17:45:43 +03:30
|
|
|
public function __construct(
|
|
|
|
private SyncService $syncService,
|
|
|
|
private IConfig $config,
|
|
|
|
) {
|
2015-11-24 23:53:27 +01:00
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
2023-07-05 17:45:43 +03:30
|
|
|
protected function configure(): void {
|
2015-11-24 23:53:27 +01:00
|
|
|
$this
|
|
|
|
->setName('dav:sync-system-addressbook')
|
|
|
|
->setDescription('Synchronizes users to the system addressbook');
|
|
|
|
}
|
|
|
|
|
2020-06-26 15:12:11 +02:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
2015-11-24 23:53:27 +01:00
|
|
|
$output->writeln('Syncing users ...');
|
|
|
|
$progress = new ProgressBar($output);
|
|
|
|
$progress->start();
|
2024-09-20 17:38:36 +02:00
|
|
|
$this->syncService->syncInstance(function () use ($progress): void {
|
2015-12-01 12:48:23 +01:00
|
|
|
$progress->advance();
|
|
|
|
});
|
2015-12-04 11:50:11 +01:00
|
|
|
|
2015-11-24 23:53:27 +01:00
|
|
|
$progress->finish();
|
2015-11-27 13:14:55 +01:00
|
|
|
$output->writeln('');
|
2023-08-17 10:19:10 +02:00
|
|
|
$this->config->setAppValue('dav', 'needs_system_address_book_sync', 'no');
|
2023-07-05 17:45:43 +03:30
|
|
|
return self::SUCCESS;
|
2015-11-24 23:53:27 +01:00
|
|
|
}
|
|
|
|
}
|