Completed
Push — master ( cee3ea...304e61 )
by Sander
02:37
created
lib/Utility/PermissionEntity.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
 use OCP\AppFramework\Db\Entity;
14 14
 
15 15
 class PermissionEntity extends Entity {
16
-	CONST READ  =   0b00000001;
17
-	CONST WRITE =   0b00000010;
18
-	CONST FILES =   0b00000100;
16
+	CONST READ  = 0b00000001;
17
+	CONST WRITE = 0b00000010;
18
+	CONST FILES = 0b00000100;
19 19
 	CONST HISTORY = 0b00001000;
20
-	CONST OWNER =   0b10000000;
20
+	CONST OWNER = 0b10000000;
21 21
 
22 22
 	/**
23 23
 	 * Checks wether a user matches one or more permissions at once
Please login to merge, or discard this patch.
lib/Db/SharingACLMapper.php 2 patches
Spacing   +7 added lines, -7 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){
33
-		$sql = "SELECT * FROM ". self::TABLE_NAME ." WHERE user_id = ? AND item_guid = ?";
32
+	public function getCredentialPermissions(IUser $userId, $item_guid) {
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
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @return SharingACL[]
47 47
 	 */
48 48
 	public function getVaultEntries($user_id, $vault_id) {
49
-		$q = "SELECT * FROM ". self::TABLE_NAME ." WHERE user_id = ? AND vault_guid = ?";
49
+		$q = "SELECT * FROM " . self::TABLE_NAME . " WHERE user_id = ? AND vault_guid = ?";
50 50
 		return $this->findEntities($q, [$user_id, $vault_id]);
51 51
 	}
52 52
 
@@ -59,7 +59,7 @@  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 64
 		}
65 65
 		else {
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 	 * @return SharingACL[]
87 87
 	 */
88 88
 	public function getCredentialAclList($item_guid) {
89
-		$q = "SELECT * FROM ". self::TABLE_NAME ." WHERE item_guid = ?";
89
+		$q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ?";
90 90
 		return $this->findEntities($q, [$item_guid]);
91 91
 	}
92 92
 
93
-	public function deleteShareACL(SharingACL $ACL){
93
+	public function deleteShareACL(SharingACL $ACL) {
94 94
 		return $this->delete($ACL);
95 95
 	}
96 96
 }
97 97
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,7 @@
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
lib/Service/CredentialService.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -81,17 +81,17 @@  discard block
 block discarded – undo
81 81
 	}
82 82
 
83 83
 	public function getCredentialById($credential_id, $user_id) {
84
-        $credential = $this->credentialMapper->getCredentialById($credential_id);
85
-        if ($credential->getUserId() === $user_id) {
86
-            return $credential;
87
-        }
88
-        else {
89
-            $acl = $this->sharingACL->getItemACL($user_id, $credential->getGuid());
90
-            if ($acl->hasPermission(SharingACL::READ));
91
-            return $credential;
92
-        }
93
-
94
-        throw new DoesNotExistException("Did expect one result but found none when executing");
84
+		$credential = $this->credentialMapper->getCredentialById($credential_id);
85
+		if ($credential->getUserId() === $user_id) {
86
+			return $credential;
87
+		}
88
+		else {
89
+			$acl = $this->sharingACL->getItemACL($user_id, $credential->getGuid());
90
+			if ($acl->hasPermission(SharingACL::READ));
91
+			return $credential;
92
+		}
93
+
94
+		throw new DoesNotExistException("Did expect one result but found none when executing");
95 95
 	}
96 96
 
97 97
 	/**
@@ -102,6 +102,6 @@  discard block
 block discarded – undo
102 102
 	}
103 103
 
104 104
 	public function getCredentialByGUID($credential_guid, $user_id = null){
105
-	    return $this->credentialMapper->getCredentialByGUID($credential_guid, $user_id);
106
-    }
105
+		return $this->credentialMapper->getCredentialByGUID($credential_guid, $user_id);
106
+	}
107 107
 }
108 108
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	/**
55 55
 	 * @param Credential $credential
56 56
 	 */
57
-	public function deleteCredential($credential){
57
+	public function deleteCredential($credential) {
58 58
 		return $this->credentialMapper->deleteCredential($credential);
59 59
 	}
60 60
 
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	/**
98 98
 	 * @param integer $credential_id
99 99
 	 */
100
-	public function getCredentialLabelById($credential_id){
100
+	public function getCredentialLabelById($credential_id) {
101 101
 		return $this->credentialMapper->getCredentialLabelById($credential_id);
102 102
 	}
103 103
 
104
-	public function getCredentialByGUID($credential_guid, $user_id = null){
104
+	public function getCredentialByGUID($credential_guid, $user_id = null) {
105 105
 	    return $this->credentialMapper->getCredentialByGUID($credential_guid, $user_id);
106 106
     }
107 107
 }
108 108
\ No newline at end of file
Please login to merge, or discard this patch.