@@ -33,52 +33,52 @@ |
||
33 | 33 | |
34 | 34 | class EnableMasterKey extends Command { |
35 | 35 | |
36 | - /** @var Util */ |
|
37 | - protected $util; |
|
36 | + /** @var Util */ |
|
37 | + protected $util; |
|
38 | 38 | |
39 | - /** @var IConfig */ |
|
40 | - protected $config; |
|
39 | + /** @var IConfig */ |
|
40 | + protected $config; |
|
41 | 41 | |
42 | - /** @var QuestionHelper */ |
|
43 | - protected $questionHelper; |
|
42 | + /** @var QuestionHelper */ |
|
43 | + protected $questionHelper; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param Util $util |
|
47 | - * @param IConfig $config |
|
48 | - * @param QuestionHelper $questionHelper |
|
49 | - */ |
|
50 | - public function __construct(Util $util, |
|
51 | - IConfig $config, |
|
52 | - QuestionHelper $questionHelper) { |
|
53 | - $this->util = $util; |
|
54 | - $this->config = $config; |
|
55 | - $this->questionHelper = $questionHelper; |
|
56 | - parent::__construct(); |
|
57 | - } |
|
45 | + /** |
|
46 | + * @param Util $util |
|
47 | + * @param IConfig $config |
|
48 | + * @param QuestionHelper $questionHelper |
|
49 | + */ |
|
50 | + public function __construct(Util $util, |
|
51 | + IConfig $config, |
|
52 | + QuestionHelper $questionHelper) { |
|
53 | + $this->util = $util; |
|
54 | + $this->config = $config; |
|
55 | + $this->questionHelper = $questionHelper; |
|
56 | + parent::__construct(); |
|
57 | + } |
|
58 | 58 | |
59 | - protected function configure() { |
|
60 | - $this |
|
61 | - ->setName('encryption:enable-master-key') |
|
62 | - ->setDescription('Enable the master key. Only available for fresh installations with no existing encrypted data! There is also no way to disable it again.'); |
|
63 | - } |
|
59 | + protected function configure() { |
|
60 | + $this |
|
61 | + ->setName('encryption:enable-master-key') |
|
62 | + ->setDescription('Enable the master key. Only available for fresh installations with no existing encrypted data! There is also no way to disable it again.'); |
|
63 | + } |
|
64 | 64 | |
65 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
66 | - $isAlreadyEnabled = $this->util->isMasterKeyEnabled(); |
|
65 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
66 | + $isAlreadyEnabled = $this->util->isMasterKeyEnabled(); |
|
67 | 67 | |
68 | - if ($isAlreadyEnabled) { |
|
69 | - $output->writeln('Master key already enabled'); |
|
70 | - } else { |
|
71 | - $question = new ConfirmationQuestion( |
|
72 | - 'Warning: Only available for fresh installations with no existing encrypted data! ' |
|
73 | - . 'There is also no way to disable it again. Do you want to continue? (y/n) ', false); |
|
74 | - if ($this->questionHelper->ask($input, $output, $question)) { |
|
75 | - $this->config->setAppValue('encryption', 'useMasterKey', '1'); |
|
76 | - $output->writeln('Master key successfully enabled.'); |
|
77 | - } else { |
|
78 | - $output->writeln('aborted.'); |
|
79 | - return 1; |
|
80 | - } |
|
81 | - } |
|
82 | - return 0; |
|
83 | - } |
|
68 | + if ($isAlreadyEnabled) { |
|
69 | + $output->writeln('Master key already enabled'); |
|
70 | + } else { |
|
71 | + $question = new ConfirmationQuestion( |
|
72 | + 'Warning: Only available for fresh installations with no existing encrypted data! ' |
|
73 | + . 'There is also no way to disable it again. Do you want to continue? (y/n) ', false); |
|
74 | + if ($this->questionHelper->ask($input, $output, $question)) { |
|
75 | + $this->config->setAppValue('encryption', 'useMasterKey', '1'); |
|
76 | + $output->writeln('Master key successfully enabled.'); |
|
77 | + } else { |
|
78 | + $output->writeln('aborted.'); |
|
79 | + return 1; |
|
80 | + } |
|
81 | + } |
|
82 | + return 0; |
|
83 | + } |
|
84 | 84 | } |
@@ -34,55 +34,55 @@ |
||
34 | 34 | |
35 | 35 | class DisableMasterKey extends Command { |
36 | 36 | |
37 | - /** @var Util */ |
|
38 | - protected $util; |
|
37 | + /** @var Util */ |
|
38 | + protected $util; |
|
39 | 39 | |
40 | - /** @var IConfig */ |
|
41 | - protected $config; |
|
40 | + /** @var IConfig */ |
|
41 | + protected $config; |
|
42 | 42 | |
43 | - /** @var QuestionHelper */ |
|
44 | - protected $questionHelper; |
|
43 | + /** @var QuestionHelper */ |
|
44 | + protected $questionHelper; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param Util $util |
|
48 | - * @param IConfig $config |
|
49 | - * @param QuestionHelper $questionHelper |
|
50 | - */ |
|
51 | - public function __construct(Util $util, |
|
52 | - IConfig $config, |
|
53 | - QuestionHelper $questionHelper) { |
|
54 | - $this->util = $util; |
|
55 | - $this->config = $config; |
|
56 | - $this->questionHelper = $questionHelper; |
|
57 | - parent::__construct(); |
|
58 | - } |
|
46 | + /** |
|
47 | + * @param Util $util |
|
48 | + * @param IConfig $config |
|
49 | + * @param QuestionHelper $questionHelper |
|
50 | + */ |
|
51 | + public function __construct(Util $util, |
|
52 | + IConfig $config, |
|
53 | + QuestionHelper $questionHelper) { |
|
54 | + $this->util = $util; |
|
55 | + $this->config = $config; |
|
56 | + $this->questionHelper = $questionHelper; |
|
57 | + parent::__construct(); |
|
58 | + } |
|
59 | 59 | |
60 | - protected function configure() { |
|
61 | - $this |
|
62 | - ->setName('encryption:disable-master-key') |
|
63 | - ->setDescription('Disable the master key and use per-user keys instead. Only available for fresh installations with no existing encrypted data! There is no way to enable it again.'); |
|
64 | - } |
|
60 | + protected function configure() { |
|
61 | + $this |
|
62 | + ->setName('encryption:disable-master-key') |
|
63 | + ->setDescription('Disable the master key and use per-user keys instead. Only available for fresh installations with no existing encrypted data! There is no way to enable it again.'); |
|
64 | + } |
|
65 | 65 | |
66 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
67 | - $isMasterKeyEnabled = $this->util->isMasterKeyEnabled(); |
|
66 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
67 | + $isMasterKeyEnabled = $this->util->isMasterKeyEnabled(); |
|
68 | 68 | |
69 | - if (!$isMasterKeyEnabled) { |
|
70 | - $output->writeln('Master key already disabled'); |
|
71 | - } else { |
|
72 | - $question = new ConfirmationQuestion( |
|
73 | - 'Warning: Only perform this operation for a fresh installations with no existing encrypted data! ' |
|
74 | - . 'There is no way to enable the master key again. ' |
|
75 | - . 'We strongly recommend to keep the master key, it provides significant performance improvements ' |
|
76 | - . 'and is easier to handle for both, users and administrators. ' |
|
77 | - . 'Do you really want to switch to per-user keys? (y/n) ', false); |
|
78 | - if ($this->questionHelper->ask($input, $output, $question)) { |
|
79 | - $this->config->setAppValue('encryption', 'useMasterKey', '0'); |
|
80 | - $output->writeln('Master key successfully disabled.'); |
|
81 | - } else { |
|
82 | - $output->writeln('aborted.'); |
|
83 | - return 1; |
|
84 | - } |
|
85 | - } |
|
86 | - return 0; |
|
87 | - } |
|
69 | + if (!$isMasterKeyEnabled) { |
|
70 | + $output->writeln('Master key already disabled'); |
|
71 | + } else { |
|
72 | + $question = new ConfirmationQuestion( |
|
73 | + 'Warning: Only perform this operation for a fresh installations with no existing encrypted data! ' |
|
74 | + . 'There is no way to enable the master key again. ' |
|
75 | + . 'We strongly recommend to keep the master key, it provides significant performance improvements ' |
|
76 | + . 'and is easier to handle for both, users and administrators. ' |
|
77 | + . 'Do you really want to switch to per-user keys? (y/n) ', false); |
|
78 | + if ($this->questionHelper->ask($input, $output, $question)) { |
|
79 | + $this->config->setAppValue('encryption', 'useMasterKey', '0'); |
|
80 | + $output->writeln('Master key successfully disabled.'); |
|
81 | + } else { |
|
82 | + $output->writeln('aborted.'); |
|
83 | + return 1; |
|
84 | + } |
|
85 | + } |
|
86 | + return 0; |
|
87 | + } |
|
88 | 88 | } |
@@ -32,37 +32,37 @@ |
||
32 | 32 | |
33 | 33 | class SyncSystemAddressBook extends Command { |
34 | 34 | |
35 | - /** @var SyncService */ |
|
36 | - private $syncService; |
|
35 | + /** @var SyncService */ |
|
36 | + private $syncService; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param SyncService $syncService |
|
40 | - */ |
|
41 | - public function __construct(SyncService $syncService) { |
|
42 | - parent::__construct(); |
|
43 | - $this->syncService = $syncService; |
|
44 | - } |
|
38 | + /** |
|
39 | + * @param SyncService $syncService |
|
40 | + */ |
|
41 | + public function __construct(SyncService $syncService) { |
|
42 | + parent::__construct(); |
|
43 | + $this->syncService = $syncService; |
|
44 | + } |
|
45 | 45 | |
46 | - protected function configure() { |
|
47 | - $this |
|
48 | - ->setName('dav:sync-system-addressbook') |
|
49 | - ->setDescription('Synchronizes users to the system addressbook'); |
|
50 | - } |
|
46 | + protected function configure() { |
|
47 | + $this |
|
48 | + ->setName('dav:sync-system-addressbook') |
|
49 | + ->setDescription('Synchronizes users to the system addressbook'); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param InputInterface $input |
|
54 | - * @param OutputInterface $output |
|
55 | - */ |
|
56 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
57 | - $output->writeln('Syncing users ...'); |
|
58 | - $progress = new ProgressBar($output); |
|
59 | - $progress->start(); |
|
60 | - $this->syncService->syncInstance(function () use ($progress) { |
|
61 | - $progress->advance(); |
|
62 | - }); |
|
52 | + /** |
|
53 | + * @param InputInterface $input |
|
54 | + * @param OutputInterface $output |
|
55 | + */ |
|
56 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
57 | + $output->writeln('Syncing users ...'); |
|
58 | + $progress = new ProgressBar($output); |
|
59 | + $progress->start(); |
|
60 | + $this->syncService->syncInstance(function () use ($progress) { |
|
61 | + $progress->advance(); |
|
62 | + }); |
|
63 | 63 | |
64 | - $progress->finish(); |
|
65 | - $output->writeln(''); |
|
66 | - return 0; |
|
67 | - } |
|
64 | + $progress->finish(); |
|
65 | + $output->writeln(''); |
|
66 | + return 0; |
|
67 | + } |
|
68 | 68 | } |
@@ -38,50 +38,50 @@ |
||
38 | 38 | */ |
39 | 39 | class RemoveInvalidShares extends Command { |
40 | 40 | |
41 | - /** @var IDBConnection */ |
|
42 | - private $connection; |
|
43 | - /** @var Principal */ |
|
44 | - private $principalBackend; |
|
41 | + /** @var IDBConnection */ |
|
42 | + private $connection; |
|
43 | + /** @var Principal */ |
|
44 | + private $principalBackend; |
|
45 | 45 | |
46 | - public function __construct(IDBConnection $connection, |
|
47 | - Principal $principalBackend) { |
|
48 | - parent::__construct(); |
|
46 | + public function __construct(IDBConnection $connection, |
|
47 | + Principal $principalBackend) { |
|
48 | + parent::__construct(); |
|
49 | 49 | |
50 | - $this->connection = $connection; |
|
51 | - $this->principalBackend = $principalBackend; |
|
52 | - } |
|
50 | + $this->connection = $connection; |
|
51 | + $this->principalBackend = $principalBackend; |
|
52 | + } |
|
53 | 53 | |
54 | - protected function configure() { |
|
55 | - $this |
|
56 | - ->setName('dav:remove-invalid-shares') |
|
57 | - ->setDescription('Remove invalid dav shares'); |
|
58 | - } |
|
54 | + protected function configure() { |
|
55 | + $this |
|
56 | + ->setName('dav:remove-invalid-shares') |
|
57 | + ->setDescription('Remove invalid dav shares'); |
|
58 | + } |
|
59 | 59 | |
60 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
61 | - $query = $this->connection->getQueryBuilder(); |
|
62 | - $result = $query->selectDistinct('principaluri') |
|
63 | - ->from('dav_shares') |
|
64 | - ->execute(); |
|
60 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
61 | + $query = $this->connection->getQueryBuilder(); |
|
62 | + $result = $query->selectDistinct('principaluri') |
|
63 | + ->from('dav_shares') |
|
64 | + ->execute(); |
|
65 | 65 | |
66 | - while ($row = $result->fetch()) { |
|
67 | - $principaluri = $row['principaluri']; |
|
68 | - $p = $this->principalBackend->getPrincipalByPath($principaluri); |
|
69 | - if ($p === null) { |
|
70 | - $this->deleteSharesForPrincipal($principaluri); |
|
71 | - } |
|
72 | - } |
|
66 | + while ($row = $result->fetch()) { |
|
67 | + $principaluri = $row['principaluri']; |
|
68 | + $p = $this->principalBackend->getPrincipalByPath($principaluri); |
|
69 | + if ($p === null) { |
|
70 | + $this->deleteSharesForPrincipal($principaluri); |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | - $result->closeCursor(); |
|
75 | - return 0; |
|
76 | - } |
|
74 | + $result->closeCursor(); |
|
75 | + return 0; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param string $principaluri |
|
80 | - */ |
|
81 | - private function deleteSharesForPrincipal($principaluri) { |
|
82 | - $delete = $this->connection->getQueryBuilder(); |
|
83 | - $delete->delete('dav_shares') |
|
84 | - ->where($delete->expr()->eq('principaluri', $delete->createNamedParameter($principaluri))); |
|
85 | - $delete->execute(); |
|
86 | - } |
|
78 | + /** |
|
79 | + * @param string $principaluri |
|
80 | + */ |
|
81 | + private function deleteSharesForPrincipal($principaluri) { |
|
82 | + $delete = $this->connection->getQueryBuilder(); |
|
83 | + $delete->delete('dav_shares') |
|
84 | + ->where($delete->expr()->eq('principaluri', $delete->createNamedParameter($principaluri))); |
|
85 | + $delete->execute(); |
|
86 | + } |
|
87 | 87 | } |
@@ -37,50 +37,50 @@ |
||
37 | 37 | */ |
38 | 38 | class SendEventReminders extends Command { |
39 | 39 | |
40 | - /** @var ReminderService */ |
|
41 | - protected $reminderService; |
|
40 | + /** @var ReminderService */ |
|
41 | + protected $reminderService; |
|
42 | 42 | |
43 | - /** @var IConfig */ |
|
44 | - protected $config; |
|
43 | + /** @var IConfig */ |
|
44 | + protected $config; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param ReminderService $reminderService |
|
48 | - * @param IConfig $config |
|
49 | - */ |
|
50 | - public function __construct(ReminderService $reminderService, |
|
51 | - IConfig $config) { |
|
52 | - parent::__construct(); |
|
53 | - $this->reminderService = $reminderService; |
|
54 | - $this->config = $config; |
|
55 | - } |
|
46 | + /** |
|
47 | + * @param ReminderService $reminderService |
|
48 | + * @param IConfig $config |
|
49 | + */ |
|
50 | + public function __construct(ReminderService $reminderService, |
|
51 | + IConfig $config) { |
|
52 | + parent::__construct(); |
|
53 | + $this->reminderService = $reminderService; |
|
54 | + $this->config = $config; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @inheritDoc |
|
59 | - */ |
|
60 | - protected function configure():void { |
|
61 | - $this |
|
62 | - ->setName('dav:send-event-reminders') |
|
63 | - ->setDescription('Sends event reminders'); |
|
64 | - } |
|
57 | + /** |
|
58 | + * @inheritDoc |
|
59 | + */ |
|
60 | + protected function configure():void { |
|
61 | + $this |
|
62 | + ->setName('dav:send-event-reminders') |
|
63 | + ->setDescription('Sends event reminders'); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param InputInterface $input |
|
68 | - * @param OutputInterface $output |
|
69 | - */ |
|
70 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
71 | - if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') { |
|
72 | - $output->writeln('<error>Sending event reminders disabled!</error>'); |
|
73 | - $output->writeln('<info>Please run "php occ config:app:set dav sendEventReminders --value yes"'); |
|
74 | - return 1; |
|
75 | - } |
|
66 | + /** |
|
67 | + * @param InputInterface $input |
|
68 | + * @param OutputInterface $output |
|
69 | + */ |
|
70 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
71 | + if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') { |
|
72 | + $output->writeln('<error>Sending event reminders disabled!</error>'); |
|
73 | + $output->writeln('<info>Please run "php occ config:app:set dav sendEventReminders --value yes"'); |
|
74 | + return 1; |
|
75 | + } |
|
76 | 76 | |
77 | - if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'occ') { |
|
78 | - $output->writeln('<error>Sending event reminders mode set to background-job!</error>'); |
|
79 | - $output->writeln('<info>Please run "php occ config:app:set dav sendEventRemindersMode --value occ"'); |
|
80 | - return 1; |
|
81 | - } |
|
77 | + if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'occ') { |
|
78 | + $output->writeln('<error>Sending event reminders mode set to background-job!</error>'); |
|
79 | + $output->writeln('<info>Please run "php occ config:app:set dav sendEventRemindersMode --value occ"'); |
|
80 | + return 1; |
|
81 | + } |
|
82 | 82 | |
83 | - $this->reminderService->processReminders(); |
|
84 | - return 0; |
|
85 | - } |
|
83 | + $this->reminderService->processReminders(); |
|
84 | + return 0; |
|
85 | + } |
|
86 | 86 | } |
@@ -37,70 +37,70 @@ |
||
37 | 37 | |
38 | 38 | class ListCalendars extends Command { |
39 | 39 | |
40 | - /** @var IUserManager */ |
|
41 | - protected $userManager; |
|
40 | + /** @var IUserManager */ |
|
41 | + protected $userManager; |
|
42 | 42 | |
43 | - /** @var CalDavBackend */ |
|
44 | - private $caldav; |
|
43 | + /** @var CalDavBackend */ |
|
44 | + private $caldav; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param IUserManager $userManager |
|
48 | - * @param CalDavBackend $caldav |
|
49 | - */ |
|
50 | - public function __construct(IUserManager $userManager, CalDavBackend $caldav) { |
|
51 | - parent::__construct(); |
|
52 | - $this->userManager = $userManager; |
|
53 | - $this->caldav = $caldav; |
|
54 | - } |
|
46 | + /** |
|
47 | + * @param IUserManager $userManager |
|
48 | + * @param CalDavBackend $caldav |
|
49 | + */ |
|
50 | + public function __construct(IUserManager $userManager, CalDavBackend $caldav) { |
|
51 | + parent::__construct(); |
|
52 | + $this->userManager = $userManager; |
|
53 | + $this->caldav = $caldav; |
|
54 | + } |
|
55 | 55 | |
56 | - protected function configure() { |
|
57 | - $this |
|
58 | - ->setName('dav:list-calendars') |
|
59 | - ->setDescription('List all calendars of a user') |
|
60 | - ->addArgument('uid', |
|
61 | - InputArgument::REQUIRED, |
|
62 | - 'User for whom all calendars will be listed'); |
|
63 | - } |
|
56 | + protected function configure() { |
|
57 | + $this |
|
58 | + ->setName('dav:list-calendars') |
|
59 | + ->setDescription('List all calendars of a user') |
|
60 | + ->addArgument('uid', |
|
61 | + InputArgument::REQUIRED, |
|
62 | + 'User for whom all calendars will be listed'); |
|
63 | + } |
|
64 | 64 | |
65 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
66 | - $user = $input->getArgument('uid'); |
|
67 | - if (!$this->userManager->userExists($user)) { |
|
68 | - throw new \InvalidArgumentException("User <$user> is unknown."); |
|
69 | - } |
|
65 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
66 | + $user = $input->getArgument('uid'); |
|
67 | + if (!$this->userManager->userExists($user)) { |
|
68 | + throw new \InvalidArgumentException("User <$user> is unknown."); |
|
69 | + } |
|
70 | 70 | |
71 | - $calendars = $this->caldav->getCalendarsForUser("principals/users/$user"); |
|
71 | + $calendars = $this->caldav->getCalendarsForUser("principals/users/$user"); |
|
72 | 72 | |
73 | - $calendarTableData = []; |
|
74 | - foreach ($calendars as $calendar) { |
|
75 | - // skip birthday calendar |
|
76 | - if ($calendar['uri'] === BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
77 | - continue; |
|
78 | - } |
|
73 | + $calendarTableData = []; |
|
74 | + foreach ($calendars as $calendar) { |
|
75 | + // skip birthday calendar |
|
76 | + if ($calendar['uri'] === BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
77 | + continue; |
|
78 | + } |
|
79 | 79 | |
80 | - $readOnly = false; |
|
81 | - $readOnlyIndex = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'; |
|
82 | - if (isset($calendar[$readOnlyIndex])) { |
|
83 | - $readOnly = $calendar[$readOnlyIndex]; |
|
84 | - } |
|
80 | + $readOnly = false; |
|
81 | + $readOnlyIndex = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'; |
|
82 | + if (isset($calendar[$readOnlyIndex])) { |
|
83 | + $readOnly = $calendar[$readOnlyIndex]; |
|
84 | + } |
|
85 | 85 | |
86 | - $calendarTableData[] = [ |
|
87 | - $calendar['uri'], |
|
88 | - $calendar['{DAV:}displayname'], |
|
89 | - $calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'], |
|
90 | - $calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'], |
|
91 | - $readOnly ? ' x ' : ' ✓ ', |
|
92 | - ]; |
|
93 | - } |
|
86 | + $calendarTableData[] = [ |
|
87 | + $calendar['uri'], |
|
88 | + $calendar['{DAV:}displayname'], |
|
89 | + $calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'], |
|
90 | + $calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'], |
|
91 | + $readOnly ? ' x ' : ' ✓ ', |
|
92 | + ]; |
|
93 | + } |
|
94 | 94 | |
95 | - if (count($calendarTableData) > 0) { |
|
96 | - $table = new Table($output); |
|
97 | - $table->setHeaders(['uri', 'displayname', 'owner\'s userid', 'owner\'s displayname', 'writable']) |
|
98 | - ->setRows($calendarTableData); |
|
95 | + if (count($calendarTableData) > 0) { |
|
96 | + $table = new Table($output); |
|
97 | + $table->setHeaders(['uri', 'displayname', 'owner\'s userid', 'owner\'s displayname', 'writable']) |
|
98 | + ->setRows($calendarTableData); |
|
99 | 99 | |
100 | - $table->render(); |
|
101 | - } else { |
|
102 | - $output->writeln("<info>User <$user> has no calendars</info>"); |
|
103 | - } |
|
104 | - return 0; |
|
105 | - } |
|
100 | + $table->render(); |
|
101 | + } else { |
|
102 | + $output->writeln("<info>User <$user> has no calendars</info>"); |
|
103 | + } |
|
104 | + return 0; |
|
105 | + } |
|
106 | 106 | } |
@@ -34,44 +34,44 @@ |
||
34 | 34 | |
35 | 35 | class CreateAddressBook extends Command { |
36 | 36 | |
37 | - /** @var IUserManager */ |
|
38 | - private $userManager; |
|
37 | + /** @var IUserManager */ |
|
38 | + private $userManager; |
|
39 | 39 | |
40 | - /** @var CardDavBackend */ |
|
41 | - private $cardDavBackend; |
|
40 | + /** @var CardDavBackend */ |
|
41 | + private $cardDavBackend; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param IUserManager $userManager |
|
45 | - * @param CardDavBackend $cardDavBackend |
|
46 | - */ |
|
47 | - public function __construct(IUserManager $userManager, |
|
48 | - CardDavBackend $cardDavBackend |
|
49 | - ) { |
|
50 | - parent::__construct(); |
|
51 | - $this->userManager = $userManager; |
|
52 | - $this->cardDavBackend = $cardDavBackend; |
|
53 | - } |
|
43 | + /** |
|
44 | + * @param IUserManager $userManager |
|
45 | + * @param CardDavBackend $cardDavBackend |
|
46 | + */ |
|
47 | + public function __construct(IUserManager $userManager, |
|
48 | + CardDavBackend $cardDavBackend |
|
49 | + ) { |
|
50 | + parent::__construct(); |
|
51 | + $this->userManager = $userManager; |
|
52 | + $this->cardDavBackend = $cardDavBackend; |
|
53 | + } |
|
54 | 54 | |
55 | - protected function configure() { |
|
56 | - $this |
|
57 | - ->setName('dav:create-addressbook') |
|
58 | - ->setDescription('Create a dav addressbook') |
|
59 | - ->addArgument('user', |
|
60 | - InputArgument::REQUIRED, |
|
61 | - 'User for whom the addressbook will be created') |
|
62 | - ->addArgument('name', |
|
63 | - InputArgument::REQUIRED, |
|
64 | - 'Name of the addressbook'); |
|
65 | - } |
|
55 | + protected function configure() { |
|
56 | + $this |
|
57 | + ->setName('dav:create-addressbook') |
|
58 | + ->setDescription('Create a dav addressbook') |
|
59 | + ->addArgument('user', |
|
60 | + InputArgument::REQUIRED, |
|
61 | + 'User for whom the addressbook will be created') |
|
62 | + ->addArgument('name', |
|
63 | + InputArgument::REQUIRED, |
|
64 | + 'Name of the addressbook'); |
|
65 | + } |
|
66 | 66 | |
67 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
68 | - $user = $input->getArgument('user'); |
|
69 | - if (!$this->userManager->userExists($user)) { |
|
70 | - throw new \InvalidArgumentException("User <$user> in unknown."); |
|
71 | - } |
|
67 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
68 | + $user = $input->getArgument('user'); |
|
69 | + if (!$this->userManager->userExists($user)) { |
|
70 | + throw new \InvalidArgumentException("User <$user> in unknown."); |
|
71 | + } |
|
72 | 72 | |
73 | - $name = $input->getArgument('name'); |
|
74 | - $this->cardDavBackend->createAddressBook("principals/users/$user", $name, []); |
|
75 | - return 0; |
|
76 | - } |
|
73 | + $name = $input->getArgument('name'); |
|
74 | + $this->cardDavBackend->createAddressBook("principals/users/$user", $name, []); |
|
75 | + return 0; |
|
76 | + } |
|
77 | 77 | } |
@@ -38,87 +38,87 @@ |
||
38 | 38 | |
39 | 39 | class SyncBirthdayCalendar extends Command { |
40 | 40 | |
41 | - /** @var BirthdayService */ |
|
42 | - private $birthdayService; |
|
43 | - |
|
44 | - /** @var IConfig */ |
|
45 | - private $config; |
|
46 | - |
|
47 | - /** @var IUserManager */ |
|
48 | - private $userManager; |
|
49 | - |
|
50 | - /** |
|
51 | - * @param IUserManager $userManager |
|
52 | - * @param IConfig $config |
|
53 | - * @param BirthdayService $birthdayService |
|
54 | - */ |
|
55 | - public function __construct(IUserManager $userManager, IConfig $config, |
|
56 | - BirthdayService $birthdayService) { |
|
57 | - parent::__construct(); |
|
58 | - $this->birthdayService = $birthdayService; |
|
59 | - $this->config = $config; |
|
60 | - $this->userManager = $userManager; |
|
61 | - } |
|
62 | - |
|
63 | - protected function configure() { |
|
64 | - $this |
|
65 | - ->setName('dav:sync-birthday-calendar') |
|
66 | - ->setDescription('Synchronizes the birthday calendar') |
|
67 | - ->addArgument('user', |
|
68 | - InputArgument::OPTIONAL, |
|
69 | - 'User for whom the birthday calendar will be synchronized'); |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * @param InputInterface $input |
|
74 | - * @param OutputInterface $output |
|
75 | - */ |
|
76 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
77 | - $this->verifyEnabled(); |
|
78 | - |
|
79 | - $user = $input->getArgument('user'); |
|
80 | - if (!is_null($user)) { |
|
81 | - if (!$this->userManager->userExists($user)) { |
|
82 | - throw new \InvalidArgumentException("User <$user> in unknown."); |
|
83 | - } |
|
84 | - |
|
85 | - // re-enable the birthday calendar in case it's called directly with a user name |
|
86 | - $isEnabled = $this->config->getUserValue($user, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
87 | - if ($isEnabled !== 'yes') { |
|
88 | - $this->config->setUserValue($user, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
89 | - $output->writeln("Re-enabling birthday calendar for $user"); |
|
90 | - } |
|
91 | - |
|
92 | - $output->writeln("Start birthday calendar sync for $user"); |
|
93 | - $this->birthdayService->syncUser($user); |
|
94 | - return 0; |
|
95 | - } |
|
96 | - $output->writeln("Start birthday calendar sync for all users ..."); |
|
97 | - $p = new ProgressBar($output); |
|
98 | - $p->start(); |
|
99 | - $this->userManager->callForSeenUsers(function ($user) use ($p) { |
|
100 | - $p->advance(); |
|
101 | - |
|
102 | - $userId = $user->getUID(); |
|
103 | - $isEnabled = $this->config->getUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
104 | - if ($isEnabled !== 'yes') { |
|
105 | - return; |
|
106 | - } |
|
107 | - |
|
108 | - /** @var IUser $user */ |
|
109 | - $this->birthdayService->syncUser($user->getUID()); |
|
110 | - }); |
|
111 | - |
|
112 | - $p->finish(); |
|
113 | - $output->writeln(''); |
|
114 | - return 0; |
|
115 | - } |
|
116 | - |
|
117 | - protected function verifyEnabled() { |
|
118 | - $isEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'); |
|
119 | - |
|
120 | - if ($isEnabled !== 'yes') { |
|
121 | - throw new \InvalidArgumentException('Birthday calendars are disabled'); |
|
122 | - } |
|
123 | - } |
|
41 | + /** @var BirthdayService */ |
|
42 | + private $birthdayService; |
|
43 | + |
|
44 | + /** @var IConfig */ |
|
45 | + private $config; |
|
46 | + |
|
47 | + /** @var IUserManager */ |
|
48 | + private $userManager; |
|
49 | + |
|
50 | + /** |
|
51 | + * @param IUserManager $userManager |
|
52 | + * @param IConfig $config |
|
53 | + * @param BirthdayService $birthdayService |
|
54 | + */ |
|
55 | + public function __construct(IUserManager $userManager, IConfig $config, |
|
56 | + BirthdayService $birthdayService) { |
|
57 | + parent::__construct(); |
|
58 | + $this->birthdayService = $birthdayService; |
|
59 | + $this->config = $config; |
|
60 | + $this->userManager = $userManager; |
|
61 | + } |
|
62 | + |
|
63 | + protected function configure() { |
|
64 | + $this |
|
65 | + ->setName('dav:sync-birthday-calendar') |
|
66 | + ->setDescription('Synchronizes the birthday calendar') |
|
67 | + ->addArgument('user', |
|
68 | + InputArgument::OPTIONAL, |
|
69 | + 'User for whom the birthday calendar will be synchronized'); |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * @param InputInterface $input |
|
74 | + * @param OutputInterface $output |
|
75 | + */ |
|
76 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
77 | + $this->verifyEnabled(); |
|
78 | + |
|
79 | + $user = $input->getArgument('user'); |
|
80 | + if (!is_null($user)) { |
|
81 | + if (!$this->userManager->userExists($user)) { |
|
82 | + throw new \InvalidArgumentException("User <$user> in unknown."); |
|
83 | + } |
|
84 | + |
|
85 | + // re-enable the birthday calendar in case it's called directly with a user name |
|
86 | + $isEnabled = $this->config->getUserValue($user, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
87 | + if ($isEnabled !== 'yes') { |
|
88 | + $this->config->setUserValue($user, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
89 | + $output->writeln("Re-enabling birthday calendar for $user"); |
|
90 | + } |
|
91 | + |
|
92 | + $output->writeln("Start birthday calendar sync for $user"); |
|
93 | + $this->birthdayService->syncUser($user); |
|
94 | + return 0; |
|
95 | + } |
|
96 | + $output->writeln("Start birthday calendar sync for all users ..."); |
|
97 | + $p = new ProgressBar($output); |
|
98 | + $p->start(); |
|
99 | + $this->userManager->callForSeenUsers(function ($user) use ($p) { |
|
100 | + $p->advance(); |
|
101 | + |
|
102 | + $userId = $user->getUID(); |
|
103 | + $isEnabled = $this->config->getUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes'); |
|
104 | + if ($isEnabled !== 'yes') { |
|
105 | + return; |
|
106 | + } |
|
107 | + |
|
108 | + /** @var IUser $user */ |
|
109 | + $this->birthdayService->syncUser($user->getUID()); |
|
110 | + }); |
|
111 | + |
|
112 | + $p->finish(); |
|
113 | + $output->writeln(''); |
|
114 | + return 0; |
|
115 | + } |
|
116 | + |
|
117 | + protected function verifyEnabled() { |
|
118 | + $isEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes'); |
|
119 | + |
|
120 | + if ($isEnabled !== 'yes') { |
|
121 | + throw new \InvalidArgumentException('Birthday calendars are disabled'); |
|
122 | + } |
|
123 | + } |
|
124 | 124 | } |
@@ -33,41 +33,41 @@ |
||
33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
34 | 34 | |
35 | 35 | class DeleteConfig extends Command { |
36 | - /** @var \OCA\User_LDAP\Helper */ |
|
37 | - protected $helper; |
|
36 | + /** @var \OCA\User_LDAP\Helper */ |
|
37 | + protected $helper; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param Helper $helper |
|
41 | - */ |
|
42 | - public function __construct(Helper $helper) { |
|
43 | - $this->helper = $helper; |
|
44 | - parent::__construct(); |
|
45 | - } |
|
39 | + /** |
|
40 | + * @param Helper $helper |
|
41 | + */ |
|
42 | + public function __construct(Helper $helper) { |
|
43 | + $this->helper = $helper; |
|
44 | + parent::__construct(); |
|
45 | + } |
|
46 | 46 | |
47 | - protected function configure() { |
|
48 | - $this |
|
49 | - ->setName('ldap:delete-config') |
|
50 | - ->setDescription('deletes an existing LDAP configuration') |
|
51 | - ->addArgument( |
|
52 | - 'configID', |
|
53 | - InputArgument::REQUIRED, |
|
54 | - 'the configuration ID' |
|
55 | - ) |
|
56 | - ; |
|
57 | - } |
|
47 | + protected function configure() { |
|
48 | + $this |
|
49 | + ->setName('ldap:delete-config') |
|
50 | + ->setDescription('deletes an existing LDAP configuration') |
|
51 | + ->addArgument( |
|
52 | + 'configID', |
|
53 | + InputArgument::REQUIRED, |
|
54 | + 'the configuration ID' |
|
55 | + ) |
|
56 | + ; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
61 | - $configPrefix = $input->getArgument('configID'); |
|
60 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
61 | + $configPrefix = $input->getArgument('configID'); |
|
62 | 62 | |
63 | - $success = $this->helper->deleteServerConfiguration($configPrefix); |
|
63 | + $success = $this->helper->deleteServerConfiguration($configPrefix); |
|
64 | 64 | |
65 | - if ($success) { |
|
66 | - $output->writeln("Deleted configuration with configID '{$configPrefix}'"); |
|
67 | - return 0; |
|
68 | - } else { |
|
69 | - $output->writeln("Cannot delete configuration with configID '{$configPrefix}'"); |
|
70 | - return 1; |
|
71 | - } |
|
72 | - } |
|
65 | + if ($success) { |
|
66 | + $output->writeln("Deleted configuration with configID '{$configPrefix}'"); |
|
67 | + return 0; |
|
68 | + } else { |
|
69 | + $output->writeln("Cannot delete configuration with configID '{$configPrefix}'"); |
|
70 | + return 1; |
|
71 | + } |
|
72 | + } |
|
73 | 73 | } |