@@ -49,6 +49,7 @@ discard block |
||
49 | 49 | * @param $target_item_guid string The shared item GUID |
50 | 50 | * @param $request_array array |
51 | 51 | * @param $permissions integer Must be created with a bitmask from options on the ShareRequest class |
52 | + * @param string $credential_owner |
|
52 | 53 | * @return array Array of sharing requests |
53 | 54 | */ |
54 | 55 | public function createBulkRequests($target_item_id, $target_item_guid, $request_array, $permissions, $credential_owner) { |
@@ -253,7 +254,6 @@ discard block |
||
253 | 254 | /** |
254 | 255 | * Delete ACL |
255 | 256 | * |
256 | - * @param ShareRequest $request |
|
257 | 257 | * @return \OCA\Passman\Db\ShareRequest[] |
258 | 258 | */ |
259 | 259 | public function deleteShareACL(SharingACL $ACL) { |
@@ -277,7 +277,6 @@ discard block |
||
277 | 277 | /** |
278 | 278 | * Get pending share requests by guid and uid |
279 | 279 | * |
280 | - * @param ShareRequest $request |
|
281 | 280 | * @return \OCA\Passman\Db\ShareRequest[] |
282 | 281 | */ |
283 | 282 | public function getPendingShareRequestsForCredential($item_guid, $user_id) { |
@@ -71,7 +71,9 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | public function createACLEntry(SharingACL $acl) { |
74 | - if ($acl->getCreated() === null) $acl->setCreated((new \DateTime())->getTimestamp()); |
|
74 | + if ($acl->getCreated() === null) { |
|
75 | + $acl->setCreated((new \DateTime())->getTimestamp()); |
|
76 | + } |
|
75 | 77 | return $this->sharingACL->createACLEntry($acl); |
76 | 78 | } |
77 | 79 | |
@@ -124,12 +126,16 @@ discard block |
||
124 | 126 | $return = []; |
125 | 127 | foreach ($entries as $entry) { |
126 | 128 | // Check if the user can read the credential, probably unnecesary, but just to be sure |
127 | - if (!$entry->hasPermission(SharingACL::READ)) continue; |
|
129 | + if (!$entry->hasPermission(SharingACL::READ)) { |
|
130 | + continue; |
|
131 | + } |
|
128 | 132 | |
129 | 133 | $tmp = $entry->jsonSerialize(); |
130 | 134 | $tmp['credential_data'] = $this->credential->getCredentialById($entry->getItemId())->jsonSerialize(); |
131 | 135 | |
132 | - if (!$entry->hasPermission(SharingACL::FILES)) unset($tmp['credential_data']['files']); |
|
136 | + if (!$entry->hasPermission(SharingACL::FILES)) { |
|
137 | + unset($tmp['credential_data']['files']); |
|
138 | + } |
|
133 | 139 | unset($tmp['credential_data']['shared_key']); |
134 | 140 | $return[] = $tmp; |
135 | 141 | } |
@@ -150,12 +156,16 @@ discard block |
||
150 | 156 | $acl = $this->sharingACL->getItemACL($user_id, $item_guid); |
151 | 157 | |
152 | 158 | // Check if the user can read the credential, probably unnecesary, but just to be sure |
153 | - if (!$acl->hasPermission(SharingACL::READ)) throw new DoesNotExistException("Item not found or wrong access level"); |
|
159 | + if (!$acl->hasPermission(SharingACL::READ)) { |
|
160 | + throw new DoesNotExistException("Item not found or wrong access level"); |
|
161 | + } |
|
154 | 162 | |
155 | 163 | $tmp = $acl->jsonSerialize(); |
156 | 164 | $tmp['credential_data'] = $this->credential->getCredentialById($acl->getItemId())->jsonSerialize(); |
157 | 165 | |
158 | - if (!$acl->hasPermission(SharingACL::FILES)) unset($tmp['credential_data']['files']); |
|
166 | + if (!$acl->hasPermission(SharingACL::FILES)) { |
|
167 | + unset($tmp['credential_data']['files']); |
|
168 | + } |
|
159 | 169 | unset($tmp['credential_data']['shared_key']); |
160 | 170 | |
161 | 171 | return $tmp; |
@@ -170,7 +180,9 @@ discard block |
||
170 | 180 | */ |
171 | 181 | public function getItemHistory($user_id, $item_guid) { |
172 | 182 | $acl = $this->sharingACL->getItemACL($user_id, $item_guid); |
173 | - if (!$acl->hasPermission(SharingACL::READ | SharingACL::HISTORY)) return []; |
|
183 | + if (!$acl->hasPermission(SharingACL::READ | SharingACL::HISTORY)) { |
|
184 | + return []; |
|
185 | + } |
|
174 | 186 | |
175 | 187 | return $this->revisions->getRevisions($acl->getItemId()); |
176 | 188 | } |
@@ -61,8 +61,7 @@ |
||
61 | 61 | $filter = [$item_guid]; |
62 | 62 | if ($user_id == null){ |
63 | 63 | $q .= 'user_id is null'; |
64 | - } |
|
65 | - else { |
|
64 | + } else { |
|
66 | 65 | $q .= 'user_id = ? '; |
67 | 66 | $filter[] = $user_id; |
68 | 67 | } |
@@ -61,8 +61,7 @@ |
||
61 | 61 | $filter = [$item_guid]; |
62 | 62 | if ($user_id == null){ |
63 | 63 | $q .= 'user_id is null'; |
64 | - } |
|
65 | - else { |
|
64 | + } else { |
|
66 | 65 | $q .= 'user_id = ? '; |
67 | 66 | $filter[] = $user_id; |
68 | 67 | } |
@@ -43,23 +43,39 @@ discard block |
||
43 | 43 | public function updateCredential($credential) { |
44 | 44 | return $this->credentialMapper->updateCredential($credential); |
45 | 45 | } |
46 | + |
|
47 | + /** |
|
48 | + * @param Credential $credential |
|
49 | + */ |
|
46 | 50 | public function upd($credential) { |
47 | 51 | return $this->credentialMapper->upd($credential); |
48 | 52 | } |
49 | 53 | |
54 | + /** |
|
55 | + * @param Credential $credential |
|
56 | + */ |
|
50 | 57 | public function deleteCredential($credential){ |
51 | 58 | return $this->credentialMapper->deleteCredential($credential); |
52 | 59 | } |
53 | 60 | |
61 | + /** |
|
62 | + * @param integer $vault_id |
|
63 | + */ |
|
54 | 64 | public function getCredentialsByVaultId($vault_id, $user_id) { |
55 | 65 | return $this->credentialMapper->getCredentialsByVaultId($vault_id, $user_id); |
56 | 66 | } |
57 | 67 | |
68 | + /** |
|
69 | + * @param integer $vault_id |
|
70 | + */ |
|
58 | 71 | public function getRandomCredentialByVaultId($vault_id, $user_id) { |
59 | 72 | $credentials = $this->credentialMapper->getRandomCredentialByVaultId($vault_id, $user_id); |
60 | 73 | return array_pop($credentials); |
61 | 74 | } |
62 | 75 | |
76 | + /** |
|
77 | + * @param integer $timestamp |
|
78 | + */ |
|
63 | 79 | public function getExpiredCredentials($timestamp) { |
64 | 80 | return $this->credentialMapper->getExpiredCredentials($timestamp); |
65 | 81 | } |
@@ -77,6 +93,10 @@ discard block |
||
77 | 93 | |
78 | 94 | throw new DoesNotExistException("Did expect one result but found none when executing"); |
79 | 95 | } |
96 | + |
|
97 | + /** |
|
98 | + * @param integer $credential_id |
|
99 | + */ |
|
80 | 100 | public function getCredentialLabelById($credential_id){ |
81 | 101 | return $this->credentialMapper->getCredentialLabelById($credential_id); |
82 | 102 | } |
@@ -257,21 +257,18 @@ |
||
257 | 257 | public function getRevision($credential_guid) { |
258 | 258 | try { |
259 | 259 | $credential = $this->credentialService->getCredentialByGUID($credential_guid); |
260 | - } |
|
261 | - catch (DoesNotExistException $ex){ |
|
260 | + } catch (DoesNotExistException $ex){ |
|
262 | 261 | return new NotFoundJSONResponse(); |
263 | 262 | } |
264 | 263 | |
265 | 264 | // If the request was made by the owner of the credential |
266 | 265 | if ($this->userId === $credential->getUserId()) { |
267 | 266 | $result = $this->credentialRevisionService->getRevisions($credential->getId(), $this->userId); |
268 | - } |
|
269 | - else { |
|
267 | + } else { |
|
270 | 268 | $acl = $this->sharingService->getACL($this->userId, $credential_guid); |
271 | 269 | if ($acl->hasPermission(SharingACL::HISTORY)){ |
272 | 270 | $result = $this->credentialRevisionService->getRevisions($credential->getId()); |
273 | - } |
|
274 | - else { |
|
271 | + } else { |
|
275 | 272 | return new NotFoundJSONResponse(); |
276 | 273 | } |
277 | 274 | } |