2015-11-24 17:53:27 -05:00
|
|
|
<?php
|
2024-05-27 11:39:07 -04:00
|
|
|
|
2016-01-12 09:02:16 -05:00
|
|
|
/**
|
2024-05-27 11:39:07 -04: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 09:02:16 -05:00
|
|
|
*/
|
2015-11-24 17:53:27 -05:00
|
|
|
namespace OCA\DAV\Command;
|
|
|
|
|
|
2016-01-13 14:56:25 -05:00
|
|
|
use OCA\DAV\CardDAV\SyncService;
|
2023-08-17 04:19:10 -04:00
|
|
|
use OCP\IConfig;
|
2015-11-24 17:53:27 -05: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 10:15:43 -04:00
|
|
|
public function __construct(
|
|
|
|
|
private SyncService $syncService,
|
|
|
|
|
private IConfig $config,
|
|
|
|
|
) {
|
2015-11-24 17:53:27 -05:00
|
|
|
parent::__construct();
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-05 10:15:43 -04:00
|
|
|
protected function configure(): void {
|
2015-11-24 17:53:27 -05:00
|
|
|
$this
|
|
|
|
|
->setName('dav:sync-system-addressbook')
|
|
|
|
|
->setDescription('Synchronizes users to the system addressbook');
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 09:12:11 -04:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
2015-11-24 17:53:27 -05:00
|
|
|
$output->writeln('Syncing users ...');
|
|
|
|
|
$progress = new ProgressBar($output);
|
|
|
|
|
$progress->start();
|
2024-09-20 11:38:36 -04:00
|
|
|
$this->syncService->syncInstance(function () use ($progress): void {
|
2015-12-01 06:48:23 -05:00
|
|
|
$progress->advance();
|
|
|
|
|
});
|
2015-12-04 05:50:11 -05:00
|
|
|
|
2015-11-24 17:53:27 -05:00
|
|
|
$progress->finish();
|
2015-11-27 07:14:55 -05:00
|
|
|
$output->writeln('');
|
2023-08-17 04:19:10 -04:00
|
|
|
$this->config->setAppValue('dav', 'needs_system_address_book_sync', 'no');
|
2023-07-05 10:15:43 -04:00
|
|
|
return self::SUCCESS;
|
2015-11-24 17:53:27 -05:00
|
|
|
}
|
|
|
|
|
}
|