@@ -25,33 +25,33 @@ |
||
| 25 | 25 | use OCP\Files\Search\ISearchOperator; |
| 26 | 26 | |
| 27 | 27 | class SearchBinaryOperator implements ISearchBinaryOperator { |
| 28 | - /** @var string */ |
|
| 29 | - private $type; |
|
| 30 | - /** @var ISearchOperator[] */ |
|
| 31 | - private $arguments; |
|
| 28 | + /** @var string */ |
|
| 29 | + private $type; |
|
| 30 | + /** @var ISearchOperator[] */ |
|
| 31 | + private $arguments; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * SearchBinaryOperator constructor. |
|
| 35 | - * |
|
| 36 | - * @param string $type |
|
| 37 | - * @param ISearchOperator[] $arguments |
|
| 38 | - */ |
|
| 39 | - public function __construct($type, array $arguments) { |
|
| 40 | - $this->type = $type; |
|
| 41 | - $this->arguments = $arguments; |
|
| 42 | - } |
|
| 33 | + /** |
|
| 34 | + * SearchBinaryOperator constructor. |
|
| 35 | + * |
|
| 36 | + * @param string $type |
|
| 37 | + * @param ISearchOperator[] $arguments |
|
| 38 | + */ |
|
| 39 | + public function __construct($type, array $arguments) { |
|
| 40 | + $this->type = $type; |
|
| 41 | + $this->arguments = $arguments; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @return string |
|
| 46 | - */ |
|
| 47 | - public function getType() { |
|
| 48 | - return $this->type; |
|
| 49 | - } |
|
| 44 | + /** |
|
| 45 | + * @return string |
|
| 46 | + */ |
|
| 47 | + public function getType() { |
|
| 48 | + return $this->type; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return ISearchOperator[] |
|
| 53 | - */ |
|
| 54 | - public function getArguments() { |
|
| 55 | - return $this->arguments; |
|
| 56 | - } |
|
| 51 | + /** |
|
| 52 | + * @return ISearchOperator[] |
|
| 53 | + */ |
|
| 54 | + public function getArguments() { |
|
| 55 | + return $this->arguments; |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -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 | } |
@@ -23,18 +23,18 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | 25 | return [ |
| 26 | - 'routes' => [ |
|
| 27 | - ['name' => 'MountPublicLink#createFederatedShare', 'url' => '/createFederatedShare', 'verb' => 'POST'], |
|
| 28 | - ['name' => 'MountPublicLink#askForFederatedShare', 'url' => '/askForFederatedShare', 'verb' => 'POST'], |
|
| 29 | - ], |
|
| 30 | - 'ocs' => [ |
|
| 31 | - ['root' => '/cloud', 'name' => 'RequestHandler#createShare', 'url' => '/shares', 'verb' => 'POST'], |
|
| 32 | - ['root' => '/cloud', 'name' => 'RequestHandler#reShare', 'url' => '/shares/{id}/reshare', 'verb' => 'POST'], |
|
| 33 | - ['root' => '/cloud', 'name' => 'RequestHandler#updatePermissions', 'url' => '/shares/{id}/permissions', 'verb' => 'POST'], |
|
| 34 | - ['root' => '/cloud', 'name' => 'RequestHandler#acceptShare', 'url' => '/shares/{id}/accept', 'verb' => 'POST'], |
|
| 35 | - ['root' => '/cloud', 'name' => 'RequestHandler#declineShare', 'url' => '/shares/{id}/decline', 'verb' => 'POST'], |
|
| 36 | - ['root' => '/cloud', 'name' => 'RequestHandler#unshare', 'url' => '/shares/{id}/unshare', 'verb' => 'POST'], |
|
| 37 | - ['root' => '/cloud', 'name' => 'RequestHandler#revoke', 'url' => '/shares/{id}/revoke', 'verb' => 'POST'], |
|
| 38 | - ['root' => '/cloud', 'name' => 'RequestHandler#move', 'url' => '/shares/{id}/move', 'verb' => 'POST'], |
|
| 39 | - ], |
|
| 26 | + 'routes' => [ |
|
| 27 | + ['name' => 'MountPublicLink#createFederatedShare', 'url' => '/createFederatedShare', 'verb' => 'POST'], |
|
| 28 | + ['name' => 'MountPublicLink#askForFederatedShare', 'url' => '/askForFederatedShare', 'verb' => 'POST'], |
|
| 29 | + ], |
|
| 30 | + 'ocs' => [ |
|
| 31 | + ['root' => '/cloud', 'name' => 'RequestHandler#createShare', 'url' => '/shares', 'verb' => 'POST'], |
|
| 32 | + ['root' => '/cloud', 'name' => 'RequestHandler#reShare', 'url' => '/shares/{id}/reshare', 'verb' => 'POST'], |
|
| 33 | + ['root' => '/cloud', 'name' => 'RequestHandler#updatePermissions', 'url' => '/shares/{id}/permissions', 'verb' => 'POST'], |
|
| 34 | + ['root' => '/cloud', 'name' => 'RequestHandler#acceptShare', 'url' => '/shares/{id}/accept', 'verb' => 'POST'], |
|
| 35 | + ['root' => '/cloud', 'name' => 'RequestHandler#declineShare', 'url' => '/shares/{id}/decline', 'verb' => 'POST'], |
|
| 36 | + ['root' => '/cloud', 'name' => 'RequestHandler#unshare', 'url' => '/shares/{id}/unshare', 'verb' => 'POST'], |
|
| 37 | + ['root' => '/cloud', 'name' => 'RequestHandler#revoke', 'url' => '/shares/{id}/revoke', 'verb' => 'POST'], |
|
| 38 | + ['root' => '/cloud', 'name' => 'RequestHandler#move', 'url' => '/shares/{id}/move', 'verb' => 'POST'], |
|
| 39 | + ], |
|
| 40 | 40 | ]; |
@@ -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; |
@@ -53,309 +53,309 @@ |
||
| 53 | 53 | */ |
| 54 | 54 | class ProviderFactory implements IProviderFactory { |
| 55 | 55 | |
| 56 | - /** @var IServerContainer */ |
|
| 57 | - private $serverContainer; |
|
| 58 | - /** @var DefaultShareProvider */ |
|
| 59 | - private $defaultProvider = null; |
|
| 60 | - /** @var FederatedShareProvider */ |
|
| 61 | - private $federatedProvider = null; |
|
| 62 | - /** @var ShareByMailProvider */ |
|
| 63 | - private $shareByMailProvider; |
|
| 64 | - /** @var \OCA\Circles\ShareByCircleProvider */ |
|
| 65 | - private $shareByCircleProvider = null; |
|
| 66 | - /** @var bool */ |
|
| 67 | - private $circlesAreNotAvailable = false; |
|
| 68 | - /** @var \OCA\Talk\Share\RoomShareProvider */ |
|
| 69 | - private $roomShareProvider = null; |
|
| 70 | - |
|
| 71 | - private $registeredShareProviders = []; |
|
| 72 | - |
|
| 73 | - private $shareProviders = []; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * IProviderFactory constructor. |
|
| 77 | - * |
|
| 78 | - * @param IServerContainer $serverContainer |
|
| 79 | - */ |
|
| 80 | - public function __construct(IServerContainer $serverContainer) { |
|
| 81 | - $this->serverContainer = $serverContainer; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - public function registerProvider(string $shareProviderClass): void { |
|
| 85 | - $this->registeredShareProviders[] = $shareProviderClass; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Create the default share provider. |
|
| 90 | - * |
|
| 91 | - * @return DefaultShareProvider |
|
| 92 | - */ |
|
| 93 | - protected function defaultShareProvider() { |
|
| 94 | - if ($this->defaultProvider === null) { |
|
| 95 | - $this->defaultProvider = new DefaultShareProvider( |
|
| 96 | - $this->serverContainer->getDatabaseConnection(), |
|
| 97 | - $this->serverContainer->getUserManager(), |
|
| 98 | - $this->serverContainer->getGroupManager(), |
|
| 99 | - $this->serverContainer->getLazyRootFolder(), |
|
| 100 | - $this->serverContainer->getMailer(), |
|
| 101 | - $this->serverContainer->query(Defaults::class), |
|
| 102 | - $this->serverContainer->getL10NFactory(), |
|
| 103 | - $this->serverContainer->getURLGenerator(), |
|
| 104 | - $this->serverContainer->getConfig() |
|
| 105 | - ); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - return $this->defaultProvider; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Create the federated share provider |
|
| 113 | - * |
|
| 114 | - * @return FederatedShareProvider |
|
| 115 | - */ |
|
| 116 | - protected function federatedShareProvider() { |
|
| 117 | - if ($this->federatedProvider === null) { |
|
| 118 | - /* |
|
| 56 | + /** @var IServerContainer */ |
|
| 57 | + private $serverContainer; |
|
| 58 | + /** @var DefaultShareProvider */ |
|
| 59 | + private $defaultProvider = null; |
|
| 60 | + /** @var FederatedShareProvider */ |
|
| 61 | + private $federatedProvider = null; |
|
| 62 | + /** @var ShareByMailProvider */ |
|
| 63 | + private $shareByMailProvider; |
|
| 64 | + /** @var \OCA\Circles\ShareByCircleProvider */ |
|
| 65 | + private $shareByCircleProvider = null; |
|
| 66 | + /** @var bool */ |
|
| 67 | + private $circlesAreNotAvailable = false; |
|
| 68 | + /** @var \OCA\Talk\Share\RoomShareProvider */ |
|
| 69 | + private $roomShareProvider = null; |
|
| 70 | + |
|
| 71 | + private $registeredShareProviders = []; |
|
| 72 | + |
|
| 73 | + private $shareProviders = []; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * IProviderFactory constructor. |
|
| 77 | + * |
|
| 78 | + * @param IServerContainer $serverContainer |
|
| 79 | + */ |
|
| 80 | + public function __construct(IServerContainer $serverContainer) { |
|
| 81 | + $this->serverContainer = $serverContainer; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + public function registerProvider(string $shareProviderClass): void { |
|
| 85 | + $this->registeredShareProviders[] = $shareProviderClass; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Create the default share provider. |
|
| 90 | + * |
|
| 91 | + * @return DefaultShareProvider |
|
| 92 | + */ |
|
| 93 | + protected function defaultShareProvider() { |
|
| 94 | + if ($this->defaultProvider === null) { |
|
| 95 | + $this->defaultProvider = new DefaultShareProvider( |
|
| 96 | + $this->serverContainer->getDatabaseConnection(), |
|
| 97 | + $this->serverContainer->getUserManager(), |
|
| 98 | + $this->serverContainer->getGroupManager(), |
|
| 99 | + $this->serverContainer->getLazyRootFolder(), |
|
| 100 | + $this->serverContainer->getMailer(), |
|
| 101 | + $this->serverContainer->query(Defaults::class), |
|
| 102 | + $this->serverContainer->getL10NFactory(), |
|
| 103 | + $this->serverContainer->getURLGenerator(), |
|
| 104 | + $this->serverContainer->getConfig() |
|
| 105 | + ); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + return $this->defaultProvider; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Create the federated share provider |
|
| 113 | + * |
|
| 114 | + * @return FederatedShareProvider |
|
| 115 | + */ |
|
| 116 | + protected function federatedShareProvider() { |
|
| 117 | + if ($this->federatedProvider === null) { |
|
| 118 | + /* |
|
| 119 | 119 | * Check if the app is enabled |
| 120 | 120 | */ |
| 121 | - $appManager = $this->serverContainer->getAppManager(); |
|
| 122 | - if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
| 123 | - return null; |
|
| 124 | - } |
|
| 121 | + $appManager = $this->serverContainer->getAppManager(); |
|
| 122 | + if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
| 123 | + return null; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /* |
|
| 126 | + /* |
|
| 127 | 127 | * TODO: add factory to federated sharing app |
| 128 | 128 | */ |
| 129 | - $l = $this->serverContainer->getL10N('federatedfilesharing'); |
|
| 130 | - $addressHandler = new AddressHandler( |
|
| 131 | - $this->serverContainer->getURLGenerator(), |
|
| 132 | - $l, |
|
| 133 | - $this->serverContainer->getCloudIdManager() |
|
| 134 | - ); |
|
| 135 | - $notifications = new Notifications( |
|
| 136 | - $addressHandler, |
|
| 137 | - $this->serverContainer->getHTTPClientService(), |
|
| 138 | - $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
| 139 | - $this->serverContainer->getJobList(), |
|
| 140 | - \OC::$server->getCloudFederationProviderManager(), |
|
| 141 | - \OC::$server->getCloudFederationFactory(), |
|
| 142 | - $this->serverContainer->query(IEventDispatcher::class) |
|
| 143 | - ); |
|
| 144 | - $tokenHandler = new TokenHandler( |
|
| 145 | - $this->serverContainer->getSecureRandom() |
|
| 146 | - ); |
|
| 147 | - |
|
| 148 | - $this->federatedProvider = new FederatedShareProvider( |
|
| 149 | - $this->serverContainer->getDatabaseConnection(), |
|
| 150 | - $addressHandler, |
|
| 151 | - $notifications, |
|
| 152 | - $tokenHandler, |
|
| 153 | - $l, |
|
| 154 | - $this->serverContainer->getLogger(), |
|
| 155 | - $this->serverContainer->getLazyRootFolder(), |
|
| 156 | - $this->serverContainer->getConfig(), |
|
| 157 | - $this->serverContainer->getUserManager(), |
|
| 158 | - $this->serverContainer->getCloudIdManager(), |
|
| 159 | - $this->serverContainer->getGlobalScaleConfig(), |
|
| 160 | - $this->serverContainer->getCloudFederationProviderManager() |
|
| 161 | - ); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - return $this->federatedProvider; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Create the federated share provider |
|
| 169 | - * |
|
| 170 | - * @return ShareByMailProvider |
|
| 171 | - */ |
|
| 172 | - protected function getShareByMailProvider() { |
|
| 173 | - if ($this->shareByMailProvider === null) { |
|
| 174 | - /* |
|
| 129 | + $l = $this->serverContainer->getL10N('federatedfilesharing'); |
|
| 130 | + $addressHandler = new AddressHandler( |
|
| 131 | + $this->serverContainer->getURLGenerator(), |
|
| 132 | + $l, |
|
| 133 | + $this->serverContainer->getCloudIdManager() |
|
| 134 | + ); |
|
| 135 | + $notifications = new Notifications( |
|
| 136 | + $addressHandler, |
|
| 137 | + $this->serverContainer->getHTTPClientService(), |
|
| 138 | + $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
| 139 | + $this->serverContainer->getJobList(), |
|
| 140 | + \OC::$server->getCloudFederationProviderManager(), |
|
| 141 | + \OC::$server->getCloudFederationFactory(), |
|
| 142 | + $this->serverContainer->query(IEventDispatcher::class) |
|
| 143 | + ); |
|
| 144 | + $tokenHandler = new TokenHandler( |
|
| 145 | + $this->serverContainer->getSecureRandom() |
|
| 146 | + ); |
|
| 147 | + |
|
| 148 | + $this->federatedProvider = new FederatedShareProvider( |
|
| 149 | + $this->serverContainer->getDatabaseConnection(), |
|
| 150 | + $addressHandler, |
|
| 151 | + $notifications, |
|
| 152 | + $tokenHandler, |
|
| 153 | + $l, |
|
| 154 | + $this->serverContainer->getLogger(), |
|
| 155 | + $this->serverContainer->getLazyRootFolder(), |
|
| 156 | + $this->serverContainer->getConfig(), |
|
| 157 | + $this->serverContainer->getUserManager(), |
|
| 158 | + $this->serverContainer->getCloudIdManager(), |
|
| 159 | + $this->serverContainer->getGlobalScaleConfig(), |
|
| 160 | + $this->serverContainer->getCloudFederationProviderManager() |
|
| 161 | + ); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + return $this->federatedProvider; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Create the federated share provider |
|
| 169 | + * |
|
| 170 | + * @return ShareByMailProvider |
|
| 171 | + */ |
|
| 172 | + protected function getShareByMailProvider() { |
|
| 173 | + if ($this->shareByMailProvider === null) { |
|
| 174 | + /* |
|
| 175 | 175 | * Check if the app is enabled |
| 176 | 176 | */ |
| 177 | - $appManager = $this->serverContainer->getAppManager(); |
|
| 178 | - if (!$appManager->isEnabledForUser('sharebymail')) { |
|
| 179 | - return null; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
| 183 | - |
|
| 184 | - $this->shareByMailProvider = new ShareByMailProvider( |
|
| 185 | - $this->serverContainer->getDatabaseConnection(), |
|
| 186 | - $this->serverContainer->getSecureRandom(), |
|
| 187 | - $this->serverContainer->getUserManager(), |
|
| 188 | - $this->serverContainer->getLazyRootFolder(), |
|
| 189 | - $this->serverContainer->getL10N('sharebymail'), |
|
| 190 | - $this->serverContainer->getLogger(), |
|
| 191 | - $this->serverContainer->getMailer(), |
|
| 192 | - $this->serverContainer->getURLGenerator(), |
|
| 193 | - $this->serverContainer->getActivityManager(), |
|
| 194 | - $settingsManager, |
|
| 195 | - $this->serverContainer->query(Defaults::class), |
|
| 196 | - $this->serverContainer->getHasher(), |
|
| 197 | - $this->serverContainer->get(IEventDispatcher::class) |
|
| 198 | - ); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - return $this->shareByMailProvider; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * Create the circle share provider |
|
| 207 | - * |
|
| 208 | - * @return FederatedShareProvider |
|
| 209 | - * |
|
| 210 | - * @suppress PhanUndeclaredClassMethod |
|
| 211 | - */ |
|
| 212 | - protected function getShareByCircleProvider() { |
|
| 213 | - if ($this->circlesAreNotAvailable) { |
|
| 214 | - return null; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
| 218 | - !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
| 219 | - ) { |
|
| 220 | - $this->circlesAreNotAvailable = true; |
|
| 221 | - return null; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - if ($this->shareByCircleProvider === null) { |
|
| 225 | - $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
| 226 | - $this->serverContainer->getDatabaseConnection(), |
|
| 227 | - $this->serverContainer->getSecureRandom(), |
|
| 228 | - $this->serverContainer->getUserManager(), |
|
| 229 | - $this->serverContainer->getLazyRootFolder(), |
|
| 230 | - $this->serverContainer->getL10N('circles'), |
|
| 231 | - $this->serverContainer->getLogger(), |
|
| 232 | - $this->serverContainer->getURLGenerator() |
|
| 233 | - ); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - return $this->shareByCircleProvider; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Create the room share provider |
|
| 241 | - * |
|
| 242 | - * @return RoomShareProvider |
|
| 243 | - */ |
|
| 244 | - protected function getRoomShareProvider() { |
|
| 245 | - if ($this->roomShareProvider === null) { |
|
| 246 | - /* |
|
| 177 | + $appManager = $this->serverContainer->getAppManager(); |
|
| 178 | + if (!$appManager->isEnabledForUser('sharebymail')) { |
|
| 179 | + return null; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
| 183 | + |
|
| 184 | + $this->shareByMailProvider = new ShareByMailProvider( |
|
| 185 | + $this->serverContainer->getDatabaseConnection(), |
|
| 186 | + $this->serverContainer->getSecureRandom(), |
|
| 187 | + $this->serverContainer->getUserManager(), |
|
| 188 | + $this->serverContainer->getLazyRootFolder(), |
|
| 189 | + $this->serverContainer->getL10N('sharebymail'), |
|
| 190 | + $this->serverContainer->getLogger(), |
|
| 191 | + $this->serverContainer->getMailer(), |
|
| 192 | + $this->serverContainer->getURLGenerator(), |
|
| 193 | + $this->serverContainer->getActivityManager(), |
|
| 194 | + $settingsManager, |
|
| 195 | + $this->serverContainer->query(Defaults::class), |
|
| 196 | + $this->serverContainer->getHasher(), |
|
| 197 | + $this->serverContainer->get(IEventDispatcher::class) |
|
| 198 | + ); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + return $this->shareByMailProvider; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * Create the circle share provider |
|
| 207 | + * |
|
| 208 | + * @return FederatedShareProvider |
|
| 209 | + * |
|
| 210 | + * @suppress PhanUndeclaredClassMethod |
|
| 211 | + */ |
|
| 212 | + protected function getShareByCircleProvider() { |
|
| 213 | + if ($this->circlesAreNotAvailable) { |
|
| 214 | + return null; |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
| 218 | + !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
| 219 | + ) { |
|
| 220 | + $this->circlesAreNotAvailable = true; |
|
| 221 | + return null; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + if ($this->shareByCircleProvider === null) { |
|
| 225 | + $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
| 226 | + $this->serverContainer->getDatabaseConnection(), |
|
| 227 | + $this->serverContainer->getSecureRandom(), |
|
| 228 | + $this->serverContainer->getUserManager(), |
|
| 229 | + $this->serverContainer->getLazyRootFolder(), |
|
| 230 | + $this->serverContainer->getL10N('circles'), |
|
| 231 | + $this->serverContainer->getLogger(), |
|
| 232 | + $this->serverContainer->getURLGenerator() |
|
| 233 | + ); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + return $this->shareByCircleProvider; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * Create the room share provider |
|
| 241 | + * |
|
| 242 | + * @return RoomShareProvider |
|
| 243 | + */ |
|
| 244 | + protected function getRoomShareProvider() { |
|
| 245 | + if ($this->roomShareProvider === null) { |
|
| 246 | + /* |
|
| 247 | 247 | * Check if the app is enabled |
| 248 | 248 | */ |
| 249 | - $appManager = $this->serverContainer->getAppManager(); |
|
| 250 | - if (!$appManager->isEnabledForUser('spreed')) { |
|
| 251 | - return null; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - try { |
|
| 255 | - $this->roomShareProvider = $this->serverContainer->query('\OCA\Talk\Share\RoomShareProvider'); |
|
| 256 | - } catch (\OCP\AppFramework\QueryException $e) { |
|
| 257 | - return null; |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - return $this->roomShareProvider; |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * @inheritdoc |
|
| 266 | - */ |
|
| 267 | - public function getProvider($id) { |
|
| 268 | - $provider = null; |
|
| 269 | - if (isset($this->shareProviders[$id])) { |
|
| 270 | - return $this->shareProviders[$id]; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - if ($id === 'ocinternal') { |
|
| 274 | - $provider = $this->defaultShareProvider(); |
|
| 275 | - } elseif ($id === 'ocFederatedSharing') { |
|
| 276 | - $provider = $this->federatedShareProvider(); |
|
| 277 | - } elseif ($id === 'ocMailShare') { |
|
| 278 | - $provider = $this->getShareByMailProvider(); |
|
| 279 | - } elseif ($id === 'ocCircleShare') { |
|
| 280 | - $provider = $this->getShareByCircleProvider(); |
|
| 281 | - } elseif ($id === 'ocRoomShare') { |
|
| 282 | - $provider = $this->getRoomShareProvider(); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - foreach ($this->registeredShareProviders as $shareProvider) { |
|
| 286 | - /** @var IShareProvider $instance */ |
|
| 287 | - $instance = $this->serverContainer->get($shareProvider); |
|
| 288 | - $this->shareProviders[$instance->identifier()] = $instance; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - if (isset($this->shareProviders[$id])) { |
|
| 292 | - $provider = $this->shareProviders[$id]; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - if ($provider === null) { |
|
| 296 | - throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - return $provider; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - /** |
|
| 303 | - * @inheritdoc |
|
| 304 | - */ |
|
| 305 | - public function getProviderForType($shareType) { |
|
| 306 | - $provider = null; |
|
| 307 | - |
|
| 308 | - if ($shareType === IShare::TYPE_USER || |
|
| 309 | - $shareType === IShare::TYPE_GROUP || |
|
| 310 | - $shareType === IShare::TYPE_LINK |
|
| 311 | - ) { |
|
| 312 | - $provider = $this->defaultShareProvider(); |
|
| 313 | - } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) { |
|
| 314 | - $provider = $this->federatedShareProvider(); |
|
| 315 | - } elseif ($shareType === IShare::TYPE_EMAIL) { |
|
| 316 | - $provider = $this->getShareByMailProvider(); |
|
| 317 | - } elseif ($shareType === IShare::TYPE_CIRCLE) { |
|
| 318 | - $provider = $this->getShareByCircleProvider(); |
|
| 319 | - } elseif ($shareType === IShare::TYPE_ROOM) { |
|
| 320 | - $provider = $this->getRoomShareProvider(); |
|
| 321 | - } elseif ($shareType === IShare::TYPE_DECK) { |
|
| 322 | - $provider = $this->getProvider('deck'); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - |
|
| 326 | - if ($provider === null) { |
|
| 327 | - throw new ProviderException('No share provider for share type ' . $shareType); |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - return $provider; |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - public function getAllProviders() { |
|
| 334 | - $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
| 335 | - $shareByMail = $this->getShareByMailProvider(); |
|
| 336 | - if ($shareByMail !== null) { |
|
| 337 | - $shares[] = $shareByMail; |
|
| 338 | - } |
|
| 339 | - $shareByCircle = $this->getShareByCircleProvider(); |
|
| 340 | - if ($shareByCircle !== null) { |
|
| 341 | - $shares[] = $shareByCircle; |
|
| 342 | - } |
|
| 343 | - $roomShare = $this->getRoomShareProvider(); |
|
| 344 | - if ($roomShare !== null) { |
|
| 345 | - $shares[] = $roomShare; |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - foreach ($this->registeredShareProviders as $shareProvider) { |
|
| 349 | - /** @var IShareProvider $instance */ |
|
| 350 | - $instance = $this->serverContainer->get($shareProvider); |
|
| 351 | - if (!isset($this->shareProviders[$instance->identifier()])) { |
|
| 352 | - $this->shareProviders[$instance->identifier()] = $instance; |
|
| 353 | - } |
|
| 354 | - $shares[] = $this->shareProviders[$instance->identifier()]; |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - return $shares; |
|
| 360 | - } |
|
| 249 | + $appManager = $this->serverContainer->getAppManager(); |
|
| 250 | + if (!$appManager->isEnabledForUser('spreed')) { |
|
| 251 | + return null; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + try { |
|
| 255 | + $this->roomShareProvider = $this->serverContainer->query('\OCA\Talk\Share\RoomShareProvider'); |
|
| 256 | + } catch (\OCP\AppFramework\QueryException $e) { |
|
| 257 | + return null; |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + return $this->roomShareProvider; |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * @inheritdoc |
|
| 266 | + */ |
|
| 267 | + public function getProvider($id) { |
|
| 268 | + $provider = null; |
|
| 269 | + if (isset($this->shareProviders[$id])) { |
|
| 270 | + return $this->shareProviders[$id]; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + if ($id === 'ocinternal') { |
|
| 274 | + $provider = $this->defaultShareProvider(); |
|
| 275 | + } elseif ($id === 'ocFederatedSharing') { |
|
| 276 | + $provider = $this->federatedShareProvider(); |
|
| 277 | + } elseif ($id === 'ocMailShare') { |
|
| 278 | + $provider = $this->getShareByMailProvider(); |
|
| 279 | + } elseif ($id === 'ocCircleShare') { |
|
| 280 | + $provider = $this->getShareByCircleProvider(); |
|
| 281 | + } elseif ($id === 'ocRoomShare') { |
|
| 282 | + $provider = $this->getRoomShareProvider(); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + foreach ($this->registeredShareProviders as $shareProvider) { |
|
| 286 | + /** @var IShareProvider $instance */ |
|
| 287 | + $instance = $this->serverContainer->get($shareProvider); |
|
| 288 | + $this->shareProviders[$instance->identifier()] = $instance; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + if (isset($this->shareProviders[$id])) { |
|
| 292 | + $provider = $this->shareProviders[$id]; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + if ($provider === null) { |
|
| 296 | + throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + return $provider; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + /** |
|
| 303 | + * @inheritdoc |
|
| 304 | + */ |
|
| 305 | + public function getProviderForType($shareType) { |
|
| 306 | + $provider = null; |
|
| 307 | + |
|
| 308 | + if ($shareType === IShare::TYPE_USER || |
|
| 309 | + $shareType === IShare::TYPE_GROUP || |
|
| 310 | + $shareType === IShare::TYPE_LINK |
|
| 311 | + ) { |
|
| 312 | + $provider = $this->defaultShareProvider(); |
|
| 313 | + } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) { |
|
| 314 | + $provider = $this->federatedShareProvider(); |
|
| 315 | + } elseif ($shareType === IShare::TYPE_EMAIL) { |
|
| 316 | + $provider = $this->getShareByMailProvider(); |
|
| 317 | + } elseif ($shareType === IShare::TYPE_CIRCLE) { |
|
| 318 | + $provider = $this->getShareByCircleProvider(); |
|
| 319 | + } elseif ($shareType === IShare::TYPE_ROOM) { |
|
| 320 | + $provider = $this->getRoomShareProvider(); |
|
| 321 | + } elseif ($shareType === IShare::TYPE_DECK) { |
|
| 322 | + $provider = $this->getProvider('deck'); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + |
|
| 326 | + if ($provider === null) { |
|
| 327 | + throw new ProviderException('No share provider for share type ' . $shareType); |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + return $provider; |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + public function getAllProviders() { |
|
| 334 | + $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
| 335 | + $shareByMail = $this->getShareByMailProvider(); |
|
| 336 | + if ($shareByMail !== null) { |
|
| 337 | + $shares[] = $shareByMail; |
|
| 338 | + } |
|
| 339 | + $shareByCircle = $this->getShareByCircleProvider(); |
|
| 340 | + if ($shareByCircle !== null) { |
|
| 341 | + $shares[] = $shareByCircle; |
|
| 342 | + } |
|
| 343 | + $roomShare = $this->getRoomShareProvider(); |
|
| 344 | + if ($roomShare !== null) { |
|
| 345 | + $shares[] = $roomShare; |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + foreach ($this->registeredShareProviders as $shareProvider) { |
|
| 349 | + /** @var IShareProvider $instance */ |
|
| 350 | + $instance = $this->serverContainer->get($shareProvider); |
|
| 351 | + if (!isset($this->shareProviders[$instance->identifier()])) { |
|
| 352 | + $this->shareProviders[$instance->identifier()] = $instance; |
|
| 353 | + } |
|
| 354 | + $shares[] = $this->shareProviders[$instance->identifier()]; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + return $shares; |
|
| 360 | + } |
|
| 361 | 361 | } |
@@ -37,57 +37,57 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | class ConsoleOutput implements IOutput { |
| 39 | 39 | |
| 40 | - /** @var OutputInterface */ |
|
| 41 | - private $output; |
|
| 40 | + /** @var OutputInterface */ |
|
| 41 | + private $output; |
|
| 42 | 42 | |
| 43 | - /** @var ProgressBar */ |
|
| 44 | - private $progressBar; |
|
| 43 | + /** @var ProgressBar */ |
|
| 44 | + private $progressBar; |
|
| 45 | 45 | |
| 46 | - public function __construct(OutputInterface $output) { |
|
| 47 | - $this->output = $output; |
|
| 48 | - } |
|
| 46 | + public function __construct(OutputInterface $output) { |
|
| 47 | + $this->output = $output; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param string $message |
|
| 52 | - */ |
|
| 53 | - public function info($message) { |
|
| 54 | - $this->output->writeln("<info>$message</info>"); |
|
| 55 | - } |
|
| 50 | + /** |
|
| 51 | + * @param string $message |
|
| 52 | + */ |
|
| 53 | + public function info($message) { |
|
| 54 | + $this->output->writeln("<info>$message</info>"); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @param string $message |
|
| 59 | - */ |
|
| 60 | - public function warning($message) { |
|
| 61 | - $this->output->writeln("<comment>$message</comment>"); |
|
| 62 | - } |
|
| 57 | + /** |
|
| 58 | + * @param string $message |
|
| 59 | + */ |
|
| 60 | + public function warning($message) { |
|
| 61 | + $this->output->writeln("<comment>$message</comment>"); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @param int $max |
|
| 66 | - */ |
|
| 67 | - public function startProgress($max = 0) { |
|
| 68 | - if (!is_null($this->progressBar)) { |
|
| 69 | - $this->progressBar->finish(); |
|
| 70 | - } |
|
| 71 | - $this->progressBar = new ProgressBar($this->output); |
|
| 72 | - $this->progressBar->start($max); |
|
| 73 | - } |
|
| 64 | + /** |
|
| 65 | + * @param int $max |
|
| 66 | + */ |
|
| 67 | + public function startProgress($max = 0) { |
|
| 68 | + if (!is_null($this->progressBar)) { |
|
| 69 | + $this->progressBar->finish(); |
|
| 70 | + } |
|
| 71 | + $this->progressBar = new ProgressBar($this->output); |
|
| 72 | + $this->progressBar->start($max); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @param int $step |
|
| 77 | - * @param string $description |
|
| 78 | - */ |
|
| 79 | - public function advance($step = 1, $description = '') { |
|
| 80 | - if (!is_null($this->progressBar)) { |
|
| 81 | - $this->progressBar = new ProgressBar($this->output); |
|
| 82 | - $this->progressBar->start(); |
|
| 83 | - } |
|
| 84 | - $this->progressBar->advance($step); |
|
| 85 | - } |
|
| 75 | + /** |
|
| 76 | + * @param int $step |
|
| 77 | + * @param string $description |
|
| 78 | + */ |
|
| 79 | + public function advance($step = 1, $description = '') { |
|
| 80 | + if (!is_null($this->progressBar)) { |
|
| 81 | + $this->progressBar = new ProgressBar($this->output); |
|
| 82 | + $this->progressBar->start(); |
|
| 83 | + } |
|
| 84 | + $this->progressBar->advance($step); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - public function finishProgress() { |
|
| 88 | - if (is_null($this->progressBar)) { |
|
| 89 | - return; |
|
| 90 | - } |
|
| 91 | - $this->progressBar->finish(); |
|
| 92 | - } |
|
| 87 | + public function finishProgress() { |
|
| 88 | + if (is_null($this->progressBar)) { |
|
| 89 | + return; |
|
| 90 | + } |
|
| 91 | + $this->progressBar->finish(); |
|
| 92 | + } |
|
| 93 | 93 | } |
@@ -31,36 +31,36 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | interface IEntry extends JsonSerializable { |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @since 12.0 |
|
| 36 | - * @return string |
|
| 37 | - */ |
|
| 38 | - public function getFullName(); |
|
| 34 | + /** |
|
| 35 | + * @since 12.0 |
|
| 36 | + * @return string |
|
| 37 | + */ |
|
| 38 | + public function getFullName(); |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @since 12.0 |
|
| 42 | - * @return string[] |
|
| 43 | - */ |
|
| 44 | - public function getEMailAddresses(); |
|
| 40 | + /** |
|
| 41 | + * @since 12.0 |
|
| 42 | + * @return string[] |
|
| 43 | + */ |
|
| 44 | + public function getEMailAddresses(); |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @since 12.0 |
|
| 48 | - * @return string|null image URI |
|
| 49 | - */ |
|
| 50 | - public function getAvatar(); |
|
| 46 | + /** |
|
| 47 | + * @since 12.0 |
|
| 48 | + * @return string|null image URI |
|
| 49 | + */ |
|
| 50 | + public function getAvatar(); |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @since 12.0 |
|
| 54 | - * @param IAction $action an action to show in the contacts menu |
|
| 55 | - */ |
|
| 56 | - public function addAction(IAction $action); |
|
| 52 | + /** |
|
| 53 | + * @since 12.0 |
|
| 54 | + * @param IAction $action an action to show in the contacts menu |
|
| 55 | + */ |
|
| 56 | + public function addAction(IAction $action); |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Get an arbitrary property from the contact |
|
| 60 | - * |
|
| 61 | - * @since 12.0 |
|
| 62 | - * @param string $key |
|
| 63 | - * @return mixed the value of the property or null |
|
| 64 | - */ |
|
| 65 | - public function getProperty($key); |
|
| 58 | + /** |
|
| 59 | + * Get an arbitrary property from the contact |
|
| 60 | + * |
|
| 61 | + * @since 12.0 |
|
| 62 | + * @param string $key |
|
| 63 | + * @return mixed the value of the property or null |
|
| 64 | + */ |
|
| 65 | + public function getProperty($key); |
|
| 66 | 66 | } |
@@ -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 |
@@ -34,118 +34,118 @@ |
||
| 34 | 34 | |
| 35 | 35 | class CalDAVRemoveEmptyValue implements IRepairStep { |
| 36 | 36 | |
| 37 | - /** @var IDBConnection */ |
|
| 38 | - private $db; |
|
| 39 | - |
|
| 40 | - /** @var CalDavBackend */ |
|
| 41 | - private $calDavBackend; |
|
| 42 | - |
|
| 43 | - /** @var ILogger */ |
|
| 44 | - private $logger; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @param IDBConnection $db |
|
| 48 | - * @param CalDavBackend $calDavBackend |
|
| 49 | - * @param ILogger $logger |
|
| 50 | - */ |
|
| 51 | - public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) { |
|
| 52 | - $this->db = $db; |
|
| 53 | - $this->calDavBackend = $calDavBackend; |
|
| 54 | - $this->logger = $logger; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - public function getName() { |
|
| 58 | - return 'Fix broken values of calendar objects'; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - public function run(IOutput $output) { |
|
| 62 | - $pattern = ';VALUE=:'; |
|
| 63 | - $count = $warnings = 0; |
|
| 64 | - |
|
| 65 | - $objects = $this->getInvalidObjects($pattern); |
|
| 66 | - |
|
| 67 | - $output->startProgress(count($objects)); |
|
| 68 | - foreach ($objects as $row) { |
|
| 69 | - $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
| 70 | - $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
| 71 | - |
|
| 72 | - if ($data !== $calObject['calendardata']) { |
|
| 73 | - $output->advance(); |
|
| 74 | - |
|
| 75 | - try { |
|
| 76 | - $this->calDavBackend->getDenormalizedData($data); |
|
| 77 | - } catch (InvalidDataException $e) { |
|
| 78 | - $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
|
| 79 | - 'app' => 'dav', |
|
| 80 | - 'cal' => (int)$row['calendarid'], |
|
| 81 | - 'uri' => $row['uri'], |
|
| 82 | - ]); |
|
| 83 | - $warnings++; |
|
| 84 | - continue; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
| 88 | - $count++; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - $output->finishProgress(); |
|
| 92 | - |
|
| 93 | - if ($warnings > 0) { |
|
| 94 | - $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings)); |
|
| 95 | - } |
|
| 96 | - if ($count > 0) { |
|
| 97 | - $output->info(sprintf('Updated %d events', $count)); |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - protected function getInvalidObjects($pattern) { |
|
| 102 | - if ($this->db->getDatabasePlatform() instanceof OraclePlatform) { |
|
| 103 | - $rows = []; |
|
| 104 | - $chunkSize = 500; |
|
| 105 | - $query = $this->db->getQueryBuilder(); |
|
| 106 | - $query->select($query->func()->count('*', 'num_entries')) |
|
| 107 | - ->from('calendarobjects'); |
|
| 108 | - $result = $query->execute(); |
|
| 109 | - $count = $result->fetchColumn(); |
|
| 110 | - $result->closeCursor(); |
|
| 111 | - |
|
| 112 | - $numChunks = ceil($count / $chunkSize); |
|
| 113 | - |
|
| 114 | - $query = $this->db->getQueryBuilder(); |
|
| 115 | - $query->select(['calendarid', 'uri', 'calendardata']) |
|
| 116 | - ->from('calendarobjects') |
|
| 117 | - ->setMaxResults($chunkSize); |
|
| 118 | - for ($chunk = 0; $chunk < $numChunks; $chunk++) { |
|
| 119 | - $query->setFirstResult($chunk * $chunkSize); |
|
| 120 | - $result = $query->execute(); |
|
| 121 | - |
|
| 122 | - while ($row = $result->fetch()) { |
|
| 123 | - if (mb_strpos($row['calendardata'], $pattern) !== false) { |
|
| 124 | - unset($row['calendardata']); |
|
| 125 | - $rows[] = $row; |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - $result->closeCursor(); |
|
| 129 | - } |
|
| 130 | - return $rows; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - $query = $this->db->getQueryBuilder(); |
|
| 134 | - $query->select(['calendarid', 'uri']) |
|
| 135 | - ->from('calendarobjects') |
|
| 136 | - ->where($query->expr()->like( |
|
| 137 | - 'calendardata', |
|
| 138 | - $query->createNamedParameter( |
|
| 139 | - '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
| 140 | - IQueryBuilder::PARAM_STR |
|
| 141 | - ), |
|
| 142 | - IQueryBuilder::PARAM_STR |
|
| 143 | - )); |
|
| 144 | - |
|
| 145 | - $result = $query->execute(); |
|
| 146 | - $rows = $result->fetchAll(); |
|
| 147 | - $result->closeCursor(); |
|
| 148 | - |
|
| 149 | - return $rows; |
|
| 150 | - } |
|
| 37 | + /** @var IDBConnection */ |
|
| 38 | + private $db; |
|
| 39 | + |
|
| 40 | + /** @var CalDavBackend */ |
|
| 41 | + private $calDavBackend; |
|
| 42 | + |
|
| 43 | + /** @var ILogger */ |
|
| 44 | + private $logger; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @param IDBConnection $db |
|
| 48 | + * @param CalDavBackend $calDavBackend |
|
| 49 | + * @param ILogger $logger |
|
| 50 | + */ |
|
| 51 | + public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) { |
|
| 52 | + $this->db = $db; |
|
| 53 | + $this->calDavBackend = $calDavBackend; |
|
| 54 | + $this->logger = $logger; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + public function getName() { |
|
| 58 | + return 'Fix broken values of calendar objects'; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + public function run(IOutput $output) { |
|
| 62 | + $pattern = ';VALUE=:'; |
|
| 63 | + $count = $warnings = 0; |
|
| 64 | + |
|
| 65 | + $objects = $this->getInvalidObjects($pattern); |
|
| 66 | + |
|
| 67 | + $output->startProgress(count($objects)); |
|
| 68 | + foreach ($objects as $row) { |
|
| 69 | + $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
| 70 | + $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
| 71 | + |
|
| 72 | + if ($data !== $calObject['calendardata']) { |
|
| 73 | + $output->advance(); |
|
| 74 | + |
|
| 75 | + try { |
|
| 76 | + $this->calDavBackend->getDenormalizedData($data); |
|
| 77 | + } catch (InvalidDataException $e) { |
|
| 78 | + $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
|
| 79 | + 'app' => 'dav', |
|
| 80 | + 'cal' => (int)$row['calendarid'], |
|
| 81 | + 'uri' => $row['uri'], |
|
| 82 | + ]); |
|
| 83 | + $warnings++; |
|
| 84 | + continue; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
| 88 | + $count++; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + $output->finishProgress(); |
|
| 92 | + |
|
| 93 | + if ($warnings > 0) { |
|
| 94 | + $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings)); |
|
| 95 | + } |
|
| 96 | + if ($count > 0) { |
|
| 97 | + $output->info(sprintf('Updated %d events', $count)); |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + protected function getInvalidObjects($pattern) { |
|
| 102 | + if ($this->db->getDatabasePlatform() instanceof OraclePlatform) { |
|
| 103 | + $rows = []; |
|
| 104 | + $chunkSize = 500; |
|
| 105 | + $query = $this->db->getQueryBuilder(); |
|
| 106 | + $query->select($query->func()->count('*', 'num_entries')) |
|
| 107 | + ->from('calendarobjects'); |
|
| 108 | + $result = $query->execute(); |
|
| 109 | + $count = $result->fetchColumn(); |
|
| 110 | + $result->closeCursor(); |
|
| 111 | + |
|
| 112 | + $numChunks = ceil($count / $chunkSize); |
|
| 113 | + |
|
| 114 | + $query = $this->db->getQueryBuilder(); |
|
| 115 | + $query->select(['calendarid', 'uri', 'calendardata']) |
|
| 116 | + ->from('calendarobjects') |
|
| 117 | + ->setMaxResults($chunkSize); |
|
| 118 | + for ($chunk = 0; $chunk < $numChunks; $chunk++) { |
|
| 119 | + $query->setFirstResult($chunk * $chunkSize); |
|
| 120 | + $result = $query->execute(); |
|
| 121 | + |
|
| 122 | + while ($row = $result->fetch()) { |
|
| 123 | + if (mb_strpos($row['calendardata'], $pattern) !== false) { |
|
| 124 | + unset($row['calendardata']); |
|
| 125 | + $rows[] = $row; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + $result->closeCursor(); |
|
| 129 | + } |
|
| 130 | + return $rows; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + $query = $this->db->getQueryBuilder(); |
|
| 134 | + $query->select(['calendarid', 'uri']) |
|
| 135 | + ->from('calendarobjects') |
|
| 136 | + ->where($query->expr()->like( |
|
| 137 | + 'calendardata', |
|
| 138 | + $query->createNamedParameter( |
|
| 139 | + '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
| 140 | + IQueryBuilder::PARAM_STR |
|
| 141 | + ), |
|
| 142 | + IQueryBuilder::PARAM_STR |
|
| 143 | + )); |
|
| 144 | + |
|
| 145 | + $result = $query->execute(); |
|
| 146 | + $rows = $result->fetchAll(); |
|
| 147 | + $result->closeCursor(); |
|
| 148 | + |
|
| 149 | + return $rows; |
|
| 150 | + } |
|
| 151 | 151 | } |