@@ -26,7 +26,7 @@ |
||
26 | 26 | $setting = (in_array($methodName, $publicMethods)) ? 'link_sharing_enabled' : 'user_sharing_enabled'; |
27 | 27 | $sharing_enabled = ($this->settings->isEnabled($setting)); |
28 | 28 | |
29 | - if(in_array($methodName, $user_pub_methods)){ |
|
29 | + if(in_array($methodName, $user_pub_methods)) { |
|
30 | 30 | $sharing_enabled = ($this->settings->isEnabled('link_sharing_enabled') || $this->settings->isEnabled('user_sharing_enabled')); |
31 | 31 | } |
32 | 32 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | parent::__construct($db, 'passman_sharing_acl'); |
37 | 37 | } |
38 | 38 | |
39 | - public function createACLEntry(SharingACL $acl){ |
|
39 | + public function createACLEntry(SharingACL $acl) { |
|
40 | 40 | return $this->insert($acl); |
41 | 41 | } |
42 | 42 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $q = "SELECT * FROM " . self::TABLE_NAME . " WHERE item_guid = ? AND "; |
62 | 62 | $filter = [$item_guid]; |
63 | 63 | $q .= ($user_id === null) ? 'user_id is null' : 'user_id = ? '; |
64 | - if ($user_id !== null){ |
|
64 | + if ($user_id !== null) { |
|
65 | 65 | $filter[] = $user_id; |
66 | 66 | } |
67 | 67 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | return $this->findEntities($q, [$item_guid]); |
90 | 90 | } |
91 | 91 | |
92 | - public function deleteShareACL(SharingACL $ACL){ |
|
92 | + public function deleteShareACL(SharingACL $ACL) { |
|
93 | 93 | return $this->delete($ACL); |
94 | 94 | } |
95 | 95 | } |
96 | 96 | \ No newline at end of file |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
63 | 63 | * @return Vault[] |
64 | 64 | */ |
65 | - public function findVaultsFromUser($userId){ |
|
65 | + public function findVaultsFromUser($userId) { |
|
66 | 66 | $sql = 'SELECT * FROM `*PREFIX*passman_vaults` ' . |
67 | 67 | 'WHERE `user_id` = ? '; |
68 | 68 | $params = [$userId]; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param $userId |
76 | 76 | * @return Vault |
77 | 77 | */ |
78 | - public function create($vault_name, $userId){ |
|
78 | + public function create($vault_name, $userId) { |
|
79 | 79 | $vault = new Vault(); |
80 | 80 | $vault->setName($vault_name); |
81 | 81 | $vault->setUserId($userId); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param $vault_id |
91 | 91 | * @param $user_id |
92 | 92 | */ |
93 | - public function setLastAccess($vault_id, $user_id){ |
|
93 | + public function setLastAccess($vault_id, $user_id) { |
|
94 | 94 | $vault = new Vault(); |
95 | 95 | $vault->setId($vault_id); |
96 | 96 | $vault->setUserId($user_id); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * Update vault |
103 | 103 | * @param Vault $vault |
104 | 104 | */ |
105 | - public function updateVault(Vault $vault){ |
|
105 | + public function updateVault(Vault $vault) { |
|
106 | 106 | $this->update($vault); |
107 | 107 | } |
108 | 108 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param $privateKey |
113 | 113 | * @param $publicKey |
114 | 114 | */ |
115 | - public function updateSharingKeys($vault_id, $privateKey, $publicKey){ |
|
115 | + public function updateSharingKeys($vault_id, $privateKey, $publicKey) { |
|
116 | 116 | $vault = new Vault(); |
117 | 117 | $vault->setId($vault_id); |
118 | 118 | $vault->setPrivateSharingKey($privateKey); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * Delete a vault |
126 | 126 | * @param Vault $vault |
127 | 127 | */ |
128 | - public function deleteVault(Vault $vault){ |
|
128 | + public function deleteVault(Vault $vault) { |
|
129 | 129 | $this->delete($vault); |
130 | 130 | } |
131 | 131 | } |
132 | 132 | \ No newline at end of file |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param $vault_id |
93 | 93 | * @param $user_id |
94 | 94 | */ |
95 | - public function setLastAccess($vault_id, $user_id){ |
|
95 | + public function setLastAccess($vault_id, $user_id) { |
|
96 | 96 | return $this->vaultMapper->setLastAccess($vault_id, $user_id); |
97 | 97 | } |
98 | 98 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param $privateKey |
103 | 103 | * @param $publicKey |
104 | 104 | */ |
105 | - public function updateSharingKeys($vault_id, $privateKey, $publicKey){ |
|
105 | + public function updateSharingKeys($vault_id, $privateKey, $publicKey) { |
|
106 | 106 | return $this->vaultMapper->updateSharingKeys($vault_id, $privateKey, $publicKey); |
107 | 107 | } |
108 | 108 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param string $vault_guid |
112 | 112 | * @param string $user_id |
113 | 113 | */ |
114 | - public function deleteVault($vault_guid, $user_id){ |
|
114 | + public function deleteVault($vault_guid, $user_id) { |
|
115 | 115 | $vault = $this->getByGuid($vault_guid, $user_id); |
116 | 116 | if($vault instanceof Vault) { |
117 | 117 | $this->vaultMapper->deleteVault($vault); |
@@ -90,7 +90,9 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | public function createACLEntry(SharingACL $acl) { |
93 | - if ($acl->getCreated() === null) $acl->setCreated((new \DateTime())->getTimestamp()); |
|
93 | + if ($acl->getCreated() === null) { |
|
94 | + $acl->setCreated((new \DateTime())->getTimestamp()); |
|
95 | + } |
|
94 | 96 | return $this->sharingACL->createACLEntry($acl); |
95 | 97 | } |
96 | 98 | |
@@ -143,13 +145,17 @@ discard block |
||
143 | 145 | $return = []; |
144 | 146 | foreach ($entries as $entry) { |
145 | 147 | // Check if the user can read the credential, probably unnecesary, but just to be sure |
146 | - if (!$entry->hasPermission(SharingACL::READ)) continue; |
|
148 | + if (!$entry->hasPermission(SharingACL::READ)) { |
|
149 | + continue; |
|
150 | + } |
|
147 | 151 | $tmp = $entry->jsonSerialize(); |
148 | 152 | $credential = $this->credential->getCredentialById($entry->getItemId()); |
149 | 153 | $credential = $this->encryptService->decryptCredential($credential); |
150 | 154 | $tmp['credential_data'] = $credential->jsonSerialize(); |
151 | 155 | |
152 | - if (!$entry->hasPermission(SharingACL::FILES)) unset($tmp['credential_data']['files']); |
|
156 | + if (!$entry->hasPermission(SharingACL::FILES)) { |
|
157 | + unset($tmp['credential_data']['files']); |
|
158 | + } |
|
153 | 159 | unset($tmp['credential_data']['shared_key']); |
154 | 160 | $return[] = $tmp; |
155 | 161 | } |
@@ -171,7 +177,9 @@ discard block |
||
171 | 177 | $acl = $this->sharingACL->getItemACL($user_id, $item_guid); |
172 | 178 | |
173 | 179 | // Check if the user can read the credential, probably unnecesary, but just to be sure |
174 | - if (!$acl->hasPermission(SharingACL::READ)) throw new DoesNotExistException("Item not found or wrong access level"); |
|
180 | + if (!$acl->hasPermission(SharingACL::READ)) { |
|
181 | + throw new DoesNotExistException("Item not found or wrong access level"); |
|
182 | + } |
|
175 | 183 | |
176 | 184 | $tmp = $acl->jsonSerialize(); |
177 | 185 | $credential = $this->credential->getCredentialById($acl->getItemId()); |
@@ -179,7 +187,9 @@ discard block |
||
179 | 187 | |
180 | 188 | $tmp['credential_data'] = $credential->jsonSerialize(); |
181 | 189 | |
182 | - if (!$acl->hasPermission(SharingACL::FILES)) unset($tmp['credential_data']['files']); |
|
190 | + if (!$acl->hasPermission(SharingACL::FILES)) { |
|
191 | + unset($tmp['credential_data']['files']); |
|
192 | + } |
|
183 | 193 | unset($tmp['credential_data']['shared_key']); |
184 | 194 | |
185 | 195 | return $tmp; |
@@ -194,7 +204,9 @@ discard block |
||
194 | 204 | */ |
195 | 205 | public function getItemHistory($user_id, $item_guid) { |
196 | 206 | $acl = $this->sharingACL->getItemACL($user_id, $item_guid); |
197 | - if (!$acl->hasPermission(SharingACL::READ | SharingACL::HISTORY)) return []; |
|
207 | + if (!$acl->hasPermission(SharingACL::READ | SharingACL::HISTORY)) { |
|
208 | + return []; |
|
209 | + } |
|
198 | 210 | |
199 | 211 | return $this->revisions->getRevisions($acl->getItemId()); |
200 | 212 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | public function __construct($AppName, |
24 | 24 | IRequest $request, |
25 | 25 | $UserId, |
26 | - FileService $fileService){ |
|
26 | + FileService $fileService) { |
|
27 | 27 | parent::__construct( |
28 | 28 | $AppName, |
29 | 29 | $request, |
@@ -65,20 +65,20 @@ discard block |
||
65 | 65 | return new JSONResponse($this->fileService->deleteFile($file_id, $this->userId)); |
66 | 66 | } |
67 | 67 | |
68 | - public function updateFile($file_id, $file_data, $filename){ |
|
68 | + public function updateFile($file_id, $file_data, $filename) { |
|
69 | 69 | try{ |
70 | 70 | $file = $this->fileService->getFile($file_id, $this->userId); |
71 | 71 | } catch (\Exception $doesNotExistException){ |
72 | 72 | |
73 | 73 | } |
74 | - if($file){ |
|
74 | + if($file) { |
|
75 | 75 | if($file_data) { |
76 | 76 | $file->setFileData($file_data); |
77 | 77 | } |
78 | 78 | if($filename) { |
79 | 79 | $file->setFilename($filename); |
80 | 80 | } |
81 | - if($filename || $file_data){ |
|
81 | + if($filename || $file_data) { |
|
82 | 82 | new JSONResponse($this->fileService->updateFile($file)); |
83 | 83 | } |
84 | 84 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | public function afterController($controller, $methodName, Response $response) { |
19 | - if($response instanceof JSONResponse){ |
|
19 | + if($response instanceof JSONResponse) { |
|
20 | 20 | if(isset($this->request->server['HTTP_ORIGIN'])) { |
21 | 21 | $response->addHeader('Access-Control-Allow-Origin', $this->request->server['HTTP_ORIGIN']); |
22 | 22 | } |
@@ -293,7 +293,7 @@ |
||
293 | 293 | $this->sharingService->unshareCredential($credential->getGuid()); |
294 | 294 | foreach ($this->credentialRevisionService->getRevisions($credential->getId()) as $revision) { |
295 | 295 | $id = $revision['revision_id']; |
296 | - if(isset($id)){ |
|
296 | + if(isset($id)) { |
|
297 | 297 | $this->credentialRevisionService->deleteRevision($id, $this->userId); |
298 | 298 | } |
299 | 299 | } |
@@ -107,10 +107,10 @@ |
||
107 | 107 | * @param string $userId |
108 | 108 | * @return File[] |
109 | 109 | */ |
110 | - public function getFilesFromUser($userId){ |
|
110 | + public function getFilesFromUser($userId) { |
|
111 | 111 | $files = $this->fileMapper->getFilesFromUser($userId); |
112 | 112 | $results = array(); |
113 | - foreach ($files as $file){ |
|
113 | + foreach ($files as $file) { |
|
114 | 114 | array_push($results, $this->encryptService->decryptFile($file)); |
115 | 115 | } |
116 | 116 | return $results; |