Completed
Pull Request — master (#70)
by Sander
02:59
created
lib/Service/ShareService.php 1 patch
Braces   +19 added lines, -7 removed lines patch added patch discarded remove patch
@@ -71,7 +71,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
@@ -285,7 +297,7 @@  discard block
 block discarded – undo
285 297
 	}
286 298
 
287 299
 
288
-	public function updatePendingShareRequestsForCredential($item_guid, $user_id, $permissions){
300
+	public function updatePendingShareRequestsForCredential($item_guid, $user_id, $permissions) {
289 301
 	    return $this->shareRequest->updatePendinRequestPermissions($item_guid, $user_id, $permissions);
290 302
     }
291 303
 }
292 304
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Service/CredentialService.php 1 patch
Braces   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		return $this->credentialMapper->upd($credential);
48 48
 	}
49 49
 
50
-	public function deleteCredential($credential){
50
+	public function deleteCredential($credential) {
51 51
 		return $this->credentialMapper->deleteCredential($credential);
52 52
 	}
53 53
 
@@ -64,12 +64,11 @@  discard block
 block discarded – undo
64 64
 		return $this->credentialMapper->getExpiredCredentials($timestamp);
65 65
 	}
66 66
 
67
-	public function getCredentialById($credential_id, $user_id){
67
+	public function getCredentialById($credential_id, $user_id) {
68 68
         $credential = $this->credentialMapper->getCredentialById($credential_id);
69
-        if ($credential->getUserId() === $user_id){
69
+        if ($credential->getUserId() === $user_id) {
70 70
             return $credential;
71
-        }
72
-        else {
71
+        } else {
73 72
             $acl = $this->sharingACL->getItemACL($user_id, $credential->getGuid());
74 73
             if ($acl->hasPermission(SharingACL::READ));
75 74
             return $credential;
@@ -77,11 +76,11 @@  discard block
 block discarded – undo
77 76
 
78 77
         throw new DoesNotExistException("Did expect one result but found none when executing");
79 78
 	}
80
-	public function getCredentialLabelById($credential_id){
79
+	public function getCredentialLabelById($credential_id) {
81 80
 		return $this->credentialMapper->getCredentialLabelById($credential_id);
82 81
 	}
83 82
 
84
-	public function getCredentialByGUID($credential_guid, $user_id = null){
83
+	public function getCredentialByGUID($credential_guid, $user_id = null) {
85 84
 	    return $this->credentialMapper->getCredentialByGUID($credential_guid, $user_id);
86 85
     }
87 86
 }
88 87
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Db/SharingACLMapper.php 1 patch
Braces   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
      * @param $item_guid
30 30
      * @return SharingACL[]
31 31
      */
32
-    public function getCredentialPermissions(IUser $userId, $item_guid){
32
+    public function getCredentialPermissions(IUser $userId, $item_guid) {
33 33
         $sql = "SELECT * FROM ". self::TABLE_NAME ." WHERE user_id = ? AND item_guid = ?";
34 34
 
35 35
         return $this->findEntities($sql, [$userId, $item_guid]);
36 36
     }
37 37
 
38
-    public function createACLEntry(SharingACL $acl){
38
+    public function createACLEntry(SharingACL $acl) {
39 39
         return $this->insert($acl);
40 40
     }
41 41
 
@@ -59,10 +59,9 @@  discard block
 block discarded – undo
59 59
     public function getItemACL($user_id, $item_guid) {
60 60
         $q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ? AND ";
61 61
         $filter = [$item_guid];
62
-        if ($user_id === null){
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
         }
@@ -90,7 +89,7 @@  discard block
 block discarded – undo
90 89
         return $this->findEntities($q, [$item_guid]);
91 90
     }
92 91
 
93
-    public function deleteShareACL(SharingACL $ACL){
92
+    public function deleteShareACL(SharingACL $ACL) {
94 93
     	return $this->delete($ACL);
95 94
 	}
96 95
 }
97 96
\ No newline at end of file
Please login to merge, or discard this patch.
controller/credentialcontroller.php 1 patch
Braces   +8 added lines, -11 removed lines patch added patch discarded remove patch
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
 			foreach ($acl_list as $sharingACL) {
204 204
 				$target_user = $sharingACL->getUserId();
205
-				if($target_user === $this->userId){
205
+				if($target_user === $this->userId) {
206 206
 					continue;
207 207
 				}
208 208
 				$this->activityService->add(
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 					$link, $storedCredential->getUserId(), Activity::TYPE_ITEM_ACTION);
218 218
 			}
219 219
 		}
220
-		if($set_share_key === true){
220
+		if($set_share_key === true) {
221 221
 			$storedCredential->setSharedKey($shared_key);
222 222
 			$credential['shared_key'] = $shared_key;
223 223
 		}
224
-		if($unshare_action === true){
224
+		if($unshare_action === true) {
225 225
 			$storedCredential->setSharedKey('');
226 226
 			$credential['shared_key'] = '';
227 227
 		}
@@ -257,21 +257,18 @@  discard block
 block discarded – undo
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
-            if ($acl->hasPermission(SharingACL::HISTORY)){
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
         }
@@ -290,7 +287,7 @@  discard block
 block discarded – undo
290 287
 	/**
291 288
 	 * @NoAdminRequired
292 289
 	 */
293
-	public function updateRevision($credential_guid, $revision_id, $credential_data){
290
+	public function updateRevision($credential_guid, $revision_id, $credential_data) {
294 291
 		$revision = null;
295 292
 		try {
296 293
 			$credential = $this->credentialService->getCredentialByGUID($credential_guid, $this->userId);
Please login to merge, or discard this patch.