@@ -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 | } |
@@ -34,15 +34,15 @@ discard block |
||
34 | 34 | $helper = new Helper(\OC::$server->getConfig()); |
35 | 35 | $ocConfig = \OC::$server->getConfig(); |
36 | 36 | $uBackend = new User_Proxy( |
37 | - $helper->getServerConfigurationPrefixes(true), |
|
38 | - new LDAP(), |
|
39 | - $ocConfig, |
|
40 | - \OC::$server->getNotificationManager(), |
|
41 | - \OC::$server->getUserSession(), |
|
42 | - \OC::$server->query('LDAPUserPluginManager') |
|
37 | + $helper->getServerConfigurationPrefixes(true), |
|
38 | + new LDAP(), |
|
39 | + $ocConfig, |
|
40 | + \OC::$server->getNotificationManager(), |
|
41 | + \OC::$server->getUserSession(), |
|
42 | + \OC::$server->query('LDAPUserPluginManager') |
|
43 | 43 | ); |
44 | 44 | $deletedUsersIndex = new DeletedUsersIndex( |
45 | - $ocConfig, $dbConnection, $userMapping |
|
45 | + $ocConfig, $dbConnection, $userMapping |
|
46 | 46 | ); |
47 | 47 | |
48 | 48 | $application->add(new OCA\User_LDAP\Command\ShowConfig($helper)); |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | $application->add(new OCA\User_LDAP\Command\DeleteConfig($helper)); |
53 | 53 | $application->add(new OCA\User_LDAP\Command\Search($ocConfig)); |
54 | 54 | $application->add(new OCA\User_LDAP\Command\ShowRemnants( |
55 | - $deletedUsersIndex, \OC::$server->getDateTimeFormatter()) |
|
55 | + $deletedUsersIndex, \OC::$server->getDateTimeFormatter()) |
|
56 | 56 | ); |
57 | 57 | $application->add(new OCA\User_LDAP\Command\CheckUser( |
58 | - $uBackend, $helper, $deletedUsersIndex, $userMapping) |
|
58 | + $uBackend, $helper, $deletedUsersIndex, $userMapping) |
|
59 | 59 | ); |
@@ -30,10 +30,10 @@ |
||
30 | 30 | use OCP\IConfig; |
31 | 31 | |
32 | 32 | class UUIDFixGroup extends UUIDFix { |
33 | - public function __construct(GroupMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) { |
|
34 | - $this->mapper = $mapper; |
|
35 | - $this->proxy = new User_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config, |
|
36 | - \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), |
|
37 | - \OC::$server->query('LDAPUserPluginManager')); |
|
38 | - } |
|
33 | + public function __construct(GroupMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) { |
|
34 | + $this->mapper = $mapper; |
|
35 | + $this->proxy = new User_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config, |
|
36 | + \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), |
|
37 | + \OC::$server->query('LDAPUserPluginManager')); |
|
38 | + } |
|
39 | 39 | } |
@@ -28,54 +28,54 @@ |
||
28 | 28 | use OCP\IServerContainer; |
29 | 29 | |
30 | 30 | class Manager implements IManager { |
31 | - /** @var string[] */ |
|
32 | - protected $sorters =[]; |
|
31 | + /** @var string[] */ |
|
32 | + protected $sorters =[]; |
|
33 | 33 | |
34 | - /** @var ISorter[] */ |
|
35 | - protected $sorterInstances = []; |
|
36 | - /** @var IServerContainer */ |
|
37 | - private $c; |
|
34 | + /** @var ISorter[] */ |
|
35 | + protected $sorterInstances = []; |
|
36 | + /** @var IServerContainer */ |
|
37 | + private $c; |
|
38 | 38 | |
39 | - public function __construct(IServerContainer $container) { |
|
40 | - $this->c = $container; |
|
41 | - } |
|
39 | + public function __construct(IServerContainer $container) { |
|
40 | + $this->c = $container; |
|
41 | + } |
|
42 | 42 | |
43 | - public function runSorters(array $sorters, array &$sortArray, array $context) { |
|
44 | - $sorterInstances = $this->getSorters(); |
|
45 | - while($sorter = array_shift($sorters)) { |
|
46 | - if(isset($sorterInstances[$sorter])) { |
|
47 | - $sorterInstances[$sorter]->sort($sortArray, $context); |
|
48 | - } else { |
|
49 | - $this->c->getLogger()->warning('No sorter for ID "{id}", skipping', [ |
|
50 | - 'app' => 'core', 'id' => $sorter |
|
51 | - ]); |
|
52 | - } |
|
53 | - } |
|
54 | - } |
|
43 | + public function runSorters(array $sorters, array &$sortArray, array $context) { |
|
44 | + $sorterInstances = $this->getSorters(); |
|
45 | + while($sorter = array_shift($sorters)) { |
|
46 | + if(isset($sorterInstances[$sorter])) { |
|
47 | + $sorterInstances[$sorter]->sort($sortArray, $context); |
|
48 | + } else { |
|
49 | + $this->c->getLogger()->warning('No sorter for ID "{id}", skipping', [ |
|
50 | + 'app' => 'core', 'id' => $sorter |
|
51 | + ]); |
|
52 | + } |
|
53 | + } |
|
54 | + } |
|
55 | 55 | |
56 | - public function registerSorter($className) { |
|
57 | - $this->sorters[] = $className; |
|
58 | - } |
|
56 | + public function registerSorter($className) { |
|
57 | + $this->sorters[] = $className; |
|
58 | + } |
|
59 | 59 | |
60 | - protected function getSorters() { |
|
61 | - if(count($this->sorterInstances) === 0) { |
|
62 | - foreach ($this->sorters as $sorter) { |
|
63 | - /** @var ISorter $instance */ |
|
64 | - $instance = $this->c->resolve($sorter); |
|
65 | - if(!$instance instanceof ISorter) { |
|
66 | - $this->c->getLogger()->notice('Skipping sorter which is not an instance of ISorter. Class name: {class}', |
|
67 | - ['app' => 'core', 'class' => $sorter]); |
|
68 | - continue; |
|
69 | - } |
|
70 | - $sorterId = trim($instance->getId()); |
|
71 | - if(trim($sorterId) === '') { |
|
72 | - $this->c->getLogger()->notice('Skipping sorter with empty ID. Class name: {class}', |
|
73 | - ['app' => 'core', 'class' => $sorter]); |
|
74 | - continue; |
|
75 | - } |
|
76 | - $this->sorterInstances[$sorterId] = $instance; |
|
77 | - } |
|
78 | - } |
|
79 | - return $this->sorterInstances; |
|
80 | - } |
|
60 | + protected function getSorters() { |
|
61 | + if(count($this->sorterInstances) === 0) { |
|
62 | + foreach ($this->sorters as $sorter) { |
|
63 | + /** @var ISorter $instance */ |
|
64 | + $instance = $this->c->resolve($sorter); |
|
65 | + if(!$instance instanceof ISorter) { |
|
66 | + $this->c->getLogger()->notice('Skipping sorter which is not an instance of ISorter. Class name: {class}', |
|
67 | + ['app' => 'core', 'class' => $sorter]); |
|
68 | + continue; |
|
69 | + } |
|
70 | + $sorterId = trim($instance->getId()); |
|
71 | + if(trim($sorterId) === '') { |
|
72 | + $this->c->getLogger()->notice('Skipping sorter with empty ID. Class name: {class}', |
|
73 | + ['app' => 'core', 'class' => $sorter]); |
|
74 | + continue; |
|
75 | + } |
|
76 | + $this->sorterInstances[$sorterId] = $instance; |
|
77 | + } |
|
78 | + } |
|
79 | + return $this->sorterInstances; |
|
80 | + } |
|
81 | 81 | } |