@@ -23,18 +23,18 @@ |
||
23 | 23 | * |
24 | 24 | */ |
25 | 25 | |
26 | -require_once __DIR__ . '/../lib/versioncheck.php'; |
|
27 | -require_once __DIR__ . '/../lib/base.php'; |
|
26 | +require_once __DIR__.'/../lib/versioncheck.php'; |
|
27 | +require_once __DIR__.'/../lib/base.php'; |
|
28 | 28 | |
29 | 29 | header('Content-type: application/xml'); |
30 | 30 | |
31 | 31 | $request = \OC::$server->getRequest(); |
32 | 32 | |
33 | -$url = $request->getServerProtocol() . '://' . substr($request->getServerHost() . $request->getRequestUri(), 0, -17).'ocs/v1.php/'; |
|
33 | +$url = $request->getServerProtocol().'://'.substr($request->getServerHost().$request->getRequestUri(), 0, -17).'ocs/v1.php/'; |
|
34 | 34 | |
35 | 35 | $writer = new XMLWriter(); |
36 | 36 | $writer->openURI('php://output'); |
37 | -$writer->startDocument('1.0','UTF-8'); |
|
37 | +$writer->startDocument('1.0', 'UTF-8'); |
|
38 | 38 | $writer->setIndent(true); |
39 | 39 | $writer->startElement('providers'); |
40 | 40 | $writer->startElement('provider'); |
@@ -27,17 +27,17 @@ |
||
27 | 27 | * @since 13.0.0 |
28 | 28 | */ |
29 | 29 | interface ICachedMountFileInfo extends ICachedMountInfo { |
30 | - /** |
|
31 | - * Return the path for the file within the cached mount |
|
32 | - * |
|
33 | - * @return string |
|
34 | - * @since 13.0.0 |
|
35 | - */ |
|
36 | - public function getInternalPath(); |
|
30 | + /** |
|
31 | + * Return the path for the file within the cached mount |
|
32 | + * |
|
33 | + * @return string |
|
34 | + * @since 13.0.0 |
|
35 | + */ |
|
36 | + public function getInternalPath(); |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return string |
|
40 | - * @since 13.0.0 |
|
41 | - */ |
|
42 | - public function getPath(); |
|
38 | + /** |
|
39 | + * @return string |
|
40 | + * @since 13.0.0 |
|
41 | + */ |
|
42 | + public function getPath(); |
|
43 | 43 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | * @inheritdoc |
30 | 30 | */ |
31 | 31 | public function like($x, $y, $type = null) { |
32 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
32 | + return parent::like($x, $y, $type)." ESCAPE '\\'"; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function iLike($x, $y, $type = null) { |
@@ -24,14 +24,14 @@ |
||
24 | 24 | namespace OC\DB\QueryBuilder\ExpressionBuilder; |
25 | 25 | |
26 | 26 | class SqliteExpressionBuilder extends ExpressionBuilder { |
27 | - /** |
|
28 | - * @inheritdoc |
|
29 | - */ |
|
30 | - public function like($x, $y, $type = null) { |
|
31 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
32 | - } |
|
27 | + /** |
|
28 | + * @inheritdoc |
|
29 | + */ |
|
30 | + public function like($x, $y, $type = null) { |
|
31 | + return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
32 | + } |
|
33 | 33 | |
34 | - public function iLike($x, $y, $type = null) { |
|
35 | - return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y), $type); |
|
36 | - } |
|
34 | + public function iLike($x, $y, $type = null) { |
|
35 | + return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y), $type); |
|
36 | + } |
|
37 | 37 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | try { |
72 | 72 | $mount = $this->globalService->getStorage($mountId); |
73 | 73 | } catch (NotFoundException $e) { |
74 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
74 | + $output->writeln('<error>Mount with id "'.$mountId.' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
75 | 75 | return 404; |
76 | 76 | } |
77 | 77 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | foreach ($configInput as $configOption) { |
107 | 107 | if (!strpos($configOption, '=')) { |
108 | - $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>'); |
|
108 | + $output->writeln('<error>Invalid mount configuration option "'.$configOption.'"</error>'); |
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 | list($key, $value) = explode('=', $configOption, 2); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | // FIXME: convert storage exceptions to StorageNotAvailableException |
138 | 138 | $storage->setStatus( |
139 | 139 | StorageNotAvailableException::STATUS_ERROR, |
140 | - get_class($e) . ': ' . $e->getMessage() |
|
140 | + get_class($e).': '.$e->getMessage() |
|
141 | 141 | ); |
142 | 142 | } |
143 | 143 | } |
@@ -38,109 +38,109 @@ |
||
38 | 38 | use Symfony\Component\Console\Output\OutputInterface; |
39 | 39 | |
40 | 40 | class Verify extends Base { |
41 | - /** |
|
42 | - * @var GlobalStoragesService |
|
43 | - */ |
|
44 | - protected $globalService; |
|
41 | + /** |
|
42 | + * @var GlobalStoragesService |
|
43 | + */ |
|
44 | + protected $globalService; |
|
45 | 45 | |
46 | - public function __construct(GlobalStoragesService $globalService) { |
|
47 | - parent::__construct(); |
|
48 | - $this->globalService = $globalService; |
|
49 | - } |
|
46 | + public function __construct(GlobalStoragesService $globalService) { |
|
47 | + parent::__construct(); |
|
48 | + $this->globalService = $globalService; |
|
49 | + } |
|
50 | 50 | |
51 | - protected function configure() { |
|
52 | - $this |
|
53 | - ->setName('files_external:verify') |
|
54 | - ->setDescription('Verify mount configuration') |
|
55 | - ->addArgument( |
|
56 | - 'mount_id', |
|
57 | - InputArgument::REQUIRED, |
|
58 | - 'The id of the mount to check' |
|
59 | - )->addOption( |
|
60 | - 'config', |
|
61 | - 'c', |
|
62 | - InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
|
63 | - 'Additional config option to set before checking in key=value pairs, required for certain auth backends such as login credentails' |
|
64 | - ); |
|
65 | - parent::configure(); |
|
66 | - } |
|
51 | + protected function configure() { |
|
52 | + $this |
|
53 | + ->setName('files_external:verify') |
|
54 | + ->setDescription('Verify mount configuration') |
|
55 | + ->addArgument( |
|
56 | + 'mount_id', |
|
57 | + InputArgument::REQUIRED, |
|
58 | + 'The id of the mount to check' |
|
59 | + )->addOption( |
|
60 | + 'config', |
|
61 | + 'c', |
|
62 | + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
|
63 | + 'Additional config option to set before checking in key=value pairs, required for certain auth backends such as login credentails' |
|
64 | + ); |
|
65 | + parent::configure(); |
|
66 | + } |
|
67 | 67 | |
68 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
69 | - $mountId = $input->getArgument('mount_id'); |
|
70 | - $configInput = $input->getOption('config'); |
|
68 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
69 | + $mountId = $input->getArgument('mount_id'); |
|
70 | + $configInput = $input->getOption('config'); |
|
71 | 71 | |
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 | - } |
|
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 | - $this->updateStorageStatus($mount, $configInput, $output); |
|
79 | + $this->updateStorageStatus($mount, $configInput, $output); |
|
80 | 80 | |
81 | - $this->writeArrayInOutputFormat($input, $output, [ |
|
82 | - 'status' => StorageNotAvailableException::getStateCodeName($mount->getStatus()), |
|
83 | - 'code' => $mount->getStatus(), |
|
84 | - 'message' => $mount->getStatusMessage() |
|
85 | - ]); |
|
86 | - return 0; |
|
87 | - } |
|
81 | + $this->writeArrayInOutputFormat($input, $output, [ |
|
82 | + 'status' => StorageNotAvailableException::getStateCodeName($mount->getStatus()), |
|
83 | + 'code' => $mount->getStatus(), |
|
84 | + 'message' => $mount->getStatusMessage() |
|
85 | + ]); |
|
86 | + return 0; |
|
87 | + } |
|
88 | 88 | |
89 | - private function manipulateStorageConfig(StorageConfig $storage) { |
|
90 | - /** @var AuthMechanism */ |
|
91 | - $authMechanism = $storage->getAuthMechanism(); |
|
92 | - $authMechanism->manipulateStorageConfig($storage); |
|
93 | - /** @var Backend */ |
|
94 | - $backend = $storage->getBackend(); |
|
95 | - $backend->manipulateStorageConfig($storage); |
|
96 | - } |
|
89 | + private function manipulateStorageConfig(StorageConfig $storage) { |
|
90 | + /** @var AuthMechanism */ |
|
91 | + $authMechanism = $storage->getAuthMechanism(); |
|
92 | + $authMechanism->manipulateStorageConfig($storage); |
|
93 | + /** @var Backend */ |
|
94 | + $backend = $storage->getBackend(); |
|
95 | + $backend->manipulateStorageConfig($storage); |
|
96 | + } |
|
97 | 97 | |
98 | - private function updateStorageStatus(StorageConfig &$storage, $configInput, OutputInterface $output) { |
|
99 | - try { |
|
100 | - try { |
|
101 | - $this->manipulateStorageConfig($storage); |
|
102 | - } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
103 | - if (count($configInput) === 0) { // extra config options might solve the error |
|
104 | - throw $e; |
|
105 | - } |
|
106 | - } |
|
98 | + private function updateStorageStatus(StorageConfig &$storage, $configInput, OutputInterface $output) { |
|
99 | + try { |
|
100 | + try { |
|
101 | + $this->manipulateStorageConfig($storage); |
|
102 | + } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
103 | + if (count($configInput) === 0) { // extra config options might solve the error |
|
104 | + throw $e; |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - foreach ($configInput as $configOption) { |
|
109 | - if (!strpos($configOption, '=')) { |
|
110 | - $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>'); |
|
111 | - return; |
|
112 | - } |
|
113 | - list($key, $value) = explode('=', $configOption, 2); |
|
114 | - $storage->setBackendOption($key, $value); |
|
115 | - } |
|
108 | + foreach ($configInput as $configOption) { |
|
109 | + if (!strpos($configOption, '=')) { |
|
110 | + $output->writeln('<error>Invalid mount configuration option "' . $configOption . '"</error>'); |
|
111 | + return; |
|
112 | + } |
|
113 | + list($key, $value) = explode('=', $configOption, 2); |
|
114 | + $storage->setBackendOption($key, $value); |
|
115 | + } |
|
116 | 116 | |
117 | - /** @var Backend */ |
|
118 | - $backend = $storage->getBackend(); |
|
119 | - // update status (can be time-consuming) |
|
120 | - $storage->setStatus( |
|
121 | - \OCA\Files_External\MountConfig::getBackendStatus( |
|
122 | - $backend->getStorageClass(), |
|
123 | - $storage->getBackendOptions(), |
|
124 | - false |
|
125 | - ) |
|
126 | - ); |
|
127 | - } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
128 | - $status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE; |
|
129 | - $storage->setStatus( |
|
130 | - $status, |
|
131 | - $e->getMessage() |
|
132 | - ); |
|
133 | - } catch (StorageNotAvailableException $e) { |
|
134 | - $storage->setStatus( |
|
135 | - $e->getCode(), |
|
136 | - $e->getMessage() |
|
137 | - ); |
|
138 | - } catch (\Exception $e) { |
|
139 | - // FIXME: convert storage exceptions to StorageNotAvailableException |
|
140 | - $storage->setStatus( |
|
141 | - StorageNotAvailableException::STATUS_ERROR, |
|
142 | - get_class($e) . ': ' . $e->getMessage() |
|
143 | - ); |
|
144 | - } |
|
145 | - } |
|
117 | + /** @var Backend */ |
|
118 | + $backend = $storage->getBackend(); |
|
119 | + // update status (can be time-consuming) |
|
120 | + $storage->setStatus( |
|
121 | + \OCA\Files_External\MountConfig::getBackendStatus( |
|
122 | + $backend->getStorageClass(), |
|
123 | + $storage->getBackendOptions(), |
|
124 | + false |
|
125 | + ) |
|
126 | + ); |
|
127 | + } catch (InsufficientDataForMeaningfulAnswerException $e) { |
|
128 | + $status = $e->getCode() ? $e->getCode() : StorageNotAvailableException::STATUS_INDETERMINATE; |
|
129 | + $storage->setStatus( |
|
130 | + $status, |
|
131 | + $e->getMessage() |
|
132 | + ); |
|
133 | + } catch (StorageNotAvailableException $e) { |
|
134 | + $storage->setStatus( |
|
135 | + $e->getCode(), |
|
136 | + $e->getMessage() |
|
137 | + ); |
|
138 | + } catch (\Exception $e) { |
|
139 | + // FIXME: convert storage exceptions to StorageNotAvailableException |
|
140 | + $storage->setStatus( |
|
141 | + StorageNotAvailableException::STATUS_ERROR, |
|
142 | + get_class($e) . ': ' . $e->getMessage() |
|
143 | + ); |
|
144 | + } |
|
145 | + } |
|
146 | 146 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $this |
50 | 50 | ->setIdentifier($invalidId) |
51 | 51 | ->setStorageClass('\OC\Files\Storage\FailedStorage') |
52 | - ->setText('Unknown storage backend ' . $invalidId); |
|
52 | + ->setText('Unknown storage backend '.$invalidId); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
65 | - $storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR)); |
|
65 | + $storage->setBackendOption('exception', new \Exception('Unknown storage backend "'.$this->invalidId.'"', StorageNotAvailableException::STATUS_ERROR)); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 |
@@ -34,33 +34,33 @@ |
||
34 | 34 | */ |
35 | 35 | class InvalidBackend extends Backend { |
36 | 36 | |
37 | - /** @var string Invalid backend id */ |
|
38 | - private $invalidId; |
|
37 | + /** @var string Invalid backend id */ |
|
38 | + private $invalidId; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Constructs a new InvalidBackend with the id of the invalid backend |
|
42 | - * for display purposes |
|
43 | - * |
|
44 | - * @param string $invalidId id of the backend that did not exist |
|
45 | - */ |
|
46 | - public function __construct($invalidId) { |
|
47 | - $this->invalidId = $invalidId; |
|
48 | - $this |
|
49 | - ->setIdentifier($invalidId) |
|
50 | - ->setStorageClass('\OC\Files\Storage\FailedStorage') |
|
51 | - ->setText('Unknown storage backend ' . $invalidId); |
|
52 | - } |
|
40 | + /** |
|
41 | + * Constructs a new InvalidBackend with the id of the invalid backend |
|
42 | + * for display purposes |
|
43 | + * |
|
44 | + * @param string $invalidId id of the backend that did not exist |
|
45 | + */ |
|
46 | + public function __construct($invalidId) { |
|
47 | + $this->invalidId = $invalidId; |
|
48 | + $this |
|
49 | + ->setIdentifier($invalidId) |
|
50 | + ->setStorageClass('\OC\Files\Storage\FailedStorage') |
|
51 | + ->setText('Unknown storage backend ' . $invalidId); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Returns the invalid backend id |
|
56 | - * |
|
57 | - * @return string invalid backend id |
|
58 | - */ |
|
59 | - public function getInvalidId() { |
|
60 | - return $this->invalidId; |
|
61 | - } |
|
54 | + /** |
|
55 | + * Returns the invalid backend id |
|
56 | + * |
|
57 | + * @return string invalid backend id |
|
58 | + */ |
|
59 | + public function getInvalidId() { |
|
60 | + return $this->invalidId; |
|
61 | + } |
|
62 | 62 | |
63 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
64 | - $storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR)); |
|
65 | - } |
|
63 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
64 | + $storage->setBackendOption('exception', new \Exception('Unknown storage backend "' . $this->invalidId . '"', StorageNotAvailableException::STATUS_ERROR)); |
|
65 | + } |
|
66 | 66 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | $username_as_share = ($storage->getBackendOption('username_as_share') === true); |
66 | 66 | |
67 | 67 | if ($username_as_share) { |
68 | - $share = '/' . $storage->getBackendOption('user'); |
|
68 | + $share = '/'.$storage->getBackendOption('user'); |
|
69 | 69 | $storage->setBackendOption('share', $share); |
70 | 70 | } |
71 | 71 | } |
@@ -37,35 +37,35 @@ |
||
37 | 37 | * Deprecated SMB_OC class - use SMB with the password::sessioncredentials auth mechanism |
38 | 38 | */ |
39 | 39 | class SMB_OC extends Backend { |
40 | - use LegacyDependencyCheckPolyfill; |
|
40 | + use LegacyDependencyCheckPolyfill; |
|
41 | 41 | |
42 | - public function __construct(IL10N $l, SessionCredentials $legacyAuth, SMB $smbBackend) { |
|
43 | - $this |
|
44 | - ->setIdentifier('\OC\Files\Storage\SMB_OC') |
|
45 | - ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB') |
|
46 | - ->setText($l->t('SMB / CIFS using OC login')) |
|
47 | - ->addParameters([ |
|
48 | - new DefinitionParameter('host', $l->t('Host')), |
|
49 | - (new DefinitionParameter('username_as_share', $l->t('Username as share'))) |
|
50 | - ->setType(DefinitionParameter::VALUE_BOOLEAN), |
|
51 | - (new DefinitionParameter('share', $l->t('Share'))) |
|
52 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
53 | - (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
54 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
55 | - ]) |
|
56 | - ->setPriority(BackendService::PRIORITY_DEFAULT - 10) |
|
57 | - ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
58 | - ->setLegacyAuthMechanism($legacyAuth) |
|
59 | - ->deprecateTo($smbBackend) |
|
60 | - ; |
|
61 | - } |
|
42 | + public function __construct(IL10N $l, SessionCredentials $legacyAuth, SMB $smbBackend) { |
|
43 | + $this |
|
44 | + ->setIdentifier('\OC\Files\Storage\SMB_OC') |
|
45 | + ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB') |
|
46 | + ->setText($l->t('SMB / CIFS using OC login')) |
|
47 | + ->addParameters([ |
|
48 | + new DefinitionParameter('host', $l->t('Host')), |
|
49 | + (new DefinitionParameter('username_as_share', $l->t('Username as share'))) |
|
50 | + ->setType(DefinitionParameter::VALUE_BOOLEAN), |
|
51 | + (new DefinitionParameter('share', $l->t('Share'))) |
|
52 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
53 | + (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
54 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
55 | + ]) |
|
56 | + ->setPriority(BackendService::PRIORITY_DEFAULT - 10) |
|
57 | + ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
58 | + ->setLegacyAuthMechanism($legacyAuth) |
|
59 | + ->deprecateTo($smbBackend) |
|
60 | + ; |
|
61 | + } |
|
62 | 62 | |
63 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
64 | - $username_as_share = ($storage->getBackendOption('username_as_share') === true); |
|
63 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
64 | + $username_as_share = ($storage->getBackendOption('username_as_share') === true); |
|
65 | 65 | |
66 | - if ($username_as_share) { |
|
67 | - $share = '/' . $storage->getBackendOption('user'); |
|
68 | - $storage->setBackendOption('share', $share); |
|
69 | - } |
|
70 | - } |
|
66 | + if ($username_as_share) { |
|
67 | + $share = '/' . $storage->getBackendOption('user'); |
|
68 | + $storage->setBackendOption('share', $share); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
@@ -122,7 +122,7 @@ |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | $eventName = $addToFavorite ? 'addFavorite' : 'removeFavorite'; |
125 | - $this->dispatcher->dispatch(self::class . '::' . $eventName, new GenericEvent(null, [ |
|
125 | + $this->dispatcher->dispatch(self::class.'::'.$eventName, new GenericEvent(null, [ |
|
126 | 126 | 'userId' => $user->getUID(), |
127 | 127 | 'fileId' => $fileId, |
128 | 128 | 'path' => $path, |
@@ -38,110 +38,110 @@ |
||
38 | 38 | */ |
39 | 39 | class TagService { |
40 | 40 | |
41 | - /** @var IUserSession */ |
|
42 | - private $userSession; |
|
43 | - /** @var IManager */ |
|
44 | - private $activityManager; |
|
45 | - /** @var ITags */ |
|
46 | - private $tagger; |
|
47 | - /** @var Folder */ |
|
48 | - private $homeFolder; |
|
49 | - /** @var EventDispatcherInterface */ |
|
50 | - private $dispatcher; |
|
41 | + /** @var IUserSession */ |
|
42 | + private $userSession; |
|
43 | + /** @var IManager */ |
|
44 | + private $activityManager; |
|
45 | + /** @var ITags */ |
|
46 | + private $tagger; |
|
47 | + /** @var Folder */ |
|
48 | + private $homeFolder; |
|
49 | + /** @var EventDispatcherInterface */ |
|
50 | + private $dispatcher; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param IUserSession $userSession |
|
54 | - * @param IManager $activityManager |
|
55 | - * @param ITags $tagger |
|
56 | - * @param Folder $homeFolder |
|
57 | - * @param EventDispatcherInterface $dispatcher |
|
58 | - */ |
|
59 | - public function __construct( |
|
60 | - IUserSession $userSession, |
|
61 | - IManager $activityManager, |
|
62 | - ITags $tagger, |
|
63 | - Folder $homeFolder, |
|
64 | - EventDispatcherInterface $dispatcher |
|
65 | - ) { |
|
66 | - $this->userSession = $userSession; |
|
67 | - $this->activityManager = $activityManager; |
|
68 | - $this->tagger = $tagger; |
|
69 | - $this->homeFolder = $homeFolder; |
|
70 | - $this->dispatcher = $dispatcher; |
|
71 | - } |
|
52 | + /** |
|
53 | + * @param IUserSession $userSession |
|
54 | + * @param IManager $activityManager |
|
55 | + * @param ITags $tagger |
|
56 | + * @param Folder $homeFolder |
|
57 | + * @param EventDispatcherInterface $dispatcher |
|
58 | + */ |
|
59 | + public function __construct( |
|
60 | + IUserSession $userSession, |
|
61 | + IManager $activityManager, |
|
62 | + ITags $tagger, |
|
63 | + Folder $homeFolder, |
|
64 | + EventDispatcherInterface $dispatcher |
|
65 | + ) { |
|
66 | + $this->userSession = $userSession; |
|
67 | + $this->activityManager = $activityManager; |
|
68 | + $this->tagger = $tagger; |
|
69 | + $this->homeFolder = $homeFolder; |
|
70 | + $this->dispatcher = $dispatcher; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Updates the tags of the specified file path. |
|
75 | - * The passed tags are absolute, which means they will |
|
76 | - * replace the actual tag selection. |
|
77 | - * |
|
78 | - * @param string $path path |
|
79 | - * @param array $tags array of tags |
|
80 | - * @return array list of tags |
|
81 | - * @throws \OCP\Files\NotFoundException if the file does not exist |
|
82 | - */ |
|
83 | - public function updateFileTags($path, $tags) { |
|
84 | - $fileId = $this->homeFolder->get($path)->getId(); |
|
73 | + /** |
|
74 | + * Updates the tags of the specified file path. |
|
75 | + * The passed tags are absolute, which means they will |
|
76 | + * replace the actual tag selection. |
|
77 | + * |
|
78 | + * @param string $path path |
|
79 | + * @param array $tags array of tags |
|
80 | + * @return array list of tags |
|
81 | + * @throws \OCP\Files\NotFoundException if the file does not exist |
|
82 | + */ |
|
83 | + public function updateFileTags($path, $tags) { |
|
84 | + $fileId = $this->homeFolder->get($path)->getId(); |
|
85 | 85 | |
86 | - $currentTags = $this->tagger->getTagsForObjects([$fileId]); |
|
86 | + $currentTags = $this->tagger->getTagsForObjects([$fileId]); |
|
87 | 87 | |
88 | - if (!empty($currentTags)) { |
|
89 | - $currentTags = current($currentTags); |
|
90 | - } |
|
88 | + if (!empty($currentTags)) { |
|
89 | + $currentTags = current($currentTags); |
|
90 | + } |
|
91 | 91 | |
92 | - $newTags = array_diff($tags, $currentTags); |
|
93 | - foreach ($newTags as $tag) { |
|
94 | - if ($tag === ITags::TAG_FAVORITE) { |
|
95 | - $this->addActivity(true, $fileId, $path); |
|
96 | - } |
|
97 | - $this->tagger->tagAs($fileId, $tag); |
|
98 | - } |
|
99 | - $deletedTags = array_diff($currentTags, $tags); |
|
100 | - foreach ($deletedTags as $tag) { |
|
101 | - if ($tag === ITags::TAG_FAVORITE) { |
|
102 | - $this->addActivity(false, $fileId, $path); |
|
103 | - } |
|
104 | - $this->tagger->unTag($fileId, $tag); |
|
105 | - } |
|
92 | + $newTags = array_diff($tags, $currentTags); |
|
93 | + foreach ($newTags as $tag) { |
|
94 | + if ($tag === ITags::TAG_FAVORITE) { |
|
95 | + $this->addActivity(true, $fileId, $path); |
|
96 | + } |
|
97 | + $this->tagger->tagAs($fileId, $tag); |
|
98 | + } |
|
99 | + $deletedTags = array_diff($currentTags, $tags); |
|
100 | + foreach ($deletedTags as $tag) { |
|
101 | + if ($tag === ITags::TAG_FAVORITE) { |
|
102 | + $this->addActivity(false, $fileId, $path); |
|
103 | + } |
|
104 | + $this->tagger->unTag($fileId, $tag); |
|
105 | + } |
|
106 | 106 | |
107 | - // TODO: re-read from tagger to make sure the |
|
108 | - // list is up to date, in case of concurrent changes ? |
|
109 | - return $tags; |
|
110 | - } |
|
107 | + // TODO: re-read from tagger to make sure the |
|
108 | + // list is up to date, in case of concurrent changes ? |
|
109 | + return $tags; |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * @param bool $addToFavorite |
|
114 | - * @param int $fileId |
|
115 | - * @param string $path |
|
116 | - */ |
|
117 | - protected function addActivity($addToFavorite, $fileId, $path) { |
|
118 | - $user = $this->userSession->getUser(); |
|
119 | - if (!$user instanceof IUser) { |
|
120 | - return; |
|
121 | - } |
|
112 | + /** |
|
113 | + * @param bool $addToFavorite |
|
114 | + * @param int $fileId |
|
115 | + * @param string $path |
|
116 | + */ |
|
117 | + protected function addActivity($addToFavorite, $fileId, $path) { |
|
118 | + $user = $this->userSession->getUser(); |
|
119 | + if (!$user instanceof IUser) { |
|
120 | + return; |
|
121 | + } |
|
122 | 122 | |
123 | - $eventName = $addToFavorite ? 'addFavorite' : 'removeFavorite'; |
|
124 | - $this->dispatcher->dispatch(self::class . '::' . $eventName, new GenericEvent(null, [ |
|
125 | - 'userId' => $user->getUID(), |
|
126 | - 'fileId' => $fileId, |
|
127 | - 'path' => $path, |
|
128 | - ])); |
|
123 | + $eventName = $addToFavorite ? 'addFavorite' : 'removeFavorite'; |
|
124 | + $this->dispatcher->dispatch(self::class . '::' . $eventName, new GenericEvent(null, [ |
|
125 | + 'userId' => $user->getUID(), |
|
126 | + 'fileId' => $fileId, |
|
127 | + 'path' => $path, |
|
128 | + ])); |
|
129 | 129 | |
130 | - $event = $this->activityManager->generateEvent(); |
|
131 | - try { |
|
132 | - $event->setApp('files') |
|
133 | - ->setObject('files', $fileId, $path) |
|
134 | - ->setType('favorite') |
|
135 | - ->setAuthor($user->getUID()) |
|
136 | - ->setAffectedUser($user->getUID()) |
|
137 | - ->setTimestamp(time()) |
|
138 | - ->setSubject( |
|
139 | - $addToFavorite ? FavoriteProvider::SUBJECT_ADDED : FavoriteProvider::SUBJECT_REMOVED, |
|
140 | - ['id' => $fileId, 'path' => $path] |
|
141 | - ); |
|
142 | - $this->activityManager->publish($event); |
|
143 | - } catch (\InvalidArgumentException $e) { |
|
144 | - } catch (\BadMethodCallException $e) { |
|
145 | - } |
|
146 | - } |
|
130 | + $event = $this->activityManager->generateEvent(); |
|
131 | + try { |
|
132 | + $event->setApp('files') |
|
133 | + ->setObject('files', $fileId, $path) |
|
134 | + ->setType('favorite') |
|
135 | + ->setAuthor($user->getUID()) |
|
136 | + ->setAffectedUser($user->getUID()) |
|
137 | + ->setTimestamp(time()) |
|
138 | + ->setSubject( |
|
139 | + $addToFavorite ? FavoriteProvider::SUBJECT_ADDED : FavoriteProvider::SUBJECT_REMOVED, |
|
140 | + ['id' => $fileId, 'path' => $path] |
|
141 | + ); |
|
142 | + $this->activityManager->publish($event); |
|
143 | + } catch (\InvalidArgumentException $e) { |
|
144 | + } catch (\BadMethodCallException $e) { |
|
145 | + } |
|
146 | + } |
|
147 | 147 | } |
@@ -29,53 +29,53 @@ |
||
29 | 29 | |
30 | 30 | class Mount extends MountPoint implements MoveableMount { |
31 | 31 | |
32 | - /** |
|
33 | - * @var \OCA\Files_Sharing\External\Manager |
|
34 | - */ |
|
35 | - protected $manager; |
|
32 | + /** |
|
33 | + * @var \OCA\Files_Sharing\External\Manager |
|
34 | + */ |
|
35 | + protected $manager; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param string|\OC\Files\Storage\Storage $storage |
|
39 | - * @param string $mountpoint |
|
40 | - * @param array $options |
|
41 | - * @param \OCA\Files_Sharing\External\Manager $manager |
|
42 | - * @param \OC\Files\Storage\StorageFactory $loader |
|
43 | - */ |
|
44 | - public function __construct($storage, $mountpoint, $options, $manager, $loader = null) { |
|
45 | - parent::__construct($storage, $mountpoint, $options, $loader); |
|
46 | - $this->manager = $manager; |
|
47 | - } |
|
37 | + /** |
|
38 | + * @param string|\OC\Files\Storage\Storage $storage |
|
39 | + * @param string $mountpoint |
|
40 | + * @param array $options |
|
41 | + * @param \OCA\Files_Sharing\External\Manager $manager |
|
42 | + * @param \OC\Files\Storage\StorageFactory $loader |
|
43 | + */ |
|
44 | + public function __construct($storage, $mountpoint, $options, $manager, $loader = null) { |
|
45 | + parent::__construct($storage, $mountpoint, $options, $loader); |
|
46 | + $this->manager = $manager; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Move the mount point to $target |
|
51 | - * |
|
52 | - * @param string $target the target mount point |
|
53 | - * @return bool |
|
54 | - */ |
|
55 | - public function moveMount($target) { |
|
56 | - $result = $this->manager->setMountPoint($this->mountPoint, $target); |
|
57 | - $this->setMountPoint($target); |
|
49 | + /** |
|
50 | + * Move the mount point to $target |
|
51 | + * |
|
52 | + * @param string $target the target mount point |
|
53 | + * @return bool |
|
54 | + */ |
|
55 | + public function moveMount($target) { |
|
56 | + $result = $this->manager->setMountPoint($this->mountPoint, $target); |
|
57 | + $this->setMountPoint($target); |
|
58 | 58 | |
59 | - return $result; |
|
60 | - } |
|
59 | + return $result; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Remove the mount points |
|
64 | - * |
|
65 | - * @return mixed |
|
66 | - * @return bool |
|
67 | - */ |
|
68 | - public function removeMount() { |
|
69 | - return $this->manager->removeShare($this->mountPoint); |
|
70 | - } |
|
62 | + /** |
|
63 | + * Remove the mount points |
|
64 | + * |
|
65 | + * @return mixed |
|
66 | + * @return bool |
|
67 | + */ |
|
68 | + public function removeMount() { |
|
69 | + return $this->manager->removeShare($this->mountPoint); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Get the type of mount point, used to distinguish things like shares and external storages |
|
74 | - * in the web interface |
|
75 | - * |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function getMountType() { |
|
79 | - return 'shared'; |
|
80 | - } |
|
72 | + /** |
|
73 | + * Get the type of mount point, used to distinguish things like shares and external storages |
|
74 | + * in the web interface |
|
75 | + * |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function getMountType() { |
|
79 | + return 'shared'; |
|
80 | + } |
|
81 | 81 | } |
@@ -33,26 +33,26 @@ |
||
33 | 33 | * @package OC\Security\RateLimiting\Backend |
34 | 34 | */ |
35 | 35 | interface IBackend { |
36 | - /** |
|
37 | - * Gets the amount of attempts within the last specified seconds |
|
38 | - * |
|
39 | - * @param string $methodIdentifier Identifier for the method |
|
40 | - * @param string $userIdentifier Identifier for the user |
|
41 | - * @param int $seconds Seconds to look back at |
|
42 | - * @return int |
|
43 | - */ |
|
44 | - public function getAttempts(string $methodIdentifier, |
|
45 | - string $userIdentifier, |
|
46 | - int $seconds): int; |
|
36 | + /** |
|
37 | + * Gets the amount of attempts within the last specified seconds |
|
38 | + * |
|
39 | + * @param string $methodIdentifier Identifier for the method |
|
40 | + * @param string $userIdentifier Identifier for the user |
|
41 | + * @param int $seconds Seconds to look back at |
|
42 | + * @return int |
|
43 | + */ |
|
44 | + public function getAttempts(string $methodIdentifier, |
|
45 | + string $userIdentifier, |
|
46 | + int $seconds): int; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Registers an attempt |
|
50 | - * |
|
51 | - * @param string $methodIdentifier Identifier for the method |
|
52 | - * @param string $userIdentifier Identifier for the user |
|
53 | - * @param int $period Period in seconds how long this attempt should be stored |
|
54 | - */ |
|
55 | - public function registerAttempt(string $methodIdentifier, |
|
56 | - string $userIdentifier, |
|
57 | - int $period); |
|
48 | + /** |
|
49 | + * Registers an attempt |
|
50 | + * |
|
51 | + * @param string $methodIdentifier Identifier for the method |
|
52 | + * @param string $userIdentifier Identifier for the user |
|
53 | + * @param int $period Period in seconds how long this attempt should be stored |
|
54 | + */ |
|
55 | + public function registerAttempt(string $methodIdentifier, |
|
56 | + string $userIdentifier, |
|
57 | + int $period); |
|
58 | 58 | } |