@@ -33,57 +33,57 @@ |
||
33 | 33 | * @package OC\Http |
34 | 34 | */ |
35 | 35 | class Response implements IResponse { |
36 | - /** @var ResponseInterface */ |
|
37 | - private $response; |
|
36 | + /** @var ResponseInterface */ |
|
37 | + private $response; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var bool |
|
41 | - */ |
|
42 | - private $stream; |
|
39 | + /** |
|
40 | + * @var bool |
|
41 | + */ |
|
42 | + private $stream; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param ResponseInterface $response |
|
46 | - * @param bool $stream |
|
47 | - */ |
|
48 | - public function __construct(ResponseInterface $response, $stream = false) { |
|
49 | - $this->response = $response; |
|
50 | - $this->stream = $stream; |
|
51 | - } |
|
44 | + /** |
|
45 | + * @param ResponseInterface $response |
|
46 | + * @param bool $stream |
|
47 | + */ |
|
48 | + public function __construct(ResponseInterface $response, $stream = false) { |
|
49 | + $this->response = $response; |
|
50 | + $this->stream = $stream; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return string|resource |
|
55 | - */ |
|
56 | - public function getBody() { |
|
57 | - return $this->stream ? |
|
58 | - $this->response->getBody()->detach(): |
|
59 | - $this->response->getBody()->getContents(); |
|
60 | - } |
|
53 | + /** |
|
54 | + * @return string|resource |
|
55 | + */ |
|
56 | + public function getBody() { |
|
57 | + return $this->stream ? |
|
58 | + $this->response->getBody()->detach(): |
|
59 | + $this->response->getBody()->getContents(); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return int |
|
64 | - */ |
|
65 | - public function getStatusCode(): int { |
|
66 | - return $this->response->getStatusCode(); |
|
67 | - } |
|
62 | + /** |
|
63 | + * @return int |
|
64 | + */ |
|
65 | + public function getStatusCode(): int { |
|
66 | + return $this->response->getStatusCode(); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param string $key |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function getHeader(string $key): string { |
|
74 | - $headers = $this->response->getHeader($key); |
|
69 | + /** |
|
70 | + * @param string $key |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function getHeader(string $key): string { |
|
74 | + $headers = $this->response->getHeader($key); |
|
75 | 75 | |
76 | - if (count($headers) === 0) { |
|
77 | - return ''; |
|
78 | - } |
|
76 | + if (count($headers) === 0) { |
|
77 | + return ''; |
|
78 | + } |
|
79 | 79 | |
80 | - return $headers[0]; |
|
81 | - } |
|
80 | + return $headers[0]; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @return array |
|
85 | - */ |
|
86 | - public function getHeaders(): array { |
|
87 | - return $this->response->getHeaders(); |
|
88 | - } |
|
83 | + /** |
|
84 | + * @return array |
|
85 | + */ |
|
86 | + public function getHeaders(): array { |
|
87 | + return $this->response->getHeaders(); |
|
88 | + } |
|
89 | 89 | } |
@@ -25,11 +25,11 @@ |
||
25 | 25 | use OpenStack\Identity\v2\Service; |
26 | 26 | |
27 | 27 | class SwiftV2CachingAuthService extends Service { |
28 | - public function authenticate(array $options = []): array { |
|
29 | - if (!empty($options['v2cachedToken'])) { |
|
30 | - return [$options['v2cachedToken'], $options['v2serviceUrl']]; |
|
31 | - } else { |
|
32 | - return parent::authenticate($options); |
|
33 | - } |
|
34 | - } |
|
28 | + public function authenticate(array $options = []): array { |
|
29 | + if (!empty($options['v2cachedToken'])) { |
|
30 | + return [$options['v2cachedToken'], $options['v2serviceUrl']]; |
|
31 | + } else { |
|
32 | + return parent::authenticate($options); |
|
33 | + } |
|
34 | + } |
|
35 | 35 | } |
@@ -26,106 +26,106 @@ |
||
26 | 26 | use OCP\Files\ObjectStore\IObjectStore; |
27 | 27 | |
28 | 28 | class Azure implements IObjectStore { |
29 | - /** @var string */ |
|
30 | - private $containerName; |
|
31 | - /** @var string */ |
|
32 | - private $accountName; |
|
33 | - /** @var string */ |
|
34 | - private $accountKey; |
|
35 | - /** @var BlobRestProxy|null */ |
|
36 | - private $blobClient = null; |
|
37 | - /** @var string|null */ |
|
38 | - private $endpoint = null; |
|
39 | - /** @var bool */ |
|
40 | - private $autoCreate = false; |
|
29 | + /** @var string */ |
|
30 | + private $containerName; |
|
31 | + /** @var string */ |
|
32 | + private $accountName; |
|
33 | + /** @var string */ |
|
34 | + private $accountKey; |
|
35 | + /** @var BlobRestProxy|null */ |
|
36 | + private $blobClient = null; |
|
37 | + /** @var string|null */ |
|
38 | + private $endpoint = null; |
|
39 | + /** @var bool */ |
|
40 | + private $autoCreate = false; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param array $parameters |
|
44 | - */ |
|
45 | - public function __construct($parameters) { |
|
46 | - $this->containerName = $parameters['container']; |
|
47 | - $this->accountName = $parameters['account_name']; |
|
48 | - $this->accountKey = $parameters['account_key']; |
|
49 | - if (isset($parameters['endpoint'])) { |
|
50 | - $this->endpoint = $parameters['endpoint']; |
|
51 | - } |
|
52 | - if (isset($parameters['autocreate'])) { |
|
53 | - $this->autoCreate = $parameters['autocreate']; |
|
54 | - } |
|
55 | - } |
|
42 | + /** |
|
43 | + * @param array $parameters |
|
44 | + */ |
|
45 | + public function __construct($parameters) { |
|
46 | + $this->containerName = $parameters['container']; |
|
47 | + $this->accountName = $parameters['account_name']; |
|
48 | + $this->accountKey = $parameters['account_key']; |
|
49 | + if (isset($parameters['endpoint'])) { |
|
50 | + $this->endpoint = $parameters['endpoint']; |
|
51 | + } |
|
52 | + if (isset($parameters['autocreate'])) { |
|
53 | + $this->autoCreate = $parameters['autocreate']; |
|
54 | + } |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return BlobRestProxy |
|
59 | - */ |
|
60 | - private function getBlobClient() { |
|
61 | - if (!$this->blobClient) { |
|
62 | - $protocol = $this->endpoint ? substr($this->endpoint, 0, strpos($this->endpoint, ':')) : 'https'; |
|
63 | - $connectionString = "DefaultEndpointsProtocol=" . $protocol . ";AccountName=" . $this->accountName . ";AccountKey=" . $this->accountKey; |
|
64 | - if ($this->endpoint) { |
|
65 | - $connectionString .= ';BlobEndpoint=' . $this->endpoint; |
|
66 | - } |
|
67 | - $this->blobClient = BlobRestProxy::createBlobService($connectionString); |
|
57 | + /** |
|
58 | + * @return BlobRestProxy |
|
59 | + */ |
|
60 | + private function getBlobClient() { |
|
61 | + if (!$this->blobClient) { |
|
62 | + $protocol = $this->endpoint ? substr($this->endpoint, 0, strpos($this->endpoint, ':')) : 'https'; |
|
63 | + $connectionString = "DefaultEndpointsProtocol=" . $protocol . ";AccountName=" . $this->accountName . ";AccountKey=" . $this->accountKey; |
|
64 | + if ($this->endpoint) { |
|
65 | + $connectionString .= ';BlobEndpoint=' . $this->endpoint; |
|
66 | + } |
|
67 | + $this->blobClient = BlobRestProxy::createBlobService($connectionString); |
|
68 | 68 | |
69 | - if ($this->autoCreate) { |
|
70 | - try { |
|
71 | - $this->blobClient->createContainer($this->containerName); |
|
72 | - } catch (ServiceException $e) { |
|
73 | - if ($e->getCode() === 409) { |
|
74 | - // already exists |
|
75 | - } else { |
|
76 | - throw $e; |
|
77 | - } |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
81 | - return $this->blobClient; |
|
82 | - } |
|
69 | + if ($this->autoCreate) { |
|
70 | + try { |
|
71 | + $this->blobClient->createContainer($this->containerName); |
|
72 | + } catch (ServiceException $e) { |
|
73 | + if ($e->getCode() === 409) { |
|
74 | + // already exists |
|
75 | + } else { |
|
76 | + throw $e; |
|
77 | + } |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | + return $this->blobClient; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return string the container or bucket name where objects are stored |
|
86 | - */ |
|
87 | - public function getStorageId() { |
|
88 | - return 'azure::blob::' . $this->containerName; |
|
89 | - } |
|
84 | + /** |
|
85 | + * @return string the container or bucket name where objects are stored |
|
86 | + */ |
|
87 | + public function getStorageId() { |
|
88 | + return 'azure::blob::' . $this->containerName; |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * @param string $urn the unified resource name used to identify the object |
|
93 | - * @return resource stream with the read data |
|
94 | - * @throws \Exception when something goes wrong, message will be logged |
|
95 | - */ |
|
96 | - public function readObject($urn) { |
|
97 | - $blob = $this->getBlobClient()->getBlob($this->containerName, $urn); |
|
98 | - return $blob->getContentStream(); |
|
99 | - } |
|
91 | + /** |
|
92 | + * @param string $urn the unified resource name used to identify the object |
|
93 | + * @return resource stream with the read data |
|
94 | + * @throws \Exception when something goes wrong, message will be logged |
|
95 | + */ |
|
96 | + public function readObject($urn) { |
|
97 | + $blob = $this->getBlobClient()->getBlob($this->containerName, $urn); |
|
98 | + return $blob->getContentStream(); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @param string $urn the unified resource name used to identify the object |
|
103 | - * @param resource $stream stream with the data to write |
|
104 | - * @throws \Exception when something goes wrong, message will be logged |
|
105 | - */ |
|
106 | - public function writeObject($urn, $stream) { |
|
107 | - $this->getBlobClient()->createBlockBlob($this->containerName, $urn, $stream); |
|
108 | - } |
|
101 | + /** |
|
102 | + * @param string $urn the unified resource name used to identify the object |
|
103 | + * @param resource $stream stream with the data to write |
|
104 | + * @throws \Exception when something goes wrong, message will be logged |
|
105 | + */ |
|
106 | + public function writeObject($urn, $stream) { |
|
107 | + $this->getBlobClient()->createBlockBlob($this->containerName, $urn, $stream); |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * @param string $urn the unified resource name used to identify the object |
|
112 | - * @return void |
|
113 | - * @throws \Exception when something goes wrong, message will be logged |
|
114 | - */ |
|
115 | - public function deleteObject($urn) { |
|
116 | - $this->getBlobClient()->deleteBlob($this->containerName, $urn); |
|
117 | - } |
|
110 | + /** |
|
111 | + * @param string $urn the unified resource name used to identify the object |
|
112 | + * @return void |
|
113 | + * @throws \Exception when something goes wrong, message will be logged |
|
114 | + */ |
|
115 | + public function deleteObject($urn) { |
|
116 | + $this->getBlobClient()->deleteBlob($this->containerName, $urn); |
|
117 | + } |
|
118 | 118 | |
119 | - public function objectExists($urn) { |
|
120 | - try { |
|
121 | - $this->getBlobClient()->getBlobMetadata($this->containerName, $urn); |
|
122 | - return true; |
|
123 | - } catch (ServiceException $e) { |
|
124 | - if ($e->getCode() === 404) { |
|
125 | - return false; |
|
126 | - } else { |
|
127 | - throw $e; |
|
128 | - } |
|
129 | - } |
|
130 | - } |
|
119 | + public function objectExists($urn) { |
|
120 | + try { |
|
121 | + $this->getBlobClient()->getBlobMetadata($this->containerName, $urn); |
|
122 | + return true; |
|
123 | + } catch (ServiceException $e) { |
|
124 | + if ($e->getCode() === 404) { |
|
125 | + return false; |
|
126 | + } else { |
|
127 | + throw $e; |
|
128 | + } |
|
129 | + } |
|
130 | + } |
|
131 | 131 | } |
@@ -33,43 +33,43 @@ |
||
33 | 33 | */ |
34 | 34 | interface IObjectStore { |
35 | 35 | |
36 | - /** |
|
37 | - * @return string the container or bucket name where objects are stored |
|
38 | - * @since 7.0.0 |
|
39 | - */ |
|
40 | - public function getStorageId(); |
|
36 | + /** |
|
37 | + * @return string the container or bucket name where objects are stored |
|
38 | + * @since 7.0.0 |
|
39 | + */ |
|
40 | + public function getStorageId(); |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param string $urn the unified resource name used to identify the object |
|
44 | - * @return resource stream with the read data |
|
45 | - * @throws \Exception when something goes wrong, message will be logged |
|
46 | - * @throws NotFoundException if file does not exist |
|
47 | - * @since 7.0.0 |
|
48 | - */ |
|
49 | - public function readObject($urn); |
|
42 | + /** |
|
43 | + * @param string $urn the unified resource name used to identify the object |
|
44 | + * @return resource stream with the read data |
|
45 | + * @throws \Exception when something goes wrong, message will be logged |
|
46 | + * @throws NotFoundException if file does not exist |
|
47 | + * @since 7.0.0 |
|
48 | + */ |
|
49 | + public function readObject($urn); |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param string $urn the unified resource name used to identify the object |
|
53 | - * @param resource $stream stream with the data to write |
|
54 | - * @throws \Exception when something goes wrong, message will be logged |
|
55 | - * @since 7.0.0 |
|
56 | - */ |
|
57 | - public function writeObject($urn, $stream); |
|
51 | + /** |
|
52 | + * @param string $urn the unified resource name used to identify the object |
|
53 | + * @param resource $stream stream with the data to write |
|
54 | + * @throws \Exception when something goes wrong, message will be logged |
|
55 | + * @since 7.0.0 |
|
56 | + */ |
|
57 | + public function writeObject($urn, $stream); |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param string $urn the unified resource name used to identify the object |
|
61 | - * @return void |
|
62 | - * @throws \Exception when something goes wrong, message will be logged |
|
63 | - * @since 7.0.0 |
|
64 | - */ |
|
65 | - public function deleteObject($urn); |
|
59 | + /** |
|
60 | + * @param string $urn the unified resource name used to identify the object |
|
61 | + * @return void |
|
62 | + * @throws \Exception when something goes wrong, message will be logged |
|
63 | + * @since 7.0.0 |
|
64 | + */ |
|
65 | + public function deleteObject($urn); |
|
66 | 66 | |
67 | - /** |
|
68 | - * Check if an object exists in the object store |
|
69 | - * |
|
70 | - * @param string $urn |
|
71 | - * @return bool |
|
72 | - * @since 16.0.0 |
|
73 | - */ |
|
74 | - public function objectExists($urn); |
|
67 | + /** |
|
68 | + * Check if an object exists in the object store |
|
69 | + * |
|
70 | + * @param string $urn |
|
71 | + * @return bool |
|
72 | + * @since 16.0.0 |
|
73 | + */ |
|
74 | + public function objectExists($urn); |
|
75 | 75 | } |
@@ -29,104 +29,104 @@ |
||
29 | 29 | |
30 | 30 | class RemoveClassifiedEventActivity implements IRepairStep { |
31 | 31 | |
32 | - /** @var IDBConnection */ |
|
33 | - private $connection; |
|
34 | - |
|
35 | - public function __construct(IDBConnection $connection) { |
|
36 | - $this->connection = $connection; |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * @inheritdoc |
|
41 | - */ |
|
42 | - public function getName() { |
|
43 | - return 'Remove activity entries of private events'; |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * @inheritdoc |
|
48 | - */ |
|
49 | - public function run(IOutput $output) { |
|
50 | - if (!$this->connection->tableExists('activity')) { |
|
51 | - return; |
|
52 | - } |
|
53 | - |
|
54 | - $deletedEvents = $this->removePrivateEventActivity(); |
|
55 | - $deletedEvents += $this->removeConfidentialUncensoredEventActivity(); |
|
56 | - |
|
57 | - $output->info("Removed $deletedEvents activity entries"); |
|
58 | - } |
|
59 | - |
|
60 | - protected function removePrivateEventActivity(): int { |
|
61 | - $deletedEvents = 0; |
|
62 | - |
|
63 | - $delete = $this->connection->getQueryBuilder(); |
|
64 | - $delete->delete('activity') |
|
65 | - ->where($delete->expr()->neq('affecteduser', $delete->createParameter('owner'))) |
|
66 | - ->andWhere($delete->expr()->eq('object_type', $delete->createParameter('type'))) |
|
67 | - ->andWhere($delete->expr()->eq('object_id', $delete->createParameter('calendar_id'))) |
|
68 | - ->andWhere($delete->expr()->like('subjectparams', $delete->createParameter('event_uid'))); |
|
69 | - |
|
70 | - $query = $this->connection->getQueryBuilder(); |
|
71 | - $query->select('c.principaluri', 'o.calendarid', 'o.uid') |
|
72 | - ->from('calendarobjects', 'o') |
|
73 | - ->leftJoin('o', 'calendars', 'c', $query->expr()->eq('c.id', 'o.calendarid')) |
|
74 | - ->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_PRIVATE))); |
|
75 | - $result = $query->execute(); |
|
76 | - |
|
77 | - while ($row = $result->fetch()) { |
|
78 | - if ($row['principaluri'] === null) { |
|
79 | - continue; |
|
80 | - } |
|
81 | - |
|
82 | - $delete->setParameter('owner', $this->getPrincipal($row['principaluri'])) |
|
83 | - ->setParameter('type', 'calendar') |
|
84 | - ->setParameter('calendar_id', $row['calendarid']) |
|
85 | - ->setParameter('event_uid', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '"') . '%'); |
|
86 | - $deletedEvents += $delete->execute(); |
|
87 | - } |
|
88 | - $result->closeCursor(); |
|
89 | - |
|
90 | - return $deletedEvents; |
|
91 | - } |
|
92 | - |
|
93 | - protected function removeConfidentialUncensoredEventActivity(): int { |
|
94 | - $deletedEvents = 0; |
|
95 | - |
|
96 | - $delete = $this->connection->getQueryBuilder(); |
|
97 | - $delete->delete('activity') |
|
98 | - ->where($delete->expr()->neq('affecteduser', $delete->createParameter('owner'))) |
|
99 | - ->andWhere($delete->expr()->eq('object_type', $delete->createParameter('type'))) |
|
100 | - ->andWhere($delete->expr()->eq('object_id', $delete->createParameter('calendar_id'))) |
|
101 | - ->andWhere($delete->expr()->like('subjectparams', $delete->createParameter('event_uid'))) |
|
102 | - ->andWhere($delete->expr()->notLike('subjectparams', $delete->createParameter('filtered_name'))); |
|
103 | - |
|
104 | - $query = $this->connection->getQueryBuilder(); |
|
105 | - $query->select('c.principaluri', 'o.calendarid', 'o.uid') |
|
106 | - ->from('calendarobjects', 'o') |
|
107 | - ->leftJoin('o', 'calendars', 'c', $query->expr()->eq('c.id', 'o.calendarid')) |
|
108 | - ->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_CONFIDENTIAL))); |
|
109 | - $result = $query->execute(); |
|
110 | - |
|
111 | - while ($row = $result->fetch()) { |
|
112 | - if ($row['principaluri'] === null) { |
|
113 | - continue; |
|
114 | - } |
|
115 | - |
|
116 | - $delete->setParameter('owner', $this->getPrincipal($row['principaluri'])) |
|
117 | - ->setParameter('type', 'calendar') |
|
118 | - ->setParameter('calendar_id', $row['calendarid']) |
|
119 | - ->setParameter('event_uid', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '"') . '%') |
|
120 | - ->setParameter('filtered_name', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '","name":"Busy"') . '%'); |
|
121 | - $deletedEvents += $delete->execute(); |
|
122 | - } |
|
123 | - $result->closeCursor(); |
|
124 | - |
|
125 | - return $deletedEvents; |
|
126 | - } |
|
127 | - |
|
128 | - protected function getPrincipal(string $principalUri): string { |
|
129 | - $uri = explode('/', $principalUri); |
|
130 | - return array_pop($uri); |
|
131 | - } |
|
32 | + /** @var IDBConnection */ |
|
33 | + private $connection; |
|
34 | + |
|
35 | + public function __construct(IDBConnection $connection) { |
|
36 | + $this->connection = $connection; |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * @inheritdoc |
|
41 | + */ |
|
42 | + public function getName() { |
|
43 | + return 'Remove activity entries of private events'; |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * @inheritdoc |
|
48 | + */ |
|
49 | + public function run(IOutput $output) { |
|
50 | + if (!$this->connection->tableExists('activity')) { |
|
51 | + return; |
|
52 | + } |
|
53 | + |
|
54 | + $deletedEvents = $this->removePrivateEventActivity(); |
|
55 | + $deletedEvents += $this->removeConfidentialUncensoredEventActivity(); |
|
56 | + |
|
57 | + $output->info("Removed $deletedEvents activity entries"); |
|
58 | + } |
|
59 | + |
|
60 | + protected function removePrivateEventActivity(): int { |
|
61 | + $deletedEvents = 0; |
|
62 | + |
|
63 | + $delete = $this->connection->getQueryBuilder(); |
|
64 | + $delete->delete('activity') |
|
65 | + ->where($delete->expr()->neq('affecteduser', $delete->createParameter('owner'))) |
|
66 | + ->andWhere($delete->expr()->eq('object_type', $delete->createParameter('type'))) |
|
67 | + ->andWhere($delete->expr()->eq('object_id', $delete->createParameter('calendar_id'))) |
|
68 | + ->andWhere($delete->expr()->like('subjectparams', $delete->createParameter('event_uid'))); |
|
69 | + |
|
70 | + $query = $this->connection->getQueryBuilder(); |
|
71 | + $query->select('c.principaluri', 'o.calendarid', 'o.uid') |
|
72 | + ->from('calendarobjects', 'o') |
|
73 | + ->leftJoin('o', 'calendars', 'c', $query->expr()->eq('c.id', 'o.calendarid')) |
|
74 | + ->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_PRIVATE))); |
|
75 | + $result = $query->execute(); |
|
76 | + |
|
77 | + while ($row = $result->fetch()) { |
|
78 | + if ($row['principaluri'] === null) { |
|
79 | + continue; |
|
80 | + } |
|
81 | + |
|
82 | + $delete->setParameter('owner', $this->getPrincipal($row['principaluri'])) |
|
83 | + ->setParameter('type', 'calendar') |
|
84 | + ->setParameter('calendar_id', $row['calendarid']) |
|
85 | + ->setParameter('event_uid', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '"') . '%'); |
|
86 | + $deletedEvents += $delete->execute(); |
|
87 | + } |
|
88 | + $result->closeCursor(); |
|
89 | + |
|
90 | + return $deletedEvents; |
|
91 | + } |
|
92 | + |
|
93 | + protected function removeConfidentialUncensoredEventActivity(): int { |
|
94 | + $deletedEvents = 0; |
|
95 | + |
|
96 | + $delete = $this->connection->getQueryBuilder(); |
|
97 | + $delete->delete('activity') |
|
98 | + ->where($delete->expr()->neq('affecteduser', $delete->createParameter('owner'))) |
|
99 | + ->andWhere($delete->expr()->eq('object_type', $delete->createParameter('type'))) |
|
100 | + ->andWhere($delete->expr()->eq('object_id', $delete->createParameter('calendar_id'))) |
|
101 | + ->andWhere($delete->expr()->like('subjectparams', $delete->createParameter('event_uid'))) |
|
102 | + ->andWhere($delete->expr()->notLike('subjectparams', $delete->createParameter('filtered_name'))); |
|
103 | + |
|
104 | + $query = $this->connection->getQueryBuilder(); |
|
105 | + $query->select('c.principaluri', 'o.calendarid', 'o.uid') |
|
106 | + ->from('calendarobjects', 'o') |
|
107 | + ->leftJoin('o', 'calendars', 'c', $query->expr()->eq('c.id', 'o.calendarid')) |
|
108 | + ->where($query->expr()->eq('o.classification', $query->createNamedParameter(CalDavBackend::CLASSIFICATION_CONFIDENTIAL))); |
|
109 | + $result = $query->execute(); |
|
110 | + |
|
111 | + while ($row = $result->fetch()) { |
|
112 | + if ($row['principaluri'] === null) { |
|
113 | + continue; |
|
114 | + } |
|
115 | + |
|
116 | + $delete->setParameter('owner', $this->getPrincipal($row['principaluri'])) |
|
117 | + ->setParameter('type', 'calendar') |
|
118 | + ->setParameter('calendar_id', $row['calendarid']) |
|
119 | + ->setParameter('event_uid', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '"') . '%') |
|
120 | + ->setParameter('filtered_name', '%' . $this->connection->escapeLikeParameter('{"id":"' . $row['uid'] . '","name":"Busy"') . '%'); |
|
121 | + $deletedEvents += $delete->execute(); |
|
122 | + } |
|
123 | + $result->closeCursor(); |
|
124 | + |
|
125 | + return $deletedEvents; |
|
126 | + } |
|
127 | + |
|
128 | + protected function getPrincipal(string $principalUri): string { |
|
129 | + $uri = explode('/', $principalUri); |
|
130 | + return array_pop($uri); |
|
131 | + } |
|
132 | 132 | } |
@@ -34,141 +34,141 @@ |
||
34 | 34 | * @since 6.0.0 |
35 | 35 | */ |
36 | 36 | interface IManager { |
37 | - /** |
|
38 | - * Generates a new IEvent object |
|
39 | - * |
|
40 | - * Make sure to call at least the following methods before sending it to the |
|
41 | - * app with via the publish() method: |
|
42 | - * - setApp() |
|
43 | - * - setType() |
|
44 | - * - setAffectedUser() |
|
45 | - * - setSubject() |
|
46 | - * |
|
47 | - * @return IEvent |
|
48 | - * @since 8.2.0 |
|
49 | - */ |
|
50 | - public function generateEvent(): IEvent; |
|
51 | - |
|
52 | - /** |
|
53 | - * Publish an event to the activity consumers |
|
54 | - * |
|
55 | - * Make sure to call at least the following methods before sending an Event: |
|
56 | - * - setApp() |
|
57 | - * - setType() |
|
58 | - * - setAffectedUser() |
|
59 | - * - setSubject() |
|
60 | - * |
|
61 | - * @param IEvent $event |
|
62 | - * @throws \BadMethodCallException if required values have not been set |
|
63 | - * @since 8.2.0 |
|
64 | - */ |
|
65 | - public function publish(IEvent $event): void; |
|
66 | - |
|
67 | - /** |
|
68 | - * In order to improve lazy loading a closure can be registered which will be called in case |
|
69 | - * activity consumers are actually requested |
|
70 | - * |
|
71 | - * $callable has to return an instance of \OCP\Activity\IConsumer |
|
72 | - * |
|
73 | - * @param \Closure $callable |
|
74 | - * @since 6.0.0 |
|
75 | - */ |
|
76 | - public function registerConsumer(\Closure $callable): void; |
|
77 | - |
|
78 | - /** |
|
79 | - * @param string $filter Class must implement OCA\Activity\IFilter |
|
80 | - * @since 11.0.0 |
|
81 | - */ |
|
82 | - public function registerFilter(string $filter): void; |
|
83 | - |
|
84 | - /** |
|
85 | - * @return IFilter[] |
|
86 | - * @since 11.0.0 |
|
87 | - */ |
|
88 | - public function getFilters(): array; |
|
89 | - |
|
90 | - /** |
|
91 | - * @param string $id |
|
92 | - * @return IFilter |
|
93 | - * @throws \InvalidArgumentException when the filter was not found |
|
94 | - * @since 11.0.0 |
|
95 | - */ |
|
96 | - public function getFilterById(string $id): IFilter; |
|
97 | - |
|
98 | - /** |
|
99 | - * @param string $setting Class must implement OCA\Activity\ISetting |
|
100 | - * @since 11.0.0 |
|
101 | - */ |
|
102 | - public function registerSetting(string $setting): void; |
|
103 | - |
|
104 | - /** |
|
105 | - * @return ISetting[] |
|
106 | - * @since 11.0.0 |
|
107 | - */ |
|
108 | - public function getSettings(): array; |
|
109 | - |
|
110 | - /** |
|
111 | - * @param string $provider Class must implement OCA\Activity\IProvider |
|
112 | - * @since 11.0.0 |
|
113 | - */ |
|
114 | - public function registerProvider(string $provider): void; |
|
115 | - |
|
116 | - /** |
|
117 | - * @return IProvider[] |
|
118 | - * @since 11.0.0 |
|
119 | - */ |
|
120 | - public function getProviders(): array; |
|
121 | - |
|
122 | - /** |
|
123 | - * @param string $id |
|
124 | - * @return ISetting |
|
125 | - * @throws \InvalidArgumentException when the setting was not found |
|
126 | - * @since 11.0.0 |
|
127 | - */ |
|
128 | - public function getSettingById(string $id): ISetting; |
|
129 | - |
|
130 | - /** |
|
131 | - * @param string $type |
|
132 | - * @param int $id |
|
133 | - * @since 8.2.0 |
|
134 | - */ |
|
135 | - public function setFormattingObject(string $type, int $id): void; |
|
136 | - |
|
137 | - /** |
|
138 | - * @return bool |
|
139 | - * @since 8.2.0 |
|
140 | - */ |
|
141 | - public function isFormattingFilteredObject(): bool; |
|
142 | - |
|
143 | - /** |
|
144 | - * @param bool $status Set to true, when parsing events should not use SVG icons |
|
145 | - * @since 12.0.1 |
|
146 | - */ |
|
147 | - public function setRequirePNG(bool $status): void; |
|
148 | - |
|
149 | - /** |
|
150 | - * @return bool |
|
151 | - * @since 12.0.1 |
|
152 | - */ |
|
153 | - public function getRequirePNG(): bool; |
|
154 | - |
|
155 | - /** |
|
156 | - * Set the user we need to use |
|
157 | - * |
|
158 | - * @param string|null $currentUserId |
|
159 | - * @throws \UnexpectedValueException If the user is invalid |
|
160 | - * @since 9.0.1 |
|
161 | - */ |
|
162 | - public function setCurrentUserId(string $currentUserId = null): void; |
|
163 | - |
|
164 | - /** |
|
165 | - * Get the user we need to use |
|
166 | - * |
|
167 | - * Either the user is logged in, or we try to get it from the token |
|
168 | - * |
|
169 | - * @return string |
|
170 | - * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique |
|
171 | - * @since 8.1.0 |
|
172 | - */ |
|
173 | - public function getCurrentUserId(): string; |
|
37 | + /** |
|
38 | + * Generates a new IEvent object |
|
39 | + * |
|
40 | + * Make sure to call at least the following methods before sending it to the |
|
41 | + * app with via the publish() method: |
|
42 | + * - setApp() |
|
43 | + * - setType() |
|
44 | + * - setAffectedUser() |
|
45 | + * - setSubject() |
|
46 | + * |
|
47 | + * @return IEvent |
|
48 | + * @since 8.2.0 |
|
49 | + */ |
|
50 | + public function generateEvent(): IEvent; |
|
51 | + |
|
52 | + /** |
|
53 | + * Publish an event to the activity consumers |
|
54 | + * |
|
55 | + * Make sure to call at least the following methods before sending an Event: |
|
56 | + * - setApp() |
|
57 | + * - setType() |
|
58 | + * - setAffectedUser() |
|
59 | + * - setSubject() |
|
60 | + * |
|
61 | + * @param IEvent $event |
|
62 | + * @throws \BadMethodCallException if required values have not been set |
|
63 | + * @since 8.2.0 |
|
64 | + */ |
|
65 | + public function publish(IEvent $event): void; |
|
66 | + |
|
67 | + /** |
|
68 | + * In order to improve lazy loading a closure can be registered which will be called in case |
|
69 | + * activity consumers are actually requested |
|
70 | + * |
|
71 | + * $callable has to return an instance of \OCP\Activity\IConsumer |
|
72 | + * |
|
73 | + * @param \Closure $callable |
|
74 | + * @since 6.0.0 |
|
75 | + */ |
|
76 | + public function registerConsumer(\Closure $callable): void; |
|
77 | + |
|
78 | + /** |
|
79 | + * @param string $filter Class must implement OCA\Activity\IFilter |
|
80 | + * @since 11.0.0 |
|
81 | + */ |
|
82 | + public function registerFilter(string $filter): void; |
|
83 | + |
|
84 | + /** |
|
85 | + * @return IFilter[] |
|
86 | + * @since 11.0.0 |
|
87 | + */ |
|
88 | + public function getFilters(): array; |
|
89 | + |
|
90 | + /** |
|
91 | + * @param string $id |
|
92 | + * @return IFilter |
|
93 | + * @throws \InvalidArgumentException when the filter was not found |
|
94 | + * @since 11.0.0 |
|
95 | + */ |
|
96 | + public function getFilterById(string $id): IFilter; |
|
97 | + |
|
98 | + /** |
|
99 | + * @param string $setting Class must implement OCA\Activity\ISetting |
|
100 | + * @since 11.0.0 |
|
101 | + */ |
|
102 | + public function registerSetting(string $setting): void; |
|
103 | + |
|
104 | + /** |
|
105 | + * @return ISetting[] |
|
106 | + * @since 11.0.0 |
|
107 | + */ |
|
108 | + public function getSettings(): array; |
|
109 | + |
|
110 | + /** |
|
111 | + * @param string $provider Class must implement OCA\Activity\IProvider |
|
112 | + * @since 11.0.0 |
|
113 | + */ |
|
114 | + public function registerProvider(string $provider): void; |
|
115 | + |
|
116 | + /** |
|
117 | + * @return IProvider[] |
|
118 | + * @since 11.0.0 |
|
119 | + */ |
|
120 | + public function getProviders(): array; |
|
121 | + |
|
122 | + /** |
|
123 | + * @param string $id |
|
124 | + * @return ISetting |
|
125 | + * @throws \InvalidArgumentException when the setting was not found |
|
126 | + * @since 11.0.0 |
|
127 | + */ |
|
128 | + public function getSettingById(string $id): ISetting; |
|
129 | + |
|
130 | + /** |
|
131 | + * @param string $type |
|
132 | + * @param int $id |
|
133 | + * @since 8.2.0 |
|
134 | + */ |
|
135 | + public function setFormattingObject(string $type, int $id): void; |
|
136 | + |
|
137 | + /** |
|
138 | + * @return bool |
|
139 | + * @since 8.2.0 |
|
140 | + */ |
|
141 | + public function isFormattingFilteredObject(): bool; |
|
142 | + |
|
143 | + /** |
|
144 | + * @param bool $status Set to true, when parsing events should not use SVG icons |
|
145 | + * @since 12.0.1 |
|
146 | + */ |
|
147 | + public function setRequirePNG(bool $status): void; |
|
148 | + |
|
149 | + /** |
|
150 | + * @return bool |
|
151 | + * @since 12.0.1 |
|
152 | + */ |
|
153 | + public function getRequirePNG(): bool; |
|
154 | + |
|
155 | + /** |
|
156 | + * Set the user we need to use |
|
157 | + * |
|
158 | + * @param string|null $currentUserId |
|
159 | + * @throws \UnexpectedValueException If the user is invalid |
|
160 | + * @since 9.0.1 |
|
161 | + */ |
|
162 | + public function setCurrentUserId(string $currentUserId = null): void; |
|
163 | + |
|
164 | + /** |
|
165 | + * Get the user we need to use |
|
166 | + * |
|
167 | + * Either the user is logged in, or we try to get it from the token |
|
168 | + * |
|
169 | + * @return string |
|
170 | + * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique |
|
171 | + * @since 8.1.0 |
|
172 | + */ |
|
173 | + public function getCurrentUserId(): string; |
|
174 | 174 | } |
@@ -32,68 +32,68 @@ |
||
32 | 32 | */ |
33 | 33 | interface ISubAdmin { |
34 | 34 | |
35 | - /** |
|
36 | - * add a SubAdmin |
|
37 | - * @param IUser $user user to be SubAdmin |
|
38 | - * @param IGroup $group group $user becomes subadmin of |
|
39 | - * |
|
40 | - * @since 16.0.0 |
|
41 | - */ |
|
42 | - public function createSubAdmin(IUser $user, IGroup $group): void; |
|
35 | + /** |
|
36 | + * add a SubAdmin |
|
37 | + * @param IUser $user user to be SubAdmin |
|
38 | + * @param IGroup $group group $user becomes subadmin of |
|
39 | + * |
|
40 | + * @since 16.0.0 |
|
41 | + */ |
|
42 | + public function createSubAdmin(IUser $user, IGroup $group): void; |
|
43 | 43 | |
44 | - /** |
|
45 | - * delete a SubAdmin |
|
46 | - * @param IUser $user the user that is the SubAdmin |
|
47 | - * @param IGroup $group the group |
|
48 | - * |
|
49 | - * @since 16.0.0 |
|
50 | - */ |
|
51 | - public function deleteSubAdmin(IUser $user, IGroup $group): void; |
|
44 | + /** |
|
45 | + * delete a SubAdmin |
|
46 | + * @param IUser $user the user that is the SubAdmin |
|
47 | + * @param IGroup $group the group |
|
48 | + * |
|
49 | + * @since 16.0.0 |
|
50 | + */ |
|
51 | + public function deleteSubAdmin(IUser $user, IGroup $group): void; |
|
52 | 52 | |
53 | - /** |
|
54 | - * get groups of a SubAdmin |
|
55 | - * @param IUser $user the SubAdmin |
|
56 | - * @return IGroup[] |
|
57 | - * |
|
58 | - * @since 16.0.0 |
|
59 | - */ |
|
60 | - public function getSubAdminsGroups(IUser $user): array; |
|
53 | + /** |
|
54 | + * get groups of a SubAdmin |
|
55 | + * @param IUser $user the SubAdmin |
|
56 | + * @return IGroup[] |
|
57 | + * |
|
58 | + * @since 16.0.0 |
|
59 | + */ |
|
60 | + public function getSubAdminsGroups(IUser $user): array; |
|
61 | 61 | |
62 | - /** |
|
63 | - * get SubAdmins of a group |
|
64 | - * @param IGroup $group the group |
|
65 | - * @return IUser[] |
|
66 | - * |
|
67 | - * @since 16.0.0 |
|
68 | - */ |
|
69 | - public function getGroupsSubAdmins(IGroup $group): array; |
|
62 | + /** |
|
63 | + * get SubAdmins of a group |
|
64 | + * @param IGroup $group the group |
|
65 | + * @return IUser[] |
|
66 | + * |
|
67 | + * @since 16.0.0 |
|
68 | + */ |
|
69 | + public function getGroupsSubAdmins(IGroup $group): array; |
|
70 | 70 | |
71 | - /** |
|
72 | - * checks if a user is a SubAdmin of a group |
|
73 | - * @param IUser $user |
|
74 | - * @param IGroup $group |
|
75 | - * @return bool |
|
76 | - * |
|
77 | - * @since 16.0.0 |
|
78 | - */ |
|
79 | - public function isSubAdminOfGroup(IUser $user, IGroup $group): bool; |
|
71 | + /** |
|
72 | + * checks if a user is a SubAdmin of a group |
|
73 | + * @param IUser $user |
|
74 | + * @param IGroup $group |
|
75 | + * @return bool |
|
76 | + * |
|
77 | + * @since 16.0.0 |
|
78 | + */ |
|
79 | + public function isSubAdminOfGroup(IUser $user, IGroup $group): bool; |
|
80 | 80 | |
81 | - /** |
|
82 | - * checks if a user is a SubAdmin |
|
83 | - * @param IUser $user |
|
84 | - * @return bool |
|
85 | - * |
|
86 | - * @since 16.0.0 |
|
87 | - */ |
|
88 | - public function isSubAdmin(IUser $user): bool; |
|
81 | + /** |
|
82 | + * checks if a user is a SubAdmin |
|
83 | + * @param IUser $user |
|
84 | + * @return bool |
|
85 | + * |
|
86 | + * @since 16.0.0 |
|
87 | + */ |
|
88 | + public function isSubAdmin(IUser $user): bool; |
|
89 | 89 | |
90 | - /** |
|
91 | - * checks if a user is a accessible by a subadmin |
|
92 | - * @param IUser $subadmin |
|
93 | - * @param IUser $user |
|
94 | - * @return bool |
|
95 | - * |
|
96 | - * @since 16.0.0 |
|
97 | - */ |
|
98 | - public function isUserAccessible(IUser $subadmin, IUser $user): bool; |
|
90 | + /** |
|
91 | + * checks if a user is a accessible by a subadmin |
|
92 | + * @param IUser $subadmin |
|
93 | + * @param IUser $user |
|
94 | + * @return bool |
|
95 | + * |
|
96 | + * @since 16.0.0 |
|
97 | + */ |
|
98 | + public function isUserAccessible(IUser $subadmin, IUser $user): bool; |
|
99 | 99 | } |
@@ -28,8 +28,8 @@ |
||
28 | 28 | use OCP\Template; |
29 | 29 | |
30 | 30 | class Personal implements IPersonalProviderSettings { |
31 | - public function getBody(): Template { |
|
32 | - return new Template('twofactor_backupcodes', 'personal'); |
|
33 | - } |
|
31 | + public function getBody(): Template { |
|
32 | + return new Template('twofactor_backupcodes', 'personal'); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | } |
@@ -30,61 +30,61 @@ |
||
30 | 30 | |
31 | 31 | class InitialStateService implements IInitialStateService { |
32 | 32 | |
33 | - /** @var ILogger */ |
|
34 | - private $logger; |
|
33 | + /** @var ILogger */ |
|
34 | + private $logger; |
|
35 | 35 | |
36 | - /** @var string[][] */ |
|
37 | - private $states = []; |
|
36 | + /** @var string[][] */ |
|
37 | + private $states = []; |
|
38 | 38 | |
39 | - /** @var Closure[][] */ |
|
40 | - private $lazyStates = []; |
|
39 | + /** @var Closure[][] */ |
|
40 | + private $lazyStates = []; |
|
41 | 41 | |
42 | - public function __construct(ILogger $logger) { |
|
43 | - $this->logger = $logger; |
|
44 | - } |
|
42 | + public function __construct(ILogger $logger) { |
|
43 | + $this->logger = $logger; |
|
44 | + } |
|
45 | 45 | |
46 | - public function provideInitialState(string $appName, string $key, $data): void { |
|
47 | - // Scalars and JsonSerializable are fine |
|
48 | - if (is_scalar($data) || $data instanceof \JsonSerializable || is_array($data)) { |
|
49 | - if (!isset($this->states[$appName])) { |
|
50 | - $this->states[$appName] = []; |
|
51 | - } |
|
52 | - $this->states[$appName][$key] = json_encode($data); |
|
53 | - return; |
|
54 | - } |
|
46 | + public function provideInitialState(string $appName, string $key, $data): void { |
|
47 | + // Scalars and JsonSerializable are fine |
|
48 | + if (is_scalar($data) || $data instanceof \JsonSerializable || is_array($data)) { |
|
49 | + if (!isset($this->states[$appName])) { |
|
50 | + $this->states[$appName] = []; |
|
51 | + } |
|
52 | + $this->states[$appName][$key] = json_encode($data); |
|
53 | + return; |
|
54 | + } |
|
55 | 55 | |
56 | - $this->logger->warning('Invalid data provided to provideInitialState by ' . $appName); |
|
57 | - } |
|
56 | + $this->logger->warning('Invalid data provided to provideInitialState by ' . $appName); |
|
57 | + } |
|
58 | 58 | |
59 | - public function provideLazyInitialState(string $appName, string $key, Closure $closure): void { |
|
60 | - if (!isset($this->lazyStates[$appName])) { |
|
61 | - $this->lazyStates[$appName] = []; |
|
62 | - } |
|
63 | - $this->lazyStates[$appName][$key] = $closure; |
|
64 | - } |
|
59 | + public function provideLazyInitialState(string $appName, string $key, Closure $closure): void { |
|
60 | + if (!isset($this->lazyStates[$appName])) { |
|
61 | + $this->lazyStates[$appName] = []; |
|
62 | + } |
|
63 | + $this->lazyStates[$appName][$key] = $closure; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Invoke all callbacks to populate the `states` property |
|
68 | - */ |
|
69 | - private function invokeLazyStateCallbacks(): void { |
|
70 | - foreach ($this->lazyStates as $app => $lazyStates) { |
|
71 | - foreach ($lazyStates as $key => $lazyState) { |
|
72 | - $this->provideInitialState($app, $key, $lazyState()); |
|
73 | - } |
|
74 | - } |
|
75 | - $this->lazyStates = []; |
|
76 | - } |
|
66 | + /** |
|
67 | + * Invoke all callbacks to populate the `states` property |
|
68 | + */ |
|
69 | + private function invokeLazyStateCallbacks(): void { |
|
70 | + foreach ($this->lazyStates as $app => $lazyStates) { |
|
71 | + foreach ($lazyStates as $key => $lazyState) { |
|
72 | + $this->provideInitialState($app, $key, $lazyState()); |
|
73 | + } |
|
74 | + } |
|
75 | + $this->lazyStates = []; |
|
76 | + } |
|
77 | 77 | |
78 | - public function getInitialStates(): array { |
|
79 | - $this->invokeLazyStateCallbacks(); |
|
78 | + public function getInitialStates(): array { |
|
79 | + $this->invokeLazyStateCallbacks(); |
|
80 | 80 | |
81 | - $appStates = []; |
|
82 | - foreach ($this->states as $app => $states) { |
|
83 | - foreach ($states as $key => $value) { |
|
84 | - $appStates["$app-$key"] = $value; |
|
85 | - } |
|
86 | - } |
|
87 | - return $appStates; |
|
88 | - } |
|
81 | + $appStates = []; |
|
82 | + foreach ($this->states as $app => $states) { |
|
83 | + foreach ($states as $key => $value) { |
|
84 | + $appStates["$app-$key"] = $value; |
|
85 | + } |
|
86 | + } |
|
87 | + return $appStates; |
|
88 | + } |
|
89 | 89 | |
90 | 90 | } |