@@ -53,205 +53,205 @@ |
||
53 | 53 | |
54 | 54 | class Application extends App { |
55 | 55 | |
56 | - /** @var ILogger */ |
|
57 | - protected $logger; |
|
58 | - |
|
59 | - public function __construct() { |
|
60 | - parent::__construct('admin_audit'); |
|
61 | - $this->initLogger(); |
|
62 | - } |
|
63 | - |
|
64 | - public function initLogger() { |
|
65 | - $c = $this->getContainer()->getServer(); |
|
66 | - $config = $c->getConfig(); |
|
67 | - |
|
68 | - $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
69 | - $logFile = $config->getAppValue('admin_audit', 'logfile', $default); |
|
70 | - if($logFile === null) { |
|
71 | - $this->logger = $c->getLogger(); |
|
72 | - return; |
|
73 | - } |
|
74 | - $this->logger = $c->getLogFactory()->getCustomLogger($logFile); |
|
75 | - |
|
76 | - } |
|
77 | - |
|
78 | - public function register() { |
|
79 | - $this->registerHooks(); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Register hooks in order to log them |
|
84 | - */ |
|
85 | - protected function registerHooks() { |
|
86 | - $this->userManagementHooks(); |
|
87 | - $this->groupHooks(); |
|
88 | - $this->authHooks(); |
|
89 | - |
|
90 | - $this->consoleHooks(); |
|
91 | - $this->appHooks(); |
|
92 | - |
|
93 | - $this->sharingHooks(); |
|
94 | - |
|
95 | - $this->fileHooks(); |
|
96 | - $this->trashbinHooks(); |
|
97 | - $this->versionsHooks(); |
|
98 | - |
|
99 | - $this->securityHooks(); |
|
100 | - } |
|
101 | - |
|
102 | - protected function userManagementHooks() { |
|
103 | - $userActions = new UserManagement($this->logger); |
|
104 | - |
|
105 | - Util::connectHook('OC_User', 'post_createUser', $userActions, 'create'); |
|
106 | - Util::connectHook('OC_User', 'post_deleteUser', $userActions, 'delete'); |
|
107 | - Util::connectHook('OC_User', 'changeUser', $userActions, 'change'); |
|
108 | - |
|
109 | - /** @var IUserSession|Session $userSession */ |
|
110 | - $userSession = $this->getContainer()->getServer()->getUserSession(); |
|
111 | - $userSession->listen('\OC\User', 'postSetPassword', [$userActions, 'setPassword']); |
|
112 | - $userSession->listen('\OC\User', 'assignedUserId', [$userActions, 'assign']); |
|
113 | - $userSession->listen('\OC\User', 'postUnassignedUserId', [$userActions, 'unassign']); |
|
114 | - } |
|
115 | - |
|
116 | - protected function groupHooks() { |
|
117 | - $groupActions = new GroupManagement($this->logger); |
|
118 | - |
|
119 | - /** @var IGroupManager|Manager $groupManager */ |
|
120 | - $groupManager = $this->getContainer()->getServer()->getGroupManager(); |
|
121 | - $groupManager->listen('\OC\Group', 'postRemoveUser', [$groupActions, 'removeUser']); |
|
122 | - $groupManager->listen('\OC\Group', 'postAddUser', [$groupActions, 'addUser']); |
|
123 | - $groupManager->listen('\OC\Group', 'postDelete', [$groupActions, 'deleteGroup']); |
|
124 | - $groupManager->listen('\OC\Group', 'postCreate', [$groupActions, 'createGroup']); |
|
125 | - } |
|
126 | - |
|
127 | - protected function sharingHooks() { |
|
128 | - $shareActions = new Sharing($this->logger); |
|
129 | - |
|
130 | - Util::connectHook(Share::class, 'post_shared', $shareActions, 'shared'); |
|
131 | - Util::connectHook(Share::class, 'post_unshare', $shareActions, 'unshare'); |
|
132 | - Util::connectHook(Share::class, 'post_update_permissions', $shareActions, 'updatePermissions'); |
|
133 | - Util::connectHook(Share::class, 'post_update_password', $shareActions, 'updatePassword'); |
|
134 | - Util::connectHook(Share::class, 'post_set_expiration_date', $shareActions, 'updateExpirationDate'); |
|
135 | - Util::connectHook(Share::class, 'share_link_access', $shareActions, 'shareAccessed'); |
|
136 | - } |
|
137 | - |
|
138 | - protected function authHooks() { |
|
139 | - $authActions = new Auth($this->logger); |
|
140 | - |
|
141 | - Util::connectHook('OC_User', 'pre_login', $authActions, 'loginAttempt'); |
|
142 | - Util::connectHook('OC_User', 'post_login', $authActions, 'loginSuccessful'); |
|
143 | - Util::connectHook('OC_User', 'logout', $authActions, 'logout'); |
|
144 | - } |
|
145 | - |
|
146 | - protected function appHooks() { |
|
147 | - |
|
148 | - $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
149 | - $eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function(ManagerEvent $event) { |
|
150 | - $appActions = new AppManagement($this->logger); |
|
151 | - $appActions->enableApp($event->getAppID()); |
|
152 | - }); |
|
153 | - $eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, function(ManagerEvent $event) { |
|
154 | - $appActions = new AppManagement($this->logger); |
|
155 | - $appActions->enableAppForGroups($event->getAppID(), $event->getGroups()); |
|
156 | - }); |
|
157 | - $eventDispatcher->addListener(ManagerEvent::EVENT_APP_DISABLE, function(ManagerEvent $event) { |
|
158 | - $appActions = new AppManagement($this->logger); |
|
159 | - $appActions->disableApp($event->getAppID()); |
|
160 | - }); |
|
161 | - |
|
162 | - } |
|
163 | - |
|
164 | - protected function consoleHooks() { |
|
165 | - $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
166 | - $eventDispatcher->addListener(ConsoleEvent::EVENT_RUN, function(ConsoleEvent $event) { |
|
167 | - $appActions = new Console($this->logger); |
|
168 | - $appActions->runCommand($event->getArguments()); |
|
169 | - }); |
|
170 | - } |
|
171 | - |
|
172 | - protected function fileHooks() { |
|
173 | - $fileActions = new Files($this->logger); |
|
174 | - $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
175 | - $eventDispatcher->addListener( |
|
176 | - IPreview::EVENT, |
|
177 | - function(GenericEvent $event) use ($fileActions) { |
|
178 | - /** @var File $file */ |
|
179 | - $file = $event->getSubject(); |
|
180 | - $fileActions->preview([ |
|
181 | - 'path' => substr($file->getInternalPath(), 5), |
|
182 | - 'width' => $event->getArguments()['width'], |
|
183 | - 'height' => $event->getArguments()['height'], |
|
184 | - 'crop' => $event->getArguments()['crop'], |
|
185 | - 'mode' => $event->getArguments()['mode'] |
|
186 | - ]); |
|
187 | - } |
|
188 | - ); |
|
189 | - |
|
190 | - Util::connectHook( |
|
191 | - Filesystem::CLASSNAME, |
|
192 | - Filesystem::signal_post_rename, |
|
193 | - $fileActions, |
|
194 | - 'rename' |
|
195 | - ); |
|
196 | - Util::connectHook( |
|
197 | - Filesystem::CLASSNAME, |
|
198 | - Filesystem::signal_post_create, |
|
199 | - $fileActions, |
|
200 | - 'create' |
|
201 | - ); |
|
202 | - Util::connectHook( |
|
203 | - Filesystem::CLASSNAME, |
|
204 | - Filesystem::signal_post_copy, |
|
205 | - $fileActions, |
|
206 | - 'copy' |
|
207 | - ); |
|
208 | - Util::connectHook( |
|
209 | - Filesystem::CLASSNAME, |
|
210 | - Filesystem::signal_post_write, |
|
211 | - $fileActions, |
|
212 | - 'write' |
|
213 | - ); |
|
214 | - Util::connectHook( |
|
215 | - Filesystem::CLASSNAME, |
|
216 | - Filesystem::signal_post_update, |
|
217 | - $fileActions, |
|
218 | - 'update' |
|
219 | - ); |
|
220 | - Util::connectHook( |
|
221 | - Filesystem::CLASSNAME, |
|
222 | - Filesystem::signal_read, |
|
223 | - $fileActions, |
|
224 | - 'read' |
|
225 | - ); |
|
226 | - Util::connectHook( |
|
227 | - Filesystem::CLASSNAME, |
|
228 | - Filesystem::signal_delete, |
|
229 | - $fileActions, |
|
230 | - 'delete' |
|
231 | - ); |
|
232 | - } |
|
233 | - |
|
234 | - protected function versionsHooks() { |
|
235 | - $versionsActions = new Versions($this->logger); |
|
236 | - Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback'); |
|
237 | - Util::connectHook('\OCP\Versions', 'delete',$versionsActions, 'delete'); |
|
238 | - } |
|
239 | - |
|
240 | - protected function trashbinHooks() { |
|
241 | - $trashActions = new Trashbin($this->logger); |
|
242 | - Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete'); |
|
243 | - Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore'); |
|
244 | - } |
|
245 | - |
|
246 | - protected function securityHooks() { |
|
247 | - $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
248 | - $eventDispatcher->addListener(IProvider::EVENT_SUCCESS, function(GenericEvent $event) { |
|
249 | - $security = new Security($this->logger); |
|
250 | - $security->twofactorSuccess($event->getSubject(), $event->getArguments()); |
|
251 | - }); |
|
252 | - $eventDispatcher->addListener(IProvider::EVENT_FAILED, function(GenericEvent $event) { |
|
253 | - $security = new Security($this->logger); |
|
254 | - $security->twofactorFailed($event->getSubject(), $event->getArguments()); |
|
255 | - }); |
|
256 | - } |
|
56 | + /** @var ILogger */ |
|
57 | + protected $logger; |
|
58 | + |
|
59 | + public function __construct() { |
|
60 | + parent::__construct('admin_audit'); |
|
61 | + $this->initLogger(); |
|
62 | + } |
|
63 | + |
|
64 | + public function initLogger() { |
|
65 | + $c = $this->getContainer()->getServer(); |
|
66 | + $config = $c->getConfig(); |
|
67 | + |
|
68 | + $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
69 | + $logFile = $config->getAppValue('admin_audit', 'logfile', $default); |
|
70 | + if($logFile === null) { |
|
71 | + $this->logger = $c->getLogger(); |
|
72 | + return; |
|
73 | + } |
|
74 | + $this->logger = $c->getLogFactory()->getCustomLogger($logFile); |
|
75 | + |
|
76 | + } |
|
77 | + |
|
78 | + public function register() { |
|
79 | + $this->registerHooks(); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Register hooks in order to log them |
|
84 | + */ |
|
85 | + protected function registerHooks() { |
|
86 | + $this->userManagementHooks(); |
|
87 | + $this->groupHooks(); |
|
88 | + $this->authHooks(); |
|
89 | + |
|
90 | + $this->consoleHooks(); |
|
91 | + $this->appHooks(); |
|
92 | + |
|
93 | + $this->sharingHooks(); |
|
94 | + |
|
95 | + $this->fileHooks(); |
|
96 | + $this->trashbinHooks(); |
|
97 | + $this->versionsHooks(); |
|
98 | + |
|
99 | + $this->securityHooks(); |
|
100 | + } |
|
101 | + |
|
102 | + protected function userManagementHooks() { |
|
103 | + $userActions = new UserManagement($this->logger); |
|
104 | + |
|
105 | + Util::connectHook('OC_User', 'post_createUser', $userActions, 'create'); |
|
106 | + Util::connectHook('OC_User', 'post_deleteUser', $userActions, 'delete'); |
|
107 | + Util::connectHook('OC_User', 'changeUser', $userActions, 'change'); |
|
108 | + |
|
109 | + /** @var IUserSession|Session $userSession */ |
|
110 | + $userSession = $this->getContainer()->getServer()->getUserSession(); |
|
111 | + $userSession->listen('\OC\User', 'postSetPassword', [$userActions, 'setPassword']); |
|
112 | + $userSession->listen('\OC\User', 'assignedUserId', [$userActions, 'assign']); |
|
113 | + $userSession->listen('\OC\User', 'postUnassignedUserId', [$userActions, 'unassign']); |
|
114 | + } |
|
115 | + |
|
116 | + protected function groupHooks() { |
|
117 | + $groupActions = new GroupManagement($this->logger); |
|
118 | + |
|
119 | + /** @var IGroupManager|Manager $groupManager */ |
|
120 | + $groupManager = $this->getContainer()->getServer()->getGroupManager(); |
|
121 | + $groupManager->listen('\OC\Group', 'postRemoveUser', [$groupActions, 'removeUser']); |
|
122 | + $groupManager->listen('\OC\Group', 'postAddUser', [$groupActions, 'addUser']); |
|
123 | + $groupManager->listen('\OC\Group', 'postDelete', [$groupActions, 'deleteGroup']); |
|
124 | + $groupManager->listen('\OC\Group', 'postCreate', [$groupActions, 'createGroup']); |
|
125 | + } |
|
126 | + |
|
127 | + protected function sharingHooks() { |
|
128 | + $shareActions = new Sharing($this->logger); |
|
129 | + |
|
130 | + Util::connectHook(Share::class, 'post_shared', $shareActions, 'shared'); |
|
131 | + Util::connectHook(Share::class, 'post_unshare', $shareActions, 'unshare'); |
|
132 | + Util::connectHook(Share::class, 'post_update_permissions', $shareActions, 'updatePermissions'); |
|
133 | + Util::connectHook(Share::class, 'post_update_password', $shareActions, 'updatePassword'); |
|
134 | + Util::connectHook(Share::class, 'post_set_expiration_date', $shareActions, 'updateExpirationDate'); |
|
135 | + Util::connectHook(Share::class, 'share_link_access', $shareActions, 'shareAccessed'); |
|
136 | + } |
|
137 | + |
|
138 | + protected function authHooks() { |
|
139 | + $authActions = new Auth($this->logger); |
|
140 | + |
|
141 | + Util::connectHook('OC_User', 'pre_login', $authActions, 'loginAttempt'); |
|
142 | + Util::connectHook('OC_User', 'post_login', $authActions, 'loginSuccessful'); |
|
143 | + Util::connectHook('OC_User', 'logout', $authActions, 'logout'); |
|
144 | + } |
|
145 | + |
|
146 | + protected function appHooks() { |
|
147 | + |
|
148 | + $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
149 | + $eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function(ManagerEvent $event) { |
|
150 | + $appActions = new AppManagement($this->logger); |
|
151 | + $appActions->enableApp($event->getAppID()); |
|
152 | + }); |
|
153 | + $eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, function(ManagerEvent $event) { |
|
154 | + $appActions = new AppManagement($this->logger); |
|
155 | + $appActions->enableAppForGroups($event->getAppID(), $event->getGroups()); |
|
156 | + }); |
|
157 | + $eventDispatcher->addListener(ManagerEvent::EVENT_APP_DISABLE, function(ManagerEvent $event) { |
|
158 | + $appActions = new AppManagement($this->logger); |
|
159 | + $appActions->disableApp($event->getAppID()); |
|
160 | + }); |
|
161 | + |
|
162 | + } |
|
163 | + |
|
164 | + protected function consoleHooks() { |
|
165 | + $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
166 | + $eventDispatcher->addListener(ConsoleEvent::EVENT_RUN, function(ConsoleEvent $event) { |
|
167 | + $appActions = new Console($this->logger); |
|
168 | + $appActions->runCommand($event->getArguments()); |
|
169 | + }); |
|
170 | + } |
|
171 | + |
|
172 | + protected function fileHooks() { |
|
173 | + $fileActions = new Files($this->logger); |
|
174 | + $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
175 | + $eventDispatcher->addListener( |
|
176 | + IPreview::EVENT, |
|
177 | + function(GenericEvent $event) use ($fileActions) { |
|
178 | + /** @var File $file */ |
|
179 | + $file = $event->getSubject(); |
|
180 | + $fileActions->preview([ |
|
181 | + 'path' => substr($file->getInternalPath(), 5), |
|
182 | + 'width' => $event->getArguments()['width'], |
|
183 | + 'height' => $event->getArguments()['height'], |
|
184 | + 'crop' => $event->getArguments()['crop'], |
|
185 | + 'mode' => $event->getArguments()['mode'] |
|
186 | + ]); |
|
187 | + } |
|
188 | + ); |
|
189 | + |
|
190 | + Util::connectHook( |
|
191 | + Filesystem::CLASSNAME, |
|
192 | + Filesystem::signal_post_rename, |
|
193 | + $fileActions, |
|
194 | + 'rename' |
|
195 | + ); |
|
196 | + Util::connectHook( |
|
197 | + Filesystem::CLASSNAME, |
|
198 | + Filesystem::signal_post_create, |
|
199 | + $fileActions, |
|
200 | + 'create' |
|
201 | + ); |
|
202 | + Util::connectHook( |
|
203 | + Filesystem::CLASSNAME, |
|
204 | + Filesystem::signal_post_copy, |
|
205 | + $fileActions, |
|
206 | + 'copy' |
|
207 | + ); |
|
208 | + Util::connectHook( |
|
209 | + Filesystem::CLASSNAME, |
|
210 | + Filesystem::signal_post_write, |
|
211 | + $fileActions, |
|
212 | + 'write' |
|
213 | + ); |
|
214 | + Util::connectHook( |
|
215 | + Filesystem::CLASSNAME, |
|
216 | + Filesystem::signal_post_update, |
|
217 | + $fileActions, |
|
218 | + 'update' |
|
219 | + ); |
|
220 | + Util::connectHook( |
|
221 | + Filesystem::CLASSNAME, |
|
222 | + Filesystem::signal_read, |
|
223 | + $fileActions, |
|
224 | + 'read' |
|
225 | + ); |
|
226 | + Util::connectHook( |
|
227 | + Filesystem::CLASSNAME, |
|
228 | + Filesystem::signal_delete, |
|
229 | + $fileActions, |
|
230 | + 'delete' |
|
231 | + ); |
|
232 | + } |
|
233 | + |
|
234 | + protected function versionsHooks() { |
|
235 | + $versionsActions = new Versions($this->logger); |
|
236 | + Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback'); |
|
237 | + Util::connectHook('\OCP\Versions', 'delete',$versionsActions, 'delete'); |
|
238 | + } |
|
239 | + |
|
240 | + protected function trashbinHooks() { |
|
241 | + $trashActions = new Trashbin($this->logger); |
|
242 | + Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete'); |
|
243 | + Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore'); |
|
244 | + } |
|
245 | + |
|
246 | + protected function securityHooks() { |
|
247 | + $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); |
|
248 | + $eventDispatcher->addListener(IProvider::EVENT_SUCCESS, function(GenericEvent $event) { |
|
249 | + $security = new Security($this->logger); |
|
250 | + $security->twofactorSuccess($event->getSubject(), $event->getArguments()); |
|
251 | + }); |
|
252 | + $eventDispatcher->addListener(IProvider::EVENT_FAILED, function(GenericEvent $event) { |
|
253 | + $security = new Security($this->logger); |
|
254 | + $security->twofactorFailed($event->getSubject(), $event->getArguments()); |
|
255 | + }); |
|
256 | + } |
|
257 | 257 | } |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | $c = $this->getContainer()->getServer(); |
66 | 66 | $config = $c->getConfig(); |
67 | 67 | |
68 | - $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
68 | + $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/audit.log'; |
|
69 | 69 | $logFile = $config->getAppValue('admin_audit', 'logfile', $default); |
70 | - if($logFile === null) { |
|
70 | + if ($logFile === null) { |
|
71 | 71 | $this->logger = $c->getLogger(); |
72 | 72 | return; |
73 | 73 | } |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | protected function userManagementHooks() { |
103 | 103 | $userActions = new UserManagement($this->logger); |
104 | 104 | |
105 | - Util::connectHook('OC_User', 'post_createUser', $userActions, 'create'); |
|
106 | - Util::connectHook('OC_User', 'post_deleteUser', $userActions, 'delete'); |
|
107 | - Util::connectHook('OC_User', 'changeUser', $userActions, 'change'); |
|
105 | + Util::connectHook('OC_User', 'post_createUser', $userActions, 'create'); |
|
106 | + Util::connectHook('OC_User', 'post_deleteUser', $userActions, 'delete'); |
|
107 | + Util::connectHook('OC_User', 'changeUser', $userActions, 'change'); |
|
108 | 108 | |
109 | 109 | /** @var IUserSession|Session $userSession */ |
110 | 110 | $userSession = $this->getContainer()->getServer()->getUserSession(); |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | $userSession->listen('\OC\User', 'postUnassignedUserId', [$userActions, 'unassign']); |
114 | 114 | } |
115 | 115 | |
116 | - protected function groupHooks() { |
|
116 | + protected function groupHooks() { |
|
117 | 117 | $groupActions = new GroupManagement($this->logger); |
118 | 118 | |
119 | 119 | /** @var IGroupManager|Manager $groupManager */ |
120 | 120 | $groupManager = $this->getContainer()->getServer()->getGroupManager(); |
121 | - $groupManager->listen('\OC\Group', 'postRemoveUser', [$groupActions, 'removeUser']); |
|
122 | - $groupManager->listen('\OC\Group', 'postAddUser', [$groupActions, 'addUser']); |
|
123 | - $groupManager->listen('\OC\Group', 'postDelete', [$groupActions, 'deleteGroup']); |
|
124 | - $groupManager->listen('\OC\Group', 'postCreate', [$groupActions, 'createGroup']); |
|
121 | + $groupManager->listen('\OC\Group', 'postRemoveUser', [$groupActions, 'removeUser']); |
|
122 | + $groupManager->listen('\OC\Group', 'postAddUser', [$groupActions, 'addUser']); |
|
123 | + $groupManager->listen('\OC\Group', 'postDelete', [$groupActions, 'deleteGroup']); |
|
124 | + $groupManager->listen('\OC\Group', 'postCreate', [$groupActions, 'createGroup']); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | protected function sharingHooks() { |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | protected function versionsHooks() { |
235 | 235 | $versionsActions = new Versions($this->logger); |
236 | 236 | Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback'); |
237 | - Util::connectHook('\OCP\Versions', 'delete',$versionsActions, 'delete'); |
|
237 | + Util::connectHook('\OCP\Versions', 'delete', $versionsActions, 'delete'); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | protected function trashbinHooks() { |
@@ -27,26 +27,26 @@ |
||
27 | 27 | use OCP\Log\RotationTrait; |
28 | 28 | |
29 | 29 | class Rotate extends TimedJob { |
30 | - use RotationTrait; |
|
30 | + use RotationTrait; |
|
31 | 31 | |
32 | - public function __construct() { |
|
33 | - $this->setInterval(60*60*3); |
|
34 | - } |
|
32 | + public function __construct() { |
|
33 | + $this->setInterval(60*60*3); |
|
34 | + } |
|
35 | 35 | |
36 | - protected function run($argument) { |
|
37 | - $config = \OC::$server->getConfig(); |
|
38 | - $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
39 | - $this->filePath = $config->getAppValue('admin_audit', 'logfile', $default); |
|
36 | + protected function run($argument) { |
|
37 | + $config = \OC::$server->getConfig(); |
|
38 | + $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
39 | + $this->filePath = $config->getAppValue('admin_audit', 'logfile', $default); |
|
40 | 40 | |
41 | - if($this->filePath === '') { |
|
42 | - // default log file, nothing to do |
|
43 | - return; |
|
44 | - } |
|
41 | + if($this->filePath === '') { |
|
42 | + // default log file, nothing to do |
|
43 | + return; |
|
44 | + } |
|
45 | 45 | |
46 | - $this->maxSize = $config->getSystemValue('log_rotate_size', 100 * 1024 * 1024); |
|
46 | + $this->maxSize = $config->getSystemValue('log_rotate_size', 100 * 1024 * 1024); |
|
47 | 47 | |
48 | - if($this->shouldRotateBySize()) { |
|
49 | - $this->rotate(); |
|
50 | - } |
|
51 | - } |
|
48 | + if($this->shouldRotateBySize()) { |
|
49 | + $this->rotate(); |
|
50 | + } |
|
51 | + } |
|
52 | 52 | } |
@@ -30,22 +30,22 @@ |
||
30 | 30 | use RotationTrait; |
31 | 31 | |
32 | 32 | public function __construct() { |
33 | - $this->setInterval(60*60*3); |
|
33 | + $this->setInterval(60 * 60 * 3); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | protected function run($argument) { |
37 | 37 | $config = \OC::$server->getConfig(); |
38 | - $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log'; |
|
38 | + $default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/audit.log'; |
|
39 | 39 | $this->filePath = $config->getAppValue('admin_audit', 'logfile', $default); |
40 | 40 | |
41 | - if($this->filePath === '') { |
|
41 | + if ($this->filePath === '') { |
|
42 | 42 | // default log file, nothing to do |
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $this->maxSize = $config->getSystemValue('log_rotate_size', 100 * 1024 * 1024); |
47 | 47 | |
48 | - if($this->shouldRotateBySize()) { |
|
48 | + if ($this->shouldRotateBySize()) { |
|
49 | 49 | $this->rotate(); |
50 | 50 | } |
51 | 51 | } |