diff --git a/apps/dav/appinfo/register_command.php b/apps/dav/appinfo/register_command.php new file mode 100644 index 0000000000..c996dd4406 --- /dev/null +++ b/apps/dav/appinfo/register_command.php @@ -0,0 +1,8 @@ +getDatabaseConnection(); +$userManager = OC::$server->getUserManager(); +/** @var Symfony\Component\Console\Application $application */ +$application->add(new CreateAddressBook($userManager, $dbConnection)); diff --git a/apps/dav/command/createaddressbook.php b/apps/dav/command/createaddressbook.php new file mode 100644 index 0000000000..286871b39e --- /dev/null +++ b/apps/dav/command/createaddressbook.php @@ -0,0 +1,52 @@ +userManager = $userManager; + $this->dbConnection = $dbConnection; + } + + protected function configure() { + $this + ->setName('dav:create-addressbook') + ->setDescription('Create a dav addressbook') + ->addArgument('user', + InputArgument::REQUIRED, + 'User for whom the addressbook will be created') + ->addArgument('name', + InputArgument::REQUIRED, + 'Name of the addressbook'); + } + + protected function execute(InputInterface $input, OutputInterface $output) { + $user = $input->getArgument('user'); + if (!$this->userManager->userExists($user)) { + throw new \InvalidArgumentException("User <$user> in unknown."); + } + $name = $input->getArgument('name'); + $carddav = new CardDavBackend($this->dbConnection); + $carddav->createAddressBook("principals/$user", $name, []); + } +}