@@ -28,27 +28,27 @@ |
||
28 | 28 | * @since 23.0.0 |
29 | 29 | */ |
30 | 30 | interface IDelegatedSettings extends ISettings { |
31 | - /** |
|
32 | - * Get the name of the settings to differentiate settings inside a section or |
|
33 | - * null if only the section name should be displayed. |
|
34 | - * @since 23.0.0 |
|
35 | - */ |
|
36 | - public function getName(): ?string; |
|
31 | + /** |
|
32 | + * Get the name of the settings to differentiate settings inside a section or |
|
33 | + * null if only the section name should be displayed. |
|
34 | + * @since 23.0.0 |
|
35 | + */ |
|
36 | + public function getName(): ?string; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Get a list of authorized app config that this setting is allowed to modify. |
|
40 | - * The format of the array is the following: |
|
41 | - * ```php |
|
42 | - * <?php |
|
43 | - * [ |
|
44 | - * 'app_name' => [ |
|
45 | - * '/simple_key/', # value |
|
46 | - * '/s[a-z]*ldap/', # regex |
|
47 | - * ], |
|
48 | - * 'another_app_name => [ ... ], |
|
49 | - * ] |
|
50 | - * ``` |
|
51 | - * @since 23.0.0 |
|
52 | - */ |
|
53 | - public function getAuthorizedAppConfig(): array; |
|
38 | + /** |
|
39 | + * Get a list of authorized app config that this setting is allowed to modify. |
|
40 | + * The format of the array is the following: |
|
41 | + * ```php |
|
42 | + * <?php |
|
43 | + * [ |
|
44 | + * 'app_name' => [ |
|
45 | + * '/simple_key/', # value |
|
46 | + * '/s[a-z]*ldap/', # regex |
|
47 | + * ], |
|
48 | + * 'another_app_name => [ ... ], |
|
49 | + * ] |
|
50 | + * ``` |
|
51 | + * @since 23.0.0 |
|
52 | + */ |
|
53 | + public function getAuthorizedAppConfig(): array; |
|
54 | 54 | } |
@@ -28,23 +28,23 @@ |
||
28 | 28 | use OCP\DB\QueryBuilder\IQueryFunction; |
29 | 29 | |
30 | 30 | class PgSqlFunctionBuilder extends FunctionBuilder { |
31 | - public function concat($x, ...$expr): IQueryFunction { |
|
32 | - $args = func_get_args(); |
|
33 | - $list = []; |
|
34 | - foreach ($args as $item) { |
|
35 | - $list[] = $this->queryBuilder->expr()->castColumn($item, IQueryBuilder::PARAM_STR); |
|
36 | - } |
|
37 | - return new QueryFunction(sprintf('(%s)', implode(' || ', $list))); |
|
38 | - } |
|
31 | + public function concat($x, ...$expr): IQueryFunction { |
|
32 | + $args = func_get_args(); |
|
33 | + $list = []; |
|
34 | + foreach ($args as $item) { |
|
35 | + $list[] = $this->queryBuilder->expr()->castColumn($item, IQueryBuilder::PARAM_STR); |
|
36 | + } |
|
37 | + return new QueryFunction(sprintf('(%s)', implode(' || ', $list))); |
|
38 | + } |
|
39 | 39 | |
40 | - public function groupConcat($expr, ?string $separator = ','): IQueryFunction { |
|
41 | - $castedExpression = $this->queryBuilder->expr()->castColumn($expr, IQueryBuilder::PARAM_STR); |
|
40 | + public function groupConcat($expr, ?string $separator = ','): IQueryFunction { |
|
41 | + $castedExpression = $this->queryBuilder->expr()->castColumn($expr, IQueryBuilder::PARAM_STR); |
|
42 | 42 | |
43 | - if (is_null($separator)) { |
|
44 | - return new QueryFunction('string_agg(' . $castedExpression . ')'); |
|
45 | - } |
|
43 | + if (is_null($separator)) { |
|
44 | + return new QueryFunction('string_agg(' . $castedExpression . ')'); |
|
45 | + } |
|
46 | 46 | |
47 | - $separator = $this->connection->quote($separator); |
|
48 | - return new QueryFunction('string_agg(' . $castedExpression . ', ' . $separator . ')'); |
|
49 | - } |
|
47 | + $separator = $this->connection->quote($separator); |
|
48 | + return new QueryFunction('string_agg(' . $castedExpression . ', ' . $separator . ')'); |
|
49 | + } |
|
50 | 50 | } |
@@ -41,10 +41,10 @@ |
||
41 | 41 | $castedExpression = $this->queryBuilder->expr()->castColumn($expr, IQueryBuilder::PARAM_STR); |
42 | 42 | |
43 | 43 | if (is_null($separator)) { |
44 | - return new QueryFunction('string_agg(' . $castedExpression . ')'); |
|
44 | + return new QueryFunction('string_agg('.$castedExpression.')'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $separator = $this->connection->quote($separator); |
48 | - return new QueryFunction('string_agg(' . $castedExpression . ', ' . $separator . ')'); |
|
48 | + return new QueryFunction('string_agg('.$castedExpression.', '.$separator.')'); |
|
49 | 49 | } |
50 | 50 | } |
@@ -24,74 +24,74 @@ |
||
24 | 24 | namespace OC; |
25 | 25 | |
26 | 26 | class AppScriptDependency { |
27 | - /** @var string */ |
|
28 | - private $id; |
|
27 | + /** @var string */ |
|
28 | + private $id; |
|
29 | 29 | |
30 | - /** @var array */ |
|
31 | - private $deps; |
|
30 | + /** @var array */ |
|
31 | + private $deps; |
|
32 | 32 | |
33 | - /** @var bool */ |
|
34 | - private $visited; |
|
33 | + /** @var bool */ |
|
34 | + private $visited; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param string $id |
|
38 | - * @param array $deps |
|
39 | - * @param bool $visited |
|
40 | - */ |
|
41 | - public function __construct(string $id, array $deps = [], bool $visited = false) { |
|
42 | - $this->setId($id); |
|
43 | - $this->setDeps($deps); |
|
44 | - $this->setVisited($visited); |
|
45 | - } |
|
36 | + /** |
|
37 | + * @param string $id |
|
38 | + * @param array $deps |
|
39 | + * @param bool $visited |
|
40 | + */ |
|
41 | + public function __construct(string $id, array $deps = [], bool $visited = false) { |
|
42 | + $this->setId($id); |
|
43 | + $this->setDeps($deps); |
|
44 | + $this->setVisited($visited); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function getId(): string { |
|
51 | - return $this->id; |
|
52 | - } |
|
47 | + /** |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function getId(): string { |
|
51 | + return $this->id; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param string $id |
|
56 | - */ |
|
57 | - public function setId(string $id): void { |
|
58 | - $this->id = $id; |
|
59 | - } |
|
54 | + /** |
|
55 | + * @param string $id |
|
56 | + */ |
|
57 | + public function setId(string $id): void { |
|
58 | + $this->id = $id; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - public function getDeps(): array { |
|
65 | - return $this->deps; |
|
66 | - } |
|
61 | + /** |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + public function getDeps(): array { |
|
65 | + return $this->deps; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param array $deps |
|
70 | - */ |
|
71 | - public function setDeps(array $deps): void { |
|
72 | - $this->deps = $deps; |
|
73 | - } |
|
68 | + /** |
|
69 | + * @param array $deps |
|
70 | + */ |
|
71 | + public function setDeps(array $deps): void { |
|
72 | + $this->deps = $deps; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @param string $dep |
|
77 | - */ |
|
78 | - public function addDep(string $dep): void { |
|
79 | - if (!in_array($dep, $this->deps, true)) { |
|
80 | - $this->deps[] = $dep; |
|
81 | - } |
|
82 | - } |
|
75 | + /** |
|
76 | + * @param string $dep |
|
77 | + */ |
|
78 | + public function addDep(string $dep): void { |
|
79 | + if (!in_array($dep, $this->deps, true)) { |
|
80 | + $this->deps[] = $dep; |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return bool |
|
86 | - */ |
|
87 | - public function isVisited(): bool { |
|
88 | - return $this->visited; |
|
89 | - } |
|
84 | + /** |
|
85 | + * @return bool |
|
86 | + */ |
|
87 | + public function isVisited(): bool { |
|
88 | + return $this->visited; |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * @param bool $visited |
|
93 | - */ |
|
94 | - public function setVisited(bool $visited): void { |
|
95 | - $this->visited = $visited; |
|
96 | - } |
|
91 | + /** |
|
92 | + * @param bool $visited |
|
93 | + */ |
|
94 | + public function setVisited(bool $visited): void { |
|
95 | + $this->visited = $visited; |
|
96 | + } |
|
97 | 97 | } |
@@ -29,16 +29,16 @@ |
||
29 | 29 | use OCP\Accounts\IAccountManager; |
30 | 30 | |
31 | 31 | trait TAccountsHelper { |
32 | - /** |
|
33 | - * returns whether the property is a collection |
|
34 | - */ |
|
35 | - protected function isCollection(string $propertyName): bool { |
|
36 | - return in_array( |
|
37 | - $propertyName, |
|
38 | - [ |
|
39 | - IAccountManager::COLLECTION_EMAIL, |
|
40 | - ], |
|
41 | - true |
|
42 | - ); |
|
43 | - } |
|
32 | + /** |
|
33 | + * returns whether the property is a collection |
|
34 | + */ |
|
35 | + protected function isCollection(string $propertyName): bool { |
|
36 | + return in_array( |
|
37 | + $propertyName, |
|
38 | + [ |
|
39 | + IAccountManager::COLLECTION_EMAIL, |
|
40 | + ], |
|
41 | + true |
|
42 | + ); |
|
43 | + } |
|
44 | 44 | } |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | foreach ($releases as $release) { |
152 | 152 | $versions[] = $release['version']; |
153 | 153 | } |
154 | - usort($versions, function ($version1, $version2) { |
|
154 | + usort($versions, function($version1, $version2) { |
|
155 | 155 | return version_compare($version1, $version2); |
156 | 156 | }); |
157 | 157 | $versions = array_reverse($versions); |
158 | 158 | if (isset($versions[0])) { |
159 | 159 | $highestVersion = $versions[0]; |
160 | 160 | foreach ($releases as $release) { |
161 | - if ((string)$release['version'] === (string)$highestVersion) { |
|
161 | + if ((string) $release['version'] === (string) $highestVersion) { |
|
162 | 162 | $response['data'][$dataKey]['releases'] = [$release]; |
163 | 163 | break; |
164 | 164 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | // If the admin specified a allow list, filter apps from the appstore |
190 | 190 | if (is_array($allowList) && $this->registry->delegateHasValidSubscription()) { |
191 | - return array_filter($apps, function ($app) use ($allowList) { |
|
191 | + return array_filter($apps, function($app) use ($allowList) { |
|
192 | 192 | return in_array($app['id'], $allowList); |
193 | 193 | }); |
194 | 194 | } |
@@ -16,157 +16,157 @@ |
||
16 | 16 | use Psr\Log\LoggerInterface; |
17 | 17 | |
18 | 18 | class AppFetcher extends Fetcher { |
19 | - /** @var bool */ |
|
20 | - private $ignoreMaxVersion; |
|
21 | - |
|
22 | - public function __construct( |
|
23 | - Factory $appDataFactory, |
|
24 | - IClientService $clientService, |
|
25 | - ITimeFactory $timeFactory, |
|
26 | - IConfig $config, |
|
27 | - private CompareVersion $compareVersion, |
|
28 | - LoggerInterface $logger, |
|
29 | - protected IRegistry $registry, |
|
30 | - ) { |
|
31 | - parent::__construct( |
|
32 | - $appDataFactory, |
|
33 | - $clientService, |
|
34 | - $timeFactory, |
|
35 | - $config, |
|
36 | - $logger, |
|
37 | - $registry |
|
38 | - ); |
|
39 | - |
|
40 | - $this->fileName = 'apps.json'; |
|
41 | - $this->endpointName = 'apps.json'; |
|
42 | - $this->ignoreMaxVersion = true; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * Only returns the latest compatible app release in the releases array |
|
47 | - * |
|
48 | - * @param string $ETag |
|
49 | - * @param string $content |
|
50 | - * @param bool [$allowUnstable] Allow unstable releases |
|
51 | - * |
|
52 | - * @return array |
|
53 | - */ |
|
54 | - protected function fetch($ETag, $content, $allowUnstable = false) { |
|
55 | - /** @var mixed[] $response */ |
|
56 | - $response = parent::fetch($ETag, $content); |
|
57 | - |
|
58 | - if (!isset($response['data']) || $response['data'] === null) { |
|
59 | - $this->logger->warning('Response from appstore is invalid, apps could not be retrieved. Try again later.', ['app' => 'appstoreFetcher']); |
|
60 | - return []; |
|
61 | - } |
|
62 | - |
|
63 | - $allowPreReleases = $allowUnstable || $this->getChannel() === 'beta' || $this->getChannel() === 'daily' || $this->getChannel() === 'git'; |
|
64 | - $allowNightly = $allowUnstable || $this->getChannel() === 'daily' || $this->getChannel() === 'git'; |
|
65 | - |
|
66 | - foreach ($response['data'] as $dataKey => $app) { |
|
67 | - $releases = []; |
|
68 | - |
|
69 | - // Filter all compatible releases |
|
70 | - foreach ($app['releases'] as $release) { |
|
71 | - // Exclude all nightly and pre-releases if required |
|
72 | - if (($allowNightly || $release['isNightly'] === false) |
|
73 | - && ($allowPreReleases || !str_contains($release['version'], '-'))) { |
|
74 | - // Exclude all versions not compatible with the current version |
|
75 | - try { |
|
76 | - $versionParser = new VersionParser(); |
|
77 | - $serverVersion = $versionParser->getVersion($release['rawPlatformVersionSpec']); |
|
78 | - $ncVersion = $this->getVersion(); |
|
79 | - $minServerVersion = $serverVersion->getMinimumVersion(); |
|
80 | - $maxServerVersion = $serverVersion->getMaximumVersion(); |
|
81 | - $minFulfilled = $this->compareVersion->isCompatible($ncVersion, $minServerVersion, '>='); |
|
82 | - $maxFulfilled = $maxServerVersion !== '' |
|
83 | - && $this->compareVersion->isCompatible($ncVersion, $maxServerVersion, '<='); |
|
84 | - $isPhpCompatible = true; |
|
85 | - if (($release['rawPhpVersionSpec'] ?? '*') !== '*') { |
|
86 | - $phpVersion = $versionParser->getVersion($release['rawPhpVersionSpec']); |
|
87 | - $minPhpVersion = $phpVersion->getMinimumVersion(); |
|
88 | - $maxPhpVersion = $phpVersion->getMaximumVersion(); |
|
89 | - $minPhpFulfilled = $minPhpVersion === '' || $this->compareVersion->isCompatible( |
|
90 | - PHP_VERSION, |
|
91 | - $minPhpVersion, |
|
92 | - '>=' |
|
93 | - ); |
|
94 | - $maxPhpFulfilled = $maxPhpVersion === '' || $this->compareVersion->isCompatible( |
|
95 | - PHP_VERSION, |
|
96 | - $maxPhpVersion, |
|
97 | - '<=' |
|
98 | - ); |
|
99 | - |
|
100 | - $isPhpCompatible = $minPhpFulfilled && $maxPhpFulfilled; |
|
101 | - } |
|
102 | - if ($minFulfilled && ($this->ignoreMaxVersion || $maxFulfilled) && $isPhpCompatible) { |
|
103 | - $releases[] = $release; |
|
104 | - } |
|
105 | - } catch (\InvalidArgumentException $e) { |
|
106 | - $this->logger->warning($e->getMessage(), [ |
|
107 | - 'exception' => $e, |
|
108 | - ]); |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
112 | - |
|
113 | - if (empty($releases)) { |
|
114 | - // Remove apps that don't have a matching release |
|
115 | - $response['data'][$dataKey] = []; |
|
116 | - continue; |
|
117 | - } |
|
118 | - |
|
119 | - // Get the highest version |
|
120 | - $versions = []; |
|
121 | - foreach ($releases as $release) { |
|
122 | - $versions[] = $release['version']; |
|
123 | - } |
|
124 | - usort($versions, function ($version1, $version2) { |
|
125 | - return version_compare($version1, $version2); |
|
126 | - }); |
|
127 | - $versions = array_reverse($versions); |
|
128 | - if (isset($versions[0])) { |
|
129 | - $highestVersion = $versions[0]; |
|
130 | - foreach ($releases as $release) { |
|
131 | - if ((string)$release['version'] === (string)$highestVersion) { |
|
132 | - $response['data'][$dataKey]['releases'] = [$release]; |
|
133 | - break; |
|
134 | - } |
|
135 | - } |
|
136 | - } |
|
137 | - } |
|
138 | - |
|
139 | - $response['data'] = array_values(array_filter($response['data'])); |
|
140 | - return $response; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * @param string $version |
|
145 | - * @param string $fileName |
|
146 | - * @param bool $ignoreMaxVersion |
|
147 | - */ |
|
148 | - public function setVersion(string $version, string $fileName = 'apps.json', bool $ignoreMaxVersion = true) { |
|
149 | - parent::setVersion($version); |
|
150 | - $this->fileName = $fileName; |
|
151 | - $this->ignoreMaxVersion = $ignoreMaxVersion; |
|
152 | - } |
|
153 | - |
|
154 | - public function get($allowUnstable = false): array { |
|
155 | - $allowPreReleases = $allowUnstable || $this->getChannel() === 'beta' || $this->getChannel() === 'daily' || $this->getChannel() === 'git'; |
|
156 | - |
|
157 | - $apps = parent::get($allowPreReleases); |
|
158 | - if (empty($apps)) { |
|
159 | - return []; |
|
160 | - } |
|
161 | - $allowList = $this->config->getSystemValue('appsallowlist'); |
|
162 | - |
|
163 | - // If the admin specified a allow list, filter apps from the appstore |
|
164 | - if (is_array($allowList) && $this->registry->delegateHasValidSubscription()) { |
|
165 | - return array_filter($apps, function ($app) use ($allowList) { |
|
166 | - return in_array($app['id'], $allowList); |
|
167 | - }); |
|
168 | - } |
|
169 | - |
|
170 | - return $apps; |
|
171 | - } |
|
19 | + /** @var bool */ |
|
20 | + private $ignoreMaxVersion; |
|
21 | + |
|
22 | + public function __construct( |
|
23 | + Factory $appDataFactory, |
|
24 | + IClientService $clientService, |
|
25 | + ITimeFactory $timeFactory, |
|
26 | + IConfig $config, |
|
27 | + private CompareVersion $compareVersion, |
|
28 | + LoggerInterface $logger, |
|
29 | + protected IRegistry $registry, |
|
30 | + ) { |
|
31 | + parent::__construct( |
|
32 | + $appDataFactory, |
|
33 | + $clientService, |
|
34 | + $timeFactory, |
|
35 | + $config, |
|
36 | + $logger, |
|
37 | + $registry |
|
38 | + ); |
|
39 | + |
|
40 | + $this->fileName = 'apps.json'; |
|
41 | + $this->endpointName = 'apps.json'; |
|
42 | + $this->ignoreMaxVersion = true; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * Only returns the latest compatible app release in the releases array |
|
47 | + * |
|
48 | + * @param string $ETag |
|
49 | + * @param string $content |
|
50 | + * @param bool [$allowUnstable] Allow unstable releases |
|
51 | + * |
|
52 | + * @return array |
|
53 | + */ |
|
54 | + protected function fetch($ETag, $content, $allowUnstable = false) { |
|
55 | + /** @var mixed[] $response */ |
|
56 | + $response = parent::fetch($ETag, $content); |
|
57 | + |
|
58 | + if (!isset($response['data']) || $response['data'] === null) { |
|
59 | + $this->logger->warning('Response from appstore is invalid, apps could not be retrieved. Try again later.', ['app' => 'appstoreFetcher']); |
|
60 | + return []; |
|
61 | + } |
|
62 | + |
|
63 | + $allowPreReleases = $allowUnstable || $this->getChannel() === 'beta' || $this->getChannel() === 'daily' || $this->getChannel() === 'git'; |
|
64 | + $allowNightly = $allowUnstable || $this->getChannel() === 'daily' || $this->getChannel() === 'git'; |
|
65 | + |
|
66 | + foreach ($response['data'] as $dataKey => $app) { |
|
67 | + $releases = []; |
|
68 | + |
|
69 | + // Filter all compatible releases |
|
70 | + foreach ($app['releases'] as $release) { |
|
71 | + // Exclude all nightly and pre-releases if required |
|
72 | + if (($allowNightly || $release['isNightly'] === false) |
|
73 | + && ($allowPreReleases || !str_contains($release['version'], '-'))) { |
|
74 | + // Exclude all versions not compatible with the current version |
|
75 | + try { |
|
76 | + $versionParser = new VersionParser(); |
|
77 | + $serverVersion = $versionParser->getVersion($release['rawPlatformVersionSpec']); |
|
78 | + $ncVersion = $this->getVersion(); |
|
79 | + $minServerVersion = $serverVersion->getMinimumVersion(); |
|
80 | + $maxServerVersion = $serverVersion->getMaximumVersion(); |
|
81 | + $minFulfilled = $this->compareVersion->isCompatible($ncVersion, $minServerVersion, '>='); |
|
82 | + $maxFulfilled = $maxServerVersion !== '' |
|
83 | + && $this->compareVersion->isCompatible($ncVersion, $maxServerVersion, '<='); |
|
84 | + $isPhpCompatible = true; |
|
85 | + if (($release['rawPhpVersionSpec'] ?? '*') !== '*') { |
|
86 | + $phpVersion = $versionParser->getVersion($release['rawPhpVersionSpec']); |
|
87 | + $minPhpVersion = $phpVersion->getMinimumVersion(); |
|
88 | + $maxPhpVersion = $phpVersion->getMaximumVersion(); |
|
89 | + $minPhpFulfilled = $minPhpVersion === '' || $this->compareVersion->isCompatible( |
|
90 | + PHP_VERSION, |
|
91 | + $minPhpVersion, |
|
92 | + '>=' |
|
93 | + ); |
|
94 | + $maxPhpFulfilled = $maxPhpVersion === '' || $this->compareVersion->isCompatible( |
|
95 | + PHP_VERSION, |
|
96 | + $maxPhpVersion, |
|
97 | + '<=' |
|
98 | + ); |
|
99 | + |
|
100 | + $isPhpCompatible = $minPhpFulfilled && $maxPhpFulfilled; |
|
101 | + } |
|
102 | + if ($minFulfilled && ($this->ignoreMaxVersion || $maxFulfilled) && $isPhpCompatible) { |
|
103 | + $releases[] = $release; |
|
104 | + } |
|
105 | + } catch (\InvalidArgumentException $e) { |
|
106 | + $this->logger->warning($e->getMessage(), [ |
|
107 | + 'exception' => $e, |
|
108 | + ]); |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | + |
|
113 | + if (empty($releases)) { |
|
114 | + // Remove apps that don't have a matching release |
|
115 | + $response['data'][$dataKey] = []; |
|
116 | + continue; |
|
117 | + } |
|
118 | + |
|
119 | + // Get the highest version |
|
120 | + $versions = []; |
|
121 | + foreach ($releases as $release) { |
|
122 | + $versions[] = $release['version']; |
|
123 | + } |
|
124 | + usort($versions, function ($version1, $version2) { |
|
125 | + return version_compare($version1, $version2); |
|
126 | + }); |
|
127 | + $versions = array_reverse($versions); |
|
128 | + if (isset($versions[0])) { |
|
129 | + $highestVersion = $versions[0]; |
|
130 | + foreach ($releases as $release) { |
|
131 | + if ((string)$release['version'] === (string)$highestVersion) { |
|
132 | + $response['data'][$dataKey]['releases'] = [$release]; |
|
133 | + break; |
|
134 | + } |
|
135 | + } |
|
136 | + } |
|
137 | + } |
|
138 | + |
|
139 | + $response['data'] = array_values(array_filter($response['data'])); |
|
140 | + return $response; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * @param string $version |
|
145 | + * @param string $fileName |
|
146 | + * @param bool $ignoreMaxVersion |
|
147 | + */ |
|
148 | + public function setVersion(string $version, string $fileName = 'apps.json', bool $ignoreMaxVersion = true) { |
|
149 | + parent::setVersion($version); |
|
150 | + $this->fileName = $fileName; |
|
151 | + $this->ignoreMaxVersion = $ignoreMaxVersion; |
|
152 | + } |
|
153 | + |
|
154 | + public function get($allowUnstable = false): array { |
|
155 | + $allowPreReleases = $allowUnstable || $this->getChannel() === 'beta' || $this->getChannel() === 'daily' || $this->getChannel() === 'git'; |
|
156 | + |
|
157 | + $apps = parent::get($allowPreReleases); |
|
158 | + if (empty($apps)) { |
|
159 | + return []; |
|
160 | + } |
|
161 | + $allowList = $this->config->getSystemValue('appsallowlist'); |
|
162 | + |
|
163 | + // If the admin specified a allow list, filter apps from the appstore |
|
164 | + if (is_array($allowList) && $this->registry->delegateHasValidSubscription()) { |
|
165 | + return array_filter($apps, function ($app) use ($allowList) { |
|
166 | + return in_array($app['id'], $allowList); |
|
167 | + }); |
|
168 | + } |
|
169 | + |
|
170 | + return $apps; |
|
171 | + } |
|
172 | 172 | } |
@@ -89,6 +89,6 @@ |
||
89 | 89 | if (empty($this->value)) { |
90 | 90 | return null; |
91 | 91 | } |
92 | - return 'tel:' . $this->value; |
|
92 | + return 'tel:'.$this->value; |
|
93 | 93 | } |
94 | 94 | } |
@@ -16,48 +16,48 @@ |
||
16 | 16 | use OCP\Profile\ILinkAction; |
17 | 17 | |
18 | 18 | class PhoneAction implements ILinkAction { |
19 | - private string $value = ''; |
|
20 | - |
|
21 | - public function __construct( |
|
22 | - private IAccountManager $accountManager, |
|
23 | - private IFactory $l10nFactory, |
|
24 | - private IURLGenerator $urlGenerator, |
|
25 | - ) { |
|
26 | - } |
|
27 | - |
|
28 | - public function preload(IUser $targetUser): void { |
|
29 | - $account = $this->accountManager->getAccount($targetUser); |
|
30 | - $this->value = $account->getProperty(IAccountManager::PROPERTY_PHONE)->getValue(); |
|
31 | - } |
|
32 | - |
|
33 | - public function getAppId(): string { |
|
34 | - return 'core'; |
|
35 | - } |
|
36 | - |
|
37 | - public function getId(): string { |
|
38 | - return IAccountManager::PROPERTY_PHONE; |
|
39 | - } |
|
40 | - |
|
41 | - public function getDisplayId(): string { |
|
42 | - return $this->l10nFactory->get('lib')->t('Phone'); |
|
43 | - } |
|
44 | - |
|
45 | - public function getTitle(): string { |
|
46 | - return $this->l10nFactory->get('lib')->t('Call %s', [$this->value]); |
|
47 | - } |
|
48 | - |
|
49 | - public function getPriority(): int { |
|
50 | - return 30; |
|
51 | - } |
|
52 | - |
|
53 | - public function getIcon(): string { |
|
54 | - return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/phone.svg')); |
|
55 | - } |
|
56 | - |
|
57 | - public function getTarget(): ?string { |
|
58 | - if (empty($this->value)) { |
|
59 | - return null; |
|
60 | - } |
|
61 | - return 'tel:' . $this->value; |
|
62 | - } |
|
19 | + private string $value = ''; |
|
20 | + |
|
21 | + public function __construct( |
|
22 | + private IAccountManager $accountManager, |
|
23 | + private IFactory $l10nFactory, |
|
24 | + private IURLGenerator $urlGenerator, |
|
25 | + ) { |
|
26 | + } |
|
27 | + |
|
28 | + public function preload(IUser $targetUser): void { |
|
29 | + $account = $this->accountManager->getAccount($targetUser); |
|
30 | + $this->value = $account->getProperty(IAccountManager::PROPERTY_PHONE)->getValue(); |
|
31 | + } |
|
32 | + |
|
33 | + public function getAppId(): string { |
|
34 | + return 'core'; |
|
35 | + } |
|
36 | + |
|
37 | + public function getId(): string { |
|
38 | + return IAccountManager::PROPERTY_PHONE; |
|
39 | + } |
|
40 | + |
|
41 | + public function getDisplayId(): string { |
|
42 | + return $this->l10nFactory->get('lib')->t('Phone'); |
|
43 | + } |
|
44 | + |
|
45 | + public function getTitle(): string { |
|
46 | + return $this->l10nFactory->get('lib')->t('Call %s', [$this->value]); |
|
47 | + } |
|
48 | + |
|
49 | + public function getPriority(): int { |
|
50 | + return 30; |
|
51 | + } |
|
52 | + |
|
53 | + public function getIcon(): string { |
|
54 | + return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/phone.svg')); |
|
55 | + } |
|
56 | + |
|
57 | + public function getTarget(): ?string { |
|
58 | + if (empty($this->value)) { |
|
59 | + return null; |
|
60 | + } |
|
61 | + return 'tel:' . $this->value; |
|
62 | + } |
|
63 | 63 | } |
@@ -89,6 +89,6 @@ |
||
89 | 89 | if (empty($this->value)) { |
90 | 90 | return null; |
91 | 91 | } |
92 | - return 'mailto:' . $this->value; |
|
92 | + return 'mailto:'.$this->value; |
|
93 | 93 | } |
94 | 94 | } |
@@ -16,48 +16,48 @@ |
||
16 | 16 | use OCP\Profile\ILinkAction; |
17 | 17 | |
18 | 18 | class EmailAction implements ILinkAction { |
19 | - private string $value = ''; |
|
20 | - |
|
21 | - public function __construct( |
|
22 | - private IAccountManager $accountManager, |
|
23 | - private IFactory $l10nFactory, |
|
24 | - private IURLGenerator $urlGenerator, |
|
25 | - ) { |
|
26 | - } |
|
27 | - |
|
28 | - public function preload(IUser $targetUser): void { |
|
29 | - $account = $this->accountManager->getAccount($targetUser); |
|
30 | - $this->value = $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(); |
|
31 | - } |
|
32 | - |
|
33 | - public function getAppId(): string { |
|
34 | - return 'core'; |
|
35 | - } |
|
36 | - |
|
37 | - public function getId(): string { |
|
38 | - return IAccountManager::PROPERTY_EMAIL; |
|
39 | - } |
|
40 | - |
|
41 | - public function getDisplayId(): string { |
|
42 | - return $this->l10nFactory->get('lib')->t('Email'); |
|
43 | - } |
|
44 | - |
|
45 | - public function getTitle(): string { |
|
46 | - return $this->l10nFactory->get('lib')->t('Mail %s', [$this->value]); |
|
47 | - } |
|
48 | - |
|
49 | - public function getPriority(): int { |
|
50 | - return 20; |
|
51 | - } |
|
52 | - |
|
53 | - public function getIcon(): string { |
|
54 | - return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); |
|
55 | - } |
|
56 | - |
|
57 | - public function getTarget(): ?string { |
|
58 | - if (empty($this->value)) { |
|
59 | - return null; |
|
60 | - } |
|
61 | - return 'mailto:' . $this->value; |
|
62 | - } |
|
19 | + private string $value = ''; |
|
20 | + |
|
21 | + public function __construct( |
|
22 | + private IAccountManager $accountManager, |
|
23 | + private IFactory $l10nFactory, |
|
24 | + private IURLGenerator $urlGenerator, |
|
25 | + ) { |
|
26 | + } |
|
27 | + |
|
28 | + public function preload(IUser $targetUser): void { |
|
29 | + $account = $this->accountManager->getAccount($targetUser); |
|
30 | + $this->value = $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(); |
|
31 | + } |
|
32 | + |
|
33 | + public function getAppId(): string { |
|
34 | + return 'core'; |
|
35 | + } |
|
36 | + |
|
37 | + public function getId(): string { |
|
38 | + return IAccountManager::PROPERTY_EMAIL; |
|
39 | + } |
|
40 | + |
|
41 | + public function getDisplayId(): string { |
|
42 | + return $this->l10nFactory->get('lib')->t('Email'); |
|
43 | + } |
|
44 | + |
|
45 | + public function getTitle(): string { |
|
46 | + return $this->l10nFactory->get('lib')->t('Mail %s', [$this->value]); |
|
47 | + } |
|
48 | + |
|
49 | + public function getPriority(): int { |
|
50 | + return 20; |
|
51 | + } |
|
52 | + |
|
53 | + public function getIcon(): string { |
|
54 | + return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); |
|
55 | + } |
|
56 | + |
|
57 | + public function getTarget(): ?string { |
|
58 | + if (empty($this->value)) { |
|
59 | + return null; |
|
60 | + } |
|
61 | + return 'mailto:' . $this->value; |
|
62 | + } |
|
63 | 63 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | public function getTitle(): string { |
78 | - $displayUsername = $this->value[0] === '@' ? $this->value : '@' . $this->value; |
|
78 | + $displayUsername = $this->value[0] === '@' ? $this->value : '@'.$this->value; |
|
79 | 79 | return $this->l10nFactory->get('lib')->t('View %s on Twitter', [$displayUsername]); |
80 | 80 | } |
81 | 81 | |
@@ -92,6 +92,6 @@ discard block |
||
92 | 92 | return null; |
93 | 93 | } |
94 | 94 | $username = $this->value[0] === '@' ? substr($this->value, 1) : $this->value; |
95 | - return 'https://twitter.com/' . $username; |
|
95 | + return 'https://twitter.com/'.$username; |
|
96 | 96 | } |
97 | 97 | } |
@@ -17,50 +17,50 @@ |
||
17 | 17 | use function substr; |
18 | 18 | |
19 | 19 | class TwitterAction implements ILinkAction { |
20 | - private string $value = ''; |
|
20 | + private string $value = ''; |
|
21 | 21 | |
22 | - public function __construct( |
|
23 | - private IAccountManager $accountManager, |
|
24 | - private IFactory $l10nFactory, |
|
25 | - private IURLGenerator $urlGenerator, |
|
26 | - ) { |
|
27 | - } |
|
22 | + public function __construct( |
|
23 | + private IAccountManager $accountManager, |
|
24 | + private IFactory $l10nFactory, |
|
25 | + private IURLGenerator $urlGenerator, |
|
26 | + ) { |
|
27 | + } |
|
28 | 28 | |
29 | - public function preload(IUser $targetUser): void { |
|
30 | - $account = $this->accountManager->getAccount($targetUser); |
|
31 | - $this->value = $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getValue(); |
|
32 | - } |
|
29 | + public function preload(IUser $targetUser): void { |
|
30 | + $account = $this->accountManager->getAccount($targetUser); |
|
31 | + $this->value = $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getValue(); |
|
32 | + } |
|
33 | 33 | |
34 | - public function getAppId(): string { |
|
35 | - return 'core'; |
|
36 | - } |
|
34 | + public function getAppId(): string { |
|
35 | + return 'core'; |
|
36 | + } |
|
37 | 37 | |
38 | - public function getId(): string { |
|
39 | - return IAccountManager::PROPERTY_TWITTER; |
|
40 | - } |
|
38 | + public function getId(): string { |
|
39 | + return IAccountManager::PROPERTY_TWITTER; |
|
40 | + } |
|
41 | 41 | |
42 | - public function getDisplayId(): string { |
|
43 | - return $this->l10nFactory->get('lib')->t('Twitter'); |
|
44 | - } |
|
42 | + public function getDisplayId(): string { |
|
43 | + return $this->l10nFactory->get('lib')->t('Twitter'); |
|
44 | + } |
|
45 | 45 | |
46 | - public function getTitle(): string { |
|
47 | - $displayUsername = $this->value[0] === '@' ? $this->value : '@' . $this->value; |
|
48 | - return $this->l10nFactory->get('lib')->t('View %s on Twitter', [$displayUsername]); |
|
49 | - } |
|
46 | + public function getTitle(): string { |
|
47 | + $displayUsername = $this->value[0] === '@' ? $this->value : '@' . $this->value; |
|
48 | + return $this->l10nFactory->get('lib')->t('View %s on Twitter', [$displayUsername]); |
|
49 | + } |
|
50 | 50 | |
51 | - public function getPriority(): int { |
|
52 | - return 50; |
|
53 | - } |
|
51 | + public function getPriority(): int { |
|
52 | + return 50; |
|
53 | + } |
|
54 | 54 | |
55 | - public function getIcon(): string { |
|
56 | - return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/twitter.svg')); |
|
57 | - } |
|
55 | + public function getIcon(): string { |
|
56 | + return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/twitter.svg')); |
|
57 | + } |
|
58 | 58 | |
59 | - public function getTarget(): ?string { |
|
60 | - if (empty($this->value)) { |
|
61 | - return null; |
|
62 | - } |
|
63 | - $username = $this->value[0] === '@' ? substr($this->value, 1) : $this->value; |
|
64 | - return 'https://twitter.com/' . $username; |
|
65 | - } |
|
59 | + public function getTarget(): ?string { |
|
60 | + if (empty($this->value)) { |
|
61 | + return null; |
|
62 | + } |
|
63 | + $username = $this->value[0] === '@' ? substr($this->value, 1) : $this->value; |
|
64 | + return 'https://twitter.com/' . $username; |
|
65 | + } |
|
66 | 66 | } |
@@ -96,7 +96,7 @@ |
||
96 | 96 | try { |
97 | 97 | $provider = $this->container->get($this->providerClass); |
98 | 98 | } catch (ContainerExceptionInterface $e) { |
99 | - $this->logger->error('Could not load user-status "' . $this->providerClass . '" provider dynamically: ' . $e->getMessage(), [ |
|
99 | + $this->logger->error('Could not load user-status "'.$this->providerClass.'" provider dynamically: '.$e->getMessage(), [ |
|
100 | 100 | 'exception' => $e, |
101 | 101 | ]); |
102 | 102 | return; |
@@ -15,86 +15,86 @@ |
||
15 | 15 | use Psr\Log\LoggerInterface; |
16 | 16 | |
17 | 17 | class Manager implements IManager { |
18 | - /** @var ?class-string */ |
|
19 | - private ?string $providerClass = null; |
|
20 | - private ?IProvider $provider = null; |
|
18 | + /** @var ?class-string */ |
|
19 | + private ?string $providerClass = null; |
|
20 | + private ?IProvider $provider = null; |
|
21 | 21 | |
22 | - public function __construct( |
|
23 | - private ContainerInterface $container, |
|
24 | - private LoggerInterface $logger, |
|
25 | - ) { |
|
26 | - } |
|
22 | + public function __construct( |
|
23 | + private ContainerInterface $container, |
|
24 | + private LoggerInterface $logger, |
|
25 | + ) { |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @inheritDoc |
|
30 | - */ |
|
31 | - public function getUserStatuses(array $userIds): array { |
|
32 | - $this->setupProvider(); |
|
33 | - if (!$this->provider) { |
|
34 | - return []; |
|
35 | - } |
|
28 | + /** |
|
29 | + * @inheritDoc |
|
30 | + */ |
|
31 | + public function getUserStatuses(array $userIds): array { |
|
32 | + $this->setupProvider(); |
|
33 | + if (!$this->provider) { |
|
34 | + return []; |
|
35 | + } |
|
36 | 36 | |
37 | - return $this->provider->getUserStatuses($userIds); |
|
38 | - } |
|
37 | + return $this->provider->getUserStatuses($userIds); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param string $class |
|
42 | - * @since 20.0.0 |
|
43 | - * @internal |
|
44 | - */ |
|
45 | - public function registerProvider(string $class): void { |
|
46 | - $this->providerClass = $class; |
|
47 | - $this->provider = null; |
|
48 | - } |
|
40 | + /** |
|
41 | + * @param string $class |
|
42 | + * @since 20.0.0 |
|
43 | + * @internal |
|
44 | + */ |
|
45 | + public function registerProvider(string $class): void { |
|
46 | + $this->providerClass = $class; |
|
47 | + $this->provider = null; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Lazily set up provider |
|
52 | - */ |
|
53 | - private function setupProvider(): void { |
|
54 | - if ($this->provider !== null) { |
|
55 | - return; |
|
56 | - } |
|
57 | - if ($this->providerClass === null) { |
|
58 | - return; |
|
59 | - } |
|
50 | + /** |
|
51 | + * Lazily set up provider |
|
52 | + */ |
|
53 | + private function setupProvider(): void { |
|
54 | + if ($this->provider !== null) { |
|
55 | + return; |
|
56 | + } |
|
57 | + if ($this->providerClass === null) { |
|
58 | + return; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @psalm-suppress InvalidCatch |
|
63 | - */ |
|
64 | - try { |
|
65 | - $provider = $this->container->get($this->providerClass); |
|
66 | - } catch (ContainerExceptionInterface $e) { |
|
67 | - $this->logger->error('Could not load user-status "' . $this->providerClass . '" provider dynamically: ' . $e->getMessage(), [ |
|
68 | - 'exception' => $e, |
|
69 | - ]); |
|
70 | - return; |
|
71 | - } |
|
61 | + /** |
|
62 | + * @psalm-suppress InvalidCatch |
|
63 | + */ |
|
64 | + try { |
|
65 | + $provider = $this->container->get($this->providerClass); |
|
66 | + } catch (ContainerExceptionInterface $e) { |
|
67 | + $this->logger->error('Could not load user-status "' . $this->providerClass . '" provider dynamically: ' . $e->getMessage(), [ |
|
68 | + 'exception' => $e, |
|
69 | + ]); |
|
70 | + return; |
|
71 | + } |
|
72 | 72 | |
73 | - $this->provider = $provider; |
|
74 | - } |
|
73 | + $this->provider = $provider; |
|
74 | + } |
|
75 | 75 | |
76 | - public function setUserStatus(string $userId, string $messageId, string $status, bool $createBackup = false, ?string $customMessage = null): void { |
|
77 | - $this->setupProvider(); |
|
78 | - if (!$this->provider instanceof ISettableProvider) { |
|
79 | - return; |
|
80 | - } |
|
76 | + public function setUserStatus(string $userId, string $messageId, string $status, bool $createBackup = false, ?string $customMessage = null): void { |
|
77 | + $this->setupProvider(); |
|
78 | + if (!$this->provider instanceof ISettableProvider) { |
|
79 | + return; |
|
80 | + } |
|
81 | 81 | |
82 | - $this->provider->setUserStatus($userId, $messageId, $status, $createBackup, $customMessage); |
|
83 | - } |
|
82 | + $this->provider->setUserStatus($userId, $messageId, $status, $createBackup, $customMessage); |
|
83 | + } |
|
84 | 84 | |
85 | - public function revertUserStatus(string $userId, string $messageId, string $status): void { |
|
86 | - $this->setupProvider(); |
|
87 | - if (!$this->provider instanceof ISettableProvider) { |
|
88 | - return; |
|
89 | - } |
|
90 | - $this->provider->revertUserStatus($userId, $messageId, $status); |
|
91 | - } |
|
85 | + public function revertUserStatus(string $userId, string $messageId, string $status): void { |
|
86 | + $this->setupProvider(); |
|
87 | + if (!$this->provider instanceof ISettableProvider) { |
|
88 | + return; |
|
89 | + } |
|
90 | + $this->provider->revertUserStatus($userId, $messageId, $status); |
|
91 | + } |
|
92 | 92 | |
93 | - public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void { |
|
94 | - $this->setupProvider(); |
|
95 | - if (!$this->provider instanceof ISettableProvider) { |
|
96 | - return; |
|
97 | - } |
|
98 | - $this->provider->revertMultipleUserStatus($userIds, $messageId, $status); |
|
99 | - } |
|
93 | + public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void { |
|
94 | + $this->setupProvider(); |
|
95 | + if (!$this->provider instanceof ISettableProvider) { |
|
96 | + return; |
|
97 | + } |
|
98 | + $this->provider->revertMultipleUserStatus($userIds, $messageId, $status); |
|
99 | + } |
|
100 | 100 | } |