@@ -28,24 +28,24 @@ |
||
28 | 28 | use OCP\Remote\IInstance; |
29 | 29 | |
30 | 30 | class ApiCollection implements IApiCollection { |
31 | - /** @var IInstance */ |
|
32 | - private $instance; |
|
33 | - /** @var ICredentials */ |
|
34 | - private $credentials; |
|
35 | - /** @var IClientService */ |
|
36 | - private $clientService; |
|
31 | + /** @var IInstance */ |
|
32 | + private $instance; |
|
33 | + /** @var ICredentials */ |
|
34 | + private $credentials; |
|
35 | + /** @var IClientService */ |
|
36 | + private $clientService; |
|
37 | 37 | |
38 | - public function __construct(IInstance $instance, ICredentials $credentials, IClientService $clientService) { |
|
39 | - $this->instance = $instance; |
|
40 | - $this->credentials = $credentials; |
|
41 | - $this->clientService = $clientService; |
|
42 | - } |
|
38 | + public function __construct(IInstance $instance, ICredentials $credentials, IClientService $clientService) { |
|
39 | + $this->instance = $instance; |
|
40 | + $this->credentials = $credentials; |
|
41 | + $this->clientService = $clientService; |
|
42 | + } |
|
43 | 43 | |
44 | - public function getCapabilitiesApi() { |
|
45 | - return new OCS($this->instance, $this->credentials, $this->clientService); |
|
46 | - } |
|
44 | + public function getCapabilitiesApi() { |
|
45 | + return new OCS($this->instance, $this->credentials, $this->clientService); |
|
46 | + } |
|
47 | 47 | |
48 | - public function getUserApi() { |
|
49 | - return new OCS($this->instance, $this->credentials, $this->clientService); |
|
50 | - } |
|
48 | + public function getUserApi() { |
|
49 | + return new OCS($this->instance, $this->credentials, $this->clientService); |
|
50 | + } |
|
51 | 51 | } |
@@ -26,72 +26,72 @@ |
||
26 | 26 | use OCP\Remote\IInstance; |
27 | 27 | |
28 | 28 | class ApiBase { |
29 | - /** @var IInstance */ |
|
30 | - private $instance; |
|
31 | - /** @var ICredentials */ |
|
32 | - private $credentials; |
|
33 | - /** @var IClientService */ |
|
34 | - private $clientService; |
|
29 | + /** @var IInstance */ |
|
30 | + private $instance; |
|
31 | + /** @var ICredentials */ |
|
32 | + private $credentials; |
|
33 | + /** @var IClientService */ |
|
34 | + private $clientService; |
|
35 | 35 | |
36 | - public function __construct(IInstance $instance, ICredentials $credentials, IClientService $clientService) { |
|
37 | - $this->instance = $instance; |
|
38 | - $this->credentials = $credentials; |
|
39 | - $this->clientService = $clientService; |
|
40 | - } |
|
36 | + public function __construct(IInstance $instance, ICredentials $credentials, IClientService $clientService) { |
|
37 | + $this->instance = $instance; |
|
38 | + $this->credentials = $credentials; |
|
39 | + $this->clientService = $clientService; |
|
40 | + } |
|
41 | 41 | |
42 | - protected function getHttpClient() { |
|
43 | - return $this->clientService->newClient(); |
|
44 | - } |
|
42 | + protected function getHttpClient() { |
|
43 | + return $this->clientService->newClient(); |
|
44 | + } |
|
45 | 45 | |
46 | - protected function addDefaultHeaders(array $headers) { |
|
47 | - return array_merge([ |
|
48 | - 'OCS-APIREQUEST' => 'true', |
|
49 | - 'Accept' => 'application/json' |
|
50 | - ], $headers); |
|
51 | - } |
|
46 | + protected function addDefaultHeaders(array $headers) { |
|
47 | + return array_merge([ |
|
48 | + 'OCS-APIREQUEST' => 'true', |
|
49 | + 'Accept' => 'application/json' |
|
50 | + ], $headers); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param string $method |
|
55 | - * @param string $url |
|
56 | - * @param array $body |
|
57 | - * @param array $query |
|
58 | - * @param array $headers |
|
59 | - * @return resource|string |
|
60 | - * @throws \InvalidArgumentException |
|
61 | - */ |
|
62 | - protected function request($method, $url, array $body = [], array $query = [], array $headers = []) { |
|
63 | - $fullUrl = trim($this->instance->getFullUrl(), '/') . '/' . $url; |
|
64 | - $options = [ |
|
65 | - 'query' => $query, |
|
66 | - 'headers' => $this->addDefaultHeaders($headers), |
|
67 | - 'auth' => [$this->credentials->getUsername(), $this->credentials->getPassword()] |
|
68 | - ]; |
|
69 | - if ($body) { |
|
70 | - $options['body'] = $body; |
|
71 | - } |
|
53 | + /** |
|
54 | + * @param string $method |
|
55 | + * @param string $url |
|
56 | + * @param array $body |
|
57 | + * @param array $query |
|
58 | + * @param array $headers |
|
59 | + * @return resource|string |
|
60 | + * @throws \InvalidArgumentException |
|
61 | + */ |
|
62 | + protected function request($method, $url, array $body = [], array $query = [], array $headers = []) { |
|
63 | + $fullUrl = trim($this->instance->getFullUrl(), '/') . '/' . $url; |
|
64 | + $options = [ |
|
65 | + 'query' => $query, |
|
66 | + 'headers' => $this->addDefaultHeaders($headers), |
|
67 | + 'auth' => [$this->credentials->getUsername(), $this->credentials->getPassword()] |
|
68 | + ]; |
|
69 | + if ($body) { |
|
70 | + $options['body'] = $body; |
|
71 | + } |
|
72 | 72 | |
73 | - $client = $this->getHttpClient(); |
|
73 | + $client = $this->getHttpClient(); |
|
74 | 74 | |
75 | - switch ($method) { |
|
76 | - case 'get': |
|
77 | - $response = $client->get($fullUrl, $options); |
|
78 | - break; |
|
79 | - case 'post': |
|
80 | - $response = $client->post($fullUrl, $options); |
|
81 | - break; |
|
82 | - case 'put': |
|
83 | - $response = $client->put($fullUrl, $options); |
|
84 | - break; |
|
85 | - case 'delete': |
|
86 | - $response = $client->delete($fullUrl, $options); |
|
87 | - break; |
|
88 | - case 'options': |
|
89 | - $response = $client->options($fullUrl, $options); |
|
90 | - break; |
|
91 | - default: |
|
92 | - throw new \InvalidArgumentException('Invalid method ' . $method); |
|
93 | - } |
|
75 | + switch ($method) { |
|
76 | + case 'get': |
|
77 | + $response = $client->get($fullUrl, $options); |
|
78 | + break; |
|
79 | + case 'post': |
|
80 | + $response = $client->post($fullUrl, $options); |
|
81 | + break; |
|
82 | + case 'put': |
|
83 | + $response = $client->put($fullUrl, $options); |
|
84 | + break; |
|
85 | + case 'delete': |
|
86 | + $response = $client->delete($fullUrl, $options); |
|
87 | + break; |
|
88 | + case 'options': |
|
89 | + $response = $client->options($fullUrl, $options); |
|
90 | + break; |
|
91 | + default: |
|
92 | + throw new \InvalidArgumentException('Invalid method ' . $method); |
|
93 | + } |
|
94 | 94 | |
95 | - return $response->getBody(); |
|
96 | - } |
|
95 | + return $response->getBody(); |
|
96 | + } |
|
97 | 97 | } |
@@ -27,17 +27,17 @@ |
||
27 | 27 | use OCP\Remote\IInstanceFactory; |
28 | 28 | |
29 | 29 | class InstanceFactory implements IInstanceFactory { |
30 | - /** @var ICache */ |
|
31 | - private $cache; |
|
32 | - /** @var IClientService */ |
|
33 | - private $clientService; |
|
30 | + /** @var ICache */ |
|
31 | + private $cache; |
|
32 | + /** @var IClientService */ |
|
33 | + private $clientService; |
|
34 | 34 | |
35 | - public function __construct(ICache $cache, IClientService $clientService) { |
|
36 | - $this->cache = $cache; |
|
37 | - $this->clientService = $clientService; |
|
38 | - } |
|
35 | + public function __construct(ICache $cache, IClientService $clientService) { |
|
36 | + $this->cache = $cache; |
|
37 | + $this->clientService = $clientService; |
|
38 | + } |
|
39 | 39 | |
40 | - public function getInstance($url) { |
|
41 | - return new Instance($url, $this->cache, $this->clientService); |
|
42 | - } |
|
40 | + public function getInstance($url) { |
|
41 | + return new Instance($url, $this->cache, $this->clientService); |
|
42 | + } |
|
43 | 43 | } |
@@ -30,70 +30,70 @@ |
||
30 | 30 | use OCP\Remote\Api\IUserApi; |
31 | 31 | |
32 | 32 | class OCS extends ApiBase implements ICapabilitiesApi, IUserApi { |
33 | - /** |
|
34 | - * @param string $method |
|
35 | - * @param string $url |
|
36 | - * @param array $body |
|
37 | - * @param array $query |
|
38 | - * @param array $headers |
|
39 | - * @return array |
|
40 | - * @throws ForbiddenException |
|
41 | - * @throws NotFoundException |
|
42 | - * @throws \Exception |
|
43 | - */ |
|
44 | - protected function request($method, $url, array $body = [], array $query = [], array $headers = []) { |
|
45 | - try { |
|
46 | - $response = json_decode(parent::request($method, 'ocs/v2.php/' . $url, $body, $query, $headers), true); |
|
47 | - } catch (ClientException $e) { |
|
48 | - if ($e->getResponse()->getStatusCode() === 404) { |
|
49 | - throw new NotFoundException(); |
|
50 | - } else if ($e->getResponse()->getStatusCode() === 403 || $e->getResponse()->getStatusCode() === 401) { |
|
51 | - throw new ForbiddenException(); |
|
52 | - } else { |
|
53 | - throw $e; |
|
54 | - } |
|
55 | - } |
|
56 | - if (!isset($response['ocs']) || !isset($response['ocs']['meta'])) { |
|
57 | - throw new \Exception('Invalid ocs response'); |
|
58 | - } |
|
59 | - if ($response['ocs']['meta']['statuscode'] === API::RESPOND_UNAUTHORISED) { |
|
60 | - throw new ForbiddenException(); |
|
61 | - } |
|
62 | - if ($response['ocs']['meta']['statuscode'] === API::RESPOND_NOT_FOUND) { |
|
63 | - throw new NotFoundException(); |
|
64 | - } |
|
65 | - if ($response['ocs']['meta']['status'] !== 'ok') { |
|
66 | - throw new \Exception('Unknown ocs error ' . $response['ocs']['meta']['message']); |
|
67 | - } |
|
33 | + /** |
|
34 | + * @param string $method |
|
35 | + * @param string $url |
|
36 | + * @param array $body |
|
37 | + * @param array $query |
|
38 | + * @param array $headers |
|
39 | + * @return array |
|
40 | + * @throws ForbiddenException |
|
41 | + * @throws NotFoundException |
|
42 | + * @throws \Exception |
|
43 | + */ |
|
44 | + protected function request($method, $url, array $body = [], array $query = [], array $headers = []) { |
|
45 | + try { |
|
46 | + $response = json_decode(parent::request($method, 'ocs/v2.php/' . $url, $body, $query, $headers), true); |
|
47 | + } catch (ClientException $e) { |
|
48 | + if ($e->getResponse()->getStatusCode() === 404) { |
|
49 | + throw new NotFoundException(); |
|
50 | + } else if ($e->getResponse()->getStatusCode() === 403 || $e->getResponse()->getStatusCode() === 401) { |
|
51 | + throw new ForbiddenException(); |
|
52 | + } else { |
|
53 | + throw $e; |
|
54 | + } |
|
55 | + } |
|
56 | + if (!isset($response['ocs']) || !isset($response['ocs']['meta'])) { |
|
57 | + throw new \Exception('Invalid ocs response'); |
|
58 | + } |
|
59 | + if ($response['ocs']['meta']['statuscode'] === API::RESPOND_UNAUTHORISED) { |
|
60 | + throw new ForbiddenException(); |
|
61 | + } |
|
62 | + if ($response['ocs']['meta']['statuscode'] === API::RESPOND_NOT_FOUND) { |
|
63 | + throw new NotFoundException(); |
|
64 | + } |
|
65 | + if ($response['ocs']['meta']['status'] !== 'ok') { |
|
66 | + throw new \Exception('Unknown ocs error ' . $response['ocs']['meta']['message']); |
|
67 | + } |
|
68 | 68 | |
69 | - return $response['ocs']['data']; |
|
70 | - } |
|
69 | + return $response['ocs']['data']; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param array $data |
|
74 | - * @param string $type |
|
75 | - * @param string[] $keys |
|
76 | - * @throws \Exception |
|
77 | - */ |
|
78 | - private function checkResponseArray(array $data, $type, array $keys) { |
|
79 | - foreach ($keys as $key) { |
|
80 | - if (!array_key_exists($key, $data)) { |
|
81 | - throw new \Exception('Invalid ' . $type . ' response, expected field ' . $key . ' not found'); |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
72 | + /** |
|
73 | + * @param array $data |
|
74 | + * @param string $type |
|
75 | + * @param string[] $keys |
|
76 | + * @throws \Exception |
|
77 | + */ |
|
78 | + private function checkResponseArray(array $data, $type, array $keys) { |
|
79 | + foreach ($keys as $key) { |
|
80 | + if (!array_key_exists($key, $data)) { |
|
81 | + throw new \Exception('Invalid ' . $type . ' response, expected field ' . $key . ' not found'); |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - public function getUser($userId) { |
|
87 | - $result = $this->request('get', 'cloud/users/' . $userId); |
|
88 | - $this->checkResponseArray($result, 'user', User::EXPECTED_KEYS); |
|
89 | - return new User($result); |
|
90 | - } |
|
86 | + public function getUser($userId) { |
|
87 | + $result = $this->request('get', 'cloud/users/' . $userId); |
|
88 | + $this->checkResponseArray($result, 'user', User::EXPECTED_KEYS); |
|
89 | + return new User($result); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @return array The capabilities in the form of [$appId => [$capability => $value]] |
|
94 | - */ |
|
95 | - public function getCapabilities() { |
|
96 | - $result = $this->request('get', 'cloud/capabilities'); |
|
97 | - return $result['capabilities']; |
|
98 | - } |
|
92 | + /** |
|
93 | + * @return array The capabilities in the form of [$appId => [$capability => $value]] |
|
94 | + */ |
|
95 | + public function getCapabilities() { |
|
96 | + $result = $this->request('get', 'cloud/capabilities'); |
|
97 | + return $result['capabilities']; |
|
98 | + } |
|
99 | 99 | } |
@@ -25,114 +25,114 @@ |
||
25 | 25 | use OCP\Remote\IUser; |
26 | 26 | |
27 | 27 | class User implements IUser { |
28 | - const EXPECTED_KEYS = [ |
|
29 | - 'id', |
|
30 | - 'email', |
|
31 | - 'displayname', |
|
32 | - 'phone', |
|
33 | - 'address', |
|
34 | - 'website', |
|
35 | - 'groups', |
|
36 | - 'language', |
|
37 | - 'quota' |
|
38 | - ]; |
|
39 | - |
|
40 | - /** @var array */ |
|
41 | - private $data; |
|
42 | - |
|
43 | - public function __construct(array $data) { |
|
44 | - $this->data = $data; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function getUserId() { |
|
52 | - return $this->data['id']; |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - public function getEmail() { |
|
59 | - return $this->data['email']; |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function getDisplayName() { |
|
66 | - return $this->data['displayname']; |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function getPhone() { |
|
73 | - return $this->data['phone']; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public function getAddress() { |
|
80 | - return $this->data['address']; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @return string |
|
85 | - */ |
|
86 | - public function getWebsite() { |
|
87 | - return $this->data['website']; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @return string |
|
92 | - */ |
|
93 | - public function getTwitter() { |
|
94 | - return isset($this->data['twitter']) ? $this->data['twitter'] : ''; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @return string[] |
|
99 | - */ |
|
100 | - public function getGroups() { |
|
101 | - return $this->data['groups']; |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - public function getLanguage() { |
|
108 | - return $this->data['language']; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @return int |
|
113 | - */ |
|
114 | - public function getUsedSpace() { |
|
115 | - return $this->data['quota']['used']; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @return int |
|
120 | - */ |
|
121 | - public function getFreeSpace() { |
|
122 | - return $this->data['quota']['free']; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @return int |
|
127 | - */ |
|
128 | - public function getTotalSpace() { |
|
129 | - return $this->data['quota']['total']; |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * @return int |
|
134 | - */ |
|
135 | - public function getQuota() { |
|
136 | - return $this->data['quota']['quota']; |
|
137 | - } |
|
28 | + const EXPECTED_KEYS = [ |
|
29 | + 'id', |
|
30 | + 'email', |
|
31 | + 'displayname', |
|
32 | + 'phone', |
|
33 | + 'address', |
|
34 | + 'website', |
|
35 | + 'groups', |
|
36 | + 'language', |
|
37 | + 'quota' |
|
38 | + ]; |
|
39 | + |
|
40 | + /** @var array */ |
|
41 | + private $data; |
|
42 | + |
|
43 | + public function __construct(array $data) { |
|
44 | + $this->data = $data; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function getUserId() { |
|
52 | + return $this->data['id']; |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + public function getEmail() { |
|
59 | + return $this->data['email']; |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function getDisplayName() { |
|
66 | + return $this->data['displayname']; |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function getPhone() { |
|
73 | + return $this->data['phone']; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public function getAddress() { |
|
80 | + return $this->data['address']; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @return string |
|
85 | + */ |
|
86 | + public function getWebsite() { |
|
87 | + return $this->data['website']; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @return string |
|
92 | + */ |
|
93 | + public function getTwitter() { |
|
94 | + return isset($this->data['twitter']) ? $this->data['twitter'] : ''; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @return string[] |
|
99 | + */ |
|
100 | + public function getGroups() { |
|
101 | + return $this->data['groups']; |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + public function getLanguage() { |
|
108 | + return $this->data['language']; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @return int |
|
113 | + */ |
|
114 | + public function getUsedSpace() { |
|
115 | + return $this->data['quota']['used']; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @return int |
|
120 | + */ |
|
121 | + public function getFreeSpace() { |
|
122 | + return $this->data['quota']['free']; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @return int |
|
127 | + */ |
|
128 | + public function getTotalSpace() { |
|
129 | + return $this->data['quota']['total']; |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * @return int |
|
134 | + */ |
|
135 | + public function getQuota() { |
|
136 | + return $this->data['quota']['quota']; |
|
137 | + } |
|
138 | 138 | } |
@@ -25,120 +25,120 @@ |
||
25 | 25 | |
26 | 26 | class Todo extends Event { |
27 | 27 | |
28 | - /** |
|
29 | - * @param string $language |
|
30 | - * @param IEvent $event |
|
31 | - * @param IEvent|null $previousEvent |
|
32 | - * @return IEvent |
|
33 | - * @throws \InvalidArgumentException |
|
34 | - * @since 11.0.0 |
|
35 | - */ |
|
36 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
37 | - if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_todo') { |
|
38 | - throw new \InvalidArgumentException(); |
|
39 | - } |
|
28 | + /** |
|
29 | + * @param string $language |
|
30 | + * @param IEvent $event |
|
31 | + * @param IEvent|null $previousEvent |
|
32 | + * @return IEvent |
|
33 | + * @throws \InvalidArgumentException |
|
34 | + * @since 11.0.0 |
|
35 | + */ |
|
36 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
37 | + if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_todo') { |
|
38 | + throw new \InvalidArgumentException(); |
|
39 | + } |
|
40 | 40 | |
41 | - $this->l = $this->languageFactory->get('dav', $language); |
|
41 | + $this->l = $this->languageFactory->get('dav', $language); |
|
42 | 42 | |
43 | - if ($this->activityManager->getRequirePNG()) { |
|
44 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.png'))); |
|
45 | - } else { |
|
46 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.svg'))); |
|
47 | - } |
|
43 | + if ($this->activityManager->getRequirePNG()) { |
|
44 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.png'))); |
|
45 | + } else { |
|
46 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.svg'))); |
|
47 | + } |
|
48 | 48 | |
49 | - if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_todo') { |
|
50 | - $subject = $this->l->t('{actor} created todo {todo} in list {calendar}'); |
|
51 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_todo_self') { |
|
52 | - $subject = $this->l->t('You created todo {todo} in list {calendar}'); |
|
53 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_todo') { |
|
54 | - $subject = $this->l->t('{actor} deleted todo {todo} from list {calendar}'); |
|
55 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_todo_self') { |
|
56 | - $subject = $this->l->t('You deleted todo {todo} from list {calendar}'); |
|
57 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo') { |
|
58 | - $subject = $this->l->t('{actor} updated todo {todo} in list {calendar}'); |
|
59 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_self') { |
|
60 | - $subject = $this->l->t('You updated todo {todo} in list {calendar}'); |
|
49 | + if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_todo') { |
|
50 | + $subject = $this->l->t('{actor} created todo {todo} in list {calendar}'); |
|
51 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_todo_self') { |
|
52 | + $subject = $this->l->t('You created todo {todo} in list {calendar}'); |
|
53 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_todo') { |
|
54 | + $subject = $this->l->t('{actor} deleted todo {todo} from list {calendar}'); |
|
55 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_todo_self') { |
|
56 | + $subject = $this->l->t('You deleted todo {todo} from list {calendar}'); |
|
57 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo') { |
|
58 | + $subject = $this->l->t('{actor} updated todo {todo} in list {calendar}'); |
|
59 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_self') { |
|
60 | + $subject = $this->l->t('You updated todo {todo} in list {calendar}'); |
|
61 | 61 | |
62 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed') { |
|
63 | - $subject = $this->l->t('{actor} solved todo {todo} in list {calendar}'); |
|
64 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self') { |
|
65 | - $subject = $this->l->t('You solved todo {todo} in list {calendar}'); |
|
66 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action') { |
|
67 | - $subject = $this->l->t('{actor} reopened todo {todo} in list {calendar}'); |
|
68 | - } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self') { |
|
69 | - $subject = $this->l->t('You reopened todo {todo} in list {calendar}'); |
|
70 | - } else { |
|
71 | - throw new \InvalidArgumentException(); |
|
72 | - } |
|
62 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed') { |
|
63 | + $subject = $this->l->t('{actor} solved todo {todo} in list {calendar}'); |
|
64 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self') { |
|
65 | + $subject = $this->l->t('You solved todo {todo} in list {calendar}'); |
|
66 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action') { |
|
67 | + $subject = $this->l->t('{actor} reopened todo {todo} in list {calendar}'); |
|
68 | + } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self') { |
|
69 | + $subject = $this->l->t('You reopened todo {todo} in list {calendar}'); |
|
70 | + } else { |
|
71 | + throw new \InvalidArgumentException(); |
|
72 | + } |
|
73 | 73 | |
74 | - $parsedParameters = $this->getParameters($event); |
|
75 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
74 | + $parsedParameters = $this->getParameters($event); |
|
75 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
76 | 76 | |
77 | - $event = $this->eventMerger->mergeEvents('todo', $event, $previousEvent); |
|
77 | + $event = $this->eventMerger->mergeEvents('todo', $event, $previousEvent); |
|
78 | 78 | |
79 | - return $event; |
|
80 | - } |
|
79 | + return $event; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @param IEvent $event |
|
84 | - * @return array |
|
85 | - */ |
|
86 | - protected function getParameters(IEvent $event) { |
|
87 | - $subject = $event->getSubject(); |
|
88 | - $parameters = $event->getSubjectParameters(); |
|
82 | + /** |
|
83 | + * @param IEvent $event |
|
84 | + * @return array |
|
85 | + */ |
|
86 | + protected function getParameters(IEvent $event) { |
|
87 | + $subject = $event->getSubject(); |
|
88 | + $parameters = $event->getSubjectParameters(); |
|
89 | 89 | |
90 | - // Nextcloud 13+ |
|
91 | - if (isset($parameters['calendar'])) { |
|
92 | - switch ($subject) { |
|
93 | - case self::SUBJECT_OBJECT_ADD . '_todo': |
|
94 | - case self::SUBJECT_OBJECT_DELETE . '_todo': |
|
95 | - case self::SUBJECT_OBJECT_UPDATE . '_todo': |
|
96 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_completed': |
|
97 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action': |
|
98 | - return [ |
|
99 | - 'actor' => $this->generateUserParameter($parameters['actor']), |
|
100 | - 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
101 | - 'todo' => $this->generateObjectParameter($parameters['object']), |
|
102 | - ]; |
|
103 | - case self::SUBJECT_OBJECT_ADD . '_todo_self': |
|
104 | - case self::SUBJECT_OBJECT_DELETE . '_todo_self': |
|
105 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_self': |
|
106 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self': |
|
107 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self': |
|
108 | - return [ |
|
109 | - 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
110 | - 'todo' => $this->generateObjectParameter($parameters['object']), |
|
111 | - ]; |
|
112 | - } |
|
113 | - } |
|
90 | + // Nextcloud 13+ |
|
91 | + if (isset($parameters['calendar'])) { |
|
92 | + switch ($subject) { |
|
93 | + case self::SUBJECT_OBJECT_ADD . '_todo': |
|
94 | + case self::SUBJECT_OBJECT_DELETE . '_todo': |
|
95 | + case self::SUBJECT_OBJECT_UPDATE . '_todo': |
|
96 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_completed': |
|
97 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action': |
|
98 | + return [ |
|
99 | + 'actor' => $this->generateUserParameter($parameters['actor']), |
|
100 | + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
101 | + 'todo' => $this->generateObjectParameter($parameters['object']), |
|
102 | + ]; |
|
103 | + case self::SUBJECT_OBJECT_ADD . '_todo_self': |
|
104 | + case self::SUBJECT_OBJECT_DELETE . '_todo_self': |
|
105 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_self': |
|
106 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self': |
|
107 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self': |
|
108 | + return [ |
|
109 | + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
110 | + 'todo' => $this->generateObjectParameter($parameters['object']), |
|
111 | + ]; |
|
112 | + } |
|
113 | + } |
|
114 | 114 | |
115 | - // Legacy - Do NOT Remove unless necessary |
|
116 | - // Removing this will break parsing of activities that were created on |
|
117 | - // Nextcloud 12, so we should keep this as long as it's acceptable. |
|
118 | - // Otherwise if people upgrade over multiple releases in a short period, |
|
119 | - // they will get the dead entries in their stream. |
|
120 | - switch ($subject) { |
|
121 | - case self::SUBJECT_OBJECT_ADD . '_todo': |
|
122 | - case self::SUBJECT_OBJECT_DELETE . '_todo': |
|
123 | - case self::SUBJECT_OBJECT_UPDATE . '_todo': |
|
124 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_completed': |
|
125 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action': |
|
126 | - return [ |
|
127 | - 'actor' => $this->generateUserParameter($parameters[0]), |
|
128 | - 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
129 | - 'todo' => $this->generateObjectParameter($parameters[2]), |
|
130 | - ]; |
|
131 | - case self::SUBJECT_OBJECT_ADD . '_todo_self': |
|
132 | - case self::SUBJECT_OBJECT_DELETE . '_todo_self': |
|
133 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_self': |
|
134 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self': |
|
135 | - case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self': |
|
136 | - return [ |
|
137 | - 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
138 | - 'todo' => $this->generateObjectParameter($parameters[2]), |
|
139 | - ]; |
|
140 | - } |
|
115 | + // Legacy - Do NOT Remove unless necessary |
|
116 | + // Removing this will break parsing of activities that were created on |
|
117 | + // Nextcloud 12, so we should keep this as long as it's acceptable. |
|
118 | + // Otherwise if people upgrade over multiple releases in a short period, |
|
119 | + // they will get the dead entries in their stream. |
|
120 | + switch ($subject) { |
|
121 | + case self::SUBJECT_OBJECT_ADD . '_todo': |
|
122 | + case self::SUBJECT_OBJECT_DELETE . '_todo': |
|
123 | + case self::SUBJECT_OBJECT_UPDATE . '_todo': |
|
124 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_completed': |
|
125 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action': |
|
126 | + return [ |
|
127 | + 'actor' => $this->generateUserParameter($parameters[0]), |
|
128 | + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
129 | + 'todo' => $this->generateObjectParameter($parameters[2]), |
|
130 | + ]; |
|
131 | + case self::SUBJECT_OBJECT_ADD . '_todo_self': |
|
132 | + case self::SUBJECT_OBJECT_DELETE . '_todo_self': |
|
133 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_self': |
|
134 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self': |
|
135 | + case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self': |
|
136 | + return [ |
|
137 | + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
138 | + 'todo' => $this->generateObjectParameter($parameters[2]), |
|
139 | + ]; |
|
140 | + } |
|
141 | 141 | |
142 | - throw new \InvalidArgumentException(); |
|
143 | - } |
|
142 | + throw new \InvalidArgumentException(); |
|
143 | + } |
|
144 | 144 | } |
@@ -29,19 +29,19 @@ |
||
29 | 29 | |
30 | 30 | class AddLogRotateJob implements IRepairStep { |
31 | 31 | |
32 | - /** @var IJobList */ |
|
33 | - private $jobList; |
|
32 | + /** @var IJobList */ |
|
33 | + private $jobList; |
|
34 | 34 | |
35 | - public function __construct(IJobList $jobList) { |
|
36 | - $this->jobList = $jobList; |
|
37 | - } |
|
35 | + public function __construct(IJobList $jobList) { |
|
36 | + $this->jobList = $jobList; |
|
37 | + } |
|
38 | 38 | |
39 | - public function getName() { |
|
40 | - return 'Add log rotate job'; |
|
41 | - } |
|
39 | + public function getName() { |
|
40 | + return 'Add log rotate job'; |
|
41 | + } |
|
42 | 42 | |
43 | - public function run(IOutput $output) { |
|
44 | - $this->jobList->add(Rotate::class); |
|
45 | - } |
|
43 | + public function run(IOutput $output) { |
|
44 | + $this->jobList->add(Rotate::class); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |
@@ -31,22 +31,22 @@ |
||
31 | 31 | |
32 | 32 | class Hooks { |
33 | 33 | |
34 | - /** |
|
35 | - * clean up user specific settings if user gets deleted |
|
36 | - * @param array $params array with uid |
|
37 | - * |
|
38 | - * This function is connected to the pre_deleteUser signal of OC_Users |
|
39 | - * to remove the used space for the trash bin stored in the database |
|
40 | - */ |
|
41 | - public static function deleteUser_hook($params) { |
|
42 | - $uid = $params['uid']; |
|
43 | - Trashbin::deleteUser($uid); |
|
44 | - } |
|
34 | + /** |
|
35 | + * clean up user specific settings if user gets deleted |
|
36 | + * @param array $params array with uid |
|
37 | + * |
|
38 | + * This function is connected to the pre_deleteUser signal of OC_Users |
|
39 | + * to remove the used space for the trash bin stored in the database |
|
40 | + */ |
|
41 | + public static function deleteUser_hook($params) { |
|
42 | + $uid = $params['uid']; |
|
43 | + Trashbin::deleteUser($uid); |
|
44 | + } |
|
45 | 45 | |
46 | - public static function post_write_hook($params) { |
|
47 | - $user = \OCP\User::getUser(); |
|
48 | - if (!empty($user)) { |
|
49 | - Trashbin::resizeTrash($user); |
|
50 | - } |
|
51 | - } |
|
46 | + public static function post_write_hook($params) { |
|
47 | + $user = \OCP\User::getUser(); |
|
48 | + if (!empty($user)) { |
|
49 | + Trashbin::resizeTrash($user); |
|
50 | + } |
|
51 | + } |
|
52 | 52 | } |
@@ -29,60 +29,60 @@ |
||
29 | 29 | |
30 | 30 | class SearchResult implements ISearchResult { |
31 | 31 | |
32 | - protected $result = [ |
|
33 | - 'exact' => [], |
|
34 | - ]; |
|
32 | + protected $result = [ |
|
33 | + 'exact' => [], |
|
34 | + ]; |
|
35 | 35 | |
36 | - protected $exactIdMatches = []; |
|
36 | + protected $exactIdMatches = []; |
|
37 | 37 | |
38 | - public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null) { |
|
39 | - $type = $type->getLabel(); |
|
40 | - if(!isset($this->result[$type])) { |
|
41 | - $this->result[$type] = []; |
|
42 | - $this->result['exact'][$type] = []; |
|
43 | - } |
|
38 | + public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null) { |
|
39 | + $type = $type->getLabel(); |
|
40 | + if(!isset($this->result[$type])) { |
|
41 | + $this->result[$type] = []; |
|
42 | + $this->result['exact'][$type] = []; |
|
43 | + } |
|
44 | 44 | |
45 | - $this->result[$type] = array_merge($this->result[$type], $matches); |
|
46 | - if(is_array($exactMatches)) { |
|
47 | - $this->result['exact'][$type] = array_merge($this->result['exact'][$type], $exactMatches); |
|
48 | - } |
|
49 | - } |
|
45 | + $this->result[$type] = array_merge($this->result[$type], $matches); |
|
46 | + if(is_array($exactMatches)) { |
|
47 | + $this->result['exact'][$type] = array_merge($this->result['exact'][$type], $exactMatches); |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - public function markExactIdMatch(SearchResultType $type) { |
|
52 | - $this->exactIdMatches[$type->getLabel()] = 1; |
|
53 | - } |
|
51 | + public function markExactIdMatch(SearchResultType $type) { |
|
52 | + $this->exactIdMatches[$type->getLabel()] = 1; |
|
53 | + } |
|
54 | 54 | |
55 | - public function hasExactIdMatch(SearchResultType $type) { |
|
56 | - return isset($this->exactIdMatches[$type->getLabel()]); |
|
57 | - } |
|
55 | + public function hasExactIdMatch(SearchResultType $type) { |
|
56 | + return isset($this->exactIdMatches[$type->getLabel()]); |
|
57 | + } |
|
58 | 58 | |
59 | - public function hasResult(SearchResultType $type, $collaboratorId) { |
|
60 | - $type = $type->getLabel(); |
|
61 | - if(!isset($this->result[$type])) { |
|
62 | - return false; |
|
63 | - } |
|
59 | + public function hasResult(SearchResultType $type, $collaboratorId) { |
|
60 | + $type = $type->getLabel(); |
|
61 | + if(!isset($this->result[$type])) { |
|
62 | + return false; |
|
63 | + } |
|
64 | 64 | |
65 | - $resultArrays = [$this->result['exact'][$type], $this->result[$type]]; |
|
66 | - foreach($resultArrays as $resultArray) { |
|
67 | - foreach ($resultArray as $result) { |
|
68 | - if ($result['value']['shareWith'] === $collaboratorId) { |
|
69 | - return true; |
|
70 | - } |
|
71 | - } |
|
72 | - } |
|
65 | + $resultArrays = [$this->result['exact'][$type], $this->result[$type]]; |
|
66 | + foreach($resultArrays as $resultArray) { |
|
67 | + foreach ($resultArray as $result) { |
|
68 | + if ($result['value']['shareWith'] === $collaboratorId) { |
|
69 | + return true; |
|
70 | + } |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | - return false; |
|
75 | - } |
|
74 | + return false; |
|
75 | + } |
|
76 | 76 | |
77 | - public function asArray() { |
|
78 | - return $this->result; |
|
79 | - } |
|
77 | + public function asArray() { |
|
78 | + return $this->result; |
|
79 | + } |
|
80 | 80 | |
81 | - public function unsetResult(SearchResultType $type) { |
|
82 | - $type = $type->getLabel(); |
|
83 | - $this->result[$type] = []; |
|
84 | - if(isset($this->result['exact'][$type])) { |
|
85 | - $this->result['exact'][$type] = []; |
|
86 | - } |
|
87 | - } |
|
81 | + public function unsetResult(SearchResultType $type) { |
|
82 | + $type = $type->getLabel(); |
|
83 | + $this->result[$type] = []; |
|
84 | + if(isset($this->result['exact'][$type])) { |
|
85 | + $this->result['exact'][$type] = []; |
|
86 | + } |
|
87 | + } |
|
88 | 88 | } |