@@ -38,7 +38,7 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | |
| 40 | 40 | |
| 41 | -class DeleteVaultRequest extends Entity implements \JsonSerializable{ |
|
| 41 | +class DeleteVaultRequest extends Entity implements \JsonSerializable { |
|
| 42 | 42 | |
| 43 | 43 | use EntityJSONSerializer; |
| 44 | 44 | |
@@ -181,7 +181,7 @@ |
||
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
| 184 | - private function parseLinkElement($htmlHead, $pageUrlInfo, $base_href){ |
|
| 184 | + private function parseLinkElement($htmlHead, $pageUrlInfo, $base_href) { |
|
| 185 | 185 | if (preg_match('#<\s*link[^>]*(rel=(["\'])[^>\2]*icon[^>\2]*\2)[^>]*>#i', $htmlHead, $matches)) { |
| 186 | 186 | $link_tag = $matches[0]; |
| 187 | 187 | $this->debugInfo['link_tag'] = $link_tag; |
@@ -45,8 +45,7 @@ discard block |
||
| 45 | 45 | * @return string |
| 46 | 46 | */ |
| 47 | 47 | public static function GUID() { |
| 48 | - if (function_exists('com_create_guid') === true) |
|
| 49 | - { |
|
| 48 | + if (function_exists('com_create_guid') === true) { |
|
| 50 | 49 | return trim(com_create_guid(), '{}'); |
| 51 | 50 | } |
| 52 | 51 | |
@@ -58,7 +57,7 @@ discard block |
||
| 58 | 57 | * @param IUserManager $userManager |
| 59 | 58 | * @return string |
| 60 | 59 | */ |
| 61 | - public static function getNameByUid(string $uid, IUserManager $userManager){ |
|
| 60 | + public static function getNameByUid(string $uid, IUserManager $userManager) { |
|
| 62 | 61 | $u = $userManager->get($uid); |
| 63 | 62 | return $u->getDisplayName(); |
| 64 | 63 | } |
@@ -68,10 +67,10 @@ discard block |
||
| 68 | 67 | * @param array $results |
| 69 | 68 | * @return array|mixed |
| 70 | 69 | */ |
| 71 | - public static function getDirContents(string $dir, &$results = array()){ |
|
| 70 | + public static function getDirContents(string $dir, &$results = array()) { |
|
| 72 | 71 | $files = scandir($dir); |
| 73 | 72 | |
| 74 | - foreach($files as $value){ |
|
| 73 | + foreach($files as $value) { |
|
| 75 | 74 | $path = realpath($dir.DIRECTORY_SEPARATOR.$value); |
| 76 | 75 | if(!is_dir($path)) { |
| 77 | 76 | $results[] = $path; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public function moveCredentials($source_account, $destination_account) { |
| 82 | 82 | $succeed = false; |
| 83 | - if ($source_account != $destination_account){ |
|
| 83 | + if ($source_account != $destination_account) { |
|
| 84 | 84 | $vaults = $this->vaultService->getByUser($source_account); |
| 85 | 85 | foreach ($vaults as $vault) { |
| 86 | 86 | $credentials = $this->credentialService->getCredentialsByVaultId($vault->getId(), $source_account); |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | return new JSONResponse(array('success' => $succeed)); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function listRequests(){ |
|
| 121 | + public function listRequests() { |
|
| 122 | 122 | $requests = $this->deleteVaultRequestService->getDeleteRequests(); |
| 123 | 123 | $results = array(); |
| 124 | - foreach($requests as $request){ |
|
| 124 | + foreach($requests as $request) { |
|
| 125 | 125 | $r = $request->jsonSerialize(); |
| 126 | 126 | $r['displayName'] = Utils::getNameByUid($request->getRequestedBy(), $this->userManager); |
| 127 | 127 | array_push($results, $r); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | return new JSONResponse($results); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - public function acceptRequestDeletion($vault_guid, $requested_by){ |
|
| 132 | + public function acceptRequestDeletion($vault_guid, $requested_by) { |
|
| 133 | 133 | $req = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
| 134 | 134 | try{ |
| 135 | 135 | $vault = $this->vaultService->getByGuid($vault_guid, $requested_by); |
@@ -137,14 +137,14 @@ discard block |
||
| 137 | 137 | //Ignore |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if(isset($vault)){ |
|
| 140 | + if(isset($vault)) { |
|
| 141 | 141 | $credentials = $this->credentialService->getCredentialsByVaultId($vault->getId(), $requested_by); |
| 142 | - foreach($credentials as $credential){ |
|
| 142 | + foreach($credentials as $credential) { |
|
| 143 | 143 | $revisions = $this->revisionService->getRevisions($credential->getId()); |
| 144 | - foreach($revisions as $revision){ |
|
| 144 | + foreach($revisions as $revision) { |
|
| 145 | 145 | $this->revisionService->deleteRevision($revision['revision_id'], $requested_by); |
| 146 | 146 | } |
| 147 | - if($credential instanceof Credential){ |
|
| 147 | + if($credential instanceof Credential) { |
|
| 148 | 148 | $this->credentialService->deleteCredential($credential); |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function requestDeletion($vault_guid, $reason) { |
| 164 | 164 | $req = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
| 165 | - if($req){ |
|
| 165 | + if($req) { |
|
| 166 | 166 | return new JSONResponse('Already exists'); |
| 167 | 167 | } |
| 168 | 168 | $vault = $this->vaultService->getByGuid($vault_guid, $this->userId); |
@@ -100,7 +100,9 @@ discard block |
||
| 100 | 100 | * @return Entity |
| 101 | 101 | */ |
| 102 | 102 | public function createACLEntry(SharingACL $acl) { |
| 103 | - if ($acl->getCreated() === null) $acl->setCreated((new \DateTime())->getTimestamp()); |
|
| 103 | + if ($acl->getCreated() === null) { |
|
| 104 | + $acl->setCreated((new \DateTime())->getTimestamp()); |
|
| 105 | + } |
|
| 104 | 106 | return $this->sharingACL->createACLEntry($acl); |
| 105 | 107 | } |
| 106 | 108 | |
@@ -158,13 +160,17 @@ discard block |
||
| 158 | 160 | $return = []; |
| 159 | 161 | foreach ($entries as $entry) { |
| 160 | 162 | // Check if the user can read the credential, probably unnecesary, but just to be sure |
| 161 | - if (!$entry->hasPermission(SharingACL::READ)) continue; |
|
| 163 | + if (!$entry->hasPermission(SharingACL::READ)) { |
|
| 164 | + continue; |
|
| 165 | + } |
|
| 162 | 166 | $tmp = $entry->jsonSerialize(); |
| 163 | 167 | $credential = $this->credential->getCredentialById($entry->getItemId()); |
| 164 | 168 | $credential = $this->encryptService->decryptCredential($credential); |
| 165 | 169 | $tmp['credential_data'] = $credential->jsonSerialize(); |
| 166 | 170 | |
| 167 | - if (!$entry->hasPermission(SharingACL::FILES)) unset($tmp['credential_data']['files']); |
|
| 171 | + if (!$entry->hasPermission(SharingACL::FILES)) { |
|
| 172 | + unset($tmp['credential_data']['files']); |
|
| 173 | + } |
|
| 168 | 174 | unset($tmp['credential_data']['shared_key']); |
| 169 | 175 | $return[] = $tmp; |
| 170 | 176 | } |
@@ -195,7 +201,9 @@ discard block |
||
| 195 | 201 | $acl = $this->sharingACL->getItemACL($user_id, $item_guid); |
| 196 | 202 | |
| 197 | 203 | // Check if the user can read the credential, probably unnecesary, but just to be sure |
| 198 | - if (!$acl->hasPermission(SharingACL::READ)) throw new DoesNotExistException("Item not found or wrong access level"); |
|
| 204 | + if (!$acl->hasPermission(SharingACL::READ)) { |
|
| 205 | + throw new DoesNotExistException("Item not found or wrong access level"); |
|
| 206 | + } |
|
| 199 | 207 | |
| 200 | 208 | $tmp = $acl->jsonSerialize(); |
| 201 | 209 | $credential = $this->credential->getCredentialById($acl->getItemId()); |
@@ -203,7 +211,9 @@ discard block |
||
| 203 | 211 | |
| 204 | 212 | $tmp['credential_data'] = $credential->jsonSerialize(); |
| 205 | 213 | |
| 206 | - if (!$acl->hasPermission(SharingACL::FILES)) unset($tmp['credential_data']['files']); |
|
| 214 | + if (!$acl->hasPermission(SharingACL::FILES)) { |
|
| 215 | + unset($tmp['credential_data']['files']); |
|
| 216 | + } |
|
| 207 | 217 | unset($tmp['credential_data']['shared_key']); |
| 208 | 218 | |
| 209 | 219 | return $tmp; |
@@ -221,7 +231,9 @@ discard block |
||
| 221 | 231 | */ |
| 222 | 232 | public function getItemHistory(?string $user_id, string $item_guid) { |
| 223 | 233 | $acl = $this->sharingACL->getItemACL($user_id, $item_guid); |
| 224 | - if (!$acl->hasPermission(SharingACL::READ | SharingACL::HISTORY)) return []; |
|
| 234 | + if (!$acl->hasPermission(SharingACL::READ | SharingACL::HISTORY)) { |
|
| 235 | + return []; |
|
| 236 | + } |
|
| 225 | 237 | |
| 226 | 238 | return $this->revisions->getRevisions($acl->getItemId()); |
| 227 | 239 | } |