@@ -32,40 +32,40 @@ |
||
32 | 32 | */ |
33 | 33 | trait RotationTrait { |
34 | 34 | |
35 | - /** |
|
36 | - * @var string |
|
37 | - * @since 14.0.0 |
|
38 | - */ |
|
39 | - protected $filePath; |
|
35 | + /** |
|
36 | + * @var string |
|
37 | + * @since 14.0.0 |
|
38 | + */ |
|
39 | + protected $filePath; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var int |
|
43 | - * @since 14.0.0 |
|
44 | - */ |
|
45 | - protected $maxSize; |
|
41 | + /** |
|
42 | + * @var int |
|
43 | + * @since 14.0.0 |
|
44 | + */ |
|
45 | + protected $maxSize; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @return string the resulting new filepath |
|
49 | - * @since 14.0.0 |
|
50 | - */ |
|
51 | - protected function rotate():string { |
|
52 | - $rotatedFile = $this->filePath.'.1'; |
|
53 | - rename($this->filePath, $rotatedFile); |
|
54 | - return $rotatedFile; |
|
55 | - } |
|
47 | + /** |
|
48 | + * @return string the resulting new filepath |
|
49 | + * @since 14.0.0 |
|
50 | + */ |
|
51 | + protected function rotate():string { |
|
52 | + $rotatedFile = $this->filePath.'.1'; |
|
53 | + rename($this->filePath, $rotatedFile); |
|
54 | + return $rotatedFile; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return bool |
|
59 | - * @since 14.0.0 |
|
60 | - */ |
|
61 | - protected function shouldRotateBySize():bool { |
|
62 | - if ((int)$this->maxSize > 0) { |
|
63 | - $filesize = @filesize($this->filePath); |
|
64 | - if ($filesize >= (int)$this->maxSize) { |
|
65 | - return true; |
|
66 | - } |
|
67 | - } |
|
68 | - return false; |
|
69 | - } |
|
57 | + /** |
|
58 | + * @return bool |
|
59 | + * @since 14.0.0 |
|
60 | + */ |
|
61 | + protected function shouldRotateBySize():bool { |
|
62 | + if ((int)$this->maxSize > 0) { |
|
63 | + $filesize = @filesize($this->filePath); |
|
64 | + if ($filesize >= (int)$this->maxSize) { |
|
65 | + return true; |
|
66 | + } |
|
67 | + } |
|
68 | + return false; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | } |
@@ -59,9 +59,9 @@ |
||
59 | 59 | * @since 14.0.0 |
60 | 60 | */ |
61 | 61 | protected function shouldRotateBySize():bool { |
62 | - if ((int)$this->maxSize > 0) { |
|
62 | + if ((int) $this->maxSize > 0) { |
|
63 | 63 | $filesize = @filesize($this->filePath); |
64 | - if ($filesize >= (int)$this->maxSize) { |
|
64 | + if ($filesize >= (int) $this->maxSize) { |
|
65 | 65 | return true; |
66 | 66 | } |
67 | 67 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | |
22 | 22 | |
23 | -require_once __DIR__ . '/../lib/base.php'; |
|
23 | +require_once __DIR__.'/../lib/base.php'; |
|
24 | 24 | |
25 | 25 | header('Content-Type: application/json'); |
26 | 26 |
@@ -29,12 +29,12 @@ |
||
29 | 29 | $isEnabled = $server->getAppManager()->isEnabledForUser('cloud_federation_api'); |
30 | 30 | |
31 | 31 | if ($isEnabled) { |
32 | - // Make sure the routes are loaded |
|
33 | - \OC_App::loadApp('cloud_federation_api'); |
|
34 | - $capabilities = new OCA\CloudFederationAPI\Capabilities($server->getURLGenerator()); |
|
35 | - header('Content-Type: application/json'); |
|
36 | - echo json_encode($capabilities->getCapabilities()['ocm']); |
|
32 | + // Make sure the routes are loaded |
|
33 | + \OC_App::loadApp('cloud_federation_api'); |
|
34 | + $capabilities = new OCA\CloudFederationAPI\Capabilities($server->getURLGenerator()); |
|
35 | + header('Content-Type: application/json'); |
|
36 | + echo json_encode($capabilities->getCapabilities()['ocm']); |
|
37 | 37 | } else { |
38 | - header($_SERVER["SERVER_PROTOCOL"]." 501 Not Implemented", true, 501); |
|
39 | - exit("501 Not Implemented"); |
|
38 | + header($_SERVER["SERVER_PROTOCOL"]." 501 Not Implemented", true, 501); |
|
39 | + exit("501 Not Implemented"); |
|
40 | 40 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | */ |
33 | 33 | public function __construct($providerId) { |
34 | 34 | $l = \OC::$server->getL10N('federation'); |
35 | - $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.'; |
|
35 | + $message = 'Cloud Federation Provider with ID: "'.$providerId.'" does not exist.'; |
|
36 | 36 | $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]); |
37 | 37 | parent::__construct($message, $hint); |
38 | 38 | } |
@@ -32,18 +32,18 @@ |
||
32 | 32 | */ |
33 | 33 | class ProviderDoesNotExistsException extends HintException { |
34 | 34 | |
35 | - /** |
|
36 | - * ProviderDoesNotExistsException constructor. |
|
37 | - * |
|
38 | - * @since 14.0.0 |
|
39 | - * |
|
40 | - * @param string $providerId cloud federation provider ID |
|
41 | - */ |
|
42 | - public function __construct($providerId) { |
|
43 | - $l = \OC::$server->getL10N('federation'); |
|
44 | - $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.'; |
|
45 | - $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]); |
|
46 | - parent::__construct($message, $hint); |
|
47 | - } |
|
35 | + /** |
|
36 | + * ProviderDoesNotExistsException constructor. |
|
37 | + * |
|
38 | + * @since 14.0.0 |
|
39 | + * |
|
40 | + * @param string $providerId cloud federation provider ID |
|
41 | + */ |
|
42 | + public function __construct($providerId) { |
|
43 | + $l = \OC::$server->getL10N('federation'); |
|
44 | + $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.'; |
|
45 | + $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]); |
|
46 | + parent::__construct($message, $hint); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $appName = $input->getArgument('app'); |
114 | 114 | $version = $input->getArgument('version'); |
115 | 115 | |
116 | - if (!preg_match('/^\d{1,16}$/',$version)) { |
|
116 | + if (!preg_match('/^\d{1,16}$/', $version)) { |
|
117 | 117 | $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
118 | 118 | return 1; |
119 | 119 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
122 | 122 | |
123 | 123 | $date = date('YmdHis'); |
124 | - $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date); |
|
124 | + $path = $this->generateMigration($ms, 'Version'.$version.'Date'.$date); |
|
125 | 125 | |
126 | 126 | $output->writeln("New migration class has been generated to <info>$path</info>"); |
127 | 127 | return 0; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
152 | 152 | |
153 | 153 | $version = explode('.', $this->appManager->getAppVersion($appName)); |
154 | - return [$version[0] . sprintf('%1$03d', $version[1])]; |
|
154 | + return [$version[0].sprintf('%1$03d', $version[1])]; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return []; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | protected function generateMigration(MigrationService $ms, $className, $schemaBody = '') { |
167 | 167 | if ($schemaBody === '') { |
168 | - $schemaBody = "\t\t" . 'return null;'; |
|
168 | + $schemaBody = "\t\t".'return null;'; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $dir = $ms->getMigrationsDirectory(); |
184 | 184 | |
185 | 185 | $this->ensureMigrationDirExists($dir); |
186 | - $path = $dir . '/' . $className . '.php'; |
|
186 | + $path = $dir.'/'.$className.'.php'; |
|
187 | 187 | |
188 | 188 | if (file_put_contents($path, $code) === false) { |
189 | 189 | throw new RuntimeException('Failed to generate new migration step.'); |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | use Symfony\Component\Console\Output\OutputInterface; |
39 | 39 | |
40 | 40 | class GenerateCommand extends Command implements CompletionAwareInterface { |
41 | - protected static $_templateSimple = |
|
42 | - '<?php |
|
41 | + protected static $_templateSimple = |
|
42 | + '<?php |
|
43 | 43 | |
44 | 44 | declare(strict_types=1); |
45 | 45 | |
@@ -83,129 +83,129 @@ discard block |
||
83 | 83 | } |
84 | 84 | '; |
85 | 85 | |
86 | - /** @var Connection */ |
|
87 | - protected $connection; |
|
88 | - |
|
89 | - /** @var IAppManager */ |
|
90 | - protected $appManager; |
|
91 | - |
|
92 | - /** |
|
93 | - * @param Connection $connection |
|
94 | - * @param IAppManager $appManager |
|
95 | - */ |
|
96 | - public function __construct(Connection $connection, IAppManager $appManager) { |
|
97 | - $this->connection = $connection; |
|
98 | - $this->appManager = $appManager; |
|
99 | - |
|
100 | - parent::__construct(); |
|
101 | - } |
|
102 | - |
|
103 | - protected function configure() { |
|
104 | - $this |
|
105 | - ->setName('migrations:generate') |
|
106 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
107 | - ->addArgument('version', InputArgument::REQUIRED, 'Major version of this app, to allow versions on parallel development branches') |
|
108 | - ; |
|
109 | - |
|
110 | - parent::configure(); |
|
111 | - } |
|
112 | - |
|
113 | - public function execute(InputInterface $input, OutputInterface $output): int { |
|
114 | - $appName = $input->getArgument('app'); |
|
115 | - $version = $input->getArgument('version'); |
|
116 | - |
|
117 | - if (!preg_match('/^\d{1,16}$/',$version)) { |
|
118 | - $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
|
119 | - return 1; |
|
120 | - } |
|
121 | - |
|
122 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
123 | - |
|
124 | - $date = date('YmdHis'); |
|
125 | - $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date); |
|
126 | - |
|
127 | - $output->writeln("New migration class has been generated to <info>$path</info>"); |
|
128 | - return 0; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * @param string $optionName |
|
133 | - * @param CompletionContext $context |
|
134 | - * @return string[] |
|
135 | - */ |
|
136 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
137 | - return []; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @param string $argumentName |
|
142 | - * @param CompletionContext $context |
|
143 | - * @return string[] |
|
144 | - */ |
|
145 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
146 | - if ($argumentName === 'app') { |
|
147 | - $allApps = \OC_App::getAllApps(); |
|
148 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
149 | - } |
|
150 | - |
|
151 | - if ($argumentName === 'version') { |
|
152 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
153 | - |
|
154 | - $version = explode('.', $this->appManager->getAppVersion($appName)); |
|
155 | - return [$version[0] . sprintf('%1$03d', $version[1])]; |
|
156 | - } |
|
157 | - |
|
158 | - return []; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @param MigrationService $ms |
|
163 | - * @param string $className |
|
164 | - * @param string $schemaBody |
|
165 | - * @return string |
|
166 | - */ |
|
167 | - protected function generateMigration(MigrationService $ms, $className, $schemaBody = '') { |
|
168 | - if ($schemaBody === '') { |
|
169 | - $schemaBody = "\t\t" . 'return null;'; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - $placeHolders = [ |
|
174 | - '{{namespace}}', |
|
175 | - '{{classname}}', |
|
176 | - '{{schemabody}}', |
|
177 | - ]; |
|
178 | - $replacements = [ |
|
179 | - $ms->getMigrationsNamespace(), |
|
180 | - $className, |
|
181 | - $schemaBody, |
|
182 | - ]; |
|
183 | - $code = str_replace($placeHolders, $replacements, self::$_templateSimple); |
|
184 | - $dir = $ms->getMigrationsDirectory(); |
|
185 | - |
|
186 | - $this->ensureMigrationDirExists($dir); |
|
187 | - $path = $dir . '/' . $className . '.php'; |
|
188 | - |
|
189 | - if (file_put_contents($path, $code) === false) { |
|
190 | - throw new RuntimeException('Failed to generate new migration step.'); |
|
191 | - } |
|
192 | - |
|
193 | - return $path; |
|
194 | - } |
|
195 | - |
|
196 | - protected function ensureMigrationDirExists($directory) { |
|
197 | - if (file_exists($directory) && is_dir($directory)) { |
|
198 | - return; |
|
199 | - } |
|
200 | - |
|
201 | - if (file_exists($directory)) { |
|
202 | - throw new \RuntimeException("Could not create folder \"$directory\""); |
|
203 | - } |
|
204 | - |
|
205 | - $this->ensureMigrationDirExists(dirname($directory)); |
|
206 | - |
|
207 | - if (!@mkdir($directory) && !is_dir($directory)) { |
|
208 | - throw new \RuntimeException("Could not create folder \"$directory\""); |
|
209 | - } |
|
210 | - } |
|
86 | + /** @var Connection */ |
|
87 | + protected $connection; |
|
88 | + |
|
89 | + /** @var IAppManager */ |
|
90 | + protected $appManager; |
|
91 | + |
|
92 | + /** |
|
93 | + * @param Connection $connection |
|
94 | + * @param IAppManager $appManager |
|
95 | + */ |
|
96 | + public function __construct(Connection $connection, IAppManager $appManager) { |
|
97 | + $this->connection = $connection; |
|
98 | + $this->appManager = $appManager; |
|
99 | + |
|
100 | + parent::__construct(); |
|
101 | + } |
|
102 | + |
|
103 | + protected function configure() { |
|
104 | + $this |
|
105 | + ->setName('migrations:generate') |
|
106 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
107 | + ->addArgument('version', InputArgument::REQUIRED, 'Major version of this app, to allow versions on parallel development branches') |
|
108 | + ; |
|
109 | + |
|
110 | + parent::configure(); |
|
111 | + } |
|
112 | + |
|
113 | + public function execute(InputInterface $input, OutputInterface $output): int { |
|
114 | + $appName = $input->getArgument('app'); |
|
115 | + $version = $input->getArgument('version'); |
|
116 | + |
|
117 | + if (!preg_match('/^\d{1,16}$/',$version)) { |
|
118 | + $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>'); |
|
119 | + return 1; |
|
120 | + } |
|
121 | + |
|
122 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
123 | + |
|
124 | + $date = date('YmdHis'); |
|
125 | + $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date); |
|
126 | + |
|
127 | + $output->writeln("New migration class has been generated to <info>$path</info>"); |
|
128 | + return 0; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * @param string $optionName |
|
133 | + * @param CompletionContext $context |
|
134 | + * @return string[] |
|
135 | + */ |
|
136 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
137 | + return []; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @param string $argumentName |
|
142 | + * @param CompletionContext $context |
|
143 | + * @return string[] |
|
144 | + */ |
|
145 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
146 | + if ($argumentName === 'app') { |
|
147 | + $allApps = \OC_App::getAllApps(); |
|
148 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
149 | + } |
|
150 | + |
|
151 | + if ($argumentName === 'version') { |
|
152 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
153 | + |
|
154 | + $version = explode('.', $this->appManager->getAppVersion($appName)); |
|
155 | + return [$version[0] . sprintf('%1$03d', $version[1])]; |
|
156 | + } |
|
157 | + |
|
158 | + return []; |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * @param MigrationService $ms |
|
163 | + * @param string $className |
|
164 | + * @param string $schemaBody |
|
165 | + * @return string |
|
166 | + */ |
|
167 | + protected function generateMigration(MigrationService $ms, $className, $schemaBody = '') { |
|
168 | + if ($schemaBody === '') { |
|
169 | + $schemaBody = "\t\t" . 'return null;'; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + $placeHolders = [ |
|
174 | + '{{namespace}}', |
|
175 | + '{{classname}}', |
|
176 | + '{{schemabody}}', |
|
177 | + ]; |
|
178 | + $replacements = [ |
|
179 | + $ms->getMigrationsNamespace(), |
|
180 | + $className, |
|
181 | + $schemaBody, |
|
182 | + ]; |
|
183 | + $code = str_replace($placeHolders, $replacements, self::$_templateSimple); |
|
184 | + $dir = $ms->getMigrationsDirectory(); |
|
185 | + |
|
186 | + $this->ensureMigrationDirExists($dir); |
|
187 | + $path = $dir . '/' . $className . '.php'; |
|
188 | + |
|
189 | + if (file_put_contents($path, $code) === false) { |
|
190 | + throw new RuntimeException('Failed to generate new migration step.'); |
|
191 | + } |
|
192 | + |
|
193 | + return $path; |
|
194 | + } |
|
195 | + |
|
196 | + protected function ensureMigrationDirExists($directory) { |
|
197 | + if (file_exists($directory) && is_dir($directory)) { |
|
198 | + return; |
|
199 | + } |
|
200 | + |
|
201 | + if (file_exists($directory)) { |
|
202 | + throw new \RuntimeException("Could not create folder \"$directory\""); |
|
203 | + } |
|
204 | + |
|
205 | + $this->ensureMigrationDirExists(dirname($directory)); |
|
206 | + |
|
207 | + if (!@mkdir($directory) && !is_dir($directory)) { |
|
208 | + throw new \RuntimeException("Could not create folder \"$directory\""); |
|
209 | + } |
|
210 | + } |
|
211 | 211 | } |
@@ -30,19 +30,19 @@ |
||
30 | 30 | |
31 | 31 | class AddPreviewBackgroundCleanupJob implements IRepairStep { |
32 | 32 | |
33 | - /** @var IJobList */ |
|
34 | - private $jobList; |
|
33 | + /** @var IJobList */ |
|
34 | + private $jobList; |
|
35 | 35 | |
36 | - public function __construct(IJobList $jobList) { |
|
37 | - $this->jobList = $jobList; |
|
38 | - } |
|
36 | + public function __construct(IJobList $jobList) { |
|
37 | + $this->jobList = $jobList; |
|
38 | + } |
|
39 | 39 | |
40 | - public function getName(): string { |
|
41 | - return 'Add preview background cleanup job'; |
|
42 | - } |
|
40 | + public function getName(): string { |
|
41 | + return 'Add preview background cleanup job'; |
|
42 | + } |
|
43 | 43 | |
44 | - public function run(IOutput $output) { |
|
45 | - $this->jobList->add(BackgroundCleanupJob::class); |
|
46 | - } |
|
44 | + public function run(IOutput $output) { |
|
45 | + $this->jobList->add(BackgroundCleanupJob::class); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | public function __construct($action) { |
33 | 33 | $l = \OC::$server->getL10N('federation'); |
34 | - $message = 'Action "' . $action . '" not supported or implemented.'; |
|
34 | + $message = 'Action "'.$action.'" not supported or implemented.'; |
|
35 | 35 | $hint = $l->t('Action "%s" not supported or implemented.', [$action]); |
36 | 36 | parent::__construct($message, $hint); |
37 | 37 | } |
@@ -32,17 +32,17 @@ |
||
32 | 32 | */ |
33 | 33 | class ActionNotSupportedException extends HintException { |
34 | 34 | |
35 | - /** |
|
36 | - * ActionNotSupportedException constructor. |
|
37 | - * |
|
38 | - * @since 14.0.0 |
|
39 | - * |
|
40 | - */ |
|
41 | - public function __construct($action) { |
|
42 | - $l = \OC::$server->getL10N('federation'); |
|
43 | - $message = 'Action "' . $action . '" not supported or implemented.'; |
|
44 | - $hint = $l->t('Action "%s" not supported or implemented.', [$action]); |
|
45 | - parent::__construct($message, $hint); |
|
46 | - } |
|
35 | + /** |
|
36 | + * ActionNotSupportedException constructor. |
|
37 | + * |
|
38 | + * @since 14.0.0 |
|
39 | + * |
|
40 | + */ |
|
41 | + public function __construct($action) { |
|
42 | + $l = \OC::$server->getL10N('federation'); |
|
43 | + $message = 'Action "' . $action . '" not supported or implemented.'; |
|
44 | + $hint = $l->t('Action "%s" not supported or implemented.', [$action]); |
|
45 | + parent::__construct($message, $hint); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | try { |
58 | - $folder = $this->appData->getFolder((string)$node->getId()); |
|
58 | + $folder = $this->appData->getFolder((string) $node->getId()); |
|
59 | 59 | $folder->delete(); |
60 | 60 | } catch (NotFoundException $e) { |
61 | 61 | //Nothing to do |
@@ -36,39 +36,39 @@ |
||
36 | 36 | * Class that will watch filesystem activity and remove previews as needed. |
37 | 37 | */ |
38 | 38 | class Watcher { |
39 | - /** @var IAppData */ |
|
40 | - private $appData; |
|
39 | + /** @var IAppData */ |
|
40 | + private $appData; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Watcher constructor. |
|
44 | - * |
|
45 | - * @param IAppData $appData |
|
46 | - */ |
|
47 | - public function __construct(IAppData $appData) { |
|
48 | - $this->appData = $appData; |
|
49 | - } |
|
42 | + /** |
|
43 | + * Watcher constructor. |
|
44 | + * |
|
45 | + * @param IAppData $appData |
|
46 | + */ |
|
47 | + public function __construct(IAppData $appData) { |
|
48 | + $this->appData = $appData; |
|
49 | + } |
|
50 | 50 | |
51 | - public function postWrite(Node $node) { |
|
52 | - $this->deleteNode($node); |
|
53 | - } |
|
51 | + public function postWrite(Node $node) { |
|
52 | + $this->deleteNode($node); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function deleteNode(Node $node) { |
|
56 | - // We only handle files |
|
57 | - if ($node instanceof Folder) { |
|
58 | - return; |
|
59 | - } |
|
55 | + protected function deleteNode(Node $node) { |
|
56 | + // We only handle files |
|
57 | + if ($node instanceof Folder) { |
|
58 | + return; |
|
59 | + } |
|
60 | 60 | |
61 | - try { |
|
62 | - $folder = $this->appData->getFolder((string)$node->getId()); |
|
63 | - $folder->delete(); |
|
64 | - } catch (NotFoundException $e) { |
|
65 | - //Nothing to do |
|
66 | - } |
|
67 | - } |
|
61 | + try { |
|
62 | + $folder = $this->appData->getFolder((string)$node->getId()); |
|
63 | + $folder->delete(); |
|
64 | + } catch (NotFoundException $e) { |
|
65 | + //Nothing to do |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | - public function versionRollback(array $data) { |
|
70 | - if (isset($data['node'])) { |
|
71 | - $this->deleteNode($data['node']); |
|
72 | - } |
|
73 | - } |
|
69 | + public function versionRollback(array $data) { |
|
70 | + if (isset($data['node'])) { |
|
71 | + $this->deleteNode($data['node']); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |
@@ -29,39 +29,39 @@ |
||
29 | 29 | |
30 | 30 | class WatcherConnector { |
31 | 31 | |
32 | - /** @var IRootFolder */ |
|
33 | - private $root; |
|
32 | + /** @var IRootFolder */ |
|
33 | + private $root; |
|
34 | 34 | |
35 | - /** @var SystemConfig */ |
|
36 | - private $config; |
|
35 | + /** @var SystemConfig */ |
|
36 | + private $config; |
|
37 | 37 | |
38 | - /** |
|
39 | - * WatcherConnector constructor. |
|
40 | - * |
|
41 | - * @param IRootFolder $root |
|
42 | - * @param SystemConfig $config |
|
43 | - */ |
|
44 | - public function __construct(IRootFolder $root, |
|
45 | - SystemConfig $config) { |
|
46 | - $this->root = $root; |
|
47 | - $this->config = $config; |
|
48 | - } |
|
38 | + /** |
|
39 | + * WatcherConnector constructor. |
|
40 | + * |
|
41 | + * @param IRootFolder $root |
|
42 | + * @param SystemConfig $config |
|
43 | + */ |
|
44 | + public function __construct(IRootFolder $root, |
|
45 | + SystemConfig $config) { |
|
46 | + $this->root = $root; |
|
47 | + $this->config = $config; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return Watcher |
|
52 | - */ |
|
53 | - private function getWatcher(): Watcher { |
|
54 | - return \OC::$server->query(Watcher::class); |
|
55 | - } |
|
50 | + /** |
|
51 | + * @return Watcher |
|
52 | + */ |
|
53 | + private function getWatcher(): Watcher { |
|
54 | + return \OC::$server->query(Watcher::class); |
|
55 | + } |
|
56 | 56 | |
57 | - public function connectWatcher() { |
|
58 | - // Do not connect if we are not setup yet! |
|
59 | - if ($this->config->getValue('instanceid', null) !== null) { |
|
60 | - $this->root->listen('\OC\Files', 'postWrite', function (Node $node) { |
|
61 | - $this->getWatcher()->postWrite($node); |
|
62 | - }); |
|
57 | + public function connectWatcher() { |
|
58 | + // Do not connect if we are not setup yet! |
|
59 | + if ($this->config->getValue('instanceid', null) !== null) { |
|
60 | + $this->root->listen('\OC\Files', 'postWrite', function (Node $node) { |
|
61 | + $this->getWatcher()->postWrite($node); |
|
62 | + }); |
|
63 | 63 | |
64 | - \OC_Hook::connect('\OCP\Versions', 'rollback', $this->getWatcher(), 'versionRollback'); |
|
65 | - } |
|
66 | - } |
|
64 | + \OC_Hook::connect('\OCP\Versions', 'rollback', $this->getWatcher(), 'versionRollback'); |
|
65 | + } |
|
66 | + } |
|
67 | 67 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | public function connectWatcher() { |
58 | 58 | // Do not connect if we are not setup yet! |
59 | 59 | if ($this->config->getValue('instanceid', null) !== null) { |
60 | - $this->root->listen('\OC\Files', 'postWrite', function (Node $node) { |
|
60 | + $this->root->listen('\OC\Files', 'postWrite', function(Node $node) { |
|
61 | 61 | $this->getWatcher()->postWrite($node); |
62 | 62 | }); |
63 | 63 |
@@ -162,7 +162,7 @@ |
||
162 | 162 | if (\is_array($scope)) { |
163 | 163 | parent::setScope(json_encode($scope)); |
164 | 164 | } else { |
165 | - parent::setScope((string)$scope); |
|
165 | + parent::setScope((string) $scope); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 |
@@ -43,168 +43,168 @@ |
||
43 | 43 | * @method void setVersion(int $version) |
44 | 44 | */ |
45 | 45 | class DefaultToken extends Entity implements INamedToken { |
46 | - public const VERSION = 1; |
|
47 | - |
|
48 | - /** @var string user UID */ |
|
49 | - protected $uid; |
|
50 | - |
|
51 | - /** @var string login name used for generating the token */ |
|
52 | - protected $loginName; |
|
53 | - |
|
54 | - /** @var string encrypted user password */ |
|
55 | - protected $password; |
|
56 | - |
|
57 | - /** @var string token name (e.g. browser/OS) */ |
|
58 | - protected $name; |
|
59 | - |
|
60 | - /** @var string */ |
|
61 | - protected $token; |
|
62 | - |
|
63 | - /** @var int */ |
|
64 | - protected $type; |
|
65 | - |
|
66 | - /** @var int */ |
|
67 | - protected $remember; |
|
68 | - |
|
69 | - /** @var int */ |
|
70 | - protected $lastActivity; |
|
71 | - |
|
72 | - /** @var int */ |
|
73 | - protected $lastCheck; |
|
74 | - |
|
75 | - /** @var string */ |
|
76 | - protected $scope; |
|
77 | - |
|
78 | - /** @var int */ |
|
79 | - protected $expires; |
|
80 | - |
|
81 | - /** @var int */ |
|
82 | - protected $version; |
|
83 | - |
|
84 | - public function __construct() { |
|
85 | - $this->addType('uid', 'string'); |
|
86 | - $this->addType('loginName', 'string'); |
|
87 | - $this->addType('password', 'string'); |
|
88 | - $this->addType('name', 'string'); |
|
89 | - $this->addType('token', 'string'); |
|
90 | - $this->addType('type', 'int'); |
|
91 | - $this->addType('remember', 'int'); |
|
92 | - $this->addType('lastActivity', 'int'); |
|
93 | - $this->addType('lastCheck', 'int'); |
|
94 | - $this->addType('scope', 'string'); |
|
95 | - $this->addType('expires', 'int'); |
|
96 | - $this->addType('version', 'int'); |
|
97 | - } |
|
98 | - |
|
99 | - public function getId(): int { |
|
100 | - return $this->id; |
|
101 | - } |
|
102 | - |
|
103 | - public function getUID(): string { |
|
104 | - return $this->uid; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Get the login name used when generating the token |
|
109 | - * |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function getLoginName(): string { |
|
113 | - return parent::getLoginName(); |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Get the (encrypted) login password |
|
118 | - * |
|
119 | - * @return string|null |
|
120 | - */ |
|
121 | - public function getPassword() { |
|
122 | - return parent::getPassword(); |
|
123 | - } |
|
124 | - |
|
125 | - public function jsonSerialize() { |
|
126 | - return [ |
|
127 | - 'id' => $this->id, |
|
128 | - 'name' => $this->name, |
|
129 | - 'lastActivity' => $this->lastActivity, |
|
130 | - 'type' => $this->type, |
|
131 | - 'scope' => $this->getScopeAsArray() |
|
132 | - ]; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Get the timestamp of the last password check |
|
137 | - * |
|
138 | - * @return int |
|
139 | - */ |
|
140 | - public function getLastCheck(): int { |
|
141 | - return parent::getLastCheck(); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Get the timestamp of the last password check |
|
146 | - * |
|
147 | - * @param int $time |
|
148 | - */ |
|
149 | - public function setLastCheck(int $time) { |
|
150 | - parent::setLastCheck($time); |
|
151 | - } |
|
152 | - |
|
153 | - public function getScope(): string { |
|
154 | - $scope = parent::getScope(); |
|
155 | - if ($scope === null) { |
|
156 | - return ''; |
|
157 | - } |
|
158 | - |
|
159 | - return $scope; |
|
160 | - } |
|
161 | - |
|
162 | - public function getScopeAsArray(): array { |
|
163 | - $scope = json_decode($this->getScope(), true); |
|
164 | - if (!$scope) { |
|
165 | - return [ |
|
166 | - 'filesystem' => true |
|
167 | - ]; |
|
168 | - } |
|
169 | - return $scope; |
|
170 | - } |
|
171 | - |
|
172 | - public function setScope($scope) { |
|
173 | - if (\is_array($scope)) { |
|
174 | - parent::setScope(json_encode($scope)); |
|
175 | - } else { |
|
176 | - parent::setScope((string)$scope); |
|
177 | - } |
|
178 | - } |
|
179 | - |
|
180 | - public function getName(): string { |
|
181 | - return parent::getName(); |
|
182 | - } |
|
183 | - |
|
184 | - public function setName(string $name): void { |
|
185 | - parent::setName($name); |
|
186 | - } |
|
187 | - |
|
188 | - public function getRemember(): int { |
|
189 | - return parent::getRemember(); |
|
190 | - } |
|
191 | - |
|
192 | - public function setToken(string $token) { |
|
193 | - parent::setToken($token); |
|
194 | - } |
|
195 | - |
|
196 | - public function setPassword(string $password = null) { |
|
197 | - parent::setPassword($password); |
|
198 | - } |
|
199 | - |
|
200 | - public function setExpires($expires) { |
|
201 | - parent::setExpires($expires); |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * @return int|null |
|
206 | - */ |
|
207 | - public function getExpires() { |
|
208 | - return parent::getExpires(); |
|
209 | - } |
|
46 | + public const VERSION = 1; |
|
47 | + |
|
48 | + /** @var string user UID */ |
|
49 | + protected $uid; |
|
50 | + |
|
51 | + /** @var string login name used for generating the token */ |
|
52 | + protected $loginName; |
|
53 | + |
|
54 | + /** @var string encrypted user password */ |
|
55 | + protected $password; |
|
56 | + |
|
57 | + /** @var string token name (e.g. browser/OS) */ |
|
58 | + protected $name; |
|
59 | + |
|
60 | + /** @var string */ |
|
61 | + protected $token; |
|
62 | + |
|
63 | + /** @var int */ |
|
64 | + protected $type; |
|
65 | + |
|
66 | + /** @var int */ |
|
67 | + protected $remember; |
|
68 | + |
|
69 | + /** @var int */ |
|
70 | + protected $lastActivity; |
|
71 | + |
|
72 | + /** @var int */ |
|
73 | + protected $lastCheck; |
|
74 | + |
|
75 | + /** @var string */ |
|
76 | + protected $scope; |
|
77 | + |
|
78 | + /** @var int */ |
|
79 | + protected $expires; |
|
80 | + |
|
81 | + /** @var int */ |
|
82 | + protected $version; |
|
83 | + |
|
84 | + public function __construct() { |
|
85 | + $this->addType('uid', 'string'); |
|
86 | + $this->addType('loginName', 'string'); |
|
87 | + $this->addType('password', 'string'); |
|
88 | + $this->addType('name', 'string'); |
|
89 | + $this->addType('token', 'string'); |
|
90 | + $this->addType('type', 'int'); |
|
91 | + $this->addType('remember', 'int'); |
|
92 | + $this->addType('lastActivity', 'int'); |
|
93 | + $this->addType('lastCheck', 'int'); |
|
94 | + $this->addType('scope', 'string'); |
|
95 | + $this->addType('expires', 'int'); |
|
96 | + $this->addType('version', 'int'); |
|
97 | + } |
|
98 | + |
|
99 | + public function getId(): int { |
|
100 | + return $this->id; |
|
101 | + } |
|
102 | + |
|
103 | + public function getUID(): string { |
|
104 | + return $this->uid; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Get the login name used when generating the token |
|
109 | + * |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function getLoginName(): string { |
|
113 | + return parent::getLoginName(); |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Get the (encrypted) login password |
|
118 | + * |
|
119 | + * @return string|null |
|
120 | + */ |
|
121 | + public function getPassword() { |
|
122 | + return parent::getPassword(); |
|
123 | + } |
|
124 | + |
|
125 | + public function jsonSerialize() { |
|
126 | + return [ |
|
127 | + 'id' => $this->id, |
|
128 | + 'name' => $this->name, |
|
129 | + 'lastActivity' => $this->lastActivity, |
|
130 | + 'type' => $this->type, |
|
131 | + 'scope' => $this->getScopeAsArray() |
|
132 | + ]; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Get the timestamp of the last password check |
|
137 | + * |
|
138 | + * @return int |
|
139 | + */ |
|
140 | + public function getLastCheck(): int { |
|
141 | + return parent::getLastCheck(); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Get the timestamp of the last password check |
|
146 | + * |
|
147 | + * @param int $time |
|
148 | + */ |
|
149 | + public function setLastCheck(int $time) { |
|
150 | + parent::setLastCheck($time); |
|
151 | + } |
|
152 | + |
|
153 | + public function getScope(): string { |
|
154 | + $scope = parent::getScope(); |
|
155 | + if ($scope === null) { |
|
156 | + return ''; |
|
157 | + } |
|
158 | + |
|
159 | + return $scope; |
|
160 | + } |
|
161 | + |
|
162 | + public function getScopeAsArray(): array { |
|
163 | + $scope = json_decode($this->getScope(), true); |
|
164 | + if (!$scope) { |
|
165 | + return [ |
|
166 | + 'filesystem' => true |
|
167 | + ]; |
|
168 | + } |
|
169 | + return $scope; |
|
170 | + } |
|
171 | + |
|
172 | + public function setScope($scope) { |
|
173 | + if (\is_array($scope)) { |
|
174 | + parent::setScope(json_encode($scope)); |
|
175 | + } else { |
|
176 | + parent::setScope((string)$scope); |
|
177 | + } |
|
178 | + } |
|
179 | + |
|
180 | + public function getName(): string { |
|
181 | + return parent::getName(); |
|
182 | + } |
|
183 | + |
|
184 | + public function setName(string $name): void { |
|
185 | + parent::setName($name); |
|
186 | + } |
|
187 | + |
|
188 | + public function getRemember(): int { |
|
189 | + return parent::getRemember(); |
|
190 | + } |
|
191 | + |
|
192 | + public function setToken(string $token) { |
|
193 | + parent::setToken($token); |
|
194 | + } |
|
195 | + |
|
196 | + public function setPassword(string $password = null) { |
|
197 | + parent::setPassword($password); |
|
198 | + } |
|
199 | + |
|
200 | + public function setExpires($expires) { |
|
201 | + parent::setExpires($expires); |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * @return int|null |
|
206 | + */ |
|
207 | + public function getExpires() { |
|
208 | + return parent::getExpires(); |
|
209 | + } |
|
210 | 210 | } |