@@ -76,14 +76,14 @@ |
||
76 | 76 | $configName = $input->getArgument('name'); |
77 | 77 | |
78 | 78 | if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { |
79 | - $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); |
|
79 | + $output->writeln('<comment>Config value '.$configName.' for app '.$appName.' not updated, as it has not been set before.</comment>'); |
|
80 | 80 | return 1; |
81 | 81 | } |
82 | 82 | |
83 | 83 | $configValue = $input->getOption('value'); |
84 | 84 | $this->config->setAppValue($appName, $configName, $configValue); |
85 | 85 | |
86 | - $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>'); |
|
86 | + $output->writeln('<info>Config value '.$configName.' for app '.$appName.' set to '.$configValue.'</info>'); |
|
87 | 87 | return 0; |
88 | 88 | } |
89 | 89 | } |
@@ -28,57 +28,57 @@ |
||
28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
29 | 29 | |
30 | 30 | class SetConfig extends Base { |
31 | - protected IConfig $config; |
|
31 | + protected IConfig $config; |
|
32 | 32 | |
33 | - public function __construct(IConfig $config) { |
|
34 | - parent::__construct(); |
|
35 | - $this->config = $config; |
|
36 | - } |
|
33 | + public function __construct(IConfig $config) { |
|
34 | + parent::__construct(); |
|
35 | + $this->config = $config; |
|
36 | + } |
|
37 | 37 | |
38 | - protected function configure() { |
|
39 | - parent::configure(); |
|
38 | + protected function configure() { |
|
39 | + parent::configure(); |
|
40 | 40 | |
41 | - $this |
|
42 | - ->setName('config:app:set') |
|
43 | - ->setDescription('Set an app config value') |
|
44 | - ->addArgument( |
|
45 | - 'app', |
|
46 | - InputArgument::REQUIRED, |
|
47 | - 'Name of the app' |
|
48 | - ) |
|
49 | - ->addArgument( |
|
50 | - 'name', |
|
51 | - InputArgument::REQUIRED, |
|
52 | - 'Name of the config to set' |
|
53 | - ) |
|
54 | - ->addOption( |
|
55 | - 'value', |
|
56 | - null, |
|
57 | - InputOption::VALUE_REQUIRED, |
|
58 | - 'The new value of the config' |
|
59 | - ) |
|
60 | - ->addOption( |
|
61 | - 'update-only', |
|
62 | - null, |
|
63 | - InputOption::VALUE_NONE, |
|
64 | - 'Only updates the value, if it is not set before, it is not being added' |
|
65 | - ) |
|
66 | - ; |
|
67 | - } |
|
41 | + $this |
|
42 | + ->setName('config:app:set') |
|
43 | + ->setDescription('Set an app config value') |
|
44 | + ->addArgument( |
|
45 | + 'app', |
|
46 | + InputArgument::REQUIRED, |
|
47 | + 'Name of the app' |
|
48 | + ) |
|
49 | + ->addArgument( |
|
50 | + 'name', |
|
51 | + InputArgument::REQUIRED, |
|
52 | + 'Name of the config to set' |
|
53 | + ) |
|
54 | + ->addOption( |
|
55 | + 'value', |
|
56 | + null, |
|
57 | + InputOption::VALUE_REQUIRED, |
|
58 | + 'The new value of the config' |
|
59 | + ) |
|
60 | + ->addOption( |
|
61 | + 'update-only', |
|
62 | + null, |
|
63 | + InputOption::VALUE_NONE, |
|
64 | + 'Only updates the value, if it is not set before, it is not being added' |
|
65 | + ) |
|
66 | + ; |
|
67 | + } |
|
68 | 68 | |
69 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
70 | - $appName = $input->getArgument('app'); |
|
71 | - $configName = $input->getArgument('name'); |
|
69 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
70 | + $appName = $input->getArgument('app'); |
|
71 | + $configName = $input->getArgument('name'); |
|
72 | 72 | |
73 | - if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { |
|
74 | - $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); |
|
75 | - return 1; |
|
76 | - } |
|
73 | + if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { |
|
74 | + $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); |
|
75 | + return 1; |
|
76 | + } |
|
77 | 77 | |
78 | - $configValue = $input->getOption('value'); |
|
79 | - $this->config->setAppValue($appName, $configName, $configValue); |
|
78 | + $configValue = $input->getOption('value'); |
|
79 | + $this->config->setAppValue($appName, $configName, $configValue); |
|
80 | 80 | |
81 | - $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>'); |
|
82 | - return 0; |
|
83 | - } |
|
81 | + $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>'); |
|
82 | + return 0; |
|
83 | + } |
|
84 | 84 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | try { |
69 | 69 | $mount = $this->globalService->getStorage($mountId); |
70 | 70 | } catch (NotFoundException $e) { |
71 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
71 | + $output->writeln('<error>Mount with id "'.$mountId.' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
72 | 72 | return 404; |
73 | 73 | } |
74 | 74 |
@@ -37,62 +37,62 @@ |
||
37 | 37 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
38 | 38 | |
39 | 39 | class Delete extends Base { |
40 | - protected GlobalStoragesService $globalService; |
|
41 | - protected UserStoragesService $userService; |
|
42 | - protected IUserSession $userSession; |
|
43 | - protected IUserManager $userManager; |
|
40 | + protected GlobalStoragesService $globalService; |
|
41 | + protected UserStoragesService $userService; |
|
42 | + protected IUserSession $userSession; |
|
43 | + protected IUserManager $userManager; |
|
44 | 44 | |
45 | - public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
46 | - parent::__construct(); |
|
47 | - $this->globalService = $globalService; |
|
48 | - $this->userService = $userService; |
|
49 | - $this->userSession = $userSession; |
|
50 | - $this->userManager = $userManager; |
|
51 | - } |
|
45 | + public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
46 | + parent::__construct(); |
|
47 | + $this->globalService = $globalService; |
|
48 | + $this->userService = $userService; |
|
49 | + $this->userSession = $userSession; |
|
50 | + $this->userManager = $userManager; |
|
51 | + } |
|
52 | 52 | |
53 | - protected function configure(): void { |
|
54 | - $this |
|
55 | - ->setName('files_external:delete') |
|
56 | - ->setDescription('Delete an external mount') |
|
57 | - ->addArgument( |
|
58 | - 'mount_id', |
|
59 | - InputArgument::REQUIRED, |
|
60 | - 'The id of the mount to edit' |
|
61 | - )->addOption( |
|
62 | - 'yes', |
|
63 | - 'y', |
|
64 | - InputOption::VALUE_NONE, |
|
65 | - 'Skip confirmation' |
|
66 | - ); |
|
67 | - parent::configure(); |
|
68 | - } |
|
53 | + protected function configure(): void { |
|
54 | + $this |
|
55 | + ->setName('files_external:delete') |
|
56 | + ->setDescription('Delete an external mount') |
|
57 | + ->addArgument( |
|
58 | + 'mount_id', |
|
59 | + InputArgument::REQUIRED, |
|
60 | + 'The id of the mount to edit' |
|
61 | + )->addOption( |
|
62 | + 'yes', |
|
63 | + 'y', |
|
64 | + InputOption::VALUE_NONE, |
|
65 | + 'Skip confirmation' |
|
66 | + ); |
|
67 | + parent::configure(); |
|
68 | + } |
|
69 | 69 | |
70 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
71 | - $mountId = $input->getArgument('mount_id'); |
|
72 | - try { |
|
73 | - $mount = $this->globalService->getStorage($mountId); |
|
74 | - } catch (NotFoundException $e) { |
|
75 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
76 | - return 404; |
|
77 | - } |
|
70 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
71 | + $mountId = $input->getArgument('mount_id'); |
|
72 | + try { |
|
73 | + $mount = $this->globalService->getStorage($mountId); |
|
74 | + } catch (NotFoundException $e) { |
|
75 | + $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
76 | + return 404; |
|
77 | + } |
|
78 | 78 | |
79 | - $noConfirm = $input->getOption('yes'); |
|
79 | + $noConfirm = $input->getOption('yes'); |
|
80 | 80 | |
81 | - if (!$noConfirm) { |
|
82 | - $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
83 | - $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
84 | - $listInput->setOption('output', $input->getOption('output')); |
|
85 | - $listCommand->listMounts(null, [$mount], $listInput, $output); |
|
81 | + if (!$noConfirm) { |
|
82 | + $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
83 | + $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
84 | + $listInput->setOption('output', $input->getOption('output')); |
|
85 | + $listCommand->listMounts(null, [$mount], $listInput, $output); |
|
86 | 86 | |
87 | - $questionHelper = $this->getHelper('question'); |
|
88 | - $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); |
|
87 | + $questionHelper = $this->getHelper('question'); |
|
88 | + $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); |
|
89 | 89 | |
90 | - if (!$questionHelper->ask($input, $output, $question)) { |
|
91 | - return 1; |
|
92 | - } |
|
93 | - } |
|
90 | + if (!$questionHelper->ask($input, $output, $question)) { |
|
91 | + return 1; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | |
95 | - $this->globalService->removeStorage($mountId); |
|
96 | - return 0; |
|
97 | - } |
|
95 | + $this->globalService->removeStorage($mountId); |
|
96 | + return 0; |
|
97 | + } |
|
98 | 98 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | $updatedEntries = $builder->execute(); |
73 | 73 | if ($updatedEntries > 0) { |
74 | - $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | + $out->info('Fixed file share permissions for '.$updatedEntries.' shares'); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | if ($deletedEntries) { |
110 | - $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | + $out->info('Removed '.$deletedEntries.' shares where the parent did not exist'); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 |
@@ -33,89 +33,89 @@ |
||
33 | 33 | * Repairs shares with invalid data |
34 | 34 | */ |
35 | 35 | class RepairInvalidShares implements IRepairStep { |
36 | - public const CHUNK_SIZE = 200; |
|
37 | - |
|
38 | - /** @var \OCP\IConfig */ |
|
39 | - protected $config; |
|
40 | - |
|
41 | - /** @var \OCP\IDBConnection */ |
|
42 | - protected $connection; |
|
43 | - |
|
44 | - /** |
|
45 | - * @param \OCP\IConfig $config |
|
46 | - * @param \OCP\IDBConnection $connection |
|
47 | - */ |
|
48 | - public function __construct($config, $connection) { |
|
49 | - $this->connection = $connection; |
|
50 | - $this->config = $config; |
|
51 | - } |
|
52 | - |
|
53 | - public function getName() { |
|
54 | - return 'Repair invalid shares'; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Adjust file share permissions |
|
59 | - */ |
|
60 | - private function adjustFileSharePermissions(IOutput $out) { |
|
61 | - $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE; |
|
62 | - $builder = $this->connection->getQueryBuilder(); |
|
63 | - |
|
64 | - $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask); |
|
65 | - $builder |
|
66 | - ->update('share') |
|
67 | - ->set('permissions', $permsFunc) |
|
68 | - ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file'))) |
|
69 | - ->andWhere($builder->expr()->neq('permissions', $permsFunc)); |
|
70 | - |
|
71 | - $updatedEntries = $builder->execute(); |
|
72 | - if ($updatedEntries > 0) { |
|
73 | - $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Remove shares where the parent share does not exist anymore |
|
79 | - */ |
|
80 | - private function removeSharesNonExistingParent(IOutput $out) { |
|
81 | - $deletedEntries = 0; |
|
82 | - |
|
83 | - $query = $this->connection->getQueryBuilder(); |
|
84 | - $query->select('s1.parent') |
|
85 | - ->from('share', 's1') |
|
86 | - ->where($query->expr()->isNotNull('s1.parent')) |
|
87 | - ->andWhere($query->expr()->isNull('s2.id')) |
|
88 | - ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id')) |
|
89 | - ->groupBy('s1.parent') |
|
90 | - ->setMaxResults(self::CHUNK_SIZE); |
|
91 | - |
|
92 | - $deleteQuery = $this->connection->getQueryBuilder(); |
|
93 | - $deleteQuery->delete('share') |
|
94 | - ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent'))); |
|
95 | - |
|
96 | - $deletedInLastChunk = self::CHUNK_SIZE; |
|
97 | - while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
98 | - $deletedInLastChunk = 0; |
|
99 | - $result = $query->execute(); |
|
100 | - while ($row = $result->fetch()) { |
|
101 | - $deletedInLastChunk++; |
|
102 | - $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent']) |
|
103 | - ->execute(); |
|
104 | - } |
|
105 | - $result->closeCursor(); |
|
106 | - } |
|
107 | - |
|
108 | - if ($deletedEntries) { |
|
109 | - $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | - } |
|
111 | - } |
|
112 | - |
|
113 | - public function run(IOutput $out) { |
|
114 | - $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
115 | - if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { |
|
116 | - $this->adjustFileSharePermissions($out); |
|
117 | - } |
|
118 | - |
|
119 | - $this->removeSharesNonExistingParent($out); |
|
120 | - } |
|
36 | + public const CHUNK_SIZE = 200; |
|
37 | + |
|
38 | + /** @var \OCP\IConfig */ |
|
39 | + protected $config; |
|
40 | + |
|
41 | + /** @var \OCP\IDBConnection */ |
|
42 | + protected $connection; |
|
43 | + |
|
44 | + /** |
|
45 | + * @param \OCP\IConfig $config |
|
46 | + * @param \OCP\IDBConnection $connection |
|
47 | + */ |
|
48 | + public function __construct($config, $connection) { |
|
49 | + $this->connection = $connection; |
|
50 | + $this->config = $config; |
|
51 | + } |
|
52 | + |
|
53 | + public function getName() { |
|
54 | + return 'Repair invalid shares'; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Adjust file share permissions |
|
59 | + */ |
|
60 | + private function adjustFileSharePermissions(IOutput $out) { |
|
61 | + $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE; |
|
62 | + $builder = $this->connection->getQueryBuilder(); |
|
63 | + |
|
64 | + $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask); |
|
65 | + $builder |
|
66 | + ->update('share') |
|
67 | + ->set('permissions', $permsFunc) |
|
68 | + ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file'))) |
|
69 | + ->andWhere($builder->expr()->neq('permissions', $permsFunc)); |
|
70 | + |
|
71 | + $updatedEntries = $builder->execute(); |
|
72 | + if ($updatedEntries > 0) { |
|
73 | + $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Remove shares where the parent share does not exist anymore |
|
79 | + */ |
|
80 | + private function removeSharesNonExistingParent(IOutput $out) { |
|
81 | + $deletedEntries = 0; |
|
82 | + |
|
83 | + $query = $this->connection->getQueryBuilder(); |
|
84 | + $query->select('s1.parent') |
|
85 | + ->from('share', 's1') |
|
86 | + ->where($query->expr()->isNotNull('s1.parent')) |
|
87 | + ->andWhere($query->expr()->isNull('s2.id')) |
|
88 | + ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id')) |
|
89 | + ->groupBy('s1.parent') |
|
90 | + ->setMaxResults(self::CHUNK_SIZE); |
|
91 | + |
|
92 | + $deleteQuery = $this->connection->getQueryBuilder(); |
|
93 | + $deleteQuery->delete('share') |
|
94 | + ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent'))); |
|
95 | + |
|
96 | + $deletedInLastChunk = self::CHUNK_SIZE; |
|
97 | + while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
98 | + $deletedInLastChunk = 0; |
|
99 | + $result = $query->execute(); |
|
100 | + while ($row = $result->fetch()) { |
|
101 | + $deletedInLastChunk++; |
|
102 | + $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent']) |
|
103 | + ->execute(); |
|
104 | + } |
|
105 | + $result->closeCursor(); |
|
106 | + } |
|
107 | + |
|
108 | + if ($deletedEntries) { |
|
109 | + $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | + } |
|
111 | + } |
|
112 | + |
|
113 | + public function run(IOutput $out) { |
|
114 | + $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
115 | + if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { |
|
116 | + $this->adjustFileSharePermissions($out); |
|
117 | + } |
|
118 | + |
|
119 | + $this->removeSharesNonExistingParent($out); |
|
120 | + } |
|
121 | 121 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | // no php execution timeout for webdav |
23 | 23 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
24 | - @set_time_limit(0); |
|
24 | + @set_time_limit(0); |
|
25 | 25 | } |
26 | 26 | ignore_user_abort(true); |
27 | 27 |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | } |
215 | 215 | |
216 | 216 | if ($provider === null) { |
217 | - throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
217 | + throw new ProviderException('No provider with id .'.$id.' found.'); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | return $provider; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | |
243 | 243 | if ($provider === null) { |
244 | - throw new ProviderException('No share provider for share type ' . $shareType); |
|
244 | + throw new ProviderException('No share provider for share type '.$shareType); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | return $provider; |
@@ -56,335 +56,335 @@ |
||
56 | 56 | * @package OC\Share20 |
57 | 57 | */ |
58 | 58 | class ProviderFactory implements IProviderFactory { |
59 | - /** @var IServerContainer */ |
|
60 | - private $serverContainer; |
|
61 | - /** @var DefaultShareProvider */ |
|
62 | - private $defaultProvider = null; |
|
63 | - /** @var FederatedShareProvider */ |
|
64 | - private $federatedProvider = null; |
|
65 | - /** @var ShareByMailProvider */ |
|
66 | - private $shareByMailProvider; |
|
67 | - /** @var \OCA\Circles\ShareByCircleProvider */ |
|
68 | - private $shareByCircleProvider = null; |
|
69 | - /** @var bool */ |
|
70 | - private $circlesAreNotAvailable = false; |
|
71 | - /** @var \OCA\Talk\Share\RoomShareProvider */ |
|
72 | - private $roomShareProvider = null; |
|
73 | - |
|
74 | - private $registeredShareProviders = []; |
|
75 | - |
|
76 | - private $shareProviders = []; |
|
77 | - |
|
78 | - /** |
|
79 | - * IProviderFactory constructor. |
|
80 | - * |
|
81 | - * @param IServerContainer $serverContainer |
|
82 | - */ |
|
83 | - public function __construct(IServerContainer $serverContainer) { |
|
84 | - $this->serverContainer = $serverContainer; |
|
85 | - } |
|
86 | - |
|
87 | - public function registerProvider(string $shareProviderClass): void { |
|
88 | - $this->registeredShareProviders[] = $shareProviderClass; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Create the default share provider. |
|
93 | - * |
|
94 | - * @return DefaultShareProvider |
|
95 | - */ |
|
96 | - protected function defaultShareProvider() { |
|
97 | - if ($this->defaultProvider === null) { |
|
98 | - $this->defaultProvider = new DefaultShareProvider( |
|
99 | - $this->serverContainer->getDatabaseConnection(), |
|
100 | - $this->serverContainer->getUserManager(), |
|
101 | - $this->serverContainer->getGroupManager(), |
|
102 | - $this->serverContainer->getLazyRootFolder(), |
|
103 | - $this->serverContainer->getMailer(), |
|
104 | - $this->serverContainer->query(Defaults::class), |
|
105 | - $this->serverContainer->getL10NFactory(), |
|
106 | - $this->serverContainer->getURLGenerator(), |
|
107 | - $this->serverContainer->getConfig() |
|
108 | - ); |
|
109 | - } |
|
110 | - |
|
111 | - return $this->defaultProvider; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Create the federated share provider |
|
116 | - * |
|
117 | - * @return FederatedShareProvider |
|
118 | - */ |
|
119 | - protected function federatedShareProvider() { |
|
120 | - if ($this->federatedProvider === null) { |
|
121 | - /* |
|
59 | + /** @var IServerContainer */ |
|
60 | + private $serverContainer; |
|
61 | + /** @var DefaultShareProvider */ |
|
62 | + private $defaultProvider = null; |
|
63 | + /** @var FederatedShareProvider */ |
|
64 | + private $federatedProvider = null; |
|
65 | + /** @var ShareByMailProvider */ |
|
66 | + private $shareByMailProvider; |
|
67 | + /** @var \OCA\Circles\ShareByCircleProvider */ |
|
68 | + private $shareByCircleProvider = null; |
|
69 | + /** @var bool */ |
|
70 | + private $circlesAreNotAvailable = false; |
|
71 | + /** @var \OCA\Talk\Share\RoomShareProvider */ |
|
72 | + private $roomShareProvider = null; |
|
73 | + |
|
74 | + private $registeredShareProviders = []; |
|
75 | + |
|
76 | + private $shareProviders = []; |
|
77 | + |
|
78 | + /** |
|
79 | + * IProviderFactory constructor. |
|
80 | + * |
|
81 | + * @param IServerContainer $serverContainer |
|
82 | + */ |
|
83 | + public function __construct(IServerContainer $serverContainer) { |
|
84 | + $this->serverContainer = $serverContainer; |
|
85 | + } |
|
86 | + |
|
87 | + public function registerProvider(string $shareProviderClass): void { |
|
88 | + $this->registeredShareProviders[] = $shareProviderClass; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Create the default share provider. |
|
93 | + * |
|
94 | + * @return DefaultShareProvider |
|
95 | + */ |
|
96 | + protected function defaultShareProvider() { |
|
97 | + if ($this->defaultProvider === null) { |
|
98 | + $this->defaultProvider = new DefaultShareProvider( |
|
99 | + $this->serverContainer->getDatabaseConnection(), |
|
100 | + $this->serverContainer->getUserManager(), |
|
101 | + $this->serverContainer->getGroupManager(), |
|
102 | + $this->serverContainer->getLazyRootFolder(), |
|
103 | + $this->serverContainer->getMailer(), |
|
104 | + $this->serverContainer->query(Defaults::class), |
|
105 | + $this->serverContainer->getL10NFactory(), |
|
106 | + $this->serverContainer->getURLGenerator(), |
|
107 | + $this->serverContainer->getConfig() |
|
108 | + ); |
|
109 | + } |
|
110 | + |
|
111 | + return $this->defaultProvider; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Create the federated share provider |
|
116 | + * |
|
117 | + * @return FederatedShareProvider |
|
118 | + */ |
|
119 | + protected function federatedShareProvider() { |
|
120 | + if ($this->federatedProvider === null) { |
|
121 | + /* |
|
122 | 122 | * Check if the app is enabled |
123 | 123 | */ |
124 | - $appManager = $this->serverContainer->getAppManager(); |
|
125 | - if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
126 | - return null; |
|
127 | - } |
|
124 | + $appManager = $this->serverContainer->getAppManager(); |
|
125 | + if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
126 | + return null; |
|
127 | + } |
|
128 | 128 | |
129 | - /* |
|
129 | + /* |
|
130 | 130 | * TODO: add factory to federated sharing app |
131 | 131 | */ |
132 | - $l = $this->serverContainer->getL10N('federatedfilesharing'); |
|
133 | - $addressHandler = new AddressHandler( |
|
134 | - $this->serverContainer->getURLGenerator(), |
|
135 | - $l, |
|
136 | - $this->serverContainer->getCloudIdManager() |
|
137 | - ); |
|
138 | - $notifications = new Notifications( |
|
139 | - $addressHandler, |
|
140 | - $this->serverContainer->getHTTPClientService(), |
|
141 | - $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
142 | - $this->serverContainer->getLogger(), |
|
143 | - $this->serverContainer->getJobList(), |
|
144 | - \OC::$server->getCloudFederationProviderManager(), |
|
145 | - \OC::$server->getCloudFederationFactory(), |
|
146 | - $this->serverContainer->query(IEventDispatcher::class) |
|
147 | - ); |
|
148 | - $tokenHandler = new TokenHandler( |
|
149 | - $this->serverContainer->getSecureRandom() |
|
150 | - ); |
|
151 | - |
|
152 | - $this->federatedProvider = new FederatedShareProvider( |
|
153 | - $this->serverContainer->getDatabaseConnection(), |
|
154 | - $addressHandler, |
|
155 | - $notifications, |
|
156 | - $tokenHandler, |
|
157 | - $l, |
|
158 | - $this->serverContainer->getLogger(), |
|
159 | - $this->serverContainer->getLazyRootFolder(), |
|
160 | - $this->serverContainer->getConfig(), |
|
161 | - $this->serverContainer->getUserManager(), |
|
162 | - $this->serverContainer->getCloudIdManager(), |
|
163 | - $this->serverContainer->getGlobalScaleConfig(), |
|
164 | - $this->serverContainer->getCloudFederationProviderManager() |
|
165 | - ); |
|
166 | - } |
|
167 | - |
|
168 | - return $this->federatedProvider; |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * Create the federated share provider |
|
173 | - * |
|
174 | - * @return ShareByMailProvider |
|
175 | - */ |
|
176 | - protected function getShareByMailProvider() { |
|
177 | - if ($this->shareByMailProvider === null) { |
|
178 | - /* |
|
132 | + $l = $this->serverContainer->getL10N('federatedfilesharing'); |
|
133 | + $addressHandler = new AddressHandler( |
|
134 | + $this->serverContainer->getURLGenerator(), |
|
135 | + $l, |
|
136 | + $this->serverContainer->getCloudIdManager() |
|
137 | + ); |
|
138 | + $notifications = new Notifications( |
|
139 | + $addressHandler, |
|
140 | + $this->serverContainer->getHTTPClientService(), |
|
141 | + $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
142 | + $this->serverContainer->getLogger(), |
|
143 | + $this->serverContainer->getJobList(), |
|
144 | + \OC::$server->getCloudFederationProviderManager(), |
|
145 | + \OC::$server->getCloudFederationFactory(), |
|
146 | + $this->serverContainer->query(IEventDispatcher::class) |
|
147 | + ); |
|
148 | + $tokenHandler = new TokenHandler( |
|
149 | + $this->serverContainer->getSecureRandom() |
|
150 | + ); |
|
151 | + |
|
152 | + $this->federatedProvider = new FederatedShareProvider( |
|
153 | + $this->serverContainer->getDatabaseConnection(), |
|
154 | + $addressHandler, |
|
155 | + $notifications, |
|
156 | + $tokenHandler, |
|
157 | + $l, |
|
158 | + $this->serverContainer->getLogger(), |
|
159 | + $this->serverContainer->getLazyRootFolder(), |
|
160 | + $this->serverContainer->getConfig(), |
|
161 | + $this->serverContainer->getUserManager(), |
|
162 | + $this->serverContainer->getCloudIdManager(), |
|
163 | + $this->serverContainer->getGlobalScaleConfig(), |
|
164 | + $this->serverContainer->getCloudFederationProviderManager() |
|
165 | + ); |
|
166 | + } |
|
167 | + |
|
168 | + return $this->federatedProvider; |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * Create the federated share provider |
|
173 | + * |
|
174 | + * @return ShareByMailProvider |
|
175 | + */ |
|
176 | + protected function getShareByMailProvider() { |
|
177 | + if ($this->shareByMailProvider === null) { |
|
178 | + /* |
|
179 | 179 | * Check if the app is enabled |
180 | 180 | */ |
181 | - $appManager = $this->serverContainer->getAppManager(); |
|
182 | - if (!$appManager->isEnabledForUser('sharebymail')) { |
|
183 | - return null; |
|
184 | - } |
|
185 | - |
|
186 | - $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
187 | - |
|
188 | - $this->shareByMailProvider = new ShareByMailProvider( |
|
189 | - $this->serverContainer->getConfig(), |
|
190 | - $this->serverContainer->getDatabaseConnection(), |
|
191 | - $this->serverContainer->getSecureRandom(), |
|
192 | - $this->serverContainer->getUserManager(), |
|
193 | - $this->serverContainer->getLazyRootFolder(), |
|
194 | - $this->serverContainer->getL10N('sharebymail'), |
|
195 | - $this->serverContainer->getLogger(), |
|
196 | - $this->serverContainer->getMailer(), |
|
197 | - $this->serverContainer->getURLGenerator(), |
|
198 | - $this->serverContainer->getActivityManager(), |
|
199 | - $settingsManager, |
|
200 | - $this->serverContainer->query(Defaults::class), |
|
201 | - $this->serverContainer->getHasher(), |
|
202 | - $this->serverContainer->get(IEventDispatcher::class), |
|
203 | - $this->serverContainer->get(IManager::class) |
|
204 | - ); |
|
205 | - } |
|
206 | - |
|
207 | - return $this->shareByMailProvider; |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * Create the circle share provider |
|
213 | - * |
|
214 | - * @return FederatedShareProvider |
|
215 | - * |
|
216 | - * @suppress PhanUndeclaredClassMethod |
|
217 | - */ |
|
218 | - protected function getShareByCircleProvider() { |
|
219 | - if ($this->circlesAreNotAvailable) { |
|
220 | - return null; |
|
221 | - } |
|
222 | - |
|
223 | - if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
224 | - !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
225 | - ) { |
|
226 | - $this->circlesAreNotAvailable = true; |
|
227 | - return null; |
|
228 | - } |
|
229 | - |
|
230 | - if ($this->shareByCircleProvider === null) { |
|
231 | - $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
232 | - $this->serverContainer->getDatabaseConnection(), |
|
233 | - $this->serverContainer->getSecureRandom(), |
|
234 | - $this->serverContainer->getUserManager(), |
|
235 | - $this->serverContainer->getLazyRootFolder(), |
|
236 | - $this->serverContainer->getL10N('circles'), |
|
237 | - $this->serverContainer->getLogger(), |
|
238 | - $this->serverContainer->getURLGenerator() |
|
239 | - ); |
|
240 | - } |
|
241 | - |
|
242 | - return $this->shareByCircleProvider; |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * Create the room share provider |
|
247 | - * |
|
248 | - * @return RoomShareProvider |
|
249 | - */ |
|
250 | - protected function getRoomShareProvider() { |
|
251 | - if ($this->roomShareProvider === null) { |
|
252 | - /* |
|
181 | + $appManager = $this->serverContainer->getAppManager(); |
|
182 | + if (!$appManager->isEnabledForUser('sharebymail')) { |
|
183 | + return null; |
|
184 | + } |
|
185 | + |
|
186 | + $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
187 | + |
|
188 | + $this->shareByMailProvider = new ShareByMailProvider( |
|
189 | + $this->serverContainer->getConfig(), |
|
190 | + $this->serverContainer->getDatabaseConnection(), |
|
191 | + $this->serverContainer->getSecureRandom(), |
|
192 | + $this->serverContainer->getUserManager(), |
|
193 | + $this->serverContainer->getLazyRootFolder(), |
|
194 | + $this->serverContainer->getL10N('sharebymail'), |
|
195 | + $this->serverContainer->getLogger(), |
|
196 | + $this->serverContainer->getMailer(), |
|
197 | + $this->serverContainer->getURLGenerator(), |
|
198 | + $this->serverContainer->getActivityManager(), |
|
199 | + $settingsManager, |
|
200 | + $this->serverContainer->query(Defaults::class), |
|
201 | + $this->serverContainer->getHasher(), |
|
202 | + $this->serverContainer->get(IEventDispatcher::class), |
|
203 | + $this->serverContainer->get(IManager::class) |
|
204 | + ); |
|
205 | + } |
|
206 | + |
|
207 | + return $this->shareByMailProvider; |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * Create the circle share provider |
|
213 | + * |
|
214 | + * @return FederatedShareProvider |
|
215 | + * |
|
216 | + * @suppress PhanUndeclaredClassMethod |
|
217 | + */ |
|
218 | + protected function getShareByCircleProvider() { |
|
219 | + if ($this->circlesAreNotAvailable) { |
|
220 | + return null; |
|
221 | + } |
|
222 | + |
|
223 | + if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
224 | + !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
225 | + ) { |
|
226 | + $this->circlesAreNotAvailable = true; |
|
227 | + return null; |
|
228 | + } |
|
229 | + |
|
230 | + if ($this->shareByCircleProvider === null) { |
|
231 | + $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
232 | + $this->serverContainer->getDatabaseConnection(), |
|
233 | + $this->serverContainer->getSecureRandom(), |
|
234 | + $this->serverContainer->getUserManager(), |
|
235 | + $this->serverContainer->getLazyRootFolder(), |
|
236 | + $this->serverContainer->getL10N('circles'), |
|
237 | + $this->serverContainer->getLogger(), |
|
238 | + $this->serverContainer->getURLGenerator() |
|
239 | + ); |
|
240 | + } |
|
241 | + |
|
242 | + return $this->shareByCircleProvider; |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * Create the room share provider |
|
247 | + * |
|
248 | + * @return RoomShareProvider |
|
249 | + */ |
|
250 | + protected function getRoomShareProvider() { |
|
251 | + if ($this->roomShareProvider === null) { |
|
252 | + /* |
|
253 | 253 | * Check if the app is enabled |
254 | 254 | */ |
255 | - $appManager = $this->serverContainer->getAppManager(); |
|
256 | - if (!$appManager->isEnabledForUser('spreed')) { |
|
257 | - return null; |
|
258 | - } |
|
259 | - |
|
260 | - try { |
|
261 | - /** |
|
262 | - * @psalm-suppress UndefinedClass |
|
263 | - */ |
|
264 | - $this->roomShareProvider = $this->serverContainer->get(RoomShareProvider::class); |
|
265 | - } catch (\Throwable $e) { |
|
266 | - $this->serverContainer->get(LoggerInterface::class)->error( |
|
267 | - $e->getMessage(), |
|
268 | - ['exception' => $e] |
|
269 | - ); |
|
270 | - return null; |
|
271 | - } |
|
272 | - } |
|
273 | - |
|
274 | - return $this->roomShareProvider; |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * @inheritdoc |
|
279 | - */ |
|
280 | - public function getProvider($id) { |
|
281 | - $provider = null; |
|
282 | - if (isset($this->shareProviders[$id])) { |
|
283 | - return $this->shareProviders[$id]; |
|
284 | - } |
|
285 | - |
|
286 | - if ($id === 'ocinternal') { |
|
287 | - $provider = $this->defaultShareProvider(); |
|
288 | - } elseif ($id === 'ocFederatedSharing') { |
|
289 | - $provider = $this->federatedShareProvider(); |
|
290 | - } elseif ($id === 'ocMailShare') { |
|
291 | - $provider = $this->getShareByMailProvider(); |
|
292 | - } elseif ($id === 'ocCircleShare') { |
|
293 | - $provider = $this->getShareByCircleProvider(); |
|
294 | - } elseif ($id === 'ocRoomShare') { |
|
295 | - $provider = $this->getRoomShareProvider(); |
|
296 | - } |
|
297 | - |
|
298 | - foreach ($this->registeredShareProviders as $shareProvider) { |
|
299 | - try { |
|
300 | - /** @var IShareProvider $instance */ |
|
301 | - $instance = $this->serverContainer->get($shareProvider); |
|
302 | - $this->shareProviders[$instance->identifier()] = $instance; |
|
303 | - } catch (\Throwable $e) { |
|
304 | - $this->serverContainer->get(LoggerInterface::class)->error( |
|
305 | - $e->getMessage(), |
|
306 | - ['exception' => $e] |
|
307 | - ); |
|
308 | - } |
|
309 | - } |
|
310 | - |
|
311 | - if (isset($this->shareProviders[$id])) { |
|
312 | - $provider = $this->shareProviders[$id]; |
|
313 | - } |
|
314 | - |
|
315 | - if ($provider === null) { |
|
316 | - throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
317 | - } |
|
318 | - |
|
319 | - return $provider; |
|
320 | - } |
|
321 | - |
|
322 | - /** |
|
323 | - * @inheritdoc |
|
324 | - */ |
|
325 | - public function getProviderForType($shareType) { |
|
326 | - $provider = null; |
|
327 | - |
|
328 | - if ($shareType === IShare::TYPE_USER || |
|
329 | - $shareType === IShare::TYPE_GROUP || |
|
330 | - $shareType === IShare::TYPE_LINK |
|
331 | - ) { |
|
332 | - $provider = $this->defaultShareProvider(); |
|
333 | - } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) { |
|
334 | - $provider = $this->federatedShareProvider(); |
|
335 | - } elseif ($shareType === IShare::TYPE_EMAIL) { |
|
336 | - $provider = $this->getShareByMailProvider(); |
|
337 | - } elseif ($shareType === IShare::TYPE_CIRCLE) { |
|
338 | - $provider = $this->getShareByCircleProvider(); |
|
339 | - } elseif ($shareType === IShare::TYPE_ROOM) { |
|
340 | - $provider = $this->getRoomShareProvider(); |
|
341 | - } elseif ($shareType === IShare::TYPE_DECK) { |
|
342 | - $provider = $this->getProvider('deck'); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - if ($provider === null) { |
|
347 | - throw new ProviderException('No share provider for share type ' . $shareType); |
|
348 | - } |
|
349 | - |
|
350 | - return $provider; |
|
351 | - } |
|
352 | - |
|
353 | - public function getAllProviders() { |
|
354 | - $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
355 | - $shareByMail = $this->getShareByMailProvider(); |
|
356 | - if ($shareByMail !== null) { |
|
357 | - $shares[] = $shareByMail; |
|
358 | - } |
|
359 | - $shareByCircle = $this->getShareByCircleProvider(); |
|
360 | - if ($shareByCircle !== null) { |
|
361 | - $shares[] = $shareByCircle; |
|
362 | - } |
|
363 | - $roomShare = $this->getRoomShareProvider(); |
|
364 | - if ($roomShare !== null) { |
|
365 | - $shares[] = $roomShare; |
|
366 | - } |
|
367 | - |
|
368 | - foreach ($this->registeredShareProviders as $shareProvider) { |
|
369 | - try { |
|
370 | - /** @var IShareProvider $instance */ |
|
371 | - $instance = $this->serverContainer->get($shareProvider); |
|
372 | - } catch (\Throwable $e) { |
|
373 | - $this->serverContainer->get(LoggerInterface::class)->error( |
|
374 | - $e->getMessage(), |
|
375 | - ['exception' => $e] |
|
376 | - ); |
|
377 | - continue; |
|
378 | - } |
|
379 | - |
|
380 | - if (!isset($this->shareProviders[$instance->identifier()])) { |
|
381 | - $this->shareProviders[$instance->identifier()] = $instance; |
|
382 | - } |
|
383 | - $shares[] = $this->shareProviders[$instance->identifier()]; |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - |
|
388 | - return $shares; |
|
389 | - } |
|
255 | + $appManager = $this->serverContainer->getAppManager(); |
|
256 | + if (!$appManager->isEnabledForUser('spreed')) { |
|
257 | + return null; |
|
258 | + } |
|
259 | + |
|
260 | + try { |
|
261 | + /** |
|
262 | + * @psalm-suppress UndefinedClass |
|
263 | + */ |
|
264 | + $this->roomShareProvider = $this->serverContainer->get(RoomShareProvider::class); |
|
265 | + } catch (\Throwable $e) { |
|
266 | + $this->serverContainer->get(LoggerInterface::class)->error( |
|
267 | + $e->getMessage(), |
|
268 | + ['exception' => $e] |
|
269 | + ); |
|
270 | + return null; |
|
271 | + } |
|
272 | + } |
|
273 | + |
|
274 | + return $this->roomShareProvider; |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * @inheritdoc |
|
279 | + */ |
|
280 | + public function getProvider($id) { |
|
281 | + $provider = null; |
|
282 | + if (isset($this->shareProviders[$id])) { |
|
283 | + return $this->shareProviders[$id]; |
|
284 | + } |
|
285 | + |
|
286 | + if ($id === 'ocinternal') { |
|
287 | + $provider = $this->defaultShareProvider(); |
|
288 | + } elseif ($id === 'ocFederatedSharing') { |
|
289 | + $provider = $this->federatedShareProvider(); |
|
290 | + } elseif ($id === 'ocMailShare') { |
|
291 | + $provider = $this->getShareByMailProvider(); |
|
292 | + } elseif ($id === 'ocCircleShare') { |
|
293 | + $provider = $this->getShareByCircleProvider(); |
|
294 | + } elseif ($id === 'ocRoomShare') { |
|
295 | + $provider = $this->getRoomShareProvider(); |
|
296 | + } |
|
297 | + |
|
298 | + foreach ($this->registeredShareProviders as $shareProvider) { |
|
299 | + try { |
|
300 | + /** @var IShareProvider $instance */ |
|
301 | + $instance = $this->serverContainer->get($shareProvider); |
|
302 | + $this->shareProviders[$instance->identifier()] = $instance; |
|
303 | + } catch (\Throwable $e) { |
|
304 | + $this->serverContainer->get(LoggerInterface::class)->error( |
|
305 | + $e->getMessage(), |
|
306 | + ['exception' => $e] |
|
307 | + ); |
|
308 | + } |
|
309 | + } |
|
310 | + |
|
311 | + if (isset($this->shareProviders[$id])) { |
|
312 | + $provider = $this->shareProviders[$id]; |
|
313 | + } |
|
314 | + |
|
315 | + if ($provider === null) { |
|
316 | + throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
317 | + } |
|
318 | + |
|
319 | + return $provider; |
|
320 | + } |
|
321 | + |
|
322 | + /** |
|
323 | + * @inheritdoc |
|
324 | + */ |
|
325 | + public function getProviderForType($shareType) { |
|
326 | + $provider = null; |
|
327 | + |
|
328 | + if ($shareType === IShare::TYPE_USER || |
|
329 | + $shareType === IShare::TYPE_GROUP || |
|
330 | + $shareType === IShare::TYPE_LINK |
|
331 | + ) { |
|
332 | + $provider = $this->defaultShareProvider(); |
|
333 | + } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) { |
|
334 | + $provider = $this->federatedShareProvider(); |
|
335 | + } elseif ($shareType === IShare::TYPE_EMAIL) { |
|
336 | + $provider = $this->getShareByMailProvider(); |
|
337 | + } elseif ($shareType === IShare::TYPE_CIRCLE) { |
|
338 | + $provider = $this->getShareByCircleProvider(); |
|
339 | + } elseif ($shareType === IShare::TYPE_ROOM) { |
|
340 | + $provider = $this->getRoomShareProvider(); |
|
341 | + } elseif ($shareType === IShare::TYPE_DECK) { |
|
342 | + $provider = $this->getProvider('deck'); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + if ($provider === null) { |
|
347 | + throw new ProviderException('No share provider for share type ' . $shareType); |
|
348 | + } |
|
349 | + |
|
350 | + return $provider; |
|
351 | + } |
|
352 | + |
|
353 | + public function getAllProviders() { |
|
354 | + $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
355 | + $shareByMail = $this->getShareByMailProvider(); |
|
356 | + if ($shareByMail !== null) { |
|
357 | + $shares[] = $shareByMail; |
|
358 | + } |
|
359 | + $shareByCircle = $this->getShareByCircleProvider(); |
|
360 | + if ($shareByCircle !== null) { |
|
361 | + $shares[] = $shareByCircle; |
|
362 | + } |
|
363 | + $roomShare = $this->getRoomShareProvider(); |
|
364 | + if ($roomShare !== null) { |
|
365 | + $shares[] = $roomShare; |
|
366 | + } |
|
367 | + |
|
368 | + foreach ($this->registeredShareProviders as $shareProvider) { |
|
369 | + try { |
|
370 | + /** @var IShareProvider $instance */ |
|
371 | + $instance = $this->serverContainer->get($shareProvider); |
|
372 | + } catch (\Throwable $e) { |
|
373 | + $this->serverContainer->get(LoggerInterface::class)->error( |
|
374 | + $e->getMessage(), |
|
375 | + ['exception' => $e] |
|
376 | + ); |
|
377 | + continue; |
|
378 | + } |
|
379 | + |
|
380 | + if (!isset($this->shareProviders[$instance->identifier()])) { |
|
381 | + $this->shareProviders[$instance->identifier()] = $instance; |
|
382 | + } |
|
383 | + $shares[] = $this->shareProviders[$instance->identifier()]; |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + |
|
388 | + return $shares; |
|
389 | + } |
|
390 | 390 | } |
@@ -7,23 +7,23 @@ |
||
7 | 7 | |
8 | 8 | class RootCollection extends AbstractPrincipalCollection { |
9 | 9 | |
10 | - /** |
|
11 | - * This method returns a node for a principal. |
|
12 | - * |
|
13 | - * The passed array contains principal information, and is guaranteed to |
|
14 | - * at least contain a uri item. Other properties may or may not be |
|
15 | - * supplied by the authentication backend. |
|
16 | - * |
|
17 | - * @param array $principalInfo |
|
18 | - * @return AvatarHome |
|
19 | - */ |
|
20 | - public function getChildForPrincipal(array $principalInfo) { |
|
21 | - $avatarManager = \OC::$server->getAvatarManager(); |
|
22 | - return new AvatarHome($principalInfo, $avatarManager); |
|
23 | - } |
|
10 | + /** |
|
11 | + * This method returns a node for a principal. |
|
12 | + * |
|
13 | + * The passed array contains principal information, and is guaranteed to |
|
14 | + * at least contain a uri item. Other properties may or may not be |
|
15 | + * supplied by the authentication backend. |
|
16 | + * |
|
17 | + * @param array $principalInfo |
|
18 | + * @return AvatarHome |
|
19 | + */ |
|
20 | + public function getChildForPrincipal(array $principalInfo) { |
|
21 | + $avatarManager = \OC::$server->getAvatarManager(); |
|
22 | + return new AvatarHome($principalInfo, $avatarManager); |
|
23 | + } |
|
24 | 24 | |
25 | - public function getName() { |
|
26 | - return 'avatars'; |
|
27 | - } |
|
25 | + public function getName() { |
|
26 | + return 'avatars'; |
|
27 | + } |
|
28 | 28 | |
29 | 29 | } |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | |
66 | 66 | $output->startProgress(count($objects)); |
67 | 67 | foreach ($objects as $row) { |
68 | - $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
69 | - $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
68 | + $calObject = $this->calDavBackend->getCalendarObject((int) $row['calendarid'], $row['uri']); |
|
69 | + $data = preg_replace('/'.$pattern.'/', ':', $calObject['calendardata']); |
|
70 | 70 | |
71 | 71 | if ($data !== $calObject['calendardata']) { |
72 | 72 | $output->advance(); |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | } catch (InvalidDataException $e) { |
77 | 77 | $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
78 | 78 | 'app' => 'dav', |
79 | - 'cal' => (int)$row['calendarid'], |
|
79 | + 'cal' => (int) $row['calendarid'], |
|
80 | 80 | 'uri' => $row['uri'], |
81 | 81 | ]); |
82 | 82 | $warnings++; |
83 | 83 | continue; |
84 | 84 | } |
85 | 85 | |
86 | - $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
86 | + $this->calDavBackend->updateCalendarObject((int) $row['calendarid'], $row['uri'], $data); |
|
87 | 87 | $count++; |
88 | 88 | } |
89 | 89 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | ->where($query->expr()->like( |
105 | 105 | 'calendardata', |
106 | 106 | $query->createNamedParameter( |
107 | - '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
107 | + '%'.$this->db->escapeLikeParameter($pattern).'%', |
|
108 | 108 | IQueryBuilder::PARAM_STR |
109 | 109 | ), |
110 | 110 | IQueryBuilder::PARAM_STR |
@@ -35,112 +35,112 @@ |
||
35 | 35 | |
36 | 36 | class CalDAVRemoveEmptyValue implements IRepairStep { |
37 | 37 | |
38 | - /** @var IDBConnection */ |
|
39 | - private $db; |
|
40 | - |
|
41 | - /** @var CalDavBackend */ |
|
42 | - private $calDavBackend; |
|
43 | - |
|
44 | - private LoggerInterface $logger; |
|
45 | - |
|
46 | - public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, LoggerInterface $logger) { |
|
47 | - $this->db = $db; |
|
48 | - $this->calDavBackend = $calDavBackend; |
|
49 | - $this->logger = $logger; |
|
50 | - } |
|
51 | - |
|
52 | - public function getName() { |
|
53 | - return 'Fix broken values of calendar objects'; |
|
54 | - } |
|
55 | - |
|
56 | - public function run(IOutput $output) { |
|
57 | - $pattern = ';VALUE=:'; |
|
58 | - $count = $warnings = 0; |
|
59 | - |
|
60 | - $objects = $this->getInvalidObjects($pattern); |
|
61 | - |
|
62 | - $output->startProgress(count($objects)); |
|
63 | - foreach ($objects as $row) { |
|
64 | - $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
65 | - $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
66 | - |
|
67 | - if ($data !== $calObject['calendardata']) { |
|
68 | - $output->advance(); |
|
69 | - |
|
70 | - try { |
|
71 | - $this->calDavBackend->getDenormalizedData($data); |
|
72 | - } catch (InvalidDataException $e) { |
|
73 | - $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
|
74 | - 'app' => 'dav', |
|
75 | - 'cal' => (int)$row['calendarid'], |
|
76 | - 'uri' => $row['uri'], |
|
77 | - ]); |
|
78 | - $warnings++; |
|
79 | - continue; |
|
80 | - } |
|
81 | - |
|
82 | - $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
83 | - $count++; |
|
84 | - } |
|
85 | - } |
|
86 | - $output->finishProgress(); |
|
87 | - |
|
88 | - if ($warnings > 0) { |
|
89 | - $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings)); |
|
90 | - } |
|
91 | - if ($count > 0) { |
|
92 | - $output->info(sprintf('Updated %d events', $count)); |
|
93 | - } |
|
94 | - } |
|
95 | - |
|
96 | - protected function getInvalidObjects($pattern) { |
|
97 | - if ($this->db->getDatabasePlatform() instanceof OraclePlatform) { |
|
98 | - $rows = []; |
|
99 | - $chunkSize = 500; |
|
100 | - $query = $this->db->getQueryBuilder(); |
|
101 | - $query->select($query->func()->count('*', 'num_entries')) |
|
102 | - ->from('calendarobjects'); |
|
103 | - $result = $query->execute(); |
|
104 | - $count = $result->fetchOne(); |
|
105 | - $result->closeCursor(); |
|
106 | - |
|
107 | - $numChunks = ceil($count / $chunkSize); |
|
108 | - |
|
109 | - $query = $this->db->getQueryBuilder(); |
|
110 | - $query->select(['calendarid', 'uri', 'calendardata']) |
|
111 | - ->from('calendarobjects') |
|
112 | - ->setMaxResults($chunkSize); |
|
113 | - for ($chunk = 0; $chunk < $numChunks; $chunk++) { |
|
114 | - $query->setFirstResult($chunk * $chunkSize); |
|
115 | - $result = $query->execute(); |
|
116 | - |
|
117 | - while ($row = $result->fetch()) { |
|
118 | - if (mb_strpos($row['calendardata'], $pattern) !== false) { |
|
119 | - unset($row['calendardata']); |
|
120 | - $rows[] = $row; |
|
121 | - } |
|
122 | - } |
|
123 | - $result->closeCursor(); |
|
124 | - } |
|
125 | - return $rows; |
|
126 | - } |
|
127 | - |
|
128 | - $query = $this->db->getQueryBuilder(); |
|
129 | - $query->select(['calendarid', 'uri']) |
|
130 | - ->from('calendarobjects') |
|
131 | - ->where($query->expr()->like( |
|
132 | - 'calendardata', |
|
133 | - $query->createNamedParameter( |
|
134 | - '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
135 | - IQueryBuilder::PARAM_STR |
|
136 | - ), |
|
137 | - IQueryBuilder::PARAM_STR |
|
138 | - )); |
|
139 | - |
|
140 | - $result = $query->execute(); |
|
141 | - $rows = $result->fetchAll(); |
|
142 | - $result->closeCursor(); |
|
143 | - |
|
144 | - return $rows; |
|
145 | - } |
|
38 | + /** @var IDBConnection */ |
|
39 | + private $db; |
|
40 | + |
|
41 | + /** @var CalDavBackend */ |
|
42 | + private $calDavBackend; |
|
43 | + |
|
44 | + private LoggerInterface $logger; |
|
45 | + |
|
46 | + public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, LoggerInterface $logger) { |
|
47 | + $this->db = $db; |
|
48 | + $this->calDavBackend = $calDavBackend; |
|
49 | + $this->logger = $logger; |
|
50 | + } |
|
51 | + |
|
52 | + public function getName() { |
|
53 | + return 'Fix broken values of calendar objects'; |
|
54 | + } |
|
55 | + |
|
56 | + public function run(IOutput $output) { |
|
57 | + $pattern = ';VALUE=:'; |
|
58 | + $count = $warnings = 0; |
|
59 | + |
|
60 | + $objects = $this->getInvalidObjects($pattern); |
|
61 | + |
|
62 | + $output->startProgress(count($objects)); |
|
63 | + foreach ($objects as $row) { |
|
64 | + $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
65 | + $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
66 | + |
|
67 | + if ($data !== $calObject['calendardata']) { |
|
68 | + $output->advance(); |
|
69 | + |
|
70 | + try { |
|
71 | + $this->calDavBackend->getDenormalizedData($data); |
|
72 | + } catch (InvalidDataException $e) { |
|
73 | + $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
|
74 | + 'app' => 'dav', |
|
75 | + 'cal' => (int)$row['calendarid'], |
|
76 | + 'uri' => $row['uri'], |
|
77 | + ]); |
|
78 | + $warnings++; |
|
79 | + continue; |
|
80 | + } |
|
81 | + |
|
82 | + $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
83 | + $count++; |
|
84 | + } |
|
85 | + } |
|
86 | + $output->finishProgress(); |
|
87 | + |
|
88 | + if ($warnings > 0) { |
|
89 | + $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings)); |
|
90 | + } |
|
91 | + if ($count > 0) { |
|
92 | + $output->info(sprintf('Updated %d events', $count)); |
|
93 | + } |
|
94 | + } |
|
95 | + |
|
96 | + protected function getInvalidObjects($pattern) { |
|
97 | + if ($this->db->getDatabasePlatform() instanceof OraclePlatform) { |
|
98 | + $rows = []; |
|
99 | + $chunkSize = 500; |
|
100 | + $query = $this->db->getQueryBuilder(); |
|
101 | + $query->select($query->func()->count('*', 'num_entries')) |
|
102 | + ->from('calendarobjects'); |
|
103 | + $result = $query->execute(); |
|
104 | + $count = $result->fetchOne(); |
|
105 | + $result->closeCursor(); |
|
106 | + |
|
107 | + $numChunks = ceil($count / $chunkSize); |
|
108 | + |
|
109 | + $query = $this->db->getQueryBuilder(); |
|
110 | + $query->select(['calendarid', 'uri', 'calendardata']) |
|
111 | + ->from('calendarobjects') |
|
112 | + ->setMaxResults($chunkSize); |
|
113 | + for ($chunk = 0; $chunk < $numChunks; $chunk++) { |
|
114 | + $query->setFirstResult($chunk * $chunkSize); |
|
115 | + $result = $query->execute(); |
|
116 | + |
|
117 | + while ($row = $result->fetch()) { |
|
118 | + if (mb_strpos($row['calendardata'], $pattern) !== false) { |
|
119 | + unset($row['calendardata']); |
|
120 | + $rows[] = $row; |
|
121 | + } |
|
122 | + } |
|
123 | + $result->closeCursor(); |
|
124 | + } |
|
125 | + return $rows; |
|
126 | + } |
|
127 | + |
|
128 | + $query = $this->db->getQueryBuilder(); |
|
129 | + $query->select(['calendarid', 'uri']) |
|
130 | + ->from('calendarobjects') |
|
131 | + ->where($query->expr()->like( |
|
132 | + 'calendardata', |
|
133 | + $query->createNamedParameter( |
|
134 | + '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
135 | + IQueryBuilder::PARAM_STR |
|
136 | + ), |
|
137 | + IQueryBuilder::PARAM_STR |
|
138 | + )); |
|
139 | + |
|
140 | + $result = $query->execute(); |
|
141 | + $rows = $result->fetchAll(); |
|
142 | + $result->closeCursor(); |
|
143 | + |
|
144 | + return $rows; |
|
145 | + } |
|
146 | 146 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $reader->parseInnerTree(); |
40 | 40 | |
41 | 41 | if (!is_string($componentName)) { |
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
42 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}comp-filter requires a valid name attribute'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | return $componentName; |
@@ -27,21 +27,21 @@ |
||
27 | 27 | |
28 | 28 | class CompFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $componentName = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $componentName = $att['name']; |
|
38 | 38 | |
39 | - $reader->parseInnerTree(); |
|
39 | + $reader->parseInnerTree(); |
|
40 | 40 | |
41 | - if (!is_string($componentName)) { |
|
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
43 | - } |
|
41 | + if (!is_string($componentName)) { |
|
42 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
43 | + } |
|
44 | 44 | |
45 | - return $componentName; |
|
46 | - } |
|
45 | + return $componentName; |
|
46 | + } |
|
47 | 47 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $reader->parseInnerTree(); |
40 | 40 | |
41 | 41 | if (!is_string($componentName)) { |
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
42 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}prop-filter requires a valid name attribute'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | return $componentName; |
@@ -27,21 +27,21 @@ |
||
27 | 27 | |
28 | 28 | class PropFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $componentName = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $componentName = $att['name']; |
|
38 | 38 | |
39 | - $reader->parseInnerTree(); |
|
39 | + $reader->parseInnerTree(); |
|
40 | 40 | |
41 | - if (!is_string($componentName)) { |
|
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
43 | - } |
|
41 | + if (!is_string($componentName)) { |
|
42 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
43 | + } |
|
44 | 44 | |
45 | - return $componentName; |
|
46 | - } |
|
45 | + return $componentName; |
|
46 | + } |
|
47 | 47 | } |