@@ -86,7 +86,7 @@ |
||
86 | 86 | $response = new Response(); |
87 | 87 | $response->addHeader('Access-Control-Allow-Origin', $origin); |
88 | 88 | $response->addHeader('Access-Control-Allow-Methods', $this->corsMethods); |
89 | - $response->addHeader('Access-Control-Max-Age', (string)$this->corsMaxAge); |
|
89 | + $response->addHeader('Access-Control-Max-Age', (string) $this->corsMaxAge); |
|
90 | 90 | $response->addHeader('Access-Control-Allow-Headers', $this->corsAllowedHeaders); |
91 | 91 | $response->addHeader('Access-Control-Allow-Credentials', 'false'); |
92 | 92 | return $response; |
@@ -18,57 +18,57 @@ |
||
18 | 18 | * @since 7.0.0 |
19 | 19 | */ |
20 | 20 | abstract class ApiController extends Controller { |
21 | - private $corsMethods; |
|
22 | - private $corsAllowedHeaders; |
|
23 | - private $corsMaxAge; |
|
21 | + private $corsMethods; |
|
22 | + private $corsAllowedHeaders; |
|
23 | + private $corsMaxAge; |
|
24 | 24 | |
25 | - /** |
|
26 | - * constructor of the controller |
|
27 | - * @param string $appName the name of the app |
|
28 | - * @param IRequest $request an instance of the request |
|
29 | - * @param string $corsMethods comma separated string of HTTP verbs which |
|
30 | - * should be allowed for websites or webapps when calling your API, defaults to |
|
31 | - * 'PUT, POST, GET, DELETE, PATCH' |
|
32 | - * @param string $corsAllowedHeaders comma separated string of HTTP headers |
|
33 | - * which should be allowed for websites or webapps when calling your API, |
|
34 | - * defaults to 'Authorization, Content-Type, Accept' |
|
35 | - * @param int $corsMaxAge number in seconds how long a preflighted OPTIONS |
|
36 | - * request should be cached, defaults to 1728000 seconds |
|
37 | - * @since 7.0.0 |
|
38 | - */ |
|
39 | - public function __construct($appName, |
|
40 | - IRequest $request, |
|
41 | - $corsMethods = 'PUT, POST, GET, DELETE, PATCH', |
|
42 | - $corsAllowedHeaders = 'Authorization, Content-Type, Accept', |
|
43 | - $corsMaxAge = 1728000) { |
|
44 | - parent::__construct($appName, $request); |
|
45 | - $this->corsMethods = $corsMethods; |
|
46 | - $this->corsAllowedHeaders = $corsAllowedHeaders; |
|
47 | - $this->corsMaxAge = $corsMaxAge; |
|
48 | - } |
|
25 | + /** |
|
26 | + * constructor of the controller |
|
27 | + * @param string $appName the name of the app |
|
28 | + * @param IRequest $request an instance of the request |
|
29 | + * @param string $corsMethods comma separated string of HTTP verbs which |
|
30 | + * should be allowed for websites or webapps when calling your API, defaults to |
|
31 | + * 'PUT, POST, GET, DELETE, PATCH' |
|
32 | + * @param string $corsAllowedHeaders comma separated string of HTTP headers |
|
33 | + * which should be allowed for websites or webapps when calling your API, |
|
34 | + * defaults to 'Authorization, Content-Type, Accept' |
|
35 | + * @param int $corsMaxAge number in seconds how long a preflighted OPTIONS |
|
36 | + * request should be cached, defaults to 1728000 seconds |
|
37 | + * @since 7.0.0 |
|
38 | + */ |
|
39 | + public function __construct($appName, |
|
40 | + IRequest $request, |
|
41 | + $corsMethods = 'PUT, POST, GET, DELETE, PATCH', |
|
42 | + $corsAllowedHeaders = 'Authorization, Content-Type, Accept', |
|
43 | + $corsMaxAge = 1728000) { |
|
44 | + parent::__construct($appName, $request); |
|
45 | + $this->corsMethods = $corsMethods; |
|
46 | + $this->corsAllowedHeaders = $corsAllowedHeaders; |
|
47 | + $this->corsMaxAge = $corsMaxAge; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * This method implements a preflighted cors response for you that you can |
|
53 | - * link to for the options request |
|
54 | - * |
|
55 | - * @since 7.0.0 |
|
56 | - */ |
|
57 | - #[NoCSRFRequired] |
|
58 | - #[PublicPage] |
|
59 | - #[NoAdminRequired] |
|
60 | - public function preflightedCors() { |
|
61 | - $origin = $this->request->getHeader('origin'); |
|
62 | - if ($origin === '') { |
|
63 | - $origin = '*'; |
|
64 | - } |
|
51 | + /** |
|
52 | + * This method implements a preflighted cors response for you that you can |
|
53 | + * link to for the options request |
|
54 | + * |
|
55 | + * @since 7.0.0 |
|
56 | + */ |
|
57 | + #[NoCSRFRequired] |
|
58 | + #[PublicPage] |
|
59 | + #[NoAdminRequired] |
|
60 | + public function preflightedCors() { |
|
61 | + $origin = $this->request->getHeader('origin'); |
|
62 | + if ($origin === '') { |
|
63 | + $origin = '*'; |
|
64 | + } |
|
65 | 65 | |
66 | - $response = new Response(); |
|
67 | - $response->addHeader('Access-Control-Allow-Origin', $origin); |
|
68 | - $response->addHeader('Access-Control-Allow-Methods', $this->corsMethods); |
|
69 | - $response->addHeader('Access-Control-Max-Age', (string)$this->corsMaxAge); |
|
70 | - $response->addHeader('Access-Control-Allow-Headers', $this->corsAllowedHeaders); |
|
71 | - $response->addHeader('Access-Control-Allow-Credentials', 'false'); |
|
72 | - return $response; |
|
73 | - } |
|
66 | + $response = new Response(); |
|
67 | + $response->addHeader('Access-Control-Allow-Origin', $origin); |
|
68 | + $response->addHeader('Access-Control-Allow-Methods', $this->corsMethods); |
|
69 | + $response->addHeader('Access-Control-Max-Age', (string)$this->corsMaxAge); |
|
70 | + $response->addHeader('Access-Control-Allow-Headers', $this->corsAllowedHeaders); |
|
71 | + $response->addHeader('Access-Control-Allow-Credentials', 'false'); |
|
72 | + return $response; |
|
73 | + } |
|
74 | 74 | } |
@@ -82,7 +82,7 @@ |
||
82 | 82 | |
83 | 83 | if ($runIsSetupDirectly) { |
84 | 84 | $applicationClassName = get_class($this); |
85 | - $e = new \RuntimeException('App class ' . $applicationClassName . ' is not setup via query() but directly'); |
|
85 | + $e = new \RuntimeException('App class '.$applicationClassName.' is not setup via query() but directly'); |
|
86 | 86 | $setUpViaQuery = false; |
87 | 87 | |
88 | 88 | $classNameParts = explode('\\', trim($applicationClassName, '\\')); |
@@ -23,118 +23,118 @@ |
||
23 | 23 | * @since 6.0.0 |
24 | 24 | */ |
25 | 25 | class App { |
26 | - /** @var IAppContainer */ |
|
27 | - private $container; |
|
26 | + /** @var IAppContainer */ |
|
27 | + private $container; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Turns an app id into a namespace by convention. The id is split at the |
|
31 | - * underscores, all parts are CamelCased and reassembled. e.g.: |
|
32 | - * some_app_id -> OCA\SomeAppId |
|
33 | - * @param string $appId the app id |
|
34 | - * @param string $topNamespace the namespace which should be prepended to |
|
35 | - * the transformed app id, defaults to OCA\ |
|
36 | - * @return string the starting namespace for the app |
|
37 | - * @since 8.0.0 |
|
38 | - */ |
|
39 | - public static function buildAppNamespace(string $appId, string $topNamespace = 'OCA\\'): string { |
|
40 | - return \OC\AppFramework\App::buildAppNamespace($appId, $topNamespace); |
|
41 | - } |
|
29 | + /** |
|
30 | + * Turns an app id into a namespace by convention. The id is split at the |
|
31 | + * underscores, all parts are CamelCased and reassembled. e.g.: |
|
32 | + * some_app_id -> OCA\SomeAppId |
|
33 | + * @param string $appId the app id |
|
34 | + * @param string $topNamespace the namespace which should be prepended to |
|
35 | + * the transformed app id, defaults to OCA\ |
|
36 | + * @return string the starting namespace for the app |
|
37 | + * @since 8.0.0 |
|
38 | + */ |
|
39 | + public static function buildAppNamespace(string $appId, string $topNamespace = 'OCA\\'): string { |
|
40 | + return \OC\AppFramework\App::buildAppNamespace($appId, $topNamespace); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @param string $appName |
|
46 | - * @param array $urlParams an array with variables extracted from the routes |
|
47 | - * @since 6.0.0 |
|
48 | - */ |
|
49 | - public function __construct(string $appName, array $urlParams = []) { |
|
50 | - $runIsSetupDirectly = Server::get(IConfig::class)->getSystemValueBool('debug') |
|
51 | - && !ini_get('zend.exception_ignore_args'); |
|
44 | + /** |
|
45 | + * @param string $appName |
|
46 | + * @param array $urlParams an array with variables extracted from the routes |
|
47 | + * @since 6.0.0 |
|
48 | + */ |
|
49 | + public function __construct(string $appName, array $urlParams = []) { |
|
50 | + $runIsSetupDirectly = Server::get(IConfig::class)->getSystemValueBool('debug') |
|
51 | + && !ini_get('zend.exception_ignore_args'); |
|
52 | 52 | |
53 | - if ($runIsSetupDirectly) { |
|
54 | - $applicationClassName = get_class($this); |
|
55 | - $e = new \RuntimeException('App class ' . $applicationClassName . ' is not setup via query() but directly'); |
|
56 | - $setUpViaQuery = false; |
|
53 | + if ($runIsSetupDirectly) { |
|
54 | + $applicationClassName = get_class($this); |
|
55 | + $e = new \RuntimeException('App class ' . $applicationClassName . ' is not setup via query() but directly'); |
|
56 | + $setUpViaQuery = false; |
|
57 | 57 | |
58 | - $classNameParts = explode('\\', trim($applicationClassName, '\\')); |
|
58 | + $classNameParts = explode('\\', trim($applicationClassName, '\\')); |
|
59 | 59 | |
60 | - foreach ($e->getTrace() as $step) { |
|
61 | - if (isset($step['class'], $step['function'], $step['args'][0]) && |
|
62 | - $step['class'] === ServerContainer::class && |
|
63 | - $step['function'] === 'query' && |
|
64 | - $step['args'][0] === $applicationClassName) { |
|
65 | - $setUpViaQuery = true; |
|
66 | - break; |
|
67 | - } elseif (isset($step['class'], $step['function'], $step['args'][0]) && |
|
68 | - $step['class'] === ServerContainer::class && |
|
69 | - $step['function'] === 'getAppContainer' && |
|
70 | - $step['args'][1] === $classNameParts[1]) { |
|
71 | - $setUpViaQuery = true; |
|
72 | - break; |
|
73 | - } elseif (isset($step['class'], $step['function'], $step['args'][0]) && |
|
74 | - $step['class'] === SimpleContainer::class && |
|
75 | - preg_match('/{closure:OC\\\\AppFramework\\\\Utility\\\\SimpleContainer::buildClass\\(\\):\\d+}/', $step['function']) && |
|
76 | - $step['args'][0] === $this) { |
|
77 | - /* We are setup through a lazy ghost, fine */ |
|
78 | - $setUpViaQuery = true; |
|
79 | - break; |
|
80 | - } |
|
81 | - } |
|
60 | + foreach ($e->getTrace() as $step) { |
|
61 | + if (isset($step['class'], $step['function'], $step['args'][0]) && |
|
62 | + $step['class'] === ServerContainer::class && |
|
63 | + $step['function'] === 'query' && |
|
64 | + $step['args'][0] === $applicationClassName) { |
|
65 | + $setUpViaQuery = true; |
|
66 | + break; |
|
67 | + } elseif (isset($step['class'], $step['function'], $step['args'][0]) && |
|
68 | + $step['class'] === ServerContainer::class && |
|
69 | + $step['function'] === 'getAppContainer' && |
|
70 | + $step['args'][1] === $classNameParts[1]) { |
|
71 | + $setUpViaQuery = true; |
|
72 | + break; |
|
73 | + } elseif (isset($step['class'], $step['function'], $step['args'][0]) && |
|
74 | + $step['class'] === SimpleContainer::class && |
|
75 | + preg_match('/{closure:OC\\\\AppFramework\\\\Utility\\\\SimpleContainer::buildClass\\(\\):\\d+}/', $step['function']) && |
|
76 | + $step['args'][0] === $this) { |
|
77 | + /* We are setup through a lazy ghost, fine */ |
|
78 | + $setUpViaQuery = true; |
|
79 | + break; |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - if (!$setUpViaQuery && $applicationClassName !== \OCP\AppFramework\App::class) { |
|
84 | - Server::get(LoggerInterface::class)->error($e->getMessage(), [ |
|
85 | - 'app' => $appName, |
|
86 | - 'exception' => $e, |
|
87 | - ]); |
|
88 | - } |
|
89 | - } |
|
83 | + if (!$setUpViaQuery && $applicationClassName !== \OCP\AppFramework\App::class) { |
|
84 | + Server::get(LoggerInterface::class)->error($e->getMessage(), [ |
|
85 | + 'app' => $appName, |
|
86 | + 'exception' => $e, |
|
87 | + ]); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - try { |
|
92 | - $this->container = \OC::$server->getRegisteredAppContainer($appName); |
|
93 | - } catch (QueryException $e) { |
|
94 | - $this->container = new \OC\AppFramework\DependencyInjection\DIContainer($appName, $urlParams); |
|
95 | - } |
|
96 | - } |
|
91 | + try { |
|
92 | + $this->container = \OC::$server->getRegisteredAppContainer($appName); |
|
93 | + } catch (QueryException $e) { |
|
94 | + $this->container = new \OC\AppFramework\DependencyInjection\DIContainer($appName, $urlParams); |
|
95 | + } |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * @return IAppContainer |
|
100 | - * @since 6.0.0 |
|
101 | - */ |
|
102 | - public function getContainer(): IAppContainer { |
|
103 | - return $this->container; |
|
104 | - } |
|
98 | + /** |
|
99 | + * @return IAppContainer |
|
100 | + * @since 6.0.0 |
|
101 | + */ |
|
102 | + public function getContainer(): IAppContainer { |
|
103 | + return $this->container; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * This function is called by the routing component to fire up the frameworks dispatch mechanism. |
|
108 | - * |
|
109 | - * Example code in routes.php of the task app: |
|
110 | - * $this->create('tasks_index', '/')->get()->action( |
|
111 | - * function($params){ |
|
112 | - * $app = new TaskApp($params); |
|
113 | - * $app->dispatch('PageController', 'index'); |
|
114 | - * } |
|
115 | - * ); |
|
116 | - * |
|
117 | - * |
|
118 | - * Example for for TaskApp implementation: |
|
119 | - * class TaskApp extends \OCP\AppFramework\App { |
|
120 | - * |
|
121 | - * public function __construct($params){ |
|
122 | - * parent::__construct('tasks', $params); |
|
123 | - * |
|
124 | - * $this->getContainer()->registerService('PageController', function(IAppContainer $c){ |
|
125 | - * $a = $c->query('API'); |
|
126 | - * $r = $c->query('Request'); |
|
127 | - * return new PageController($a, $r); |
|
128 | - * }); |
|
129 | - * } |
|
130 | - * } |
|
131 | - * |
|
132 | - * @param string $controllerName the name of the controller under which it is |
|
133 | - * stored in the DI container |
|
134 | - * @param string $methodName the method that you want to call |
|
135 | - * @since 6.0.0 |
|
136 | - */ |
|
137 | - public function dispatch(string $controllerName, string $methodName) { |
|
138 | - \OC\AppFramework\App::main($controllerName, $methodName, $this->container); |
|
139 | - } |
|
106 | + /** |
|
107 | + * This function is called by the routing component to fire up the frameworks dispatch mechanism. |
|
108 | + * |
|
109 | + * Example code in routes.php of the task app: |
|
110 | + * $this->create('tasks_index', '/')->get()->action( |
|
111 | + * function($params){ |
|
112 | + * $app = new TaskApp($params); |
|
113 | + * $app->dispatch('PageController', 'index'); |
|
114 | + * } |
|
115 | + * ); |
|
116 | + * |
|
117 | + * |
|
118 | + * Example for for TaskApp implementation: |
|
119 | + * class TaskApp extends \OCP\AppFramework\App { |
|
120 | + * |
|
121 | + * public function __construct($params){ |
|
122 | + * parent::__construct('tasks', $params); |
|
123 | + * |
|
124 | + * $this->getContainer()->registerService('PageController', function(IAppContainer $c){ |
|
125 | + * $a = $c->query('API'); |
|
126 | + * $r = $c->query('Request'); |
|
127 | + * return new PageController($a, $r); |
|
128 | + * }); |
|
129 | + * } |
|
130 | + * } |
|
131 | + * |
|
132 | + * @param string $controllerName the name of the controller under which it is |
|
133 | + * stored in the DI container |
|
134 | + * @param string $methodName the method that you want to call |
|
135 | + * @since 6.0.0 |
|
136 | + */ |
|
137 | + public function dispatch(string $controllerName, string $methodName) { |
|
138 | + \OC\AppFramework\App::main($controllerName, $methodName, $this->container); |
|
139 | + } |
|
140 | 140 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | $this->manager->invalidateTokenById($uid, $token->getId()); |
65 | 65 | } |
66 | 66 | } catch (Throwable $e) { |
67 | - $this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [ |
|
67 | + $this->logger->error('Could not clean up auth tokens after user deletion: '.$e->getMessage(), [ |
|
68 | 68 | 'exception' => $e, |
69 | 69 | ]); |
70 | 70 | } |
@@ -19,38 +19,38 @@ |
||
19 | 19 | * @template-implements IEventListener<\OCP\User\Events\UserDeletedEvent> |
20 | 20 | */ |
21 | 21 | class UserDeletedTokenCleanupListener implements IEventListener { |
22 | - /** @var Manager */ |
|
23 | - private $manager; |
|
24 | - |
|
25 | - /** @var LoggerInterface */ |
|
26 | - private $logger; |
|
27 | - |
|
28 | - public function __construct(Manager $manager, |
|
29 | - LoggerInterface $logger) { |
|
30 | - $this->manager = $manager; |
|
31 | - $this->logger = $logger; |
|
32 | - } |
|
33 | - |
|
34 | - public function handle(Event $event): void { |
|
35 | - if (!($event instanceof UserDeletedEvent)) { |
|
36 | - // Unrelated |
|
37 | - return; |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * Catch any exception during this process as any failure here shouldn't block the |
|
42 | - * user deletion. |
|
43 | - */ |
|
44 | - try { |
|
45 | - $uid = $event->getUser()->getUID(); |
|
46 | - $tokens = $this->manager->getTokenByUser($uid); |
|
47 | - foreach ($tokens as $token) { |
|
48 | - $this->manager->invalidateTokenById($uid, $token->getId()); |
|
49 | - } |
|
50 | - } catch (Throwable $e) { |
|
51 | - $this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [ |
|
52 | - 'exception' => $e, |
|
53 | - ]); |
|
54 | - } |
|
55 | - } |
|
22 | + /** @var Manager */ |
|
23 | + private $manager; |
|
24 | + |
|
25 | + /** @var LoggerInterface */ |
|
26 | + private $logger; |
|
27 | + |
|
28 | + public function __construct(Manager $manager, |
|
29 | + LoggerInterface $logger) { |
|
30 | + $this->manager = $manager; |
|
31 | + $this->logger = $logger; |
|
32 | + } |
|
33 | + |
|
34 | + public function handle(Event $event): void { |
|
35 | + if (!($event instanceof UserDeletedEvent)) { |
|
36 | + // Unrelated |
|
37 | + return; |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * Catch any exception during this process as any failure here shouldn't block the |
|
42 | + * user deletion. |
|
43 | + */ |
|
44 | + try { |
|
45 | + $uid = $event->getUser()->getUID(); |
|
46 | + $tokens = $this->manager->getTokenByUser($uid); |
|
47 | + foreach ($tokens as $token) { |
|
48 | + $this->manager->invalidateTokenById($uid, $token->getId()); |
|
49 | + } |
|
50 | + } catch (Throwable $e) { |
|
51 | + $this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [ |
|
52 | + 'exception' => $e, |
|
53 | + ]); |
|
54 | + } |
|
55 | + } |
|
56 | 56 | } |
@@ -25,12 +25,12 @@ |
||
25 | 25 | ?> |
26 | 26 | |
27 | 27 | <div id="two-factor-auth" class="section"> |
28 | - <h2><?php p($l->t('Two-Factor Authentication'));?></h2> |
|
28 | + <h2><?php p($l->t('Two-Factor Authentication')); ?></h2> |
|
29 | 29 | <a target="_blank" rel="noreferrer noopener" class="icon-info" |
30 | - title="<?php p($l->t('Open documentation'));?>" |
|
30 | + title="<?php p($l->t('Open documentation')); ?>" |
|
31 | 31 | href="<?php p(link_to_docs('user-2fa')); ?>"></a> |
32 | - <p class="settings-hint"><?php p($l->t('Use a second factor besides your password to increase security for your account.'));?></p> |
|
33 | - <p class="settings-hint"><?php p($l->t('If you use third party applications to connect to Nextcloud, please make sure to create and configure an app password for each before enabling second factor authentication.'));?></p> |
|
32 | + <p class="settings-hint"><?php p($l->t('Use a second factor besides your password to increase security for your account.')); ?></p> |
|
33 | + <p class="settings-hint"><?php p($l->t('If you use third party applications to connect to Nextcloud, please make sure to create and configure an app password for each before enabling second factor authentication.')); ?></p> |
|
34 | 34 | <ul> |
35 | 35 | <?php foreach ($_['twoFactorProviderData']['providers'] as $data) { ?> |
36 | 36 | <li> |
@@ -19,18 +19,18 @@ |
||
19 | 19 | <li> |
20 | 20 | <?php |
21 | 21 | |
22 | - /** @var \OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings $provider */ |
|
23 | - $provider = $data['provider']; |
|
24 | - //Handle 2FA provider icons and theme |
|
25 | - if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) { |
|
26 | - $icon = $provider->getDarkIcon(); |
|
27 | - //fallback icon if the 2factor provider doesn't provide an icon. |
|
28 | - } else { |
|
29 | - $icon = image_path('core', 'actions/password.svg'); |
|
30 | - } |
|
31 | - /** @var \OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings $settings */ |
|
32 | - $settings = $data['settings']; |
|
33 | - ?> |
|
22 | + /** @var \OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings $provider */ |
|
23 | + $provider = $data['provider']; |
|
24 | + //Handle 2FA provider icons and theme |
|
25 | + if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) { |
|
26 | + $icon = $provider->getDarkIcon(); |
|
27 | + //fallback icon if the 2factor provider doesn't provide an icon. |
|
28 | + } else { |
|
29 | + $icon = image_path('core', 'actions/password.svg'); |
|
30 | + } |
|
31 | + /** @var \OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings $settings */ |
|
32 | + $settings = $data['settings']; |
|
33 | + ?> |
|
34 | 34 | <h3> |
35 | 35 | <img class="two-factor-provider-settings-icon" src="<?php p($icon) ?>" alt=""> |
36 | 36 | <?php p($provider->getDisplayName()) ?> |
@@ -29,15 +29,15 @@ |
||
29 | 29 | * @deprecated 18.0.0 use events and the \OCP\EventDispatcher\IEventDispatcher service |
30 | 30 | */ |
31 | 31 | class PublicEmitter extends BasicEmitter { |
32 | - /** |
|
33 | - * @param string $scope |
|
34 | - * @param string $method |
|
35 | - * @param array $arguments optional |
|
36 | - * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTyped |
|
37 | - * |
|
38 | - * @suppress PhanAccessMethodProtected |
|
39 | - */ |
|
40 | - public function emit($scope, $method, array $arguments = []) { |
|
41 | - parent::emit($scope, $method, $arguments); |
|
42 | - } |
|
32 | + /** |
|
33 | + * @param string $scope |
|
34 | + * @param string $method |
|
35 | + * @param array $arguments optional |
|
36 | + * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTyped |
|
37 | + * |
|
38 | + * @suppress PhanAccessMethodProtected |
|
39 | + */ |
|
40 | + public function emit($scope, $method, array $arguments = []) { |
|
41 | + parent::emit($scope, $method, $arguments); |
|
42 | + } |
|
43 | 43 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener |
42 | 42 | */ |
43 | 43 | public function listen($scope, $method, callable $callback) { |
44 | - $eventName = $scope . '::' . $method; |
|
44 | + $eventName = $scope.'::'.$method; |
|
45 | 45 | if (!isset($this->listeners[$eventName])) { |
46 | 46 | $this->listeners[$eventName] = []; |
47 | 47 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $names = []; |
61 | 61 | $allNames = array_keys($this->listeners); |
62 | 62 | if ($scope and $method) { |
63 | - $name = $scope . '::' . $method; |
|
63 | + $name = $scope.'::'.$method; |
|
64 | 64 | if (isset($this->listeners[$name])) { |
65 | 65 | $names[] = $name; |
66 | 66 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTyped |
102 | 102 | */ |
103 | 103 | protected function emit($scope, $method, array $arguments = []) { |
104 | - $eventName = $scope . '::' . $method; |
|
104 | + $eventName = $scope.'::'.$method; |
|
105 | 105 | if (isset($this->listeners[$eventName])) { |
106 | 106 | foreach ($this->listeners[$eventName] as $callback) { |
107 | 107 | call_user_func_array($callback, $arguments); |
@@ -10,83 +10,83 @@ |
||
10 | 10 | * @deprecated 18.0.0 use events and the \OCP\EventDispatcher\IEventDispatcher service |
11 | 11 | */ |
12 | 12 | trait EmitterTrait { |
13 | - /** |
|
14 | - * @var callable[][] $listeners |
|
15 | - */ |
|
16 | - protected $listeners = []; |
|
13 | + /** |
|
14 | + * @var callable[][] $listeners |
|
15 | + */ |
|
16 | + protected $listeners = []; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @param string $scope |
|
20 | - * @param string $method |
|
21 | - * @param callable $callback |
|
22 | - * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener |
|
23 | - */ |
|
24 | - public function listen($scope, $method, callable $callback) { |
|
25 | - $eventName = $scope . '::' . $method; |
|
26 | - if (!isset($this->listeners[$eventName])) { |
|
27 | - $this->listeners[$eventName] = []; |
|
28 | - } |
|
29 | - if (!in_array($callback, $this->listeners[$eventName], true)) { |
|
30 | - $this->listeners[$eventName][] = $callback; |
|
31 | - } |
|
32 | - } |
|
18 | + /** |
|
19 | + * @param string $scope |
|
20 | + * @param string $method |
|
21 | + * @param callable $callback |
|
22 | + * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener |
|
23 | + */ |
|
24 | + public function listen($scope, $method, callable $callback) { |
|
25 | + $eventName = $scope . '::' . $method; |
|
26 | + if (!isset($this->listeners[$eventName])) { |
|
27 | + $this->listeners[$eventName] = []; |
|
28 | + } |
|
29 | + if (!in_array($callback, $this->listeners[$eventName], true)) { |
|
30 | + $this->listeners[$eventName][] = $callback; |
|
31 | + } |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param string $scope optional |
|
36 | - * @param string $method optional |
|
37 | - * @param callable $callback optional |
|
38 | - * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::removeListener |
|
39 | - */ |
|
40 | - public function removeListener($scope = null, $method = null, ?callable $callback = null) { |
|
41 | - $names = []; |
|
42 | - $allNames = array_keys($this->listeners); |
|
43 | - if ($scope and $method) { |
|
44 | - $name = $scope . '::' . $method; |
|
45 | - if (isset($this->listeners[$name])) { |
|
46 | - $names[] = $name; |
|
47 | - } |
|
48 | - } elseif ($scope) { |
|
49 | - foreach ($allNames as $name) { |
|
50 | - $parts = explode('::', $name, 2); |
|
51 | - if ($parts[0] == $scope) { |
|
52 | - $names[] = $name; |
|
53 | - } |
|
54 | - } |
|
55 | - } elseif ($method) { |
|
56 | - foreach ($allNames as $name) { |
|
57 | - $parts = explode('::', $name, 2); |
|
58 | - if ($parts[1] == $method) { |
|
59 | - $names[] = $name; |
|
60 | - } |
|
61 | - } |
|
62 | - } else { |
|
63 | - $names = $allNames; |
|
64 | - } |
|
34 | + /** |
|
35 | + * @param string $scope optional |
|
36 | + * @param string $method optional |
|
37 | + * @param callable $callback optional |
|
38 | + * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::removeListener |
|
39 | + */ |
|
40 | + public function removeListener($scope = null, $method = null, ?callable $callback = null) { |
|
41 | + $names = []; |
|
42 | + $allNames = array_keys($this->listeners); |
|
43 | + if ($scope and $method) { |
|
44 | + $name = $scope . '::' . $method; |
|
45 | + if (isset($this->listeners[$name])) { |
|
46 | + $names[] = $name; |
|
47 | + } |
|
48 | + } elseif ($scope) { |
|
49 | + foreach ($allNames as $name) { |
|
50 | + $parts = explode('::', $name, 2); |
|
51 | + if ($parts[0] == $scope) { |
|
52 | + $names[] = $name; |
|
53 | + } |
|
54 | + } |
|
55 | + } elseif ($method) { |
|
56 | + foreach ($allNames as $name) { |
|
57 | + $parts = explode('::', $name, 2); |
|
58 | + if ($parts[1] == $method) { |
|
59 | + $names[] = $name; |
|
60 | + } |
|
61 | + } |
|
62 | + } else { |
|
63 | + $names = $allNames; |
|
64 | + } |
|
65 | 65 | |
66 | - foreach ($names as $name) { |
|
67 | - if ($callback) { |
|
68 | - $index = array_search($callback, $this->listeners[$name], true); |
|
69 | - if ($index !== false) { |
|
70 | - unset($this->listeners[$name][$index]); |
|
71 | - } |
|
72 | - } else { |
|
73 | - $this->listeners[$name] = []; |
|
74 | - } |
|
75 | - } |
|
76 | - } |
|
66 | + foreach ($names as $name) { |
|
67 | + if ($callback) { |
|
68 | + $index = array_search($callback, $this->listeners[$name], true); |
|
69 | + if ($index !== false) { |
|
70 | + unset($this->listeners[$name][$index]); |
|
71 | + } |
|
72 | + } else { |
|
73 | + $this->listeners[$name] = []; |
|
74 | + } |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param string $scope |
|
80 | - * @param string $method |
|
81 | - * @param array $arguments optional |
|
82 | - * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTyped |
|
83 | - */ |
|
84 | - protected function emit($scope, $method, array $arguments = []) { |
|
85 | - $eventName = $scope . '::' . $method; |
|
86 | - if (isset($this->listeners[$eventName])) { |
|
87 | - foreach ($this->listeners[$eventName] as $callback) { |
|
88 | - call_user_func_array($callback, $arguments); |
|
89 | - } |
|
90 | - } |
|
91 | - } |
|
78 | + /** |
|
79 | + * @param string $scope |
|
80 | + * @param string $method |
|
81 | + * @param array $arguments optional |
|
82 | + * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTyped |
|
83 | + */ |
|
84 | + protected function emit($scope, $method, array $arguments = []) { |
|
85 | + $eventName = $scope . '::' . $method; |
|
86 | + if (isset($this->listeners[$eventName])) { |
|
87 | + foreach ($this->listeners[$eventName] as $callback) { |
|
88 | + call_user_func_array($callback, $arguments); |
|
89 | + } |
|
90 | + } |
|
91 | + } |
|
92 | 92 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | $managerProvider = $this->managerProvider; |
64 | 64 | $manager = $managerProvider(); |
65 | 65 | $data['manager'] = $manager; |
66 | - $mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/'); |
|
66 | + $mountPoint = '/'.$user->getUID().'/files/'.ltrim($data['mountpoint'], '/'); |
|
67 | 67 | $data['mountpoint'] = $mountPoint; |
68 | 68 | $data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']); |
69 | 69 | $data['certificateManager'] = \OC::$server->getCertificateManager(); |
@@ -16,52 +16,52 @@ |
||
16 | 16 | use OCP\Server; |
17 | 17 | |
18 | 18 | class MountProvider implements IMountProvider { |
19 | - public const STORAGE = '\OCA\Files_Sharing\External\Storage'; |
|
19 | + public const STORAGE = '\OCA\Files_Sharing\External\Storage'; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @var callable |
|
23 | - */ |
|
24 | - private $managerProvider; |
|
21 | + /** |
|
22 | + * @var callable |
|
23 | + */ |
|
24 | + private $managerProvider; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param IDBConnection $connection |
|
28 | - * @param callable $managerProvider due to setup order we need a callable that return the manager instead of the manager itself |
|
29 | - * @param ICloudIdManager $cloudIdManager |
|
30 | - */ |
|
31 | - public function __construct( |
|
32 | - private IDBConnection $connection, |
|
33 | - callable $managerProvider, |
|
34 | - private ICloudIdManager $cloudIdManager, |
|
35 | - ) { |
|
36 | - $this->managerProvider = $managerProvider; |
|
37 | - } |
|
26 | + /** |
|
27 | + * @param IDBConnection $connection |
|
28 | + * @param callable $managerProvider due to setup order we need a callable that return the manager instead of the manager itself |
|
29 | + * @param ICloudIdManager $cloudIdManager |
|
30 | + */ |
|
31 | + public function __construct( |
|
32 | + private IDBConnection $connection, |
|
33 | + callable $managerProvider, |
|
34 | + private ICloudIdManager $cloudIdManager, |
|
35 | + ) { |
|
36 | + $this->managerProvider = $managerProvider; |
|
37 | + } |
|
38 | 38 | |
39 | - public function getMount(IUser $user, $data, IStorageFactory $storageFactory) { |
|
40 | - $managerProvider = $this->managerProvider; |
|
41 | - $manager = $managerProvider(); |
|
42 | - $data['manager'] = $manager; |
|
43 | - $mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/'); |
|
44 | - $data['mountpoint'] = $mountPoint; |
|
45 | - $data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']); |
|
46 | - $data['certificateManager'] = \OC::$server->getCertificateManager(); |
|
47 | - $data['HttpClientService'] = Server::get(IClientService::class); |
|
48 | - return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory); |
|
49 | - } |
|
39 | + public function getMount(IUser $user, $data, IStorageFactory $storageFactory) { |
|
40 | + $managerProvider = $this->managerProvider; |
|
41 | + $manager = $managerProvider(); |
|
42 | + $data['manager'] = $manager; |
|
43 | + $mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/'); |
|
44 | + $data['mountpoint'] = $mountPoint; |
|
45 | + $data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']); |
|
46 | + $data['certificateManager'] = \OC::$server->getCertificateManager(); |
|
47 | + $data['HttpClientService'] = Server::get(IClientService::class); |
|
48 | + return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory); |
|
49 | + } |
|
50 | 50 | |
51 | - public function getMountsForUser(IUser $user, IStorageFactory $loader) { |
|
52 | - $qb = $this->connection->getQueryBuilder(); |
|
53 | - $qb->select('remote', 'share_token', 'password', 'mountpoint', 'owner') |
|
54 | - ->from('share_external') |
|
55 | - ->where($qb->expr()->eq('user', $qb->createNamedParameter($user->getUID()))) |
|
56 | - ->andWhere($qb->expr()->eq('accepted', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))); |
|
57 | - $result = $qb->executeQuery(); |
|
58 | - $mounts = []; |
|
59 | - while ($row = $result->fetch()) { |
|
60 | - $row['manager'] = $this; |
|
61 | - $row['token'] = $row['share_token']; |
|
62 | - $mounts[] = $this->getMount($user, $row, $loader); |
|
63 | - } |
|
64 | - $result->closeCursor(); |
|
65 | - return $mounts; |
|
66 | - } |
|
51 | + public function getMountsForUser(IUser $user, IStorageFactory $loader) { |
|
52 | + $qb = $this->connection->getQueryBuilder(); |
|
53 | + $qb->select('remote', 'share_token', 'password', 'mountpoint', 'owner') |
|
54 | + ->from('share_external') |
|
55 | + ->where($qb->expr()->eq('user', $qb->createNamedParameter($user->getUID()))) |
|
56 | + ->andWhere($qb->expr()->eq('accepted', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT))); |
|
57 | + $result = $qb->executeQuery(); |
|
58 | + $mounts = []; |
|
59 | + while ($row = $result->fetch()) { |
|
60 | + $row['manager'] = $this; |
|
61 | + $row['token'] = $row['share_token']; |
|
62 | + $mounts[] = $this->getMount($user, $row, $loader); |
|
63 | + } |
|
64 | + $result->closeCursor(); |
|
65 | + return $mounts; |
|
66 | + } |
|
67 | 67 | } |
@@ -32,77 +32,77 @@ |
||
32 | 32 | * Very thin wrapper class to make output testable |
33 | 33 | */ |
34 | 34 | class Output implements IOutput { |
35 | - /** @var string */ |
|
36 | - private $webRoot; |
|
35 | + /** @var string */ |
|
36 | + private $webRoot; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param $webRoot |
|
40 | - */ |
|
41 | - public function __construct($webRoot) { |
|
42 | - $this->webRoot = $webRoot; |
|
43 | - } |
|
38 | + /** |
|
39 | + * @param $webRoot |
|
40 | + */ |
|
41 | + public function __construct($webRoot) { |
|
42 | + $this->webRoot = $webRoot; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param string $out |
|
47 | - */ |
|
48 | - public function setOutput($out) { |
|
49 | - print($out); |
|
50 | - } |
|
45 | + /** |
|
46 | + * @param string $out |
|
47 | + */ |
|
48 | + public function setOutput($out) { |
|
49 | + print($out); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param string|resource $path or file handle |
|
54 | - * |
|
55 | - * @return bool false if an error occurred |
|
56 | - */ |
|
57 | - public function setReadfile($path) { |
|
58 | - if (is_resource($path)) { |
|
59 | - $output = fopen('php://output', 'w'); |
|
60 | - return stream_copy_to_stream($path, $output) > 0; |
|
61 | - } else { |
|
62 | - return @readfile($path); |
|
63 | - } |
|
64 | - } |
|
52 | + /** |
|
53 | + * @param string|resource $path or file handle |
|
54 | + * |
|
55 | + * @return bool false if an error occurred |
|
56 | + */ |
|
57 | + public function setReadfile($path) { |
|
58 | + if (is_resource($path)) { |
|
59 | + $output = fopen('php://output', 'w'); |
|
60 | + return stream_copy_to_stream($path, $output) > 0; |
|
61 | + } else { |
|
62 | + return @readfile($path); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param string $header |
|
68 | - */ |
|
69 | - public function setHeader($header) { |
|
70 | - header($header); |
|
71 | - } |
|
66 | + /** |
|
67 | + * @param string $header |
|
68 | + */ |
|
69 | + public function setHeader($header) { |
|
70 | + header($header); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param int $code sets the http status code |
|
75 | - */ |
|
76 | - public function setHttpResponseCode($code) { |
|
77 | - http_response_code($code); |
|
78 | - } |
|
73 | + /** |
|
74 | + * @param int $code sets the http status code |
|
75 | + */ |
|
76 | + public function setHttpResponseCode($code) { |
|
77 | + http_response_code($code); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return int returns the current http response code |
|
82 | - */ |
|
83 | - public function getHttpResponseCode() { |
|
84 | - return http_response_code(); |
|
85 | - } |
|
80 | + /** |
|
81 | + * @return int returns the current http response code |
|
82 | + */ |
|
83 | + public function getHttpResponseCode() { |
|
84 | + return http_response_code(); |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @param string $name |
|
89 | - * @param string $value |
|
90 | - * @param int $expire |
|
91 | - * @param string $path |
|
92 | - * @param string $domain |
|
93 | - * @param bool $secure |
|
94 | - * @param bool $httpOnly |
|
95 | - */ |
|
96 | - public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite = 'Lax') { |
|
97 | - $path = $this->webRoot ? : '/'; |
|
87 | + /** |
|
88 | + * @param string $name |
|
89 | + * @param string $value |
|
90 | + * @param int $expire |
|
91 | + * @param string $path |
|
92 | + * @param string $domain |
|
93 | + * @param bool $secure |
|
94 | + * @param bool $httpOnly |
|
95 | + */ |
|
96 | + public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite = 'Lax') { |
|
97 | + $path = $this->webRoot ? : '/'; |
|
98 | 98 | |
99 | - setcookie($name, $value, [ |
|
100 | - 'expires' => $expire, |
|
101 | - 'path' => $path, |
|
102 | - 'domain' => $domain, |
|
103 | - 'secure' => $secure, |
|
104 | - 'httponly' => $httpOnly, |
|
105 | - 'samesite' => $sameSite |
|
106 | - ]); |
|
107 | - } |
|
99 | + setcookie($name, $value, [ |
|
100 | + 'expires' => $expire, |
|
101 | + 'path' => $path, |
|
102 | + 'domain' => $domain, |
|
103 | + 'secure' => $secure, |
|
104 | + 'httponly' => $httpOnly, |
|
105 | + 'samesite' => $sameSite |
|
106 | + ]); |
|
107 | + } |
|
108 | 108 | } |
@@ -94,7 +94,7 @@ |
||
94 | 94 | * @param bool $httpOnly |
95 | 95 | */ |
96 | 96 | public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite = 'Lax') { |
97 | - $path = $this->webRoot ? : '/'; |
|
97 | + $path = $this->webRoot ?: '/'; |
|
98 | 98 | |
99 | 99 | setcookie($name, $value, [ |
100 | 100 | 'expires' => $expire, |
@@ -34,19 +34,19 @@ |
||
34 | 34 | use OCP\Migration\SimpleMigrationStep; |
35 | 35 | |
36 | 36 | class Version14000Date20180710092004 extends SimpleMigrationStep { |
37 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
38 | - /** @var ISchemaWrapper $schema */ |
|
39 | - $schema = $schemaClosure(); |
|
37 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
38 | + /** @var ISchemaWrapper $schema */ |
|
39 | + $schema = $schemaClosure(); |
|
40 | 40 | |
41 | - $table = $schema->getTable('share'); |
|
41 | + $table = $schema->getTable('share'); |
|
42 | 42 | |
43 | - if (!$table->hasColumn('password_by_talk')) { |
|
44 | - $table->addColumn('password_by_talk', Types::BOOLEAN, [ |
|
45 | - 'default' => 0, |
|
46 | - 'notnull' => false, |
|
47 | - ]); |
|
48 | - } |
|
43 | + if (!$table->hasColumn('password_by_talk')) { |
|
44 | + $table->addColumn('password_by_talk', Types::BOOLEAN, [ |
|
45 | + 'default' => 0, |
|
46 | + 'notnull' => false, |
|
47 | + ]); |
|
48 | + } |
|
49 | 49 | |
50 | - return $schema; |
|
51 | - } |
|
50 | + return $schema; |
|
51 | + } |
|
52 | 52 | } |