@@ -32,15 +32,15 @@ |
||
32 | 32 | use Doctrine\DBAL\TransactionIsolationLevel; |
33 | 33 | |
34 | 34 | class SetTransactionIsolationLevel implements EventSubscriber { |
35 | - /** |
|
36 | - * @param ConnectionEventArgs $args |
|
37 | - * @return void |
|
38 | - */ |
|
39 | - public function postConnect(ConnectionEventArgs $args) { |
|
40 | - $args->getConnection()->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @param ConnectionEventArgs $args |
|
37 | + * @return void |
|
38 | + */ |
|
39 | + public function postConnect(ConnectionEventArgs $args) { |
|
40 | + $args->getConnection()->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED); |
|
41 | + } |
|
42 | 42 | |
43 | - public function getSubscribedEvents() { |
|
44 | - return [Events::postConnect]; |
|
45 | - } |
|
43 | + public function getSubscribedEvents() { |
|
44 | + return [Events::postConnect]; |
|
45 | + } |
|
46 | 46 | } |
@@ -32,42 +32,42 @@ |
||
32 | 32 | */ |
33 | 33 | interface ICalendarProvider { |
34 | 34 | |
35 | - /** |
|
36 | - * Provides the appId of the plugin |
|
37 | - * |
|
38 | - * @since 19.0.0 |
|
39 | - * @return string AppId |
|
40 | - */ |
|
41 | - public function getAppId(): string; |
|
35 | + /** |
|
36 | + * Provides the appId of the plugin |
|
37 | + * |
|
38 | + * @since 19.0.0 |
|
39 | + * @return string AppId |
|
40 | + */ |
|
41 | + public function getAppId(): string; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Fetches all calendars for a given principal uri |
|
45 | - * |
|
46 | - * @since 19.0.0 |
|
47 | - * @param string $principalUri E.g. principals/users/user1 |
|
48 | - * @return ExternalCalendar[] Array of all calendars |
|
49 | - */ |
|
50 | - public function fetchAllForCalendarHome(string $principalUri): array; |
|
43 | + /** |
|
44 | + * Fetches all calendars for a given principal uri |
|
45 | + * |
|
46 | + * @since 19.0.0 |
|
47 | + * @param string $principalUri E.g. principals/users/user1 |
|
48 | + * @return ExternalCalendar[] Array of all calendars |
|
49 | + */ |
|
50 | + public function fetchAllForCalendarHome(string $principalUri): array; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Checks whether plugin has a calendar for a given principalUri and calendarUri |
|
54 | - * |
|
55 | - * @since 19.0.0 |
|
56 | - * @param string $principalUri E.g. principals/users/user1 |
|
57 | - * @param string $calendarUri E.g. personal |
|
58 | - * @return bool True if calendar for principalUri and calendarUri exists, false otherwise |
|
59 | - */ |
|
60 | - public function hasCalendarInCalendarHome(string $principalUri, string $calendarUri): bool; |
|
52 | + /** |
|
53 | + * Checks whether plugin has a calendar for a given principalUri and calendarUri |
|
54 | + * |
|
55 | + * @since 19.0.0 |
|
56 | + * @param string $principalUri E.g. principals/users/user1 |
|
57 | + * @param string $calendarUri E.g. personal |
|
58 | + * @return bool True if calendar for principalUri and calendarUri exists, false otherwise |
|
59 | + */ |
|
60 | + public function hasCalendarInCalendarHome(string $principalUri, string $calendarUri): bool; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Fetches a calendar for a given principalUri and calendarUri |
|
64 | - * Returns null if calendar does not exist |
|
65 | - * |
|
66 | - * @since 19.0.0 |
|
67 | - * @param string $principalUri E.g. principals/users/user1 |
|
68 | - * @param string $calendarUri E.g. personal |
|
69 | - * @return ExternalCalendar|null Calendar if it exists, null otherwise |
|
70 | - */ |
|
71 | - public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar; |
|
62 | + /** |
|
63 | + * Fetches a calendar for a given principalUri and calendarUri |
|
64 | + * Returns null if calendar does not exist |
|
65 | + * |
|
66 | + * @since 19.0.0 |
|
67 | + * @param string $principalUri E.g. principals/users/user1 |
|
68 | + * @param string $calendarUri E.g. personal |
|
69 | + * @return ExternalCalendar|null Calendar if it exists, null otherwise |
|
70 | + */ |
|
71 | + public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar; |
|
72 | 72 | |
73 | 73 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | 'targetUser' => $recipient, |
113 | 113 | 'nodeName' => $node->getName(), |
114 | 114 | ]) |
115 | - ->setObject('transfer', (string)$transferOwnership->getId()); |
|
115 | + ->setObject('transfer', (string) $transferOwnership->getId()); |
|
116 | 116 | |
117 | 117 | $this->notificationManager->notify($notification); |
118 | 118 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | $notification = $this->notificationManager->createNotification(); |
137 | 137 | $notification->setApp('files') |
138 | - ->setObject('transfer', (string)$id); |
|
138 | + ->setObject('transfer', (string) $id); |
|
139 | 139 | $this->notificationManager->markProcessed($notification); |
140 | 140 | |
141 | 141 | $newTransferOwnership = new TransferOwnershipEntity(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | $notification = $this->notificationManager->createNotification(); |
170 | 170 | $notification->setApp('files') |
171 | - ->setObject('transfer', (string)$id); |
|
171 | + ->setObject('transfer', (string) $id); |
|
172 | 172 | $this->notificationManager->markProcessed($notification); |
173 | 173 | |
174 | 174 | $notification = $this->notificationManager->createNotification(); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | 'targetUser' => $transferOwnership->getTargetUser(), |
181 | 181 | 'nodeName' => $transferOwnership->getNodeName() |
182 | 182 | ]) |
183 | - ->setObject('transfer', (string)$transferOwnership->getId()); |
|
183 | + ->setObject('transfer', (string) $transferOwnership->getId()); |
|
184 | 184 | $this->notificationManager->notify($notification); |
185 | 185 | |
186 | 186 | $this->mapper->delete($transferOwnership); |
@@ -44,153 +44,153 @@ |
||
44 | 44 | |
45 | 45 | class TransferOwnershipController extends OCSController { |
46 | 46 | |
47 | - /** @var string */ |
|
48 | - private $userId; |
|
49 | - /** @var NotificationManager */ |
|
50 | - private $notificationManager; |
|
51 | - /** @var ITimeFactory */ |
|
52 | - private $timeFactory; |
|
53 | - /** @var IJobList */ |
|
54 | - private $jobList; |
|
55 | - /** @var TransferOwnershipMapper */ |
|
56 | - private $mapper; |
|
57 | - /** @var IUserManager */ |
|
58 | - private $userManager; |
|
59 | - /** @var IRootFolder */ |
|
60 | - private $rootFolder; |
|
61 | - |
|
62 | - public function __construct(string $appName, |
|
63 | - IRequest $request, |
|
64 | - string $userId, |
|
65 | - NotificationManager $notificationManager, |
|
66 | - ITimeFactory $timeFactory, |
|
67 | - IJobList $jobList, |
|
68 | - TransferOwnershipMapper $mapper, |
|
69 | - IUserManager $userManager, |
|
70 | - IRootFolder $rootFolder) { |
|
71 | - parent::__construct($appName, $request); |
|
72 | - |
|
73 | - $this->userId = $userId; |
|
74 | - $this->notificationManager = $notificationManager; |
|
75 | - $this->timeFactory = $timeFactory; |
|
76 | - $this->jobList = $jobList; |
|
77 | - $this->mapper = $mapper; |
|
78 | - $this->userManager = $userManager; |
|
79 | - $this->rootFolder = $rootFolder; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @NoAdminRequired |
|
85 | - */ |
|
86 | - public function transfer(string $recipient, string $path): DataResponse { |
|
87 | - $recipientUser = $this->userManager->get($recipient); |
|
88 | - |
|
89 | - if ($recipientUser === null) { |
|
90 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
91 | - } |
|
92 | - |
|
93 | - $userRoot = $this->rootFolder->getUserFolder($this->userId); |
|
94 | - |
|
95 | - try { |
|
96 | - $node = $userRoot->get($path); |
|
97 | - } catch (\Exception $e) { |
|
98 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
99 | - } |
|
100 | - |
|
101 | - if ($node->getOwner()->getUID() !== $this->userId || !$node->getStorage()->instanceOfStorage(IHomeStorage::class)) { |
|
102 | - return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
103 | - } |
|
104 | - |
|
105 | - $transferOwnership = new TransferOwnershipEntity(); |
|
106 | - $transferOwnership->setSourceUser($this->userId); |
|
107 | - $transferOwnership->setTargetUser($recipient); |
|
108 | - $transferOwnership->setFileId($node->getId()); |
|
109 | - $transferOwnership->setNodeName($node->getName()); |
|
110 | - $transferOwnership = $this->mapper->insert($transferOwnership); |
|
111 | - |
|
112 | - $notification = $this->notificationManager->createNotification(); |
|
113 | - $notification->setUser($recipient) |
|
114 | - ->setApp($this->appName) |
|
115 | - ->setDateTime($this->timeFactory->getDateTime()) |
|
116 | - ->setSubject('transferownershipRequest', [ |
|
117 | - 'sourceUser' => $this->userId, |
|
118 | - 'targetUser' => $recipient, |
|
119 | - 'nodeName' => $node->getName(), |
|
120 | - ]) |
|
121 | - ->setObject('transfer', (string)$transferOwnership->getId()); |
|
122 | - |
|
123 | - $this->notificationManager->notify($notification); |
|
124 | - |
|
125 | - return new DataResponse([]); |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @NoAdminRequired |
|
130 | - */ |
|
131 | - public function accept(int $id): DataResponse { |
|
132 | - try { |
|
133 | - $transferOwnership = $this->mapper->getById($id); |
|
134 | - } catch (DoesNotExistException $e) { |
|
135 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
136 | - } |
|
137 | - |
|
138 | - if ($transferOwnership->getTargetUser() !== $this->userId) { |
|
139 | - return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
140 | - } |
|
141 | - |
|
142 | - $notification = $this->notificationManager->createNotification(); |
|
143 | - $notification->setApp('files') |
|
144 | - ->setObject('transfer', (string)$id); |
|
145 | - $this->notificationManager->markProcessed($notification); |
|
146 | - |
|
147 | - $newTransferOwnership = new TransferOwnershipEntity(); |
|
148 | - $newTransferOwnership->setNodeName($transferOwnership->getNodeName()); |
|
149 | - $newTransferOwnership->setFileId($transferOwnership->getFileId()); |
|
150 | - $newTransferOwnership->setSourceUser($transferOwnership->getSourceUser()); |
|
151 | - $newTransferOwnership->setTargetUser($transferOwnership->getTargetUser()); |
|
152 | - $this->mapper->insert($newTransferOwnership); |
|
153 | - |
|
154 | - $this->jobList->add(TransferOwnership::class, [ |
|
155 | - 'id' => $newTransferOwnership->getId(), |
|
156 | - ]); |
|
157 | - |
|
158 | - return new DataResponse([], Http::STATUS_OK); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @NoAdminRequired |
|
163 | - */ |
|
164 | - public function reject(int $id): DataResponse { |
|
165 | - try { |
|
166 | - $transferOwnership = $this->mapper->getById($id); |
|
167 | - } catch (DoesNotExistException $e) { |
|
168 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
169 | - } |
|
170 | - |
|
171 | - if ($transferOwnership->getTargetUser() !== $this->userId) { |
|
172 | - return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
173 | - } |
|
174 | - |
|
175 | - $notification = $this->notificationManager->createNotification(); |
|
176 | - $notification->setApp('files') |
|
177 | - ->setObject('transfer', (string)$id); |
|
178 | - $this->notificationManager->markProcessed($notification); |
|
179 | - |
|
180 | - $notification = $this->notificationManager->createNotification(); |
|
181 | - $notification->setUser($transferOwnership->getSourceUser()) |
|
182 | - ->setApp($this->appName) |
|
183 | - ->setDateTime($this->timeFactory->getDateTime()) |
|
184 | - ->setSubject('transferownershipRequestDenied', [ |
|
185 | - 'sourceUser' => $transferOwnership->getSourceUser(), |
|
186 | - 'targetUser' => $transferOwnership->getTargetUser(), |
|
187 | - 'nodeName' => $transferOwnership->getNodeName() |
|
188 | - ]) |
|
189 | - ->setObject('transfer', (string)$transferOwnership->getId()); |
|
190 | - $this->notificationManager->notify($notification); |
|
191 | - |
|
192 | - $this->mapper->delete($transferOwnership); |
|
193 | - |
|
194 | - return new DataResponse([], Http::STATUS_OK); |
|
195 | - } |
|
47 | + /** @var string */ |
|
48 | + private $userId; |
|
49 | + /** @var NotificationManager */ |
|
50 | + private $notificationManager; |
|
51 | + /** @var ITimeFactory */ |
|
52 | + private $timeFactory; |
|
53 | + /** @var IJobList */ |
|
54 | + private $jobList; |
|
55 | + /** @var TransferOwnershipMapper */ |
|
56 | + private $mapper; |
|
57 | + /** @var IUserManager */ |
|
58 | + private $userManager; |
|
59 | + /** @var IRootFolder */ |
|
60 | + private $rootFolder; |
|
61 | + |
|
62 | + public function __construct(string $appName, |
|
63 | + IRequest $request, |
|
64 | + string $userId, |
|
65 | + NotificationManager $notificationManager, |
|
66 | + ITimeFactory $timeFactory, |
|
67 | + IJobList $jobList, |
|
68 | + TransferOwnershipMapper $mapper, |
|
69 | + IUserManager $userManager, |
|
70 | + IRootFolder $rootFolder) { |
|
71 | + parent::__construct($appName, $request); |
|
72 | + |
|
73 | + $this->userId = $userId; |
|
74 | + $this->notificationManager = $notificationManager; |
|
75 | + $this->timeFactory = $timeFactory; |
|
76 | + $this->jobList = $jobList; |
|
77 | + $this->mapper = $mapper; |
|
78 | + $this->userManager = $userManager; |
|
79 | + $this->rootFolder = $rootFolder; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @NoAdminRequired |
|
85 | + */ |
|
86 | + public function transfer(string $recipient, string $path): DataResponse { |
|
87 | + $recipientUser = $this->userManager->get($recipient); |
|
88 | + |
|
89 | + if ($recipientUser === null) { |
|
90 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
91 | + } |
|
92 | + |
|
93 | + $userRoot = $this->rootFolder->getUserFolder($this->userId); |
|
94 | + |
|
95 | + try { |
|
96 | + $node = $userRoot->get($path); |
|
97 | + } catch (\Exception $e) { |
|
98 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
99 | + } |
|
100 | + |
|
101 | + if ($node->getOwner()->getUID() !== $this->userId || !$node->getStorage()->instanceOfStorage(IHomeStorage::class)) { |
|
102 | + return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
103 | + } |
|
104 | + |
|
105 | + $transferOwnership = new TransferOwnershipEntity(); |
|
106 | + $transferOwnership->setSourceUser($this->userId); |
|
107 | + $transferOwnership->setTargetUser($recipient); |
|
108 | + $transferOwnership->setFileId($node->getId()); |
|
109 | + $transferOwnership->setNodeName($node->getName()); |
|
110 | + $transferOwnership = $this->mapper->insert($transferOwnership); |
|
111 | + |
|
112 | + $notification = $this->notificationManager->createNotification(); |
|
113 | + $notification->setUser($recipient) |
|
114 | + ->setApp($this->appName) |
|
115 | + ->setDateTime($this->timeFactory->getDateTime()) |
|
116 | + ->setSubject('transferownershipRequest', [ |
|
117 | + 'sourceUser' => $this->userId, |
|
118 | + 'targetUser' => $recipient, |
|
119 | + 'nodeName' => $node->getName(), |
|
120 | + ]) |
|
121 | + ->setObject('transfer', (string)$transferOwnership->getId()); |
|
122 | + |
|
123 | + $this->notificationManager->notify($notification); |
|
124 | + |
|
125 | + return new DataResponse([]); |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @NoAdminRequired |
|
130 | + */ |
|
131 | + public function accept(int $id): DataResponse { |
|
132 | + try { |
|
133 | + $transferOwnership = $this->mapper->getById($id); |
|
134 | + } catch (DoesNotExistException $e) { |
|
135 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
136 | + } |
|
137 | + |
|
138 | + if ($transferOwnership->getTargetUser() !== $this->userId) { |
|
139 | + return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
140 | + } |
|
141 | + |
|
142 | + $notification = $this->notificationManager->createNotification(); |
|
143 | + $notification->setApp('files') |
|
144 | + ->setObject('transfer', (string)$id); |
|
145 | + $this->notificationManager->markProcessed($notification); |
|
146 | + |
|
147 | + $newTransferOwnership = new TransferOwnershipEntity(); |
|
148 | + $newTransferOwnership->setNodeName($transferOwnership->getNodeName()); |
|
149 | + $newTransferOwnership->setFileId($transferOwnership->getFileId()); |
|
150 | + $newTransferOwnership->setSourceUser($transferOwnership->getSourceUser()); |
|
151 | + $newTransferOwnership->setTargetUser($transferOwnership->getTargetUser()); |
|
152 | + $this->mapper->insert($newTransferOwnership); |
|
153 | + |
|
154 | + $this->jobList->add(TransferOwnership::class, [ |
|
155 | + 'id' => $newTransferOwnership->getId(), |
|
156 | + ]); |
|
157 | + |
|
158 | + return new DataResponse([], Http::STATUS_OK); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * @NoAdminRequired |
|
163 | + */ |
|
164 | + public function reject(int $id): DataResponse { |
|
165 | + try { |
|
166 | + $transferOwnership = $this->mapper->getById($id); |
|
167 | + } catch (DoesNotExistException $e) { |
|
168 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
169 | + } |
|
170 | + |
|
171 | + if ($transferOwnership->getTargetUser() !== $this->userId) { |
|
172 | + return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
173 | + } |
|
174 | + |
|
175 | + $notification = $this->notificationManager->createNotification(); |
|
176 | + $notification->setApp('files') |
|
177 | + ->setObject('transfer', (string)$id); |
|
178 | + $this->notificationManager->markProcessed($notification); |
|
179 | + |
|
180 | + $notification = $this->notificationManager->createNotification(); |
|
181 | + $notification->setUser($transferOwnership->getSourceUser()) |
|
182 | + ->setApp($this->appName) |
|
183 | + ->setDateTime($this->timeFactory->getDateTime()) |
|
184 | + ->setSubject('transferownershipRequestDenied', [ |
|
185 | + 'sourceUser' => $transferOwnership->getSourceUser(), |
|
186 | + 'targetUser' => $transferOwnership->getTargetUser(), |
|
187 | + 'nodeName' => $transferOwnership->getNodeName() |
|
188 | + ]) |
|
189 | + ->setObject('transfer', (string)$transferOwnership->getId()); |
|
190 | + $this->notificationManager->notify($notification); |
|
191 | + |
|
192 | + $this->mapper->delete($transferOwnership); |
|
193 | + |
|
194 | + return new DataResponse([], Http::STATUS_OK); |
|
195 | + } |
|
196 | 196 | } |
@@ -37,64 +37,64 @@ |
||
37 | 37 | * @since 15.0.0 |
38 | 38 | */ |
39 | 39 | interface IVersionBackend { |
40 | - /** |
|
41 | - * Whether or not this version backend should be used for a storage |
|
42 | - * |
|
43 | - * If false is returned then the next applicable backend will be used |
|
44 | - * |
|
45 | - * @param IStorage $storage |
|
46 | - * @return bool |
|
47 | - * @since 17.0.0 |
|
48 | - */ |
|
49 | - public function useBackendForStorage(IStorage $storage): bool; |
|
40 | + /** |
|
41 | + * Whether or not this version backend should be used for a storage |
|
42 | + * |
|
43 | + * If false is returned then the next applicable backend will be used |
|
44 | + * |
|
45 | + * @param IStorage $storage |
|
46 | + * @return bool |
|
47 | + * @since 17.0.0 |
|
48 | + */ |
|
49 | + public function useBackendForStorage(IStorage $storage): bool; |
|
50 | 50 | |
51 | - /** |
|
52 | - * Get all versions for a file |
|
53 | - * |
|
54 | - * @param IUser $user |
|
55 | - * @param FileInfo $file |
|
56 | - * @return IVersion[] |
|
57 | - * @since 15.0.0 |
|
58 | - */ |
|
59 | - public function getVersionsForFile(IUser $user, FileInfo $file): array; |
|
51 | + /** |
|
52 | + * Get all versions for a file |
|
53 | + * |
|
54 | + * @param IUser $user |
|
55 | + * @param FileInfo $file |
|
56 | + * @return IVersion[] |
|
57 | + * @since 15.0.0 |
|
58 | + */ |
|
59 | + public function getVersionsForFile(IUser $user, FileInfo $file): array; |
|
60 | 60 | |
61 | - /** |
|
62 | - * Create a new version for a file |
|
63 | - * |
|
64 | - * @param IUser $user |
|
65 | - * @param FileInfo $file |
|
66 | - * @since 15.0.0 |
|
67 | - */ |
|
68 | - public function createVersion(IUser $user, FileInfo $file); |
|
61 | + /** |
|
62 | + * Create a new version for a file |
|
63 | + * |
|
64 | + * @param IUser $user |
|
65 | + * @param FileInfo $file |
|
66 | + * @since 15.0.0 |
|
67 | + */ |
|
68 | + public function createVersion(IUser $user, FileInfo $file); |
|
69 | 69 | |
70 | - /** |
|
71 | - * Restore this version |
|
72 | - * |
|
73 | - * @param IVersion $version |
|
74 | - * @since 15.0.0 |
|
75 | - */ |
|
76 | - public function rollback(IVersion $version); |
|
70 | + /** |
|
71 | + * Restore this version |
|
72 | + * |
|
73 | + * @param IVersion $version |
|
74 | + * @since 15.0.0 |
|
75 | + */ |
|
76 | + public function rollback(IVersion $version); |
|
77 | 77 | |
78 | - /** |
|
79 | - * Open the file for reading |
|
80 | - * |
|
81 | - * @param IVersion $version |
|
82 | - * @return resource |
|
83 | - * @throws NotFoundException |
|
84 | - * @since 15.0.0 |
|
85 | - */ |
|
86 | - public function read(IVersion $version); |
|
78 | + /** |
|
79 | + * Open the file for reading |
|
80 | + * |
|
81 | + * @param IVersion $version |
|
82 | + * @return resource |
|
83 | + * @throws NotFoundException |
|
84 | + * @since 15.0.0 |
|
85 | + */ |
|
86 | + public function read(IVersion $version); |
|
87 | 87 | |
88 | - /** |
|
89 | - * Get the preview for a specific version of a file |
|
90 | - * |
|
91 | - * @param IUser $user |
|
92 | - * @param FileInfo $sourceFile |
|
93 | - * @param int|string $revision |
|
94 | - * |
|
95 | - * @return File |
|
96 | - * |
|
97 | - * @since 15.0.0 |
|
98 | - */ |
|
99 | - public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File; |
|
88 | + /** |
|
89 | + * Get the preview for a specific version of a file |
|
90 | + * |
|
91 | + * @param IUser $user |
|
92 | + * @param FileInfo $sourceFile |
|
93 | + * @param int|string $revision |
|
94 | + * |
|
95 | + * @return File |
|
96 | + * |
|
97 | + * @since 15.0.0 |
|
98 | + */ |
|
99 | + public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File; |
|
100 | 100 | } |
@@ -135,15 +135,15 @@ |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | if ( |
138 | - $this->testUrl('https://' . $remote . '/ocs-provider/') || |
|
139 | - $this->testUrl('https://' . $remote . '/ocs-provider/index.php') || |
|
140 | - $this->testUrl('https://' . $remote . '/status.php', true) |
|
138 | + $this->testUrl('https://'.$remote.'/ocs-provider/') || |
|
139 | + $this->testUrl('https://'.$remote.'/ocs-provider/index.php') || |
|
140 | + $this->testUrl('https://'.$remote.'/status.php', true) |
|
141 | 141 | ) { |
142 | 142 | return new DataResponse('https'); |
143 | 143 | } elseif ( |
144 | - $this->testUrl('http://' . $remote . '/ocs-provider/') || |
|
145 | - $this->testUrl('http://' . $remote . '/ocs-provider/index.php') || |
|
146 | - $this->testUrl('http://' . $remote . '/status.php', true) |
|
144 | + $this->testUrl('http://'.$remote.'/ocs-provider/') || |
|
145 | + $this->testUrl('http://'.$remote.'/ocs-provider/index.php') || |
|
146 | + $this->testUrl('http://'.$remote.'/status.php', true) |
|
147 | 147 | ) { |
148 | 148 | return new DataResponse('http'); |
149 | 149 | } else { |
@@ -40,115 +40,115 @@ |
||
40 | 40 | */ |
41 | 41 | class ExternalSharesController extends Controller { |
42 | 42 | |
43 | - /** @var \OCA\Files_Sharing\External\Manager */ |
|
44 | - private $externalManager; |
|
45 | - /** @var IClientService */ |
|
46 | - private $clientService; |
|
43 | + /** @var \OCA\Files_Sharing\External\Manager */ |
|
44 | + private $externalManager; |
|
45 | + /** @var IClientService */ |
|
46 | + private $clientService; |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param string $appName |
|
50 | - * @param IRequest $request |
|
51 | - * @param \OCA\Files_Sharing\External\Manager $externalManager |
|
52 | - * @param IClientService $clientService |
|
53 | - */ |
|
54 | - public function __construct($appName, |
|
55 | - IRequest $request, |
|
56 | - \OCA\Files_Sharing\External\Manager $externalManager, |
|
57 | - IClientService $clientService) { |
|
58 | - parent::__construct($appName, $request); |
|
59 | - $this->externalManager = $externalManager; |
|
60 | - $this->clientService = $clientService; |
|
61 | - } |
|
48 | + /** |
|
49 | + * @param string $appName |
|
50 | + * @param IRequest $request |
|
51 | + * @param \OCA\Files_Sharing\External\Manager $externalManager |
|
52 | + * @param IClientService $clientService |
|
53 | + */ |
|
54 | + public function __construct($appName, |
|
55 | + IRequest $request, |
|
56 | + \OCA\Files_Sharing\External\Manager $externalManager, |
|
57 | + IClientService $clientService) { |
|
58 | + parent::__construct($appName, $request); |
|
59 | + $this->externalManager = $externalManager; |
|
60 | + $this->clientService = $clientService; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @NoAdminRequired |
|
65 | - * @NoOutgoingFederatedSharingRequired |
|
66 | - * |
|
67 | - * @return JSONResponse |
|
68 | - */ |
|
69 | - public function index() { |
|
70 | - return new JSONResponse($this->externalManager->getOpenShares()); |
|
71 | - } |
|
63 | + /** |
|
64 | + * @NoAdminRequired |
|
65 | + * @NoOutgoingFederatedSharingRequired |
|
66 | + * |
|
67 | + * @return JSONResponse |
|
68 | + */ |
|
69 | + public function index() { |
|
70 | + return new JSONResponse($this->externalManager->getOpenShares()); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @NoAdminRequired |
|
75 | - * @NoOutgoingFederatedSharingRequired |
|
76 | - * |
|
77 | - * @param int $id |
|
78 | - * @return JSONResponse |
|
79 | - */ |
|
80 | - public function create($id) { |
|
81 | - $this->externalManager->acceptShare($id); |
|
82 | - return new JSONResponse(); |
|
83 | - } |
|
73 | + /** |
|
74 | + * @NoAdminRequired |
|
75 | + * @NoOutgoingFederatedSharingRequired |
|
76 | + * |
|
77 | + * @param int $id |
|
78 | + * @return JSONResponse |
|
79 | + */ |
|
80 | + public function create($id) { |
|
81 | + $this->externalManager->acceptShare($id); |
|
82 | + return new JSONResponse(); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @NoAdminRequired |
|
87 | - * @NoOutgoingFederatedSharingRequired |
|
88 | - * |
|
89 | - * @param integer $id |
|
90 | - * @return JSONResponse |
|
91 | - */ |
|
92 | - public function destroy($id) { |
|
93 | - $this->externalManager->declineShare($id); |
|
94 | - return new JSONResponse(); |
|
95 | - } |
|
85 | + /** |
|
86 | + * @NoAdminRequired |
|
87 | + * @NoOutgoingFederatedSharingRequired |
|
88 | + * |
|
89 | + * @param integer $id |
|
90 | + * @return JSONResponse |
|
91 | + */ |
|
92 | + public function destroy($id) { |
|
93 | + $this->externalManager->declineShare($id); |
|
94 | + return new JSONResponse(); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * Test whether the specified remote is accessible |
|
99 | - * |
|
100 | - * @param string $remote |
|
101 | - * @param bool $checkVersion |
|
102 | - * @return bool |
|
103 | - */ |
|
104 | - protected function testUrl($remote, $checkVersion = false) { |
|
105 | - try { |
|
106 | - $client = $this->clientService->newClient(); |
|
107 | - $response = json_decode($client->get( |
|
108 | - $remote, |
|
109 | - [ |
|
110 | - 'timeout' => 3, |
|
111 | - 'connect_timeout' => 3, |
|
112 | - ] |
|
113 | - )->getBody()); |
|
97 | + /** |
|
98 | + * Test whether the specified remote is accessible |
|
99 | + * |
|
100 | + * @param string $remote |
|
101 | + * @param bool $checkVersion |
|
102 | + * @return bool |
|
103 | + */ |
|
104 | + protected function testUrl($remote, $checkVersion = false) { |
|
105 | + try { |
|
106 | + $client = $this->clientService->newClient(); |
|
107 | + $response = json_decode($client->get( |
|
108 | + $remote, |
|
109 | + [ |
|
110 | + 'timeout' => 3, |
|
111 | + 'connect_timeout' => 3, |
|
112 | + ] |
|
113 | + )->getBody()); |
|
114 | 114 | |
115 | - if ($checkVersion) { |
|
116 | - return !empty($response->version) && version_compare($response->version, '7.0.0', '>='); |
|
117 | - } else { |
|
118 | - return is_object($response); |
|
119 | - } |
|
120 | - } catch (\Exception $e) { |
|
121 | - return false; |
|
122 | - } |
|
123 | - } |
|
115 | + if ($checkVersion) { |
|
116 | + return !empty($response->version) && version_compare($response->version, '7.0.0', '>='); |
|
117 | + } else { |
|
118 | + return is_object($response); |
|
119 | + } |
|
120 | + } catch (\Exception $e) { |
|
121 | + return false; |
|
122 | + } |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * @PublicPage |
|
127 | - * @NoOutgoingFederatedSharingRequired |
|
128 | - * @NoIncomingFederatedSharingRequired |
|
129 | - * |
|
130 | - * @param string $remote |
|
131 | - * @return DataResponse |
|
132 | - */ |
|
133 | - public function testRemote($remote) { |
|
134 | - if (strpos($remote, '#') !== false || strpos($remote, '?') !== false || strpos($remote, ';') !== false) { |
|
135 | - return new DataResponse(false); |
|
136 | - } |
|
125 | + /** |
|
126 | + * @PublicPage |
|
127 | + * @NoOutgoingFederatedSharingRequired |
|
128 | + * @NoIncomingFederatedSharingRequired |
|
129 | + * |
|
130 | + * @param string $remote |
|
131 | + * @return DataResponse |
|
132 | + */ |
|
133 | + public function testRemote($remote) { |
|
134 | + if (strpos($remote, '#') !== false || strpos($remote, '?') !== false || strpos($remote, ';') !== false) { |
|
135 | + return new DataResponse(false); |
|
136 | + } |
|
137 | 137 | |
138 | - if ( |
|
139 | - $this->testUrl('https://' . $remote . '/ocs-provider/') || |
|
140 | - $this->testUrl('https://' . $remote . '/ocs-provider/index.php') || |
|
141 | - $this->testUrl('https://' . $remote . '/status.php', true) |
|
142 | - ) { |
|
143 | - return new DataResponse('https'); |
|
144 | - } elseif ( |
|
145 | - $this->testUrl('http://' . $remote . '/ocs-provider/') || |
|
146 | - $this->testUrl('http://' . $remote . '/ocs-provider/index.php') || |
|
147 | - $this->testUrl('http://' . $remote . '/status.php', true) |
|
148 | - ) { |
|
149 | - return new DataResponse('http'); |
|
150 | - } else { |
|
151 | - return new DataResponse(false); |
|
152 | - } |
|
153 | - } |
|
138 | + if ( |
|
139 | + $this->testUrl('https://' . $remote . '/ocs-provider/') || |
|
140 | + $this->testUrl('https://' . $remote . '/ocs-provider/index.php') || |
|
141 | + $this->testUrl('https://' . $remote . '/status.php', true) |
|
142 | + ) { |
|
143 | + return new DataResponse('https'); |
|
144 | + } elseif ( |
|
145 | + $this->testUrl('http://' . $remote . '/ocs-provider/') || |
|
146 | + $this->testUrl('http://' . $remote . '/ocs-provider/index.php') || |
|
147 | + $this->testUrl('http://' . $remote . '/status.php', true) |
|
148 | + ) { |
|
149 | + return new DataResponse('http'); |
|
150 | + } else { |
|
151 | + return new DataResponse(false); |
|
152 | + } |
|
153 | + } |
|
154 | 154 | } |
@@ -33,61 +33,61 @@ |
||
33 | 33 | |
34 | 34 | class Version010000Date20200304152605 extends SimpleMigrationStep { |
35 | 35 | |
36 | - /** |
|
37 | - * @param IOutput $output |
|
38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | - * @param array $options |
|
40 | - * |
|
41 | - * @return ISchemaWrapper |
|
42 | - */ |
|
43 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
44 | - /** @var ISchemaWrapper $schema */ |
|
45 | - $schema = $schemaClosure(); |
|
36 | + /** |
|
37 | + * @param IOutput $output |
|
38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | + * @param array $options |
|
40 | + * |
|
41 | + * @return ISchemaWrapper |
|
42 | + */ |
|
43 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
44 | + /** @var ISchemaWrapper $schema */ |
|
45 | + $schema = $schemaClosure(); |
|
46 | 46 | |
47 | - $table = $schema->createTable(RecentContactMapper::TABLE_NAME); |
|
48 | - $table->addColumn('id', 'integer', [ |
|
49 | - 'autoincrement' => true, |
|
50 | - 'notnull' => true, |
|
51 | - 'length' => 4, |
|
52 | - ]); |
|
53 | - $table->addColumn('actor_uid', 'string', [ |
|
54 | - 'notnull' => true, |
|
55 | - 'length' => 64, |
|
56 | - ]); |
|
57 | - $table->addColumn('uid', 'string', [ |
|
58 | - 'notnull' => false, |
|
59 | - 'length' => 64, |
|
60 | - ]); |
|
61 | - $table->addColumn('email', 'string', [ |
|
62 | - 'notnull' => false, |
|
63 | - 'length' => 255, |
|
64 | - ]); |
|
65 | - $table->addColumn('federated_cloud_id', 'string', [ |
|
66 | - 'notnull' => false, |
|
67 | - 'length' => 255, |
|
68 | - ]); |
|
69 | - $table->addColumn('card', 'blob', [ |
|
70 | - 'notnull' => true, |
|
71 | - ]); |
|
72 | - $table->addColumn('last_contact', 'integer', [ |
|
73 | - 'notnull' => true, |
|
74 | - 'length' => 4, |
|
75 | - ]); |
|
76 | - $table->setPrimaryKey(['id']); |
|
77 | - // To find all recent entries |
|
78 | - $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
79 | - // To find a specific entry |
|
80 | - $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
81 | - // To find all recent entries with a given UID |
|
82 | - $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
83 | - // To find all recent entries with a given email address |
|
84 | - $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
85 | - // To find all recent entries with a give federated cloud id |
|
86 | - $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
87 | - // For the cleanup |
|
88 | - $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
47 | + $table = $schema->createTable(RecentContactMapper::TABLE_NAME); |
|
48 | + $table->addColumn('id', 'integer', [ |
|
49 | + 'autoincrement' => true, |
|
50 | + 'notnull' => true, |
|
51 | + 'length' => 4, |
|
52 | + ]); |
|
53 | + $table->addColumn('actor_uid', 'string', [ |
|
54 | + 'notnull' => true, |
|
55 | + 'length' => 64, |
|
56 | + ]); |
|
57 | + $table->addColumn('uid', 'string', [ |
|
58 | + 'notnull' => false, |
|
59 | + 'length' => 64, |
|
60 | + ]); |
|
61 | + $table->addColumn('email', 'string', [ |
|
62 | + 'notnull' => false, |
|
63 | + 'length' => 255, |
|
64 | + ]); |
|
65 | + $table->addColumn('federated_cloud_id', 'string', [ |
|
66 | + 'notnull' => false, |
|
67 | + 'length' => 255, |
|
68 | + ]); |
|
69 | + $table->addColumn('card', 'blob', [ |
|
70 | + 'notnull' => true, |
|
71 | + ]); |
|
72 | + $table->addColumn('last_contact', 'integer', [ |
|
73 | + 'notnull' => true, |
|
74 | + 'length' => 4, |
|
75 | + ]); |
|
76 | + $table->setPrimaryKey(['id']); |
|
77 | + // To find all recent entries |
|
78 | + $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
79 | + // To find a specific entry |
|
80 | + $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
81 | + // To find all recent entries with a given UID |
|
82 | + $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
83 | + // To find all recent entries with a given email address |
|
84 | + $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
85 | + // To find all recent entries with a give federated cloud id |
|
86 | + $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
87 | + // For the cleanup |
|
88 | + $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
89 | 89 | |
90 | - return $schema; |
|
91 | - } |
|
90 | + return $schema; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | } |
@@ -75,17 +75,17 @@ |
||
75 | 75 | ]); |
76 | 76 | $table->setPrimaryKey(['id']); |
77 | 77 | // To find all recent entries |
78 | - $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
78 | + $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME.'_actor_uid'); |
|
79 | 79 | // To find a specific entry |
80 | - $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
80 | + $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME.'_id_uid'); |
|
81 | 81 | // To find all recent entries with a given UID |
82 | - $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
82 | + $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME.'_uid'); |
|
83 | 83 | // To find all recent entries with a given email address |
84 | - $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
84 | + $table->addIndex(['email'], RecentContactMapper::TABLE_NAME.'_email'); |
|
85 | 85 | // To find all recent entries with a give federated cloud id |
86 | - $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
86 | + $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME.'_fed_id'); |
|
87 | 87 | // For the cleanup |
88 | - $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
88 | + $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME.'_last_contact'); |
|
89 | 89 | |
90 | 90 | return $schema; |
91 | 91 | } |
@@ -67,7 +67,7 @@ |
||
67 | 67 | } |
68 | 68 | $addressbooksQuery->selectDistinct('id') |
69 | 69 | ->from('addressbooks') |
70 | - ->where($addressbooksQuery->expr()->eq('principaluri', $cardQuery->createNamedParameter("principals/users/" . $user->getUID()))); |
|
70 | + ->where($addressbooksQuery->expr()->eq('principaluri', $cardQuery->createNamedParameter("principals/users/".$user->getUID()))); |
|
71 | 71 | $propQuery->selectDistinct('cardid') |
72 | 72 | ->from('cards_properties') |
73 | 73 | ->where($propQuery->expr()->in('addressbookid', $propQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY)) |
@@ -32,63 +32,63 @@ |
||
32 | 32 | use function stream_get_contents; |
33 | 33 | |
34 | 34 | class CardSearchDao { |
35 | - private IDBConnection $db; |
|
35 | + private IDBConnection $db; |
|
36 | 36 | |
37 | - public function __construct(IDBConnection $db) { |
|
38 | - $this->db = $db; |
|
39 | - } |
|
37 | + public function __construct(IDBConnection $db) { |
|
38 | + $this->db = $db; |
|
39 | + } |
|
40 | 40 | |
41 | - public function findExisting(IUser $user, |
|
42 | - ?string $uid, |
|
43 | - ?string $email, |
|
44 | - ?string $cloudId): ?string { |
|
45 | - $addressbooksQuery = $this->db->getQueryBuilder(); |
|
46 | - $cardQuery = $this->db->getQueryBuilder(); |
|
47 | - $propQuery = $this->db->getQueryBuilder(); |
|
41 | + public function findExisting(IUser $user, |
|
42 | + ?string $uid, |
|
43 | + ?string $email, |
|
44 | + ?string $cloudId): ?string { |
|
45 | + $addressbooksQuery = $this->db->getQueryBuilder(); |
|
46 | + $cardQuery = $this->db->getQueryBuilder(); |
|
47 | + $propQuery = $this->db->getQueryBuilder(); |
|
48 | 48 | |
49 | - $propOr = $propQuery->expr()->orX(); |
|
50 | - if ($uid !== null) { |
|
51 | - $propOr->add($propQuery->expr()->andX( |
|
52 | - $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('UID')), |
|
53 | - $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($uid)) |
|
54 | - )); |
|
55 | - } |
|
56 | - if ($email !== null) { |
|
57 | - $propOr->add($propQuery->expr()->andX( |
|
58 | - $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('EMAIL')), |
|
59 | - $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($email)) |
|
60 | - )); |
|
61 | - } |
|
62 | - if ($cloudId !== null) { |
|
63 | - $propOr->add($propQuery->expr()->andX( |
|
64 | - $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('CLOUD')), |
|
65 | - $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($cloudId)) |
|
66 | - )); |
|
67 | - } |
|
68 | - $addressbooksQuery->selectDistinct('id') |
|
69 | - ->from('addressbooks') |
|
70 | - ->where($addressbooksQuery->expr()->eq('principaluri', $cardQuery->createNamedParameter("principals/users/" . $user->getUID()))); |
|
71 | - $propQuery->selectDistinct('cardid') |
|
72 | - ->from('cards_properties') |
|
73 | - ->where($propQuery->expr()->in('addressbookid', $propQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY)) |
|
74 | - ->andWhere($propOr) |
|
75 | - ->groupBy('cardid'); |
|
76 | - $cardQuery->select('carddata') |
|
77 | - ->from('cards') |
|
78 | - ->where($cardQuery->expr()->in('id', $cardQuery->createFunction($propQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY)) |
|
79 | - ->andWhere($cardQuery->expr()->in('addressbookid', $cardQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY)) |
|
80 | - ->setMaxResults(1); |
|
81 | - $result = $cardQuery->execute(); |
|
82 | - /** @var string|resource|false $card */ |
|
83 | - $card = $result->fetchOne(); |
|
49 | + $propOr = $propQuery->expr()->orX(); |
|
50 | + if ($uid !== null) { |
|
51 | + $propOr->add($propQuery->expr()->andX( |
|
52 | + $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('UID')), |
|
53 | + $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($uid)) |
|
54 | + )); |
|
55 | + } |
|
56 | + if ($email !== null) { |
|
57 | + $propOr->add($propQuery->expr()->andX( |
|
58 | + $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('EMAIL')), |
|
59 | + $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($email)) |
|
60 | + )); |
|
61 | + } |
|
62 | + if ($cloudId !== null) { |
|
63 | + $propOr->add($propQuery->expr()->andX( |
|
64 | + $propQuery->expr()->eq('name', $cardQuery->createNamedParameter('CLOUD')), |
|
65 | + $propQuery->expr()->eq('value', $cardQuery->createNamedParameter($cloudId)) |
|
66 | + )); |
|
67 | + } |
|
68 | + $addressbooksQuery->selectDistinct('id') |
|
69 | + ->from('addressbooks') |
|
70 | + ->where($addressbooksQuery->expr()->eq('principaluri', $cardQuery->createNamedParameter("principals/users/" . $user->getUID()))); |
|
71 | + $propQuery->selectDistinct('cardid') |
|
72 | + ->from('cards_properties') |
|
73 | + ->where($propQuery->expr()->in('addressbookid', $propQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY)) |
|
74 | + ->andWhere($propOr) |
|
75 | + ->groupBy('cardid'); |
|
76 | + $cardQuery->select('carddata') |
|
77 | + ->from('cards') |
|
78 | + ->where($cardQuery->expr()->in('id', $cardQuery->createFunction($propQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY)) |
|
79 | + ->andWhere($cardQuery->expr()->in('addressbookid', $cardQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY)) |
|
80 | + ->setMaxResults(1); |
|
81 | + $result = $cardQuery->execute(); |
|
82 | + /** @var string|resource|false $card */ |
|
83 | + $card = $result->fetchOne(); |
|
84 | 84 | |
85 | - if ($card === false) { |
|
86 | - return null; |
|
87 | - } |
|
88 | - if (is_resource($card)) { |
|
89 | - return stream_get_contents($card); |
|
90 | - } |
|
85 | + if ($card === false) { |
|
86 | + return null; |
|
87 | + } |
|
88 | + if (is_resource($card)) { |
|
89 | + return stream_get_contents($card); |
|
90 | + } |
|
91 | 91 | |
92 | - return $card; |
|
93 | - } |
|
92 | + return $card; |
|
93 | + } |
|
94 | 94 | } |
@@ -33,49 +33,49 @@ |
||
33 | 33 | |
34 | 34 | class AddressBookProvider implements IAddressBookProvider { |
35 | 35 | |
36 | - /** @var RecentContactMapper */ |
|
37 | - private $mapper; |
|
36 | + /** @var RecentContactMapper */ |
|
37 | + private $mapper; |
|
38 | 38 | |
39 | - /** @var IL10N */ |
|
40 | - private $l10n; |
|
39 | + /** @var IL10N */ |
|
40 | + private $l10n; |
|
41 | 41 | |
42 | - public function __construct(RecentContactMapper $mapper, IL10N $l10n) { |
|
43 | - $this->mapper = $mapper; |
|
44 | - $this->l10n = $l10n; |
|
45 | - } |
|
42 | + public function __construct(RecentContactMapper $mapper, IL10N $l10n) { |
|
43 | + $this->mapper = $mapper; |
|
44 | + $this->l10n = $l10n; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @inheritDoc |
|
49 | - */ |
|
50 | - public function getAppId(): string { |
|
51 | - return Application::APP_ID; |
|
52 | - } |
|
47 | + /** |
|
48 | + * @inheritDoc |
|
49 | + */ |
|
50 | + public function getAppId(): string { |
|
51 | + return Application::APP_ID; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @inheritDoc |
|
56 | - */ |
|
57 | - public function fetchAllForAddressBookHome(string $principalUri): array { |
|
58 | - return [ |
|
59 | - new AddressBook($this->mapper, $this->l10n, $principalUri) |
|
60 | - ]; |
|
61 | - } |
|
54 | + /** |
|
55 | + * @inheritDoc |
|
56 | + */ |
|
57 | + public function fetchAllForAddressBookHome(string $principalUri): array { |
|
58 | + return [ |
|
59 | + new AddressBook($this->mapper, $this->l10n, $principalUri) |
|
60 | + ]; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @inheritDoc |
|
65 | - */ |
|
66 | - public function hasAddressBookInAddressBookHome(string $principalUri, string $uri): bool { |
|
67 | - return $uri === AddressBook::URI; |
|
68 | - } |
|
63 | + /** |
|
64 | + * @inheritDoc |
|
65 | + */ |
|
66 | + public function hasAddressBookInAddressBookHome(string $principalUri, string $uri): bool { |
|
67 | + return $uri === AddressBook::URI; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @inheritDoc |
|
72 | - */ |
|
73 | - public function getAddressBookInAddressBookHome(string $principalUri, string $uri): ?ExternalAddressBook { |
|
74 | - if ($uri === AddressBook::URI) { |
|
75 | - return new AddressBook($this->mapper, $this->l10n, $principalUri); |
|
76 | - } |
|
70 | + /** |
|
71 | + * @inheritDoc |
|
72 | + */ |
|
73 | + public function getAddressBookInAddressBookHome(string $principalUri, string $uri): ?ExternalAddressBook { |
|
74 | + if ($uri === AddressBook::URI) { |
|
75 | + return new AddressBook($this->mapper, $this->l10n, $principalUri); |
|
76 | + } |
|
77 | 77 | |
78 | - return null; |
|
79 | - } |
|
78 | + return null; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'OCA\\ContactsInteraction\\' => array($baseDir . '/../lib'), |
|
9 | + 'OCA\\ContactsInteraction\\' => array($baseDir.'/../lib'), |
|
10 | 10 | ); |