summaryrefslogtreecommitdiffstats
path: root/apps/dav/command
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-01-25 17:18:47 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-09 11:20:31 +0100
commitbf3a843e892e39e6c4d12b632da31d5718bc45c7 (patch)
tree7e65e9cd5baf4b46c2f10cce1be4f2cc7ab5b668 /apps/dav/command
parent254e0fa71a31d0ee77136ba0fee95fe7b136a4a0 (diff)
downloadnextcloud-server-bf3a843e892e39e6c4d12b632da31d5718bc45c7.tar.gz
nextcloud-server-bf3a843e892e39e6c4d12b632da31d5718bc45c7.zip
Migration of calendars
Diffstat (limited to 'apps/dav/command')
-rw-r--r--apps/dav/command/migrateaddressbooks.php1
-rw-r--r--apps/dav/command/migratecalendars.php66
2 files changed, 67 insertions, 0 deletions
diff --git a/apps/dav/command/migrateaddressbooks.php b/apps/dav/command/migrateaddressbooks.php
index 2ab7113ab1f..f37c29e7ab3 100644
--- a/apps/dav/command/migrateaddressbooks.php
+++ b/apps/dav/command/migrateaddressbooks.php
@@ -68,6 +68,7 @@ class MigrateAddressbooks extends Command {
}
$output->writeln("Start migration for $user");
$this->service->migrateForUser($user);
+ return;
}
$output->writeln("Start migration of all known users ...");
$p = new ProgressBar($output);
diff --git a/apps/dav/command/migratecalendars.php b/apps/dav/command/migratecalendars.php
new file mode 100644
index 00000000000..eda4f5fb417
--- /dev/null
+++ b/apps/dav/command/migratecalendars.php
@@ -0,0 +1,66 @@
+<?php
+
+namespace OCA\Dav\Command;
+
+use OCP\IUser;
+use OCP\IUserManager;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Helper\ProgressBar;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class MigrateCalendars extends Command {
+
+ /** @var IUserManager */
+ protected $userManager;
+
+ /** @var \OCA\Dav\Migration\MigrateCalendars */
+ private $service;
+
+ /**
+ * @param IUserManager $userManager
+ * @param \OCA\Dav\Migration\MigrateCalendars $service
+ */
+ function __construct(IUserManager $userManager,
+ \OCA\Dav\Migration\MigrateCalendars $service
+ ) {
+ parent::__construct();
+ $this->userManager = $userManager;
+ $this->service = $service;
+ }
+
+ protected function configure() {
+ $this
+ ->setName('dav:migrate-calendars')
+ ->setDescription('Migrate calendars from the calendar app to core')
+ ->addArgument('user',
+ InputArgument::OPTIONAL,
+ 'User for whom all calendars will be migrated');
+ }
+
+ 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('');
+ }
+}