@@ -110,7 +110,7 @@ |
||
110 | 110 | /** |
111 | 111 | * Check if an setting is enabled (value of 1) |
112 | 112 | * |
113 | - * @param $setting |
|
113 | + * @param string $setting |
|
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | public function isEnabled($setting) { |
@@ -59,7 +59,7 @@ |
||
59 | 59 | foreach ($vaults as $vault) { |
60 | 60 | $credential = $this->credentialService->getRandomCredentialByVaultId($vault->getId(), $this->userId); |
61 | 61 | $secret_field = $protected_credential_fields[array_rand($protected_credential_fields)]; |
62 | - if(isset($credential)) { |
|
62 | + if (isset($credential)) { |
|
63 | 63 | array_push($result, array( |
64 | 64 | 'vault_id' => $vault->getId(), |
65 | 65 | 'guid' => $vault->getGuid(), |
@@ -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 |
@@ -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,9 +111,9 @@ 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 | - if($vault instanceof Vault) { |
|
116 | + if ($vault instanceof Vault) { |
|
117 | 117 | $this->vaultMapper->deleteVault($vault); |
118 | 118 | } |
119 | 119 | } |
@@ -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); |
@@ -16,8 +16,8 @@ |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | public function afterController($controller, $methodName, Response $response) { |
19 | - if($response instanceof JSONResponse){ |
|
20 | - if(isset($this->request->server['HTTP_ORIGIN'])) { |
|
19 | + if ($response instanceof JSONResponse) { |
|
20 | + if (isset($this->request->server['HTTP_ORIGIN'])) { |
|
21 | 21 | $response->addHeader('Access-Control-Allow-Origin', $this->request->server['HTTP_ORIGIN']); |
22 | 22 | } |
23 | 23 | } |
@@ -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 | } |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | namespace OCA\Passman\Utility; |
25 | 25 | |
26 | 26 | class Utils { |
27 | - /** |
|
28 | - * Gets the unix epoch UTC timestamp |
|
29 | - * @return int |
|
30 | - */ |
|
27 | + /** |
|
28 | + * Gets the unix epoch UTC timestamp |
|
29 | + * @return int |
|
30 | + */ |
|
31 | 31 | public static function getTime() { |
32 | 32 | return (new \DateTime())->getTimestamp(); |
33 | 33 | } |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | return microtime(true); |
39 | 39 | } |
40 | 40 | |
41 | - /** |
|
42 | - * Generates a Globally Unique ID |
|
43 | - * @return string |
|
44 | - */ |
|
41 | + /** |
|
42 | + * Generates a Globally Unique ID |
|
43 | + * @return string |
|
44 | + */ |
|
45 | 45 | public static function GUID() { |
46 | 46 | if (function_exists('com_create_guid') === true) |
47 | 47 | { |
@@ -55,20 +55,20 @@ |
||
55 | 55 | * @param $uid |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - public static function getNameByUid($uid){ |
|
58 | + public static function getNameByUid($uid) { |
|
59 | 59 | $um = \OC::$server->getUserManager(); |
60 | 60 | $u = $um->get($uid); |
61 | 61 | return $u->getDisplayName(); |
62 | 62 | } |
63 | 63 | |
64 | - public static function getDirContents($dir, &$results = array()){ |
|
64 | + public static function getDirContents($dir, &$results = array()) { |
|
65 | 65 | $files = scandir($dir); |
66 | 66 | |
67 | - foreach($files as $value){ |
|
68 | - $path = realpath($dir.DIRECTORY_SEPARATOR.$value); |
|
69 | - if(!is_dir($path)) { |
|
67 | + foreach ($files as $value) { |
|
68 | + $path = realpath($dir . DIRECTORY_SEPARATOR . $value); |
|
69 | + if (!is_dir($path)) { |
|
70 | 70 | $results[] = $path; |
71 | - } else if($value != "." && $value != "..") { |
|
71 | + } else if ($value != "." && $value != "..") { |
|
72 | 72 | Utils::getDirContents($path, $results); |
73 | 73 | $results[] = $path; |
74 | 74 | } |
@@ -43,8 +43,7 @@ discard block |
||
43 | 43 | * @return string |
44 | 44 | */ |
45 | 45 | public static function GUID() { |
46 | - if (function_exists('com_create_guid') === true) |
|
47 | - { |
|
46 | + if (function_exists('com_create_guid') === true) { |
|
48 | 47 | return trim(com_create_guid(), '{}'); |
49 | 48 | } |
50 | 49 | |
@@ -55,16 +54,16 @@ discard block |
||
55 | 54 | * @param $uid |
56 | 55 | * @return string |
57 | 56 | */ |
58 | - public static function getNameByUid($uid){ |
|
57 | + public static function getNameByUid($uid) { |
|
59 | 58 | $um = \OC::$server->getUserManager(); |
60 | 59 | $u = $um->get($uid); |
61 | 60 | return $u->getDisplayName(); |
62 | 61 | } |
63 | 62 | |
64 | - public static function getDirContents($dir, &$results = array()){ |
|
63 | + public static function getDirContents($dir, &$results = array()) { |
|
65 | 64 | $files = scandir($dir); |
66 | 65 | |
67 | - foreach($files as $value){ |
|
66 | + foreach($files as $value) { |
|
68 | 67 | $path = realpath($dir.DIRECTORY_SEPARATOR.$value); |
69 | 68 | if(!is_dir($path)) { |
70 | 69 | $results[] = $path; |
@@ -52,19 +52,19 @@ |
||
52 | 52 | //Sharing stuff |
53 | 53 | ['name' => 'share#search', 'url' => '/api/v2/sharing/search', 'verb' => 'POST'], |
54 | 54 | ['name' => 'share#getVaultsByUser', 'url' => '/api/v2/sharing/vaults/{user_id}', 'verb' => 'GET'], |
55 | - ['name' => 'share#applyIntermediateShare', 'url' => '/api/v2/sharing/share', 'verb' => 'POST'], |
|
56 | - ['name' => 'share#savePendingRequest', 'url' => '/api/v2/sharing/save', 'verb' => 'POST'], |
|
57 | - ['name' => 'share#getPendingRequests', 'url' => '/api/v2/sharing/pending', 'verb' => 'GET'], |
|
58 | - ['name' => 'share#deleteShareRequest', 'url' => '/api/v2/sharing/decline/{share_request_id}', 'verb' => 'DELETE'], |
|
59 | - ['name' => 'share#getVaultItems', 'url' => '/api/v2/sharing/vault/{vault_guid}/get', 'verb' => 'GET'], |
|
60 | - ['name' => 'share#createPublicShare', 'url' => '/api/v2/sharing/public', 'verb' => 'POST'], |
|
61 | - ['name' => 'share#getPublicCredentialData', 'url' => '/api/v2/sharing/credential/{credential_guid}/public', 'verb' => 'GET'], |
|
62 | - ['name' => 'share#unshareCredential', 'url' => '/api/v2/sharing/credential/{item_guid}', 'verb' => 'DELETE'], |
|
63 | - ['name' => 'share#unshareCredentialFromUser', 'url' => '/api/v2/sharing/credential/{item_guid}/{user_id}', 'verb' => 'DELETE'], |
|
64 | - ['name' => 'share#getRevisions', 'url' => '/api/v2/sharing/credential/{item_guid}/revisions', 'verb' => 'GET'], |
|
65 | - ['name' => 'share#getItemAcl', 'url' => '/api/v2/sharing/credential/{item_guid}/acl', 'verb' => 'GET'], |
|
66 | - ['name' => 'share#getFile', 'url' => '/api/v2/sharing/credential/{item_guid}/file/{file_guid}', 'verb' => 'GET'], |
|
67 | - ['name' => 'share#updateSharedCredentialACL', 'url' => '/api/v2/sharing/credential/{item_guid}/acl', 'verb' => 'PATCH'], |
|
55 | + ['name' => 'share#applyIntermediateShare', 'url' => '/api/v2/sharing/share', 'verb' => 'POST'], |
|
56 | + ['name' => 'share#savePendingRequest', 'url' => '/api/v2/sharing/save', 'verb' => 'POST'], |
|
57 | + ['name' => 'share#getPendingRequests', 'url' => '/api/v2/sharing/pending', 'verb' => 'GET'], |
|
58 | + ['name' => 'share#deleteShareRequest', 'url' => '/api/v2/sharing/decline/{share_request_id}', 'verb' => 'DELETE'], |
|
59 | + ['name' => 'share#getVaultItems', 'url' => '/api/v2/sharing/vault/{vault_guid}/get', 'verb' => 'GET'], |
|
60 | + ['name' => 'share#createPublicShare', 'url' => '/api/v2/sharing/public', 'verb' => 'POST'], |
|
61 | + ['name' => 'share#getPublicCredentialData', 'url' => '/api/v2/sharing/credential/{credential_guid}/public', 'verb' => 'GET'], |
|
62 | + ['name' => 'share#unshareCredential', 'url' => '/api/v2/sharing/credential/{item_guid}', 'verb' => 'DELETE'], |
|
63 | + ['name' => 'share#unshareCredentialFromUser', 'url' => '/api/v2/sharing/credential/{item_guid}/{user_id}', 'verb' => 'DELETE'], |
|
64 | + ['name' => 'share#getRevisions', 'url' => '/api/v2/sharing/credential/{item_guid}/revisions', 'verb' => 'GET'], |
|
65 | + ['name' => 'share#getItemAcl', 'url' => '/api/v2/sharing/credential/{item_guid}/acl', 'verb' => 'GET'], |
|
66 | + ['name' => 'share#getFile', 'url' => '/api/v2/sharing/credential/{item_guid}/file/{file_guid}', 'verb' => 'GET'], |
|
67 | + ['name' => 'share#updateSharedCredentialACL', 'url' => '/api/v2/sharing/credential/{item_guid}/acl', 'verb' => 'PATCH'], |
|
68 | 68 | ['name' => 'internal#getAppVersion', 'url' => '/api/v2/version', 'verb' => 'GET'], |
69 | 69 | |
70 | 70 | //Settings |
@@ -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){ |
|
69 | - try{ |
|
68 | + public function updateFile($file_id, $file_data, $filename) { |
|
69 | + try { |
|
70 | 70 | $file = $this->fileService->getFile($file_id, $this->userId); |
71 | - } catch (\Exception $doesNotExistException){ |
|
71 | + } catch (\Exception $doesNotExistException) { |
|
72 | 72 | |
73 | 73 | } |
74 | - if($file){ |
|
75 | - if($file_data) { |
|
74 | + if ($file) { |
|
75 | + if ($file_data) { |
|
76 | 76 | $file->setFileData($file_data); |
77 | 77 | } |
78 | - if($filename) { |
|
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 | } |
@@ -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 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | protected $URLGenerator; |
57 | 57 | |
58 | - public function __construct( IURLGenerator $URLGenerator) { |
|
58 | + public function __construct(IURLGenerator $URLGenerator) { |
|
59 | 59 | $this->URLGenerator = $URLGenerator; |
60 | 60 | } |
61 | 61 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $l = \OC::$server->getL10N(self::APP_NAME); |
262 | 262 | return array( |
263 | 263 | 'top' => array(), |
264 | - 'apps' => array( self::FILTER_PASSMAN => |
|
264 | + 'apps' => array(self::FILTER_PASSMAN => |
|
265 | 265 | array( |
266 | 266 | 'id' => 'passman', |
267 | 267 | 'name' => (string) $l->t('Passwords'), |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @return boolean |
279 | 279 | */ |
280 | 280 | public function isFilterValid($filterValue) { |
281 | - return $filterValue === self::FILTER_PASSMAN; |
|
281 | + return $filterValue === self::FILTER_PASSMAN; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |