@@ -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 | } |
@@ -36,64 +36,64 @@ |
||
36 | 36 | use Symfony\Component\Console\Output\OutputInterface; |
37 | 37 | |
38 | 38 | class ExiprationNotification extends Command { |
39 | - /** @var NotificationManager */ |
|
40 | - private $notificationManager; |
|
41 | - /** @var IDBConnection */ |
|
42 | - private $connection; |
|
43 | - /** @var ITimeFactory */ |
|
44 | - private $time; |
|
45 | - /** @var ShareManager */ |
|
46 | - private $shareManager; |
|
39 | + /** @var NotificationManager */ |
|
40 | + private $notificationManager; |
|
41 | + /** @var IDBConnection */ |
|
42 | + private $connection; |
|
43 | + /** @var ITimeFactory */ |
|
44 | + private $time; |
|
45 | + /** @var ShareManager */ |
|
46 | + private $shareManager; |
|
47 | 47 | |
48 | - public function __construct(ITimeFactory $time, |
|
49 | - NotificationManager $notificationManager, |
|
50 | - IDBConnection $connection, |
|
51 | - ShareManager $shareManager) { |
|
52 | - parent::__construct(); |
|
48 | + public function __construct(ITimeFactory $time, |
|
49 | + NotificationManager $notificationManager, |
|
50 | + IDBConnection $connection, |
|
51 | + ShareManager $shareManager) { |
|
52 | + parent::__construct(); |
|
53 | 53 | |
54 | - $this->notificationManager = $notificationManager; |
|
55 | - $this->connection = $connection; |
|
56 | - $this->time = $time; |
|
57 | - $this->shareManager = $shareManager; |
|
58 | - } |
|
54 | + $this->notificationManager = $notificationManager; |
|
55 | + $this->connection = $connection; |
|
56 | + $this->time = $time; |
|
57 | + $this->shareManager = $shareManager; |
|
58 | + } |
|
59 | 59 | |
60 | - protected function configure() { |
|
61 | - $this |
|
62 | - ->setName('sharing:expiration-notification') |
|
63 | - ->setDescription('Notify share initiators when a share will expire the next day.'); |
|
64 | - } |
|
60 | + protected function configure() { |
|
61 | + $this |
|
62 | + ->setName('sharing:expiration-notification') |
|
63 | + ->setDescription('Notify share initiators when a share will expire the next day.'); |
|
64 | + } |
|
65 | 65 | |
66 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
67 | - //Current time |
|
68 | - $minTime = $this->time->getDateTime(); |
|
69 | - $minTime->add(new \DateInterval('P1D')); |
|
70 | - $minTime->setTime(0,0,0); |
|
66 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
67 | + //Current time |
|
68 | + $minTime = $this->time->getDateTime(); |
|
69 | + $minTime->add(new \DateInterval('P1D')); |
|
70 | + $minTime->setTime(0,0,0); |
|
71 | 71 | |
72 | - $maxTime = clone $minTime; |
|
73 | - $maxTime->setTime(23, 59, 59); |
|
72 | + $maxTime = clone $minTime; |
|
73 | + $maxTime->setTime(23, 59, 59); |
|
74 | 74 | |
75 | - $shares = $this->shareManager->getAllShares(); |
|
75 | + $shares = $this->shareManager->getAllShares(); |
|
76 | 76 | |
77 | - $now = $this->time->getDateTime(); |
|
77 | + $now = $this->time->getDateTime(); |
|
78 | 78 | |
79 | - /** @var IShare $share */ |
|
80 | - foreach ($shares as $share) { |
|
81 | - if ($share->getExpirationDate() === null |
|
82 | - || $share->getExpirationDate()->getTimestamp() < $minTime->getTimestamp() |
|
83 | - || $share->getExpirationDate()->getTimestamp() > $maxTime->getTimestamp()) { |
|
84 | - continue; |
|
85 | - } |
|
79 | + /** @var IShare $share */ |
|
80 | + foreach ($shares as $share) { |
|
81 | + if ($share->getExpirationDate() === null |
|
82 | + || $share->getExpirationDate()->getTimestamp() < $minTime->getTimestamp() |
|
83 | + || $share->getExpirationDate()->getTimestamp() > $maxTime->getTimestamp()) { |
|
84 | + continue; |
|
85 | + } |
|
86 | 86 | |
87 | - $notification = $this->notificationManager->createNotification(); |
|
88 | - $notification->setApp('files_sharing') |
|
89 | - ->setDateTime($now) |
|
90 | - ->setObject('share', $share->getFullId()) |
|
91 | - ->setSubject('expiresTomorrow'); |
|
87 | + $notification = $this->notificationManager->createNotification(); |
|
88 | + $notification->setApp('files_sharing') |
|
89 | + ->setDateTime($now) |
|
90 | + ->setObject('share', $share->getFullId()) |
|
91 | + ->setSubject('expiresTomorrow'); |
|
92 | 92 | |
93 | - // Only send to initiator for now |
|
94 | - $notification->setUser($share->getSharedBy()); |
|
95 | - $this->notificationManager->notify($notification); |
|
96 | - } |
|
97 | - return 0; |
|
98 | - } |
|
93 | + // Only send to initiator for now |
|
94 | + $notification->setUser($share->getSharedBy()); |
|
95 | + $this->notificationManager->notify($notification); |
|
96 | + } |
|
97 | + return 0; |
|
98 | + } |
|
99 | 99 | } |
@@ -35,48 +35,48 @@ |
||
35 | 35 | |
36 | 36 | class Index extends Command { |
37 | 37 | |
38 | - /** @var Manager */ |
|
39 | - private $manager; |
|
38 | + /** @var Manager */ |
|
39 | + private $manager; |
|
40 | 40 | |
41 | - public function __construct(Manager $manager) { |
|
42 | - $this->manager = $manager; |
|
43 | - parent::__construct(); |
|
44 | - } |
|
41 | + public function __construct(Manager $manager) { |
|
42 | + $this->manager = $manager; |
|
43 | + parent::__construct(); |
|
44 | + } |
|
45 | 45 | |
46 | - protected function configure() { |
|
47 | - $this |
|
48 | - ->setName('workflows:list') |
|
49 | - ->setDescription('Lists configured workflows') |
|
50 | - ->addArgument( |
|
51 | - 'scope', |
|
52 | - InputArgument::OPTIONAL, |
|
53 | - 'Lists workflows for "admin", "user"', |
|
54 | - 'admin' |
|
55 | - ) |
|
56 | - ->addArgument( |
|
57 | - 'scopeId', |
|
58 | - InputArgument::OPTIONAL, |
|
59 | - 'User IDs when the scope is "user"', |
|
60 | - null |
|
61 | - ); |
|
62 | - } |
|
46 | + protected function configure() { |
|
47 | + $this |
|
48 | + ->setName('workflows:list') |
|
49 | + ->setDescription('Lists configured workflows') |
|
50 | + ->addArgument( |
|
51 | + 'scope', |
|
52 | + InputArgument::OPTIONAL, |
|
53 | + 'Lists workflows for "admin", "user"', |
|
54 | + 'admin' |
|
55 | + ) |
|
56 | + ->addArgument( |
|
57 | + 'scopeId', |
|
58 | + InputArgument::OPTIONAL, |
|
59 | + 'User IDs when the scope is "user"', |
|
60 | + null |
|
61 | + ); |
|
62 | + } |
|
63 | 63 | |
64 | - protected function mappedScope(string $scope): int { |
|
65 | - static $scopes = [ |
|
66 | - 'admin' => IManager::SCOPE_ADMIN, |
|
67 | - 'user' => IManager::SCOPE_USER, |
|
68 | - ]; |
|
69 | - return $scopes[$scope] ?? -1; |
|
70 | - } |
|
64 | + protected function mappedScope(string $scope): int { |
|
65 | + static $scopes = [ |
|
66 | + 'admin' => IManager::SCOPE_ADMIN, |
|
67 | + 'user' => IManager::SCOPE_USER, |
|
68 | + ]; |
|
69 | + return $scopes[$scope] ?? -1; |
|
70 | + } |
|
71 | 71 | |
72 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
73 | - $ops = $this->manager->getAllOperations( |
|
74 | - new ScopeContext( |
|
75 | - $this->mappedScope($input->getArgument('scope')), |
|
76 | - $input->getArgument('scopeId') |
|
77 | - ) |
|
78 | - ); |
|
79 | - $output->writeln(\json_encode($ops)); |
|
80 | - return 0; |
|
81 | - } |
|
72 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
73 | + $ops = $this->manager->getAllOperations( |
|
74 | + new ScopeContext( |
|
75 | + $this->mappedScope($input->getArgument('scope')), |
|
76 | + $input->getArgument('scopeId') |
|
77 | + ) |
|
78 | + ); |
|
79 | + $output->writeln(\json_encode($ops)); |
|
80 | + return 0; |
|
81 | + } |
|
82 | 82 | } |
@@ -39,98 +39,98 @@ |
||
39 | 39 | |
40 | 40 | class CleanUp extends Command { |
41 | 41 | |
42 | - /** @var IUserManager */ |
|
43 | - protected $userManager; |
|
42 | + /** @var IUserManager */ |
|
43 | + protected $userManager; |
|
44 | 44 | |
45 | - /** @var IRootFolder */ |
|
46 | - protected $rootFolder; |
|
45 | + /** @var IRootFolder */ |
|
46 | + protected $rootFolder; |
|
47 | 47 | |
48 | - /** @var \OCP\IDBConnection */ |
|
49 | - protected $dbConnection; |
|
48 | + /** @var \OCP\IDBConnection */ |
|
49 | + protected $dbConnection; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param IRootFolder $rootFolder |
|
53 | - * @param IUserManager $userManager |
|
54 | - * @param IDBConnection $dbConnection |
|
55 | - */ |
|
56 | - public function __construct(IRootFolder $rootFolder, IUserManager $userManager, IDBConnection $dbConnection) { |
|
57 | - parent::__construct(); |
|
58 | - $this->userManager = $userManager; |
|
59 | - $this->rootFolder = $rootFolder; |
|
60 | - $this->dbConnection = $dbConnection; |
|
61 | - } |
|
51 | + /** |
|
52 | + * @param IRootFolder $rootFolder |
|
53 | + * @param IUserManager $userManager |
|
54 | + * @param IDBConnection $dbConnection |
|
55 | + */ |
|
56 | + public function __construct(IRootFolder $rootFolder, IUserManager $userManager, IDBConnection $dbConnection) { |
|
57 | + parent::__construct(); |
|
58 | + $this->userManager = $userManager; |
|
59 | + $this->rootFolder = $rootFolder; |
|
60 | + $this->dbConnection = $dbConnection; |
|
61 | + } |
|
62 | 62 | |
63 | - protected function configure() { |
|
64 | - $this |
|
65 | - ->setName('trashbin:cleanup') |
|
66 | - ->setDescription('Remove deleted files') |
|
67 | - ->addArgument( |
|
68 | - 'user_id', |
|
69 | - InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
70 | - 'remove deleted files of the given user(s)' |
|
71 | - ) |
|
72 | - ->addOption( |
|
73 | - 'all-users', |
|
74 | - null, |
|
75 | - InputOption::VALUE_NONE, |
|
76 | - 'run action on all users' |
|
77 | - ); |
|
78 | - } |
|
63 | + protected function configure() { |
|
64 | + $this |
|
65 | + ->setName('trashbin:cleanup') |
|
66 | + ->setDescription('Remove deleted files') |
|
67 | + ->addArgument( |
|
68 | + 'user_id', |
|
69 | + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
70 | + 'remove deleted files of the given user(s)' |
|
71 | + ) |
|
72 | + ->addOption( |
|
73 | + 'all-users', |
|
74 | + null, |
|
75 | + InputOption::VALUE_NONE, |
|
76 | + 'run action on all users' |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
81 | - $users = $input->getArgument('user_id'); |
|
82 | - if ((!empty($users)) and ($input->getOption('all-users'))) { |
|
83 | - throw new InvalidOptionException('Either specify a user_id or --all-users'); |
|
84 | - } elseif (!empty($users)) { |
|
85 | - foreach ($users as $user) { |
|
86 | - if ($this->userManager->userExists($user)) { |
|
87 | - $output->writeln("Remove deleted files of <info>$user</info>"); |
|
88 | - $this->removeDeletedFiles($user); |
|
89 | - } else { |
|
90 | - $output->writeln("<error>Unknown user $user</error>"); |
|
91 | - return 1; |
|
92 | - } |
|
93 | - } |
|
94 | - } elseif ($input->getOption('all-users')) { |
|
95 | - $output->writeln('Remove deleted files for all users'); |
|
96 | - foreach ($this->userManager->getBackends() as $backend) { |
|
97 | - $name = get_class($backend); |
|
98 | - if ($backend instanceof IUserBackend) { |
|
99 | - $name = $backend->getBackendName(); |
|
100 | - } |
|
101 | - $output->writeln("Remove deleted files for users on backend <info>$name</info>"); |
|
102 | - $limit = 500; |
|
103 | - $offset = 0; |
|
104 | - do { |
|
105 | - $users = $backend->getUsers('', $limit, $offset); |
|
106 | - foreach ($users as $user) { |
|
107 | - $output->writeln(" <info>$user</info>"); |
|
108 | - $this->removeDeletedFiles($user); |
|
109 | - } |
|
110 | - $offset += $limit; |
|
111 | - } while (count($users) >= $limit); |
|
112 | - } |
|
113 | - } else { |
|
114 | - throw new InvalidOptionException('Either specify a user_id or --all-users'); |
|
115 | - } |
|
116 | - return 0; |
|
117 | - } |
|
80 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
81 | + $users = $input->getArgument('user_id'); |
|
82 | + if ((!empty($users)) and ($input->getOption('all-users'))) { |
|
83 | + throw new InvalidOptionException('Either specify a user_id or --all-users'); |
|
84 | + } elseif (!empty($users)) { |
|
85 | + foreach ($users as $user) { |
|
86 | + if ($this->userManager->userExists($user)) { |
|
87 | + $output->writeln("Remove deleted files of <info>$user</info>"); |
|
88 | + $this->removeDeletedFiles($user); |
|
89 | + } else { |
|
90 | + $output->writeln("<error>Unknown user $user</error>"); |
|
91 | + return 1; |
|
92 | + } |
|
93 | + } |
|
94 | + } elseif ($input->getOption('all-users')) { |
|
95 | + $output->writeln('Remove deleted files for all users'); |
|
96 | + foreach ($this->userManager->getBackends() as $backend) { |
|
97 | + $name = get_class($backend); |
|
98 | + if ($backend instanceof IUserBackend) { |
|
99 | + $name = $backend->getBackendName(); |
|
100 | + } |
|
101 | + $output->writeln("Remove deleted files for users on backend <info>$name</info>"); |
|
102 | + $limit = 500; |
|
103 | + $offset = 0; |
|
104 | + do { |
|
105 | + $users = $backend->getUsers('', $limit, $offset); |
|
106 | + foreach ($users as $user) { |
|
107 | + $output->writeln(" <info>$user</info>"); |
|
108 | + $this->removeDeletedFiles($user); |
|
109 | + } |
|
110 | + $offset += $limit; |
|
111 | + } while (count($users) >= $limit); |
|
112 | + } |
|
113 | + } else { |
|
114 | + throw new InvalidOptionException('Either specify a user_id or --all-users'); |
|
115 | + } |
|
116 | + return 0; |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * remove deleted files for the given user |
|
121 | - * |
|
122 | - * @param string $uid |
|
123 | - */ |
|
124 | - protected function removeDeletedFiles($uid) { |
|
125 | - \OC_Util::tearDownFS(); |
|
126 | - \OC_Util::setupFS($uid); |
|
127 | - if ($this->rootFolder->nodeExists('/' . $uid . '/files_trashbin')) { |
|
128 | - $this->rootFolder->get('/' . $uid . '/files_trashbin')->delete(); |
|
129 | - $query = $this->dbConnection->getQueryBuilder(); |
|
130 | - $query->delete('files_trash') |
|
131 | - ->where($query->expr()->eq('user', $query->createParameter('uid'))) |
|
132 | - ->setParameter('uid', $uid); |
|
133 | - $query->execute(); |
|
134 | - } |
|
135 | - } |
|
119 | + /** |
|
120 | + * remove deleted files for the given user |
|
121 | + * |
|
122 | + * @param string $uid |
|
123 | + */ |
|
124 | + protected function removeDeletedFiles($uid) { |
|
125 | + \OC_Util::tearDownFS(); |
|
126 | + \OC_Util::setupFS($uid); |
|
127 | + if ($this->rootFolder->nodeExists('/' . $uid . '/files_trashbin')) { |
|
128 | + $this->rootFolder->get('/' . $uid . '/files_trashbin')->delete(); |
|
129 | + $query = $this->dbConnection->getQueryBuilder(); |
|
130 | + $query->delete('files_trash') |
|
131 | + ->where($query->expr()->eq('user', $query->createParameter('uid'))) |
|
132 | + ->setParameter('uid', $uid); |
|
133 | + $query->execute(); |
|
134 | + } |
|
135 | + } |
|
136 | 136 | } |
@@ -35,72 +35,72 @@ |
||
35 | 35 | use OCP\Migration\SimpleMigrationStep; |
36 | 36 | |
37 | 37 | class Version16000Date20190212081545 extends SimpleMigrationStep { |
38 | - /** |
|
39 | - * @param IOutput $output |
|
40 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | - * @param array $options |
|
42 | - * |
|
43 | - * @return ISchemaWrapper |
|
44 | - */ |
|
45 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
46 | - /** @var ISchemaWrapper $schema */ |
|
47 | - $schema = $schemaClosure(); |
|
38 | + /** |
|
39 | + * @param IOutput $output |
|
40 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | + * @param array $options |
|
42 | + * |
|
43 | + * @return ISchemaWrapper |
|
44 | + */ |
|
45 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
46 | + /** @var ISchemaWrapper $schema */ |
|
47 | + $schema = $schemaClosure(); |
|
48 | 48 | |
49 | - $table = $schema->createTable('login_flow_v2'); |
|
50 | - $table->addColumn('id', Types::BIGINT, [ |
|
51 | - 'autoincrement' => true, |
|
52 | - 'notnull' => true, |
|
53 | - 'length' => 20, |
|
54 | - 'unsigned' => true, |
|
55 | - ]); |
|
56 | - $table->addColumn('timestamp', Types::BIGINT, [ |
|
57 | - 'notnull' => true, |
|
58 | - 'length' => 20, |
|
59 | - 'unsigned' => true, |
|
60 | - ]); |
|
61 | - $table->addColumn('started', Types::SMALLINT, [ |
|
62 | - 'notnull' => true, |
|
63 | - 'length' => 1, |
|
64 | - 'unsigned' => true, |
|
65 | - 'default' => 0, |
|
66 | - ]); |
|
67 | - $table->addColumn('poll_token', Types::STRING, [ |
|
68 | - 'notnull' => true, |
|
69 | - 'length' => 255, |
|
70 | - ]); |
|
71 | - $table->addColumn('login_token', Types::STRING, [ |
|
72 | - 'notnull' => true, |
|
73 | - 'length' => 255, |
|
74 | - ]); |
|
75 | - $table->addColumn('public_key', Types::TEXT, [ |
|
76 | - 'notnull' => true, |
|
77 | - 'length' => 32768, |
|
78 | - ]); |
|
79 | - $table->addColumn('private_key', Types::TEXT, [ |
|
80 | - 'notnull' => true, |
|
81 | - 'length' => 32768, |
|
82 | - ]); |
|
83 | - $table->addColumn('client_name', Types::STRING, [ |
|
84 | - 'notnull' => true, |
|
85 | - 'length' => 255, |
|
86 | - ]); |
|
87 | - $table->addColumn('login_name', Types::STRING, [ |
|
88 | - 'notnull' => false, |
|
89 | - 'length' => 255, |
|
90 | - ]); |
|
91 | - $table->addColumn('server', Types::STRING, [ |
|
92 | - 'notnull' => false, |
|
93 | - 'length' => 255, |
|
94 | - ]); |
|
95 | - $table->addColumn('app_password', Types::STRING, [ |
|
96 | - 'notnull' => false, |
|
97 | - 'length' => 1024, |
|
98 | - ]); |
|
99 | - $table->setPrimaryKey(['id']); |
|
100 | - $table->addUniqueIndex(['poll_token'], 'poll_token'); |
|
101 | - $table->addUniqueIndex(['login_token'], 'login_token'); |
|
102 | - $table->addIndex(['timestamp'], 'timestamp'); |
|
49 | + $table = $schema->createTable('login_flow_v2'); |
|
50 | + $table->addColumn('id', Types::BIGINT, [ |
|
51 | + 'autoincrement' => true, |
|
52 | + 'notnull' => true, |
|
53 | + 'length' => 20, |
|
54 | + 'unsigned' => true, |
|
55 | + ]); |
|
56 | + $table->addColumn('timestamp', Types::BIGINT, [ |
|
57 | + 'notnull' => true, |
|
58 | + 'length' => 20, |
|
59 | + 'unsigned' => true, |
|
60 | + ]); |
|
61 | + $table->addColumn('started', Types::SMALLINT, [ |
|
62 | + 'notnull' => true, |
|
63 | + 'length' => 1, |
|
64 | + 'unsigned' => true, |
|
65 | + 'default' => 0, |
|
66 | + ]); |
|
67 | + $table->addColumn('poll_token', Types::STRING, [ |
|
68 | + 'notnull' => true, |
|
69 | + 'length' => 255, |
|
70 | + ]); |
|
71 | + $table->addColumn('login_token', Types::STRING, [ |
|
72 | + 'notnull' => true, |
|
73 | + 'length' => 255, |
|
74 | + ]); |
|
75 | + $table->addColumn('public_key', Types::TEXT, [ |
|
76 | + 'notnull' => true, |
|
77 | + 'length' => 32768, |
|
78 | + ]); |
|
79 | + $table->addColumn('private_key', Types::TEXT, [ |
|
80 | + 'notnull' => true, |
|
81 | + 'length' => 32768, |
|
82 | + ]); |
|
83 | + $table->addColumn('client_name', Types::STRING, [ |
|
84 | + 'notnull' => true, |
|
85 | + 'length' => 255, |
|
86 | + ]); |
|
87 | + $table->addColumn('login_name', Types::STRING, [ |
|
88 | + 'notnull' => false, |
|
89 | + 'length' => 255, |
|
90 | + ]); |
|
91 | + $table->addColumn('server', Types::STRING, [ |
|
92 | + 'notnull' => false, |
|
93 | + 'length' => 255, |
|
94 | + ]); |
|
95 | + $table->addColumn('app_password', Types::STRING, [ |
|
96 | + 'notnull' => false, |
|
97 | + 'length' => 1024, |
|
98 | + ]); |
|
99 | + $table->setPrimaryKey(['id']); |
|
100 | + $table->addUniqueIndex(['poll_token'], 'poll_token'); |
|
101 | + $table->addUniqueIndex(['login_token'], 'login_token'); |
|
102 | + $table->addIndex(['timestamp'], 'timestamp'); |
|
103 | 103 | |
104 | - return $schema; |
|
105 | - } |
|
104 | + return $schema; |
|
105 | + } |
|
106 | 106 | } |
@@ -30,65 +30,65 @@ |
||
30 | 30 | use OCP\Migration\SimpleMigrationStep; |
31 | 31 | |
32 | 32 | class Version13000Date20170705121758 extends SimpleMigrationStep { |
33 | - /** |
|
34 | - * @param IOutput $output |
|
35 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
36 | - * @param array $options |
|
37 | - * @return null|ISchemaWrapper |
|
38 | - * @since 13.0.0 |
|
39 | - */ |
|
40 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
41 | - /** @var ISchemaWrapper $schema */ |
|
42 | - $schema = $schemaClosure(); |
|
33 | + /** |
|
34 | + * @param IOutput $output |
|
35 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
36 | + * @param array $options |
|
37 | + * @return null|ISchemaWrapper |
|
38 | + * @since 13.0.0 |
|
39 | + */ |
|
40 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
41 | + /** @var ISchemaWrapper $schema */ |
|
42 | + $schema = $schemaClosure(); |
|
43 | 43 | |
44 | - if (!$schema->hasTable('personal_sections')) { |
|
45 | - $table = $schema->createTable('personal_sections'); |
|
44 | + if (!$schema->hasTable('personal_sections')) { |
|
45 | + $table = $schema->createTable('personal_sections'); |
|
46 | 46 | |
47 | - $table->addColumn('id', Types::STRING, [ |
|
48 | - 'notnull' => false, |
|
49 | - 'length' => 64, |
|
50 | - ]); |
|
51 | - $table->addColumn('class', Types::STRING, [ |
|
52 | - 'notnull' => true, |
|
53 | - 'length' => 255, |
|
54 | - ]); |
|
55 | - $table->addColumn('priority', Types::INTEGER, [ |
|
56 | - 'notnull' => true, |
|
57 | - 'length' => 6, |
|
58 | - 'default' => 0, |
|
59 | - ]); |
|
47 | + $table->addColumn('id', Types::STRING, [ |
|
48 | + 'notnull' => false, |
|
49 | + 'length' => 64, |
|
50 | + ]); |
|
51 | + $table->addColumn('class', Types::STRING, [ |
|
52 | + 'notnull' => true, |
|
53 | + 'length' => 255, |
|
54 | + ]); |
|
55 | + $table->addColumn('priority', Types::INTEGER, [ |
|
56 | + 'notnull' => true, |
|
57 | + 'length' => 6, |
|
58 | + 'default' => 0, |
|
59 | + ]); |
|
60 | 60 | |
61 | - $table->setPrimaryKey(['id'], 'personal_sections_id_index'); |
|
62 | - $table->addUniqueIndex(['class'], 'personal_sections_class'); |
|
63 | - } |
|
61 | + $table->setPrimaryKey(['id'], 'personal_sections_id_index'); |
|
62 | + $table->addUniqueIndex(['class'], 'personal_sections_class'); |
|
63 | + } |
|
64 | 64 | |
65 | - if (!$schema->hasTable('personal_settings')) { |
|
66 | - $table = $schema->createTable('personal_settings'); |
|
65 | + if (!$schema->hasTable('personal_settings')) { |
|
66 | + $table = $schema->createTable('personal_settings'); |
|
67 | 67 | |
68 | - $table->addColumn('id', Types::INTEGER, [ |
|
69 | - 'autoincrement' => true, |
|
70 | - 'notnull' => true, |
|
71 | - 'length' => 20, |
|
72 | - ]); |
|
73 | - $table->addColumn('class', Types::STRING, [ |
|
74 | - 'notnull' => true, |
|
75 | - 'length' => 255, |
|
76 | - ]); |
|
77 | - $table->addColumn('section', Types::STRING, [ |
|
78 | - 'notnull' => false, |
|
79 | - 'length' => 64, |
|
80 | - ]); |
|
81 | - $table->addColumn('priority', Types::INTEGER, [ |
|
82 | - 'notnull' => true, |
|
83 | - 'length' => 6, |
|
84 | - 'default' => 0, |
|
85 | - ]); |
|
68 | + $table->addColumn('id', Types::INTEGER, [ |
|
69 | + 'autoincrement' => true, |
|
70 | + 'notnull' => true, |
|
71 | + 'length' => 20, |
|
72 | + ]); |
|
73 | + $table->addColumn('class', Types::STRING, [ |
|
74 | + 'notnull' => true, |
|
75 | + 'length' => 255, |
|
76 | + ]); |
|
77 | + $table->addColumn('section', Types::STRING, [ |
|
78 | + 'notnull' => false, |
|
79 | + 'length' => 64, |
|
80 | + ]); |
|
81 | + $table->addColumn('priority', Types::INTEGER, [ |
|
82 | + 'notnull' => true, |
|
83 | + 'length' => 6, |
|
84 | + 'default' => 0, |
|
85 | + ]); |
|
86 | 86 | |
87 | - $table->setPrimaryKey(['id'], 'personal_settings_id_index'); |
|
88 | - $table->addUniqueIndex(['class'], 'personal_settings_class'); |
|
89 | - $table->addIndex(['section'], 'personal_settings_section'); |
|
90 | - } |
|
87 | + $table->setPrimaryKey(['id'], 'personal_settings_id_index'); |
|
88 | + $table->addUniqueIndex(['class'], 'personal_settings_class'); |
|
89 | + $table->addIndex(['section'], 'personal_settings_section'); |
|
90 | + } |
|
91 | 91 | |
92 | - return $schema; |
|
93 | - } |
|
92 | + return $schema; |
|
93 | + } |
|
94 | 94 | } |
@@ -30,43 +30,43 @@ |
||
30 | 30 | use OCP\Migration\SimpleMigrationStep; |
31 | 31 | |
32 | 32 | class Version1002Date20170607104347 extends SimpleMigrationStep { |
33 | - /** |
|
34 | - * @param IOutput $output |
|
35 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
36 | - * @param array $options |
|
37 | - * @return null|ISchemaWrapper |
|
38 | - * @since 13.0.0 |
|
39 | - */ |
|
40 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
41 | - /** @var ISchemaWrapper $schema */ |
|
42 | - $schema = $schemaClosure(); |
|
33 | + /** |
|
34 | + * @param IOutput $output |
|
35 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
36 | + * @param array $options |
|
37 | + * @return null|ISchemaWrapper |
|
38 | + * @since 13.0.0 |
|
39 | + */ |
|
40 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
41 | + /** @var ISchemaWrapper $schema */ |
|
42 | + $schema = $schemaClosure(); |
|
43 | 43 | |
44 | - if (!$schema->hasTable('twofactor_backupcodes')) { |
|
45 | - $table = $schema->createTable('twofactor_backupcodes'); |
|
44 | + if (!$schema->hasTable('twofactor_backupcodes')) { |
|
45 | + $table = $schema->createTable('twofactor_backupcodes'); |
|
46 | 46 | |
47 | - $table->addColumn('id', Types::INTEGER, [ |
|
48 | - 'autoincrement' => true, |
|
49 | - 'notnull' => true, |
|
50 | - 'length' => 20, |
|
51 | - ]); |
|
52 | - $table->addColumn('user_id', Types::STRING, [ |
|
53 | - 'notnull' => true, |
|
54 | - 'length' => 64, |
|
55 | - ]); |
|
56 | - $table->addColumn('code', Types::STRING, [ |
|
57 | - 'notnull' => true, |
|
58 | - 'length' => 64, |
|
59 | - ]); |
|
60 | - $table->addColumn('used', Types::INTEGER, [ |
|
61 | - 'notnull' => true, |
|
62 | - 'length' => 1, |
|
63 | - 'default' => 0, |
|
64 | - ]); |
|
47 | + $table->addColumn('id', Types::INTEGER, [ |
|
48 | + 'autoincrement' => true, |
|
49 | + 'notnull' => true, |
|
50 | + 'length' => 20, |
|
51 | + ]); |
|
52 | + $table->addColumn('user_id', Types::STRING, [ |
|
53 | + 'notnull' => true, |
|
54 | + 'length' => 64, |
|
55 | + ]); |
|
56 | + $table->addColumn('code', Types::STRING, [ |
|
57 | + 'notnull' => true, |
|
58 | + 'length' => 64, |
|
59 | + ]); |
|
60 | + $table->addColumn('used', Types::INTEGER, [ |
|
61 | + 'notnull' => true, |
|
62 | + 'length' => 1, |
|
63 | + 'default' => 0, |
|
64 | + ]); |
|
65 | 65 | |
66 | - $table->setPrimaryKey(['id']); |
|
67 | - $table->addIndex(['user_id'], 'twofactor_backupcodes_uid'); |
|
68 | - } |
|
66 | + $table->setPrimaryKey(['id']); |
|
67 | + $table->addIndex(['user_id'], 'twofactor_backupcodes_uid'); |
|
68 | + } |
|
69 | 69 | |
70 | - return $schema; |
|
71 | - } |
|
70 | + return $schema; |
|
71 | + } |
|
72 | 72 | } |
@@ -35,45 +35,45 @@ |
||
35 | 35 | |
36 | 36 | class Version1008Date20181105110300 extends SimpleMigrationStep { |
37 | 37 | |
38 | - /** @var IDBConnection */ |
|
39 | - private $connection; |
|
38 | + /** @var IDBConnection */ |
|
39 | + private $connection; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Version1008Date20181105110300 constructor. |
|
43 | - * |
|
44 | - * @param IDBConnection $connection |
|
45 | - */ |
|
46 | - public function __construct(IDBConnection $connection) { |
|
47 | - $this->connection = $connection; |
|
48 | - } |
|
41 | + /** |
|
42 | + * Version1008Date20181105110300 constructor. |
|
43 | + * |
|
44 | + * @param IDBConnection $connection |
|
45 | + */ |
|
46 | + public function __construct(IDBConnection $connection) { |
|
47 | + $this->connection = $connection; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param IOutput $output |
|
52 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
53 | - * @param array $options |
|
54 | - * @return null|ISchemaWrapper |
|
55 | - */ |
|
56 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
57 | - /** @var ISchemaWrapper $schema */ |
|
58 | - $schema = $schemaClosure(); |
|
59 | - $table = $schema->getTable('calendarsubscriptions'); |
|
60 | - $table->addColumn('source', Types::TEXT, [ |
|
61 | - 'notnull' => false, |
|
62 | - 'length' => null, |
|
63 | - ]); |
|
50 | + /** |
|
51 | + * @param IOutput $output |
|
52 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
53 | + * @param array $options |
|
54 | + * @return null|ISchemaWrapper |
|
55 | + */ |
|
56 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
57 | + /** @var ISchemaWrapper $schema */ |
|
58 | + $schema = $schemaClosure(); |
|
59 | + $table = $schema->getTable('calendarsubscriptions'); |
|
60 | + $table->addColumn('source', Types::TEXT, [ |
|
61 | + 'notnull' => false, |
|
62 | + 'length' => null, |
|
63 | + ]); |
|
64 | 64 | |
65 | - return $schema; |
|
66 | - } |
|
65 | + return $schema; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param IOutput $output |
|
70 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
71 | - * @param array $options |
|
72 | - */ |
|
73 | - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
|
74 | - $qb = $this->connection->getQueryBuilder(); |
|
75 | - $qb->update('calendarsubscriptions') |
|
76 | - ->set('source', 'source_copy') |
|
77 | - ->execute(); |
|
78 | - } |
|
68 | + /** |
|
69 | + * @param IOutput $output |
|
70 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
71 | + * @param array $options |
|
72 | + */ |
|
73 | + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
|
74 | + $qb = $this->connection->getQueryBuilder(); |
|
75 | + $qb->update('calendarsubscriptions') |
|
76 | + ->set('source', 'source_copy') |
|
77 | + ->execute(); |
|
78 | + } |
|
79 | 79 | } |