@@ -68,7 +68,7 @@ |
||
68 | 68 | |
69 | 69 | $query = $this->connection->getQueryBuilder(); |
70 | 70 | $query->update('share') |
71 | - ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) |
|
71 | + ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) |
|
72 | 72 | ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL))); |
73 | 73 | $query->execute(); |
74 | 74 | } |
@@ -36,47 +36,47 @@ |
||
36 | 36 | */ |
37 | 37 | class OwncloudGuestShareType implements IRepairStep { |
38 | 38 | |
39 | - /** @var IDBConnection */ |
|
40 | - private $connection; |
|
39 | + /** @var IDBConnection */ |
|
40 | + private $connection; |
|
41 | 41 | |
42 | - /** @var IConfig */ |
|
43 | - private $config; |
|
42 | + /** @var IConfig */ |
|
43 | + private $config; |
|
44 | 44 | |
45 | 45 | |
46 | - public function __construct(IDBConnection $connection, IConfig $config) { |
|
47 | - $this->connection = $connection; |
|
48 | - $this->config = $config; |
|
49 | - } |
|
46 | + public function __construct(IDBConnection $connection, IConfig $config) { |
|
47 | + $this->connection = $connection; |
|
48 | + $this->config = $config; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Returns the step's name |
|
53 | - * |
|
54 | - * @return string |
|
55 | - * @since 9.1.0 |
|
56 | - */ |
|
57 | - public function getName() { |
|
58 | - return 'Fix the share type of guest shares when migrating from ownCloud'; |
|
59 | - } |
|
51 | + /** |
|
52 | + * Returns the step's name |
|
53 | + * |
|
54 | + * @return string |
|
55 | + * @since 9.1.0 |
|
56 | + */ |
|
57 | + public function getName() { |
|
58 | + return 'Fix the share type of guest shares when migrating from ownCloud'; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param IOutput $output |
|
63 | - */ |
|
64 | - public function run(IOutput $output) { |
|
65 | - if (!$this->shouldRun()) { |
|
66 | - return; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @param IOutput $output |
|
63 | + */ |
|
64 | + public function run(IOutput $output) { |
|
65 | + if (!$this->shouldRun()) { |
|
66 | + return; |
|
67 | + } |
|
68 | 68 | |
69 | - $query = $this->connection->getQueryBuilder(); |
|
70 | - $query->update('share') |
|
71 | - ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) |
|
72 | - ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL))); |
|
73 | - $query->execute(); |
|
74 | - } |
|
69 | + $query = $this->connection->getQueryBuilder(); |
|
70 | + $query->update('share') |
|
71 | + ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST)) |
|
72 | + ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL))); |
|
73 | + $query->execute(); |
|
74 | + } |
|
75 | 75 | |
76 | - protected function shouldRun() { |
|
77 | - $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
78 | - return $appVersion === '0.10.0' || |
|
79 | - $this->config->getAppValue('core', 'vendor', '') === 'owncloud'; |
|
80 | - } |
|
76 | + protected function shouldRun() { |
|
77 | + $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
78 | + return $appVersion === '0.10.0' || |
|
79 | + $this->config->getAppValue('core', 'vendor', '') === 'owncloud'; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | } |
@@ -36,62 +36,62 @@ |
||
36 | 36 | */ |
37 | 37 | class SetPasswordColumn implements IRepairStep { |
38 | 38 | |
39 | - /** @var IDBConnection */ |
|
40 | - private $connection; |
|
41 | - |
|
42 | - /** @var IConfig */ |
|
43 | - private $config; |
|
44 | - |
|
45 | - |
|
46 | - public function __construct(IDBConnection $connection, IConfig $config) { |
|
47 | - $this->connection = $connection; |
|
48 | - $this->config = $config; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Returns the step's name |
|
53 | - * |
|
54 | - * @return string |
|
55 | - * @since 9.1.0 |
|
56 | - */ |
|
57 | - public function getName() { |
|
58 | - return 'Copy the share password into the dedicated column'; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @param IOutput $output |
|
63 | - */ |
|
64 | - public function run(IOutput $output) { |
|
65 | - if (!$this->shouldRun()) { |
|
66 | - return; |
|
67 | - } |
|
68 | - |
|
69 | - $query = $this->connection->getQueryBuilder(); |
|
70 | - $query |
|
71 | - ->update('share') |
|
72 | - ->set('password', 'share_with') |
|
73 | - ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK))) |
|
74 | - ->andWhere($query->expr()->isNotNull('share_with')); |
|
75 | - $result = $query->execute(); |
|
76 | - |
|
77 | - if ($result === 0) { |
|
78 | - // No link updated, no need to run the second query |
|
79 | - return; |
|
80 | - } |
|
81 | - |
|
82 | - $clearQuery = $this->connection->getQueryBuilder(); |
|
83 | - $clearQuery |
|
84 | - ->update('share') |
|
85 | - ->set('share_with', $clearQuery->createNamedParameter(null)) |
|
86 | - ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK))); |
|
87 | - |
|
88 | - $clearQuery->execute(); |
|
89 | - |
|
90 | - } |
|
91 | - |
|
92 | - protected function shouldRun() { |
|
93 | - $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
94 | - return version_compare($appVersion, '1.4.0', '<'); |
|
95 | - } |
|
39 | + /** @var IDBConnection */ |
|
40 | + private $connection; |
|
41 | + |
|
42 | + /** @var IConfig */ |
|
43 | + private $config; |
|
44 | + |
|
45 | + |
|
46 | + public function __construct(IDBConnection $connection, IConfig $config) { |
|
47 | + $this->connection = $connection; |
|
48 | + $this->config = $config; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Returns the step's name |
|
53 | + * |
|
54 | + * @return string |
|
55 | + * @since 9.1.0 |
|
56 | + */ |
|
57 | + public function getName() { |
|
58 | + return 'Copy the share password into the dedicated column'; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @param IOutput $output |
|
63 | + */ |
|
64 | + public function run(IOutput $output) { |
|
65 | + if (!$this->shouldRun()) { |
|
66 | + return; |
|
67 | + } |
|
68 | + |
|
69 | + $query = $this->connection->getQueryBuilder(); |
|
70 | + $query |
|
71 | + ->update('share') |
|
72 | + ->set('password', 'share_with') |
|
73 | + ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK))) |
|
74 | + ->andWhere($query->expr()->isNotNull('share_with')); |
|
75 | + $result = $query->execute(); |
|
76 | + |
|
77 | + if ($result === 0) { |
|
78 | + // No link updated, no need to run the second query |
|
79 | + return; |
|
80 | + } |
|
81 | + |
|
82 | + $clearQuery = $this->connection->getQueryBuilder(); |
|
83 | + $clearQuery |
|
84 | + ->update('share') |
|
85 | + ->set('share_with', $clearQuery->createNamedParameter(null)) |
|
86 | + ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK))); |
|
87 | + |
|
88 | + $clearQuery->execute(); |
|
89 | + |
|
90 | + } |
|
91 | + |
|
92 | + protected function shouldRun() { |
|
93 | + $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0'); |
|
94 | + return version_compare($appVersion, '1.4.0', '<'); |
|
95 | + } |
|
96 | 96 | |
97 | 97 | } |
@@ -28,26 +28,26 @@ |
||
28 | 28 | use OCP\ILogger; |
29 | 29 | |
30 | 30 | class CategoryFetcher extends Fetcher { |
31 | - /** |
|
32 | - * @param Factory $appDataFactory |
|
33 | - * @param IClientService $clientService |
|
34 | - * @param ITimeFactory $timeFactory |
|
35 | - * @param IConfig $config |
|
36 | - * @param ILogger $logger |
|
37 | - */ |
|
38 | - public function __construct(Factory $appDataFactory, |
|
39 | - IClientService $clientService, |
|
40 | - ITimeFactory $timeFactory, |
|
41 | - IConfig $config, |
|
42 | - ILogger $logger) { |
|
43 | - parent::__construct( |
|
44 | - $appDataFactory, |
|
45 | - $clientService, |
|
46 | - $timeFactory, |
|
47 | - $config, |
|
48 | - $logger |
|
49 | - ); |
|
50 | - $this->fileName = 'categories.json'; |
|
51 | - $this->endpointUrl = 'https://apps.nextcloud.com/api/v1/categories.json'; |
|
52 | - } |
|
31 | + /** |
|
32 | + * @param Factory $appDataFactory |
|
33 | + * @param IClientService $clientService |
|
34 | + * @param ITimeFactory $timeFactory |
|
35 | + * @param IConfig $config |
|
36 | + * @param ILogger $logger |
|
37 | + */ |
|
38 | + public function __construct(Factory $appDataFactory, |
|
39 | + IClientService $clientService, |
|
40 | + ITimeFactory $timeFactory, |
|
41 | + IConfig $config, |
|
42 | + ILogger $logger) { |
|
43 | + parent::__construct( |
|
44 | + $appDataFactory, |
|
45 | + $clientService, |
|
46 | + $timeFactory, |
|
47 | + $config, |
|
48 | + $logger |
|
49 | + ); |
|
50 | + $this->fileName = 'categories.json'; |
|
51 | + $this->endpointUrl = 'https://apps.nextcloud.com/api/v1/categories.json'; |
|
52 | + } |
|
53 | 53 | } |
@@ -34,20 +34,20 @@ |
||
34 | 34 | * @method void setName(string $name) |
35 | 35 | */ |
36 | 36 | class Client extends Entity { |
37 | - /** @var string */ |
|
38 | - protected $name; |
|
39 | - /** @var string */ |
|
40 | - protected $redirectUri; |
|
41 | - /** @var string */ |
|
42 | - protected $clientIdentifier; |
|
43 | - /** @var string */ |
|
44 | - protected $secret; |
|
37 | + /** @var string */ |
|
38 | + protected $name; |
|
39 | + /** @var string */ |
|
40 | + protected $redirectUri; |
|
41 | + /** @var string */ |
|
42 | + protected $clientIdentifier; |
|
43 | + /** @var string */ |
|
44 | + protected $secret; |
|
45 | 45 | |
46 | - public function __construct() { |
|
47 | - $this->addType('id', 'int'); |
|
48 | - $this->addType('name', 'string'); |
|
49 | - $this->addType('redirect_uri', 'string'); |
|
50 | - $this->addType('client_identifier', 'string'); |
|
51 | - $this->addType('secret', 'string'); |
|
52 | - } |
|
46 | + public function __construct() { |
|
47 | + $this->addType('id', 'int'); |
|
48 | + $this->addType('name', 'string'); |
|
49 | + $this->addType('redirect_uri', 'string'); |
|
50 | + $this->addType('client_identifier', 'string'); |
|
51 | + $this->addType('secret', 'string'); |
|
52 | + } |
|
53 | 53 | } |
@@ -31,31 +31,31 @@ |
||
31 | 31 | */ |
32 | 32 | interface ICredentials { |
33 | 33 | |
34 | - /** |
|
35 | - * Get the user UID |
|
36 | - * |
|
37 | - * @since 12 |
|
38 | - * |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function getUID(); |
|
34 | + /** |
|
35 | + * Get the user UID |
|
36 | + * |
|
37 | + * @since 12 |
|
38 | + * |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function getUID(); |
|
42 | 42 | |
43 | - /** |
|
44 | - * Get the login name the users used to login |
|
45 | - * |
|
46 | - * @since 12 |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function getLoginName(); |
|
43 | + /** |
|
44 | + * Get the login name the users used to login |
|
45 | + * |
|
46 | + * @since 12 |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function getLoginName(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get the password |
|
54 | - * |
|
55 | - * @since 12 |
|
56 | - * |
|
57 | - * @return string |
|
58 | - * @throws PasswordUnavailableException |
|
59 | - */ |
|
60 | - public function getPassword(); |
|
52 | + /** |
|
53 | + * Get the password |
|
54 | + * |
|
55 | + * @since 12 |
|
56 | + * |
|
57 | + * @return string |
|
58 | + * @throws PasswordUnavailableException |
|
59 | + */ |
|
60 | + public function getPassword(); |
|
61 | 61 | } |
@@ -14,8 +14,8 @@ |
||
14 | 14 | |
15 | 15 | <?php if ($_['tooBig']) { ?> |
16 | 16 | <div class="warning updateAnyways"> |
17 | - <?php p($l->t('I know that if I continue doing the update via web UI has the risk, that the request runs into a timeout and could cause data loss, but I have a backup and know how to restore my instance in case of a failure.' )); ?> |
|
18 | - <a href="?IKnowThatThisIsABigInstanceAndTheUpdateRequestCouldRunIntoATimeoutAndHowToRestoreABackup=IAmSuperSureToDoThis" class="button updateAnywaysButton"><?php p($l->t('Upgrade via web on my own risk' )); ?></a> |
|
17 | + <?php p($l->t('I know that if I continue doing the update via web UI has the risk, that the request runs into a timeout and could cause data loss, but I have a backup and know how to restore my instance in case of a failure.')); ?> |
|
18 | + <a href="?IKnowThatThisIsABigInstanceAndTheUpdateRequestCouldRunIntoATimeoutAndHowToRestoreABackup=IAmSuperSureToDoThis" class="button updateAnywaysButton"><?php p($l->t('Upgrade via web on my own risk')); ?></a> |
|
19 | 19 | </div> |
20 | 20 | <?php } ?> |
21 | 21 |
@@ -3,12 +3,12 @@ |
||
3 | 3 | <h2 class="title"><?php p($l->t('Update needed')) ?></h2> |
4 | 4 | <div class="infogroup"> |
5 | 5 | <?php if ($_['tooBig']) { |
6 | - p($l->t('Please use the command line updater because you have a big instance with more than 50 users.')); |
|
7 | - } else { |
|
8 | - p($l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
9 | - } ?><br><br> |
|
6 | + p($l->t('Please use the command line updater because you have a big instance with more than 50 users.')); |
|
7 | + } else { |
|
8 | + p($l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
9 | + } ?><br><br> |
|
10 | 10 | <?php |
11 | - print_unescaped($l->t('For help, see the <a target="_blank" rel="noreferrer noopener" href="%s">documentation</a>.', [link_to_docs('admin-cli-upgrade')])); ?><br><br> |
|
11 | + print_unescaped($l->t('For help, see the <a target="_blank" rel="noreferrer noopener" href="%s">documentation</a>.', [link_to_docs('admin-cli-upgrade')])); ?><br><br> |
|
12 | 12 | </div> |
13 | 13 | </div> |
14 | 14 |
@@ -84,7 +84,7 @@ |
||
84 | 84 | |
85 | 85 | if (isset($this->namespaces[$namespace])) { |
86 | 86 | if (!isset($this->hasNoAppContainer[$namespace])) { |
87 | - $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
87 | + $applicationClassName = 'OCA\\'.$sensitiveNamespace.'\\AppInfo\\Application'; |
|
88 | 88 | if (class_exists($applicationClassName)) { |
89 | 89 | new $applicationClassName(); |
90 | 90 | if (isset($this->appContainers[$namespace])) { |
@@ -35,113 +35,113 @@ |
||
35 | 35 | * @package OC |
36 | 36 | */ |
37 | 37 | class ServerContainer extends SimpleContainer { |
38 | - /** @var DIContainer[] */ |
|
39 | - protected $appContainers; |
|
40 | - |
|
41 | - /** @var string[] */ |
|
42 | - protected $hasNoAppContainer; |
|
43 | - |
|
44 | - /** @var string[] */ |
|
45 | - protected $namespaces; |
|
46 | - |
|
47 | - /** |
|
48 | - * ServerContainer constructor. |
|
49 | - */ |
|
50 | - public function __construct() { |
|
51 | - parent::__construct(); |
|
52 | - $this->appContainers = []; |
|
53 | - $this->namespaces = []; |
|
54 | - $this->hasNoAppContainer = []; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param string $appName |
|
59 | - * @param string $appNamespace |
|
60 | - */ |
|
61 | - public function registerNamespace(string $appName, string $appNamespace): void { |
|
62 | - // Cut of OCA\ and lowercase |
|
63 | - $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1)); |
|
64 | - $this->namespaces[$appNamespace] = $appName; |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * @param string $appName |
|
69 | - * @param DIContainer $container |
|
70 | - */ |
|
71 | - public function registerAppContainer(string $appName, DIContainer $container): void { |
|
72 | - $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @param string $appName |
|
77 | - * @return DIContainer |
|
78 | - * @throws QueryException |
|
79 | - */ |
|
80 | - public function getRegisteredAppContainer(string $appName): DIContainer { |
|
81 | - if (isset($this->appContainers[strtolower(App::buildAppNamespace($appName, ''))])) { |
|
82 | - return $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))]; |
|
83 | - } |
|
84 | - |
|
85 | - throw new QueryException(); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @param string $namespace |
|
90 | - * @param string $sensitiveNamespace |
|
91 | - * @return DIContainer |
|
92 | - * @throws QueryException |
|
93 | - */ |
|
94 | - protected function getAppContainer(string $namespace, string $sensitiveNamespace): DIContainer { |
|
95 | - if (isset($this->appContainers[$namespace])) { |
|
96 | - return $this->appContainers[$namespace]; |
|
97 | - } |
|
98 | - |
|
99 | - if (isset($this->namespaces[$namespace])) { |
|
100 | - if (!isset($this->hasNoAppContainer[$namespace])) { |
|
101 | - $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
102 | - if (class_exists($applicationClassName)) { |
|
103 | - new $applicationClassName(); |
|
104 | - if (isset($this->appContainers[$namespace])) { |
|
105 | - return $this->appContainers[$namespace]; |
|
106 | - } |
|
107 | - } |
|
108 | - $this->hasNoAppContainer[$namespace] = true; |
|
109 | - } |
|
110 | - |
|
111 | - return new DIContainer($this->namespaces[$namespace]); |
|
112 | - } |
|
113 | - throw new QueryException(); |
|
114 | - } |
|
115 | - |
|
116 | - public function query(string $name, bool $autoload = true) { |
|
117 | - $name = $this->sanitizeName($name); |
|
118 | - |
|
119 | - if (isset($this[$name])) { |
|
120 | - return $this[$name]; |
|
121 | - } |
|
122 | - |
|
123 | - // In case the service starts with OCA\ we try to find the service in |
|
124 | - // the apps container first. |
|
125 | - if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
126 | - $segments = explode('\\', $name); |
|
127 | - try { |
|
128 | - $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
129 | - return $appContainer->queryNoFallback($name); |
|
130 | - } catch (QueryException $e) { |
|
131 | - // Didn't find the service or the respective app container, |
|
132 | - // ignore it and fall back to the core container. |
|
133 | - } |
|
134 | - } else if (strpos($name, 'OC\\Settings\\') === 0 && substr_count($name, '\\') >= 3) { |
|
135 | - $segments = explode('\\', $name); |
|
136 | - try { |
|
137 | - $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
138 | - return $appContainer->queryNoFallback($name); |
|
139 | - } catch (QueryException $e) { |
|
140 | - // Didn't find the service or the respective app container, |
|
141 | - // ignore it and fall back to the core container. |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - return parent::query($name, $autoload); |
|
146 | - } |
|
38 | + /** @var DIContainer[] */ |
|
39 | + protected $appContainers; |
|
40 | + |
|
41 | + /** @var string[] */ |
|
42 | + protected $hasNoAppContainer; |
|
43 | + |
|
44 | + /** @var string[] */ |
|
45 | + protected $namespaces; |
|
46 | + |
|
47 | + /** |
|
48 | + * ServerContainer constructor. |
|
49 | + */ |
|
50 | + public function __construct() { |
|
51 | + parent::__construct(); |
|
52 | + $this->appContainers = []; |
|
53 | + $this->namespaces = []; |
|
54 | + $this->hasNoAppContainer = []; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param string $appName |
|
59 | + * @param string $appNamespace |
|
60 | + */ |
|
61 | + public function registerNamespace(string $appName, string $appNamespace): void { |
|
62 | + // Cut of OCA\ and lowercase |
|
63 | + $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1)); |
|
64 | + $this->namespaces[$appNamespace] = $appName; |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * @param string $appName |
|
69 | + * @param DIContainer $container |
|
70 | + */ |
|
71 | + public function registerAppContainer(string $appName, DIContainer $container): void { |
|
72 | + $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * @param string $appName |
|
77 | + * @return DIContainer |
|
78 | + * @throws QueryException |
|
79 | + */ |
|
80 | + public function getRegisteredAppContainer(string $appName): DIContainer { |
|
81 | + if (isset($this->appContainers[strtolower(App::buildAppNamespace($appName, ''))])) { |
|
82 | + return $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))]; |
|
83 | + } |
|
84 | + |
|
85 | + throw new QueryException(); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @param string $namespace |
|
90 | + * @param string $sensitiveNamespace |
|
91 | + * @return DIContainer |
|
92 | + * @throws QueryException |
|
93 | + */ |
|
94 | + protected function getAppContainer(string $namespace, string $sensitiveNamespace): DIContainer { |
|
95 | + if (isset($this->appContainers[$namespace])) { |
|
96 | + return $this->appContainers[$namespace]; |
|
97 | + } |
|
98 | + |
|
99 | + if (isset($this->namespaces[$namespace])) { |
|
100 | + if (!isset($this->hasNoAppContainer[$namespace])) { |
|
101 | + $applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application'; |
|
102 | + if (class_exists($applicationClassName)) { |
|
103 | + new $applicationClassName(); |
|
104 | + if (isset($this->appContainers[$namespace])) { |
|
105 | + return $this->appContainers[$namespace]; |
|
106 | + } |
|
107 | + } |
|
108 | + $this->hasNoAppContainer[$namespace] = true; |
|
109 | + } |
|
110 | + |
|
111 | + return new DIContainer($this->namespaces[$namespace]); |
|
112 | + } |
|
113 | + throw new QueryException(); |
|
114 | + } |
|
115 | + |
|
116 | + public function query(string $name, bool $autoload = true) { |
|
117 | + $name = $this->sanitizeName($name); |
|
118 | + |
|
119 | + if (isset($this[$name])) { |
|
120 | + return $this[$name]; |
|
121 | + } |
|
122 | + |
|
123 | + // In case the service starts with OCA\ we try to find the service in |
|
124 | + // the apps container first. |
|
125 | + if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
126 | + $segments = explode('\\', $name); |
|
127 | + try { |
|
128 | + $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
129 | + return $appContainer->queryNoFallback($name); |
|
130 | + } catch (QueryException $e) { |
|
131 | + // Didn't find the service or the respective app container, |
|
132 | + // ignore it and fall back to the core container. |
|
133 | + } |
|
134 | + } else if (strpos($name, 'OC\\Settings\\') === 0 && substr_count($name, '\\') >= 3) { |
|
135 | + $segments = explode('\\', $name); |
|
136 | + try { |
|
137 | + $appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]); |
|
138 | + return $appContainer->queryNoFallback($name); |
|
139 | + } catch (QueryException $e) { |
|
140 | + // Didn't find the service or the respective app container, |
|
141 | + // ignore it and fall back to the core container. |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + return parent::query($name, $autoload); |
|
146 | + } |
|
147 | 147 | } |
@@ -24,25 +24,25 @@ |
||
24 | 24 | namespace OC\Files\Cache\Wrapper; |
25 | 25 | |
26 | 26 | class CachePermissionsMask extends CacheWrapper { |
27 | - /** |
|
28 | - * @var int |
|
29 | - */ |
|
30 | - protected $mask; |
|
27 | + /** |
|
28 | + * @var int |
|
29 | + */ |
|
30 | + protected $mask; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param \OCP\Files\Cache\ICache $cache |
|
34 | - * @param int $mask |
|
35 | - */ |
|
36 | - public function __construct($cache, $mask) { |
|
37 | - parent::__construct($cache); |
|
38 | - $this->mask = $mask; |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param \OCP\Files\Cache\ICache $cache |
|
34 | + * @param int $mask |
|
35 | + */ |
|
36 | + public function __construct($cache, $mask) { |
|
37 | + parent::__construct($cache); |
|
38 | + $this->mask = $mask; |
|
39 | + } |
|
40 | 40 | |
41 | - protected function formatCacheEntry($entry) { |
|
42 | - if (isset($entry['permissions'])) { |
|
43 | - $entry['scan_permissions'] = $entry['permissions']; |
|
44 | - $entry['permissions'] &= $this->mask; |
|
45 | - } |
|
46 | - return $entry; |
|
47 | - } |
|
41 | + protected function formatCacheEntry($entry) { |
|
42 | + if (isset($entry['permissions'])) { |
|
43 | + $entry['scan_permissions'] = $entry['permissions']; |
|
44 | + $entry['permissions'] &= $this->mask; |
|
45 | + } |
|
46 | + return $entry; |
|
47 | + } |
|
48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | private function setupUserFs($userId) { |
56 | 56 | \OC_Util::setupFS($userId); |
57 | 57 | $this->session->close(); |
58 | - return $this->principalPrefix . $userId; |
|
58 | + return $this->principalPrefix.$userId; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | public function validateBearerToken($bearerToken) { |
65 | 65 | \OC_Util::setupFS(); |
66 | 66 | |
67 | - if(!$this->userSession->isLoggedIn()) { |
|
67 | + if (!$this->userSession->isLoggedIn()) { |
|
68 | 68 | $this->userSession->tryTokenLogin($this->request); |
69 | 69 | } |
70 | - if($this->userSession->isLoggedIn()) { |
|
70 | + if ($this->userSession->isLoggedIn()) { |
|
71 | 71 | return $this->setupUserFs($this->userSession->getUser()->getUID()); |
72 | 72 | } |
73 | 73 |
@@ -29,66 +29,66 @@ |
||
29 | 29 | use Sabre\HTTP\ResponseInterface; |
30 | 30 | |
31 | 31 | class BearerAuth extends AbstractBearer { |
32 | - /** @var IUserSession */ |
|
33 | - private $userSession; |
|
34 | - /** @var ISession */ |
|
35 | - private $session; |
|
36 | - /** @var IRequest */ |
|
37 | - private $request; |
|
38 | - /** @var string */ |
|
39 | - private $principalPrefix; |
|
32 | + /** @var IUserSession */ |
|
33 | + private $userSession; |
|
34 | + /** @var ISession */ |
|
35 | + private $session; |
|
36 | + /** @var IRequest */ |
|
37 | + private $request; |
|
38 | + /** @var string */ |
|
39 | + private $principalPrefix; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param IUserSession $userSession |
|
43 | - * @param ISession $session |
|
44 | - * @param string $principalPrefix |
|
45 | - * @param IRequest $request |
|
46 | - */ |
|
47 | - public function __construct(IUserSession $userSession, |
|
48 | - ISession $session, |
|
49 | - IRequest $request, |
|
50 | - $principalPrefix = 'principals/users/') { |
|
51 | - $this->userSession = $userSession; |
|
52 | - $this->session = $session; |
|
53 | - $this->request = $request; |
|
54 | - $this->principalPrefix = $principalPrefix; |
|
41 | + /** |
|
42 | + * @param IUserSession $userSession |
|
43 | + * @param ISession $session |
|
44 | + * @param string $principalPrefix |
|
45 | + * @param IRequest $request |
|
46 | + */ |
|
47 | + public function __construct(IUserSession $userSession, |
|
48 | + ISession $session, |
|
49 | + IRequest $request, |
|
50 | + $principalPrefix = 'principals/users/') { |
|
51 | + $this->userSession = $userSession; |
|
52 | + $this->session = $session; |
|
53 | + $this->request = $request; |
|
54 | + $this->principalPrefix = $principalPrefix; |
|
55 | 55 | |
56 | - // setup realm |
|
57 | - $defaults = new \OCP\Defaults(); |
|
58 | - $this->realm = $defaults->getName(); |
|
59 | - } |
|
56 | + // setup realm |
|
57 | + $defaults = new \OCP\Defaults(); |
|
58 | + $this->realm = $defaults->getName(); |
|
59 | + } |
|
60 | 60 | |
61 | - private function setupUserFs($userId) { |
|
62 | - \OC_Util::setupFS($userId); |
|
63 | - $this->session->close(); |
|
64 | - return $this->principalPrefix . $userId; |
|
65 | - } |
|
61 | + private function setupUserFs($userId) { |
|
62 | + \OC_Util::setupFS($userId); |
|
63 | + $this->session->close(); |
|
64 | + return $this->principalPrefix . $userId; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * {@inheritdoc} |
|
69 | - */ |
|
70 | - public function validateBearerToken($bearerToken) { |
|
71 | - \OC_Util::setupFS(); |
|
67 | + /** |
|
68 | + * {@inheritdoc} |
|
69 | + */ |
|
70 | + public function validateBearerToken($bearerToken) { |
|
71 | + \OC_Util::setupFS(); |
|
72 | 72 | |
73 | - if(!$this->userSession->isLoggedIn()) { |
|
74 | - $this->userSession->tryTokenLogin($this->request); |
|
75 | - } |
|
76 | - if($this->userSession->isLoggedIn()) { |
|
77 | - return $this->setupUserFs($this->userSession->getUser()->getUID()); |
|
78 | - } |
|
73 | + if(!$this->userSession->isLoggedIn()) { |
|
74 | + $this->userSession->tryTokenLogin($this->request); |
|
75 | + } |
|
76 | + if($this->userSession->isLoggedIn()) { |
|
77 | + return $this->setupUserFs($this->userSession->getUser()->getUID()); |
|
78 | + } |
|
79 | 79 | |
80 | - return false; |
|
81 | - } |
|
80 | + return false; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * \Sabre\DAV\Auth\Backend\AbstractBearer::challenge sets an WWW-Authenticate |
|
85 | - * header which some DAV clients can't handle. Thus we override this function |
|
86 | - * and make it simply return a 401. |
|
87 | - * |
|
88 | - * @param RequestInterface $request |
|
89 | - * @param ResponseInterface $response |
|
90 | - */ |
|
91 | - public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
92 | - $response->setStatus(401); |
|
93 | - } |
|
83 | + /** |
|
84 | + * \Sabre\DAV\Auth\Backend\AbstractBearer::challenge sets an WWW-Authenticate |
|
85 | + * header which some DAV clients can't handle. Thus we override this function |
|
86 | + * and make it simply return a 401. |
|
87 | + * |
|
88 | + * @param RequestInterface $request |
|
89 | + * @param ResponseInterface $response |
|
90 | + */ |
|
91 | + public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
92 | + $response->setStatus(401); |
|
93 | + } |
|
94 | 94 | } |