@@ -148,7 +148,7 @@ |
||
148 | 148 | * Update a credential |
149 | 149 | * |
150 | 150 | * @param $raw_credential array An array containing all the credential fields |
151 | - * @param $useRawUser bool |
|
151 | + * @param boolean $useRawUser bool |
|
152 | 152 | * @return Credential The updated credential |
153 | 153 | */ |
154 | 154 | public function updateCredential($raw_credential, $useRawUser) { |
@@ -174,13 +174,13 @@ discard block |
||
174 | 174 | $activity . '_self', array($label, $this->userId, $revision_created), |
175 | 175 | '', array(), |
176 | 176 | $link, $this->userId, Activity::TYPE_ITEM_ACTION); |
177 | - } else if (($storedCredential->getDeleteTime() === 0) && (int)$delete_time > 0) { |
|
177 | + } else if (($storedCredential->getDeleteTime() === 0) && (int) $delete_time > 0) { |
|
178 | 178 | $activity = 'item_deleted'; |
179 | 179 | $this->activityService->add( |
180 | 180 | $activity . '_self', array($label, $this->userId), |
181 | 181 | '', array(), |
182 | 182 | $link, $this->userId, Activity::TYPE_ITEM_ACTION); |
183 | - } else if (($storedCredential->getDeleteTime() > 0) && (int)$delete_time === 0) { |
|
183 | + } else if (($storedCredential->getDeleteTime() > 0) && (int) $delete_time === 0) { |
|
184 | 184 | $activity = 'item_recovered'; |
185 | 185 | $this->activityService->add( |
186 | 186 | $activity . '_self', array($label, $this->userId), |
@@ -293,7 +293,7 @@ discard block |
||
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 | } |
@@ -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; |
@@ -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; |
@@ -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 |
@@ -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 |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | return new JSONResponse(array('success' => true)); |
110 | 110 | } |
111 | 111 | |
112 | - public function listRequests(){ |
|
112 | + public function listRequests() { |
|
113 | 113 | $requests = $this->deleteVaultRequestService->getDeleteRequests(); |
114 | 114 | $results = array(); |
115 | - foreach($requests as $request){ |
|
115 | + foreach ($requests as $request) { |
|
116 | 116 | $r = $request->jsonSerialize(); |
117 | 117 | $r['displayName'] = Utils::getNameByUid($request->getRequestedBy()); |
118 | 118 | array_push($results, $r); |
@@ -120,28 +120,28 @@ discard block |
||
120 | 120 | return new JSONResponse($results); |
121 | 121 | } |
122 | 122 | |
123 | - public function acceptRequestDeletion($vault_guid, $requested_by){ |
|
123 | + public function acceptRequestDeletion($vault_guid, $requested_by) { |
|
124 | 124 | $req = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
125 | - try{ |
|
125 | + try { |
|
126 | 126 | $vault = $this->vaultService->getByGuid($vault_guid, $requested_by); |
127 | - } catch (\Exception $e){ |
|
127 | + } catch (\Exception $e) { |
|
128 | 128 | //Ignore |
129 | 129 | } |
130 | 130 | |
131 | - if(isset($vault)){ |
|
131 | + if (isset($vault)) { |
|
132 | 132 | $credentials = $this->credentialService->getCredentialsByVaultId($vault->getId(), $requested_by); |
133 | - foreach($credentials as $credential){ |
|
133 | + foreach ($credentials as $credential) { |
|
134 | 134 | $revisions = $this->revisionService->getRevisions($credential->getId()); |
135 | - foreach($revisions as $revision){ |
|
135 | + foreach ($revisions as $revision) { |
|
136 | 136 | $this->revisionService->deleteRevision($revision['revision_id'], $requested_by); |
137 | 137 | } |
138 | - if($credential instanceof Credential){ |
|
138 | + if ($credential instanceof Credential) { |
|
139 | 139 | $this->credentialService->deleteCredential($credential); |
140 | 140 | } |
141 | 141 | } |
142 | 142 | $this->vaultService->deleteVault($vault_guid, $requested_by); |
143 | 143 | } |
144 | - if($req instanceof DeleteVaultRequest) { |
|
144 | + if ($req instanceof DeleteVaultRequest) { |
|
145 | 145 | $this->deleteVaultRequestService->removeDeleteRequestForVault($req); |
146 | 146 | } |
147 | 147 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function requestDeletion($vault_guid, $reason) { |
155 | 155 | $req = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
156 | - if($req){ |
|
156 | + if ($req) { |
|
157 | 157 | return new JSONResponse('Already exists'); |
158 | 158 | } |
159 | 159 | $vault = $this->vaultService->getByGuid($vault_guid, $this->userId); |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $result = false; |
179 | 179 | try { |
180 | 180 | $delete_request = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
181 | - } catch (\Exception $exception){ |
|
181 | + } catch (\Exception $exception) { |
|
182 | 182 | // Ignore it |
183 | 183 | } |
184 | 184 |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | return new JSONResponse(array('success' => true)); |
110 | 110 | } |
111 | 111 | |
112 | - public function listRequests(){ |
|
112 | + public function listRequests() { |
|
113 | 113 | $requests = $this->deleteVaultRequestService->getDeleteRequests(); |
114 | 114 | $results = array(); |
115 | - foreach($requests as $request){ |
|
115 | + foreach($requests as $request) { |
|
116 | 116 | $r = $request->jsonSerialize(); |
117 | 117 | $r['displayName'] = Utils::getNameByUid($request->getRequestedBy()); |
118 | 118 | array_push($results, $r); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | return new JSONResponse($results); |
121 | 121 | } |
122 | 122 | |
123 | - public function acceptRequestDeletion($vault_guid, $requested_by){ |
|
123 | + public function acceptRequestDeletion($vault_guid, $requested_by) { |
|
124 | 124 | $req = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
125 | 125 | try{ |
126 | 126 | $vault = $this->vaultService->getByGuid($vault_guid, $requested_by); |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | //Ignore |
129 | 129 | } |
130 | 130 | |
131 | - if(isset($vault)){ |
|
131 | + if(isset($vault)) { |
|
132 | 132 | $credentials = $this->credentialService->getCredentialsByVaultId($vault->getId(), $requested_by); |
133 | - foreach($credentials as $credential){ |
|
133 | + foreach($credentials as $credential) { |
|
134 | 134 | $revisions = $this->revisionService->getRevisions($credential->getId()); |
135 | - foreach($revisions as $revision){ |
|
135 | + foreach($revisions as $revision) { |
|
136 | 136 | $this->revisionService->deleteRevision($revision['revision_id'], $requested_by); |
137 | 137 | } |
138 | - if($credential instanceof Credential){ |
|
138 | + if($credential instanceof Credential) { |
|
139 | 139 | $this->credentialService->deleteCredential($credential); |
140 | 140 | } |
141 | 141 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function requestDeletion($vault_guid, $reason) { |
155 | 155 | $req = $this->deleteVaultRequestService->getDeleteRequestForVault($vault_guid); |
156 | - if($req){ |
|
156 | + if($req) { |
|
157 | 157 | return new JSONResponse('Already exists'); |
158 | 158 | } |
159 | 159 | $vault = $this->vaultService->getByGuid($vault_guid, $this->userId); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param DeleteVaultRequest $request |
43 | 43 | * @return \OCP\AppFramework\Db\Entity |
44 | 44 | */ |
45 | - public function createRequest(DeleteVaultRequest $request){ |
|
45 | + public function createRequest(DeleteVaultRequest $request) { |
|
46 | 46 | return $this->insert($request); |
47 | 47 | } |
48 | 48 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * Get all delete requests |
51 | 51 | * @return \OCP\AppFramework\Db\Entity |
52 | 52 | */ |
53 | - public function getDeleteRequests(){ |
|
53 | + public function getDeleteRequests() { |
|
54 | 54 | $q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME; |
55 | 55 | return $this->findEntities($q); |
56 | 56 | } |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @param $vault_id integer The vault id |
61 | 61 | * @return \OCP\AppFramework\Db\Entity |
62 | 62 | */ |
63 | - public function getDeleteRequestsForVault($vault_guid){ |
|
64 | - $q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME .' WHERE `vault_guid` = ?'; |
|
63 | + public function getDeleteRequestsForVault($vault_guid) { |
|
64 | + $q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME . ' WHERE `vault_guid` = ?'; |
|
65 | 65 | return $this->findEntity($q, [$vault_guid]); |
66 | 66 | } |
67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param DeleteVaultRequest $request Request to delete |
71 | 71 | * @return DeleteVaultRequest The deleted request |
72 | 72 | */ |
73 | - public function removeDeleteVaultRequest(DeleteVaultRequest $request){ |
|
73 | + public function removeDeleteVaultRequest(DeleteVaultRequest $request) { |
|
74 | 74 | return $this->delete($request); |
75 | 75 | } |
76 | 76 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param DeleteVaultRequest $request |
43 | 43 | * @return \OCP\AppFramework\Db\Entity |
44 | 44 | */ |
45 | - public function createRequest(DeleteVaultRequest $request){ |
|
45 | + public function createRequest(DeleteVaultRequest $request) { |
|
46 | 46 | return $this->insert($request); |
47 | 47 | } |
48 | 48 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * Get all delete requests |
51 | 51 | * @return \OCP\AppFramework\Db\Entity |
52 | 52 | */ |
53 | - public function getDeleteRequests(){ |
|
53 | + public function getDeleteRequests() { |
|
54 | 54 | $q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME; |
55 | 55 | return $this->findEntities($q); |
56 | 56 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param $vault_id integer The vault id |
61 | 61 | * @return \OCP\AppFramework\Db\Entity |
62 | 62 | */ |
63 | - public function getDeleteRequestsForVault($vault_guid){ |
|
63 | + public function getDeleteRequestsForVault($vault_guid) { |
|
64 | 64 | $q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME .' WHERE `vault_guid` = ?'; |
65 | 65 | return $this->findEntity($q, [$vault_guid]); |
66 | 66 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param DeleteVaultRequest $request Request to delete |
71 | 71 | * @return DeleteVaultRequest The deleted request |
72 | 72 | */ |
73 | - public function removeDeleteVaultRequest(DeleteVaultRequest $request){ |
|
73 | + public function removeDeleteVaultRequest(DeleteVaultRequest $request) { |
|
74 | 74 | return $this->delete($request); |
75 | 75 | } |
76 | 76 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function remind($credential_id) { |
47 | 47 | $credential = $this->credentialService->getCredentialById($credential_id, $this->userId); |
48 | - if($credential) { |
|
48 | + if ($credential) { |
|
49 | 49 | $credential->setExpireTime(time() + (24 * 60 * 60)); |
50 | 50 | $this->credentialService->upd($credential); |
51 | 51 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public function read($credential_id) { |
65 | 65 | |
66 | 66 | $credential = $this->credentialService->getCredentialById($credential_id, $this->userId); |
67 | - if($credential) { |
|
67 | + if ($credential) { |
|
68 | 68 | $credential->setExpireTime(0); |
69 | 69 | $this->credentialService->upd($credential); |
70 | 70 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @NoAdminRequired |
91 | 91 | */ |
92 | 92 | public function generatePerson() { |
93 | - $context = [ 'http' => [ 'method' => 'GET' ], 'ssl' => [ 'verify_peer' => false, 'allow_self_signed'=> true ] ]; |
|
93 | + $context = ['http' => ['method' => 'GET'], 'ssl' => ['verify_peer' => false, 'allow_self_signed'=> true]]; |
|
94 | 94 | $context = stream_context_create($context); |
95 | 95 | $random_person = json_decode(file_get_contents('http://api.namefake.com/', false, $context)); |
96 | 96 | return new JSONResponse($random_person); |
@@ -49,16 +49,16 @@ |
||
49 | 49 | |
50 | 50 | public function expireCredentials() { |
51 | 51 | $expired_credentials = $this->credentialService->getExpiredCredentials($this->utils->getTime()); |
52 | - foreach($expired_credentials as $credential){ |
|
52 | + foreach ($expired_credentials as $credential) { |
|
53 | 53 | $link = ''; // @TODO create direct link to credential |
54 | 54 | |
55 | 55 | $sql = 'SELECT count(*) as rows from `*PREFIX*notifications` WHERE `subject`= \'credential_expired\' AND object_id=?'; |
56 | 56 | $id = $credential->getId(); |
57 | 57 | $result = $this->db->executeQuery($sql, array($id)); |
58 | - $this->logger->debug($credential->getLabel() .' is expired, checking notifications!', array('app' => 'passman')); |
|
58 | + $this->logger->debug($credential->getLabel() . ' is expired, checking notifications!', array('app' => 'passman')); |
|
59 | 59 | $notifications = intval($result->fetch()['rows']); |
60 | - if($notifications === 0) { |
|
61 | - $this->logger->debug($credential->getLabel() .' is expired, adding notification!', array('app' => 'passman')); |
|
60 | + if ($notifications === 0) { |
|
61 | + $this->logger->debug($credential->getLabel() . ' is expired, adding notification!', array('app' => 'passman')); |
|
62 | 62 | $this->activityService->add( |
63 | 63 | Activity::SUBJECT_ITEM_EXPIRED, array($credential->getLabel(), $credential->getUserId()), |
64 | 64 | '', array(), |
@@ -49,7 +49,7 @@ |
||
49 | 49 | |
50 | 50 | public function expireCredentials() { |
51 | 51 | $expired_credentials = $this->credentialService->getExpiredCredentials($this->utils->getTime()); |
52 | - foreach($expired_credentials as $credential){ |
|
52 | + foreach($expired_credentials as $credential) { |
|
53 | 53 | $link = ''; // @TODO create direct link to credential |
54 | 54 | |
55 | 55 | $sql = 'SELECT count(*) as rows from `*PREFIX*notifications` WHERE `subject`= \'credential_expired\' AND object_id=?'; |
@@ -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; |
@@ -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; |