@@ -25,64 +25,64 @@ |
||
| 25 | 25 | use OCP\ILogger; |
| 26 | 26 | |
| 27 | 27 | class Action { |
| 28 | - /** @var ILogger */ |
|
| 29 | - private $logger; |
|
| 28 | + /** @var ILogger */ |
|
| 29 | + private $logger; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @param ILogger $logger |
|
| 33 | - */ |
|
| 34 | - public function __construct(ILogger $logger) { |
|
| 35 | - $this->logger = $logger; |
|
| 36 | - } |
|
| 31 | + /** |
|
| 32 | + * @param ILogger $logger |
|
| 33 | + */ |
|
| 34 | + public function __construct(ILogger $logger) { |
|
| 35 | + $this->logger = $logger; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Log a single action with a log level of info |
|
| 40 | - * |
|
| 41 | - * @param string $text |
|
| 42 | - * @param array $params |
|
| 43 | - * @param array $elements |
|
| 44 | - * @param bool $obfuscateParameters |
|
| 45 | - */ |
|
| 46 | - public function log($text, |
|
| 47 | - array $params, |
|
| 48 | - array $elements, |
|
| 49 | - $obfuscateParameters = false) { |
|
| 50 | - foreach($elements as $element) { |
|
| 51 | - if(!isset($params[$element])) { |
|
| 52 | - if ($obfuscateParameters) { |
|
| 53 | - $this->logger->critical( |
|
| 54 | - '$params["'.$element.'"] was missing.', |
|
| 55 | - ['app' => 'admin_audit'] |
|
| 56 | - ); |
|
| 57 | - } else { |
|
| 58 | - $this->logger->critical( |
|
| 59 | - sprintf( |
|
| 60 | - '$params["'.$element.'"] was missing. Transferred value: %s', |
|
| 61 | - print_r($params, true) |
|
| 62 | - ), |
|
| 63 | - ['app' => 'admin_audit'] |
|
| 64 | - ); |
|
| 65 | - } |
|
| 66 | - return; |
|
| 67 | - } |
|
| 68 | - } |
|
| 38 | + /** |
|
| 39 | + * Log a single action with a log level of info |
|
| 40 | + * |
|
| 41 | + * @param string $text |
|
| 42 | + * @param array $params |
|
| 43 | + * @param array $elements |
|
| 44 | + * @param bool $obfuscateParameters |
|
| 45 | + */ |
|
| 46 | + public function log($text, |
|
| 47 | + array $params, |
|
| 48 | + array $elements, |
|
| 49 | + $obfuscateParameters = false) { |
|
| 50 | + foreach($elements as $element) { |
|
| 51 | + if(!isset($params[$element])) { |
|
| 52 | + if ($obfuscateParameters) { |
|
| 53 | + $this->logger->critical( |
|
| 54 | + '$params["'.$element.'"] was missing.', |
|
| 55 | + ['app' => 'admin_audit'] |
|
| 56 | + ); |
|
| 57 | + } else { |
|
| 58 | + $this->logger->critical( |
|
| 59 | + sprintf( |
|
| 60 | + '$params["'.$element.'"] was missing. Transferred value: %s', |
|
| 61 | + print_r($params, true) |
|
| 62 | + ), |
|
| 63 | + ['app' => 'admin_audit'] |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | + return; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - $replaceArray = []; |
|
| 71 | - foreach($elements as $element) { |
|
| 72 | - if($params[$element] instanceof \DateTime) { |
|
| 73 | - $params[$element] = $params[$element]->format('Y-m-d H:i:s'); |
|
| 74 | - } |
|
| 75 | - $replaceArray[] = $params[$element]; |
|
| 76 | - } |
|
| 70 | + $replaceArray = []; |
|
| 71 | + foreach($elements as $element) { |
|
| 72 | + if($params[$element] instanceof \DateTime) { |
|
| 73 | + $params[$element] = $params[$element]->format('Y-m-d H:i:s'); |
|
| 74 | + } |
|
| 75 | + $replaceArray[] = $params[$element]; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $this->logger->info( |
|
| 79 | - vsprintf( |
|
| 80 | - $text, |
|
| 81 | - $replaceArray |
|
| 82 | - ), |
|
| 83 | - [ |
|
| 84 | - 'app' => 'admin_audit' |
|
| 85 | - ] |
|
| 86 | - ); |
|
| 87 | - } |
|
| 78 | + $this->logger->info( |
|
| 79 | + vsprintf( |
|
| 80 | + $text, |
|
| 81 | + $replaceArray |
|
| 82 | + ), |
|
| 83 | + [ |
|
| 84 | + 'app' => 'admin_audit' |
|
| 85 | + ] |
|
| 86 | + ); |
|
| 87 | + } |
|
| 88 | 88 | } |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | array $params, |
| 48 | 48 | array $elements, |
| 49 | 49 | $obfuscateParameters = false) { |
| 50 | - foreach($elements as $element) { |
|
| 51 | - if(!isset($params[$element])) { |
|
| 50 | + foreach ($elements as $element) { |
|
| 51 | + if (!isset($params[$element])) { |
|
| 52 | 52 | if ($obfuscateParameters) { |
| 53 | 53 | $this->logger->critical( |
| 54 | 54 | '$params["'.$element.'"] was missing.', |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $replaceArray = []; |
| 71 | - foreach($elements as $element) { |
|
| 72 | - if($params[$element] instanceof \DateTime) { |
|
| 71 | + foreach ($elements as $element) { |
|
| 72 | + if ($params[$element] instanceof \DateTime) { |
|
| 73 | 73 | $params[$element] = $params[$element]->format('Y-m-d H:i:s'); |
| 74 | 74 | } |
| 75 | 75 | $replaceArray[] = $params[$element]; |
@@ -28,110 +28,110 @@ |
||
| 28 | 28 | * @package OCA\Admin_Audit\Actions |
| 29 | 29 | */ |
| 30 | 30 | class Files extends Action { |
| 31 | - /** |
|
| 32 | - * Logs file read actions |
|
| 33 | - * |
|
| 34 | - * @param array $params |
|
| 35 | - */ |
|
| 36 | - public function read(array $params) { |
|
| 37 | - $this->log( |
|
| 38 | - 'File accessed: "%s"', |
|
| 39 | - $params, |
|
| 40 | - [ |
|
| 41 | - 'path', |
|
| 42 | - ] |
|
| 43 | - ); |
|
| 44 | - } |
|
| 31 | + /** |
|
| 32 | + * Logs file read actions |
|
| 33 | + * |
|
| 34 | + * @param array $params |
|
| 35 | + */ |
|
| 36 | + public function read(array $params) { |
|
| 37 | + $this->log( |
|
| 38 | + 'File accessed: "%s"', |
|
| 39 | + $params, |
|
| 40 | + [ |
|
| 41 | + 'path', |
|
| 42 | + ] |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Logs rename actions of files |
|
| 48 | - * |
|
| 49 | - * @param array $params |
|
| 50 | - */ |
|
| 51 | - public function rename(array $params) { |
|
| 52 | - $this->log( |
|
| 53 | - 'File renamed: "%s" to "%s"', |
|
| 54 | - $params, |
|
| 55 | - [ |
|
| 56 | - 'oldpath', |
|
| 57 | - 'newpath', |
|
| 58 | - ] |
|
| 59 | - ); |
|
| 60 | - } |
|
| 46 | + /** |
|
| 47 | + * Logs rename actions of files |
|
| 48 | + * |
|
| 49 | + * @param array $params |
|
| 50 | + */ |
|
| 51 | + public function rename(array $params) { |
|
| 52 | + $this->log( |
|
| 53 | + 'File renamed: "%s" to "%s"', |
|
| 54 | + $params, |
|
| 55 | + [ |
|
| 56 | + 'oldpath', |
|
| 57 | + 'newpath', |
|
| 58 | + ] |
|
| 59 | + ); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Logs creation of files |
|
| 64 | - * |
|
| 65 | - * @param array $params |
|
| 66 | - */ |
|
| 67 | - public function create(array $params) { |
|
| 68 | - $this->log( |
|
| 69 | - 'File created: "%s"', |
|
| 70 | - $params, |
|
| 71 | - [ |
|
| 72 | - 'path', |
|
| 73 | - ] |
|
| 74 | - ); |
|
| 75 | - } |
|
| 62 | + /** |
|
| 63 | + * Logs creation of files |
|
| 64 | + * |
|
| 65 | + * @param array $params |
|
| 66 | + */ |
|
| 67 | + public function create(array $params) { |
|
| 68 | + $this->log( |
|
| 69 | + 'File created: "%s"', |
|
| 70 | + $params, |
|
| 71 | + [ |
|
| 72 | + 'path', |
|
| 73 | + ] |
|
| 74 | + ); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Logs copying of files |
|
| 79 | - * |
|
| 80 | - * @param array $params |
|
| 81 | - */ |
|
| 82 | - public function copy(array $params) { |
|
| 83 | - $this->log( |
|
| 84 | - 'File copied: "%s" to "%s"', |
|
| 85 | - $params, |
|
| 86 | - [ |
|
| 87 | - 'oldpath', |
|
| 88 | - 'newpath', |
|
| 89 | - ] |
|
| 90 | - ); |
|
| 91 | - } |
|
| 77 | + /** |
|
| 78 | + * Logs copying of files |
|
| 79 | + * |
|
| 80 | + * @param array $params |
|
| 81 | + */ |
|
| 82 | + public function copy(array $params) { |
|
| 83 | + $this->log( |
|
| 84 | + 'File copied: "%s" to "%s"', |
|
| 85 | + $params, |
|
| 86 | + [ |
|
| 87 | + 'oldpath', |
|
| 88 | + 'newpath', |
|
| 89 | + ] |
|
| 90 | + ); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * Logs writing of files |
|
| 95 | - * |
|
| 96 | - * @param array $params |
|
| 97 | - */ |
|
| 98 | - public function write(array $params) { |
|
| 99 | - $this->log( |
|
| 100 | - 'File written to: "%s"', |
|
| 101 | - $params, |
|
| 102 | - [ |
|
| 103 | - 'path', |
|
| 104 | - ] |
|
| 105 | - ); |
|
| 106 | - } |
|
| 93 | + /** |
|
| 94 | + * Logs writing of files |
|
| 95 | + * |
|
| 96 | + * @param array $params |
|
| 97 | + */ |
|
| 98 | + public function write(array $params) { |
|
| 99 | + $this->log( |
|
| 100 | + 'File written to: "%s"', |
|
| 101 | + $params, |
|
| 102 | + [ |
|
| 103 | + 'path', |
|
| 104 | + ] |
|
| 105 | + ); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Logs update of files |
|
| 110 | - * |
|
| 111 | - * @param array $params |
|
| 112 | - */ |
|
| 113 | - public function update(array $params) { |
|
| 114 | - $this->log( |
|
| 115 | - 'File updated: "%s"', |
|
| 116 | - $params, |
|
| 117 | - [ |
|
| 118 | - 'path', |
|
| 119 | - ] |
|
| 120 | - ); |
|
| 121 | - } |
|
| 108 | + /** |
|
| 109 | + * Logs update of files |
|
| 110 | + * |
|
| 111 | + * @param array $params |
|
| 112 | + */ |
|
| 113 | + public function update(array $params) { |
|
| 114 | + $this->log( |
|
| 115 | + 'File updated: "%s"', |
|
| 116 | + $params, |
|
| 117 | + [ |
|
| 118 | + 'path', |
|
| 119 | + ] |
|
| 120 | + ); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Logs deletions of files |
|
| 125 | - * |
|
| 126 | - * @param array $params |
|
| 127 | - */ |
|
| 128 | - public function delete(array $params) { |
|
| 129 | - $this->log( |
|
| 130 | - 'File deleted: "%s"', |
|
| 131 | - $params, |
|
| 132 | - [ |
|
| 133 | - 'path', |
|
| 134 | - ] |
|
| 135 | - ); |
|
| 136 | - } |
|
| 123 | + /** |
|
| 124 | + * Logs deletions of files |
|
| 125 | + * |
|
| 126 | + * @param array $params |
|
| 127 | + */ |
|
| 128 | + public function delete(array $params) { |
|
| 129 | + $this->log( |
|
| 130 | + 'File deleted: "%s"', |
|
| 131 | + $params, |
|
| 132 | + [ |
|
| 133 | + 'path', |
|
| 134 | + ] |
|
| 135 | + ); |
|
| 136 | + } |
|
| 137 | 137 | } |
@@ -28,33 +28,33 @@ |
||
| 28 | 28 | * @package OCA\Admin_Audit\Actions |
| 29 | 29 | */ |
| 30 | 30 | class Auth extends Action { |
| 31 | - public function loginAttempt(array $params) { |
|
| 32 | - $this->log( |
|
| 33 | - 'Login attempt: "%s"', |
|
| 34 | - $params, |
|
| 35 | - [ |
|
| 36 | - 'uid', |
|
| 37 | - ], |
|
| 38 | - true |
|
| 39 | - ); |
|
| 40 | - } |
|
| 31 | + public function loginAttempt(array $params) { |
|
| 32 | + $this->log( |
|
| 33 | + 'Login attempt: "%s"', |
|
| 34 | + $params, |
|
| 35 | + [ |
|
| 36 | + 'uid', |
|
| 37 | + ], |
|
| 38 | + true |
|
| 39 | + ); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function loginSuccessful(array $params) { |
|
| 43 | - $this->log( |
|
| 44 | - 'Login successful: "%s"', |
|
| 45 | - $params, |
|
| 46 | - [ |
|
| 47 | - 'uid', |
|
| 48 | - ], |
|
| 49 | - true |
|
| 50 | - ); |
|
| 51 | - } |
|
| 42 | + public function loginSuccessful(array $params) { |
|
| 43 | + $this->log( |
|
| 44 | + 'Login successful: "%s"', |
|
| 45 | + $params, |
|
| 46 | + [ |
|
| 47 | + 'uid', |
|
| 48 | + ], |
|
| 49 | + true |
|
| 50 | + ); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function logout(array $params) { |
|
| 54 | - $this->log( |
|
| 55 | - 'Logout occurred', |
|
| 56 | - [], |
|
| 57 | - [] |
|
| 58 | - ); |
|
| 59 | - } |
|
| 53 | + public function logout(array $params) { |
|
| 54 | + $this->log( |
|
| 55 | + 'Logout occurred', |
|
| 56 | + [], |
|
| 57 | + [] |
|
| 58 | + ); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -27,21 +27,21 @@ |
||
| 27 | 27 | |
| 28 | 28 | class Versions extends Action { |
| 29 | 29 | |
| 30 | - public function rollback($params) { |
|
| 31 | - $this->log('Version "%s" of "%s" was restored.', |
|
| 32 | - [ |
|
| 33 | - 'version' => $params['revision'], |
|
| 34 | - 'path' => $params['path'] |
|
| 35 | - ], |
|
| 36 | - ['version', 'path'] |
|
| 37 | - ); |
|
| 38 | - } |
|
| 30 | + public function rollback($params) { |
|
| 31 | + $this->log('Version "%s" of "%s" was restored.', |
|
| 32 | + [ |
|
| 33 | + 'version' => $params['revision'], |
|
| 34 | + 'path' => $params['path'] |
|
| 35 | + ], |
|
| 36 | + ['version', 'path'] |
|
| 37 | + ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public function delete($params) { |
|
| 41 | - $this->log('Version "%s" was deleted.', |
|
| 42 | - ['path' => $params['path']], |
|
| 43 | - ['path'] |
|
| 44 | - ); |
|
| 45 | - } |
|
| 40 | + public function delete($params) { |
|
| 41 | + $this->log('Version "%s" was deleted.', |
|
| 42 | + ['path' => $params['path']], |
|
| 43 | + ['path'] |
|
| 44 | + ); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | } |
@@ -29,163 +29,163 @@ |
||
| 29 | 29 | * @package OCA\Admin_Audit\Actions |
| 30 | 30 | */ |
| 31 | 31 | class Sharing extends Action { |
| 32 | - /** |
|
| 33 | - * Logs sharing of data |
|
| 34 | - * |
|
| 35 | - * @param array $params |
|
| 36 | - */ |
|
| 37 | - public function shared(array $params) { |
|
| 38 | - if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
| 39 | - $this->log( |
|
| 40 | - 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', |
|
| 41 | - $params, |
|
| 42 | - [ |
|
| 43 | - 'itemType', |
|
| 44 | - 'itemTarget', |
|
| 45 | - 'itemSource', |
|
| 46 | - 'permissions', |
|
| 47 | - 'id', |
|
| 48 | - ] |
|
| 49 | - ); |
|
| 50 | - } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
| 51 | - $this->log( |
|
| 52 | - 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', |
|
| 53 | - $params, |
|
| 54 | - [ |
|
| 55 | - 'itemType', |
|
| 56 | - 'itemTarget', |
|
| 57 | - 'itemSource', |
|
| 58 | - 'shareWith', |
|
| 59 | - 'permissions', |
|
| 60 | - 'id', |
|
| 61 | - ] |
|
| 62 | - ); |
|
| 63 | - } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
| 64 | - $this->log( |
|
| 65 | - 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', |
|
| 66 | - $params, |
|
| 67 | - [ |
|
| 68 | - 'itemType', |
|
| 69 | - 'itemTarget', |
|
| 70 | - 'itemSource', |
|
| 71 | - 'shareWith', |
|
| 72 | - 'permissions', |
|
| 73 | - 'id', |
|
| 74 | - ] |
|
| 75 | - ); |
|
| 76 | - } |
|
| 77 | - } |
|
| 32 | + /** |
|
| 33 | + * Logs sharing of data |
|
| 34 | + * |
|
| 35 | + * @param array $params |
|
| 36 | + */ |
|
| 37 | + public function shared(array $params) { |
|
| 38 | + if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
| 39 | + $this->log( |
|
| 40 | + 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', |
|
| 41 | + $params, |
|
| 42 | + [ |
|
| 43 | + 'itemType', |
|
| 44 | + 'itemTarget', |
|
| 45 | + 'itemSource', |
|
| 46 | + 'permissions', |
|
| 47 | + 'id', |
|
| 48 | + ] |
|
| 49 | + ); |
|
| 50 | + } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
| 51 | + $this->log( |
|
| 52 | + 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', |
|
| 53 | + $params, |
|
| 54 | + [ |
|
| 55 | + 'itemType', |
|
| 56 | + 'itemTarget', |
|
| 57 | + 'itemSource', |
|
| 58 | + 'shareWith', |
|
| 59 | + 'permissions', |
|
| 60 | + 'id', |
|
| 61 | + ] |
|
| 62 | + ); |
|
| 63 | + } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
| 64 | + $this->log( |
|
| 65 | + 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', |
|
| 66 | + $params, |
|
| 67 | + [ |
|
| 68 | + 'itemType', |
|
| 69 | + 'itemTarget', |
|
| 70 | + 'itemSource', |
|
| 71 | + 'shareWith', |
|
| 72 | + 'permissions', |
|
| 73 | + 'id', |
|
| 74 | + ] |
|
| 75 | + ); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Logs unsharing of data |
|
| 81 | - * |
|
| 82 | - * @param array $params |
|
| 83 | - */ |
|
| 84 | - public function unshare(array $params) { |
|
| 85 | - if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
| 86 | - $this->log( |
|
| 87 | - 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', |
|
| 88 | - $params, |
|
| 89 | - [ |
|
| 90 | - 'itemType', |
|
| 91 | - 'fileTarget', |
|
| 92 | - 'itemSource', |
|
| 93 | - 'id', |
|
| 94 | - ] |
|
| 95 | - ); |
|
| 96 | - } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
| 97 | - $this->log( |
|
| 98 | - 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', |
|
| 99 | - $params, |
|
| 100 | - [ |
|
| 101 | - 'itemType', |
|
| 102 | - 'fileTarget', |
|
| 103 | - 'itemSource', |
|
| 104 | - 'shareWith', |
|
| 105 | - 'id', |
|
| 106 | - ] |
|
| 107 | - ); |
|
| 108 | - } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
| 109 | - $this->log( |
|
| 110 | - 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', |
|
| 111 | - $params, |
|
| 112 | - [ |
|
| 113 | - 'itemType', |
|
| 114 | - 'fileTarget', |
|
| 115 | - 'itemSource', |
|
| 116 | - 'shareWith', |
|
| 117 | - 'id', |
|
| 118 | - ] |
|
| 119 | - ); |
|
| 120 | - } |
|
| 121 | - } |
|
| 79 | + /** |
|
| 80 | + * Logs unsharing of data |
|
| 81 | + * |
|
| 82 | + * @param array $params |
|
| 83 | + */ |
|
| 84 | + public function unshare(array $params) { |
|
| 85 | + if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
| 86 | + $this->log( |
|
| 87 | + 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', |
|
| 88 | + $params, |
|
| 89 | + [ |
|
| 90 | + 'itemType', |
|
| 91 | + 'fileTarget', |
|
| 92 | + 'itemSource', |
|
| 93 | + 'id', |
|
| 94 | + ] |
|
| 95 | + ); |
|
| 96 | + } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
| 97 | + $this->log( |
|
| 98 | + 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', |
|
| 99 | + $params, |
|
| 100 | + [ |
|
| 101 | + 'itemType', |
|
| 102 | + 'fileTarget', |
|
| 103 | + 'itemSource', |
|
| 104 | + 'shareWith', |
|
| 105 | + 'id', |
|
| 106 | + ] |
|
| 107 | + ); |
|
| 108 | + } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
| 109 | + $this->log( |
|
| 110 | + 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', |
|
| 111 | + $params, |
|
| 112 | + [ |
|
| 113 | + 'itemType', |
|
| 114 | + 'fileTarget', |
|
| 115 | + 'itemSource', |
|
| 116 | + 'shareWith', |
|
| 117 | + 'id', |
|
| 118 | + ] |
|
| 119 | + ); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Logs the updating of permission changes for shares |
|
| 125 | - * |
|
| 126 | - * @param array $params |
|
| 127 | - */ |
|
| 128 | - public function updatePermissions(array $params) { |
|
| 129 | - $this->log( |
|
| 130 | - 'The permissions of the shared %s "%s" with ID "%s" have been changed to "%s"', |
|
| 131 | - $params, |
|
| 132 | - [ |
|
| 133 | - 'itemType', |
|
| 134 | - 'path', |
|
| 135 | - 'itemSource', |
|
| 136 | - 'permissions', |
|
| 137 | - ] |
|
| 138 | - ); |
|
| 139 | - } |
|
| 123 | + /** |
|
| 124 | + * Logs the updating of permission changes for shares |
|
| 125 | + * |
|
| 126 | + * @param array $params |
|
| 127 | + */ |
|
| 128 | + public function updatePermissions(array $params) { |
|
| 129 | + $this->log( |
|
| 130 | + 'The permissions of the shared %s "%s" with ID "%s" have been changed to "%s"', |
|
| 131 | + $params, |
|
| 132 | + [ |
|
| 133 | + 'itemType', |
|
| 134 | + 'path', |
|
| 135 | + 'itemSource', |
|
| 136 | + 'permissions', |
|
| 137 | + ] |
|
| 138 | + ); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Logs the password changes for a share |
|
| 143 | - * |
|
| 144 | - * @param array $params |
|
| 145 | - */ |
|
| 146 | - public function updatePassword(array $params) { |
|
| 147 | - $this->log( |
|
| 148 | - 'The password of the publicly shared %s "%s" with ID "%s" has been changed', |
|
| 149 | - $params, |
|
| 150 | - [ |
|
| 151 | - 'itemType', |
|
| 152 | - 'token', |
|
| 153 | - 'itemSource', |
|
| 154 | - ] |
|
| 155 | - ); |
|
| 156 | - } |
|
| 141 | + /** |
|
| 142 | + * Logs the password changes for a share |
|
| 143 | + * |
|
| 144 | + * @param array $params |
|
| 145 | + */ |
|
| 146 | + public function updatePassword(array $params) { |
|
| 147 | + $this->log( |
|
| 148 | + 'The password of the publicly shared %s "%s" with ID "%s" has been changed', |
|
| 149 | + $params, |
|
| 150 | + [ |
|
| 151 | + 'itemType', |
|
| 152 | + 'token', |
|
| 153 | + 'itemSource', |
|
| 154 | + ] |
|
| 155 | + ); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Logs the expiration date changes for a share |
|
| 160 | - * |
|
| 161 | - * @param array $params |
|
| 162 | - */ |
|
| 163 | - public function updateExpirationDate(array $params) { |
|
| 164 | - $this->log( |
|
| 165 | - 'The expiration date of the publicly shared %s with ID "%s" has been changed to "%s"', |
|
| 166 | - $params, |
|
| 167 | - [ |
|
| 168 | - 'itemType', |
|
| 169 | - 'itemSource', |
|
| 170 | - 'date', |
|
| 171 | - ] |
|
| 172 | - ); |
|
| 173 | - } |
|
| 158 | + /** |
|
| 159 | + * Logs the expiration date changes for a share |
|
| 160 | + * |
|
| 161 | + * @param array $params |
|
| 162 | + */ |
|
| 163 | + public function updateExpirationDate(array $params) { |
|
| 164 | + $this->log( |
|
| 165 | + 'The expiration date of the publicly shared %s with ID "%s" has been changed to "%s"', |
|
| 166 | + $params, |
|
| 167 | + [ |
|
| 168 | + 'itemType', |
|
| 169 | + 'itemSource', |
|
| 170 | + 'date', |
|
| 171 | + ] |
|
| 172 | + ); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Logs access of shared files |
|
| 177 | - * |
|
| 178 | - * @param array $params |
|
| 179 | - */ |
|
| 180 | - public function shareAccessed(array $params) { |
|
| 181 | - $this->log( |
|
| 182 | - 'The shared %s with the token "%s" by "%s" has been accessed.', |
|
| 183 | - $params, |
|
| 184 | - [ |
|
| 185 | - 'itemType', |
|
| 186 | - 'token', |
|
| 187 | - 'uidOwner', |
|
| 188 | - ] |
|
| 189 | - ); |
|
| 190 | - } |
|
| 175 | + /** |
|
| 176 | + * Logs access of shared files |
|
| 177 | + * |
|
| 178 | + * @param array $params |
|
| 179 | + */ |
|
| 180 | + public function shareAccessed(array $params) { |
|
| 181 | + $this->log( |
|
| 182 | + 'The shared %s with the token "%s" by "%s" has been accessed.', |
|
| 183 | + $params, |
|
| 184 | + [ |
|
| 185 | + 'itemType', |
|
| 186 | + 'token', |
|
| 187 | + 'uidOwner', |
|
| 188 | + ] |
|
| 189 | + ); |
|
| 190 | + } |
|
| 191 | 191 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param array $params |
| 36 | 36 | */ |
| 37 | 37 | public function shared(array $params) { |
| 38 | - if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
| 38 | + if ($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
| 39 | 39 | $this->log( |
| 40 | 40 | 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', |
| 41 | 41 | $params, |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | 'id', |
| 48 | 48 | ] |
| 49 | 49 | ); |
| 50 | - } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
| 50 | + } elseif ($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
| 51 | 51 | $this->log( |
| 52 | 52 | 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', |
| 53 | 53 | $params, |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | 'id', |
| 61 | 61 | ] |
| 62 | 62 | ); |
| 63 | - } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
| 63 | + } elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
| 64 | 64 | $this->log( |
| 65 | 65 | 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', |
| 66 | 66 | $params, |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param array $params |
| 83 | 83 | */ |
| 84 | 84 | public function unshare(array $params) { |
| 85 | - if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
| 85 | + if ($params['shareType'] === Share::SHARE_TYPE_LINK) { |
|
| 86 | 86 | $this->log( |
| 87 | 87 | 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', |
| 88 | 88 | $params, |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | 'id', |
| 94 | 94 | ] |
| 95 | 95 | ); |
| 96 | - } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
| 96 | + } elseif ($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
| 97 | 97 | $this->log( |
| 98 | 98 | 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', |
| 99 | 99 | $params, |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | 'id', |
| 106 | 106 | ] |
| 107 | 107 | ); |
| 108 | - } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
| 108 | + } elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
|
| 109 | 109 | $this->log( |
| 110 | 110 | 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', |
| 111 | 111 | $params, |
@@ -1,6 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - |
|
| 4 | 3 | * |
| 5 | 4 | * @author Bjoern Schiessle <[email protected]> |
| 6 | 5 | * @author Lukas Reschke <[email protected]> |
@@ -35,22 +35,22 @@ |
||
| 35 | 35 | $versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source); |
| 36 | 36 | if( $versions ) { |
| 37 | 37 | |
| 38 | - $endReached = false; |
|
| 39 | - if (count($versions) <= $start+$count) { |
|
| 40 | - $endReached = true; |
|
| 41 | - } |
|
| 38 | + $endReached = false; |
|
| 39 | + if (count($versions) <= $start+$count) { |
|
| 40 | + $endReached = true; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $versions = array_slice($versions, $start, $count); |
|
| 43 | + $versions = array_slice($versions, $start, $count); |
|
| 44 | 44 | |
| 45 | - // remove owner path from request to not disclose it to the recipient |
|
| 46 | - foreach ($versions as $version) { |
|
| 47 | - unset($version['path']); |
|
| 48 | - } |
|
| 45 | + // remove owner path from request to not disclose it to the recipient |
|
| 46 | + foreach ($versions as $version) { |
|
| 47 | + unset($version['path']); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - \OCP\JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached))); |
|
| 50 | + \OCP\JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached))); |
|
| 51 | 51 | |
| 52 | 52 | } else { |
| 53 | 53 | |
| 54 | - \OCP\JSON::success(array('data' => array('versions' => [], 'endReached' => true))); |
|
| 54 | + \OCP\JSON::success(array('data' => array('versions' => [], 'endReached' => true))); |
|
| 55 | 55 | |
| 56 | 56 | } |
@@ -28,15 +28,15 @@ |
||
| 28 | 28 | OCP\JSON::callCheck(); |
| 29 | 29 | OCP\JSON::checkAppEnabled('files_versions'); |
| 30 | 30 | |
| 31 | -$source = (string)$_GET['source']; |
|
| 32 | -$start = (int)$_GET['start']; |
|
| 31 | +$source = (string) $_GET['source']; |
|
| 32 | +$start = (int) $_GET['start']; |
|
| 33 | 33 | list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source); |
| 34 | 34 | $count = 5; //show the newest revisions |
| 35 | 35 | $versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source); |
| 36 | -if( $versions ) { |
|
| 36 | +if ($versions) { |
|
| 37 | 37 | |
| 38 | 38 | $endReached = false; |
| 39 | - if (count($versions) <= $start+$count) { |
|
| 39 | + if (count($versions) <= $start + $count) { |
|
| 40 | 40 | $endReached = true; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -34,8 +34,8 @@ |
||
| 34 | 34 | $revision=(int)$_GET['revision']; |
| 35 | 35 | |
| 36 | 36 | if(OCA\Files_Versions\Storage::rollback( $file, $revision )) { |
| 37 | - OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); |
|
| 37 | + OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); |
|
| 38 | 38 | }else{ |
| 39 | - $l = \OC::$server->getL10N('files_versions'); |
|
| 40 | - OCP\JSON::error(array("data" => array( "message" => $l->t("Could not revert: %s", array($file) )))); |
|
| 39 | + $l = \OC::$server->getL10N('files_versions'); |
|
| 40 | + OCP\JSON::error(array("data" => array( "message" => $l->t("Could not revert: %s", array($file) )))); |
|
| 41 | 41 | } |
@@ -30,12 +30,12 @@ |
||
| 30 | 30 | OCP\JSON::checkAppEnabled('files_versions'); |
| 31 | 31 | OCP\JSON::callCheck(); |
| 32 | 32 | |
| 33 | -$file = (string)$_GET['file']; |
|
| 34 | -$revision=(int)$_GET['revision']; |
|
| 33 | +$file = (string) $_GET['file']; |
|
| 34 | +$revision = (int) $_GET['revision']; |
|
| 35 | 35 | |
| 36 | -if(OCA\Files_Versions\Storage::rollback( $file, $revision )) { |
|
| 37 | - OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); |
|
| 38 | -}else{ |
|
| 36 | +if (OCA\Files_Versions\Storage::rollback($file, $revision)) { |
|
| 37 | + OCP\JSON::success(array("data" => array("revision" => $revision, "file" => $file))); |
|
| 38 | +} else { |
|
| 39 | 39 | $l = \OC::$server->getL10N('files_versions'); |
| 40 | - OCP\JSON::error(array("data" => array( "message" => $l->t("Could not revert: %s", array($file) )))); |
|
| 40 | + OCP\JSON::error(array("data" => array("message" => $l->t("Could not revert: %s", array($file))))); |
|
| 41 | 41 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | if(OCA\Files_Versions\Storage::rollback( $file, $revision )) { |
| 37 | 37 | OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); |
| 38 | -}else{ |
|
| 38 | +} else{ |
|
| 39 | 39 | $l = \OC::$server->getL10N('files_versions'); |
| 40 | 40 | OCP\JSON::error(array("data" => array( "message" => $l->t("Could not revert: %s", array($file) )))); |
| 41 | 41 | } |
@@ -27,24 +27,24 @@ |
||
| 27 | 27 | use OCA\Files_Versions\Expiration; |
| 28 | 28 | |
| 29 | 29 | class Application extends App { |
| 30 | - public function __construct(array $urlParams = array()) { |
|
| 31 | - parent::__construct('files_versions', $urlParams); |
|
| 30 | + public function __construct(array $urlParams = array()) { |
|
| 31 | + parent::__construct('files_versions', $urlParams); |
|
| 32 | 32 | |
| 33 | - $container = $this->getContainer(); |
|
| 33 | + $container = $this->getContainer(); |
|
| 34 | 34 | |
| 35 | - /* |
|
| 35 | + /* |
|
| 36 | 36 | * Register capabilities |
| 37 | 37 | */ |
| 38 | - $container->registerCapability('OCA\Files_Versions\Capabilities'); |
|
| 38 | + $container->registerCapability('OCA\Files_Versions\Capabilities'); |
|
| 39 | 39 | |
| 40 | - /* |
|
| 40 | + /* |
|
| 41 | 41 | * Register expiration |
| 42 | 42 | */ |
| 43 | - $container->registerService('Expiration', function($c) { |
|
| 44 | - return new Expiration( |
|
| 45 | - $c->query('ServerContainer')->getConfig(), |
|
| 46 | - $c->query('OCP\AppFramework\Utility\ITimeFactory') |
|
| 47 | - ); |
|
| 48 | - }); |
|
| 49 | - } |
|
| 43 | + $container->registerService('Expiration', function($c) { |
|
| 44 | + return new Expiration( |
|
| 45 | + $c->query('ServerContainer')->getConfig(), |
|
| 46 | + $c->query('OCP\AppFramework\Utility\ITimeFactory') |
|
| 47 | + ); |
|
| 48 | + }); |
|
| 49 | + } |
|
| 50 | 50 | } |