@@ -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 | } |
@@ -6,39 +6,39 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInitAdminAudit |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'O' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'OCA\\AdminAudit\\' => 15, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'OCA\\AdminAudit\\' => |
18 | - array ( |
|
19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
18 | + array( |
|
19 | + 0 => __DIR__.'/..'.'/../lib', |
|
20 | 20 | ), |
21 | 21 | ); |
22 | 22 | |
23 | - public static $classMap = array ( |
|
24 | - 'OCA\\AdminAudit\\Actions\\Action' => __DIR__ . '/..' . '/../lib/Actions/Action.php', |
|
25 | - 'OCA\\AdminAudit\\Actions\\AppManagement' => __DIR__ . '/..' . '/../lib/Actions/AppManagement.php', |
|
26 | - 'OCA\\AdminAudit\\Actions\\Auth' => __DIR__ . '/..' . '/../lib/Actions/Auth.php', |
|
27 | - 'OCA\\AdminAudit\\Actions\\Console' => __DIR__ . '/..' . '/../lib/Actions/Console.php', |
|
28 | - 'OCA\\AdminAudit\\Actions\\Files' => __DIR__ . '/..' . '/../lib/Actions/Files.php', |
|
29 | - 'OCA\\AdminAudit\\Actions\\GroupManagement' => __DIR__ . '/..' . '/../lib/Actions/GroupManagement.php', |
|
30 | - 'OCA\\AdminAudit\\Actions\\Security' => __DIR__ . '/..' . '/../lib/Actions/Security.php', |
|
31 | - 'OCA\\AdminAudit\\Actions\\Sharing' => __DIR__ . '/..' . '/../lib/Actions/Sharing.php', |
|
32 | - 'OCA\\AdminAudit\\Actions\\Trashbin' => __DIR__ . '/..' . '/../lib/Actions/Trashbin.php', |
|
33 | - 'OCA\\AdminAudit\\Actions\\UserManagement' => __DIR__ . '/..' . '/../lib/Actions/UserManagement.php', |
|
34 | - 'OCA\\AdminAudit\\Actions\\Versions' => __DIR__ . '/..' . '/../lib/Actions/Versions.php', |
|
35 | - 'OCA\\AdminAudit\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
36 | - 'OCA\\AdminAudit\\BackgroundJobs\\Rotate' => __DIR__ . '/..' . '/../lib/BackgroundJobs/Rotate.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'OCA\\AdminAudit\\Actions\\Action' => __DIR__.'/..'.'/../lib/Actions/Action.php', |
|
25 | + 'OCA\\AdminAudit\\Actions\\AppManagement' => __DIR__.'/..'.'/../lib/Actions/AppManagement.php', |
|
26 | + 'OCA\\AdminAudit\\Actions\\Auth' => __DIR__.'/..'.'/../lib/Actions/Auth.php', |
|
27 | + 'OCA\\AdminAudit\\Actions\\Console' => __DIR__.'/..'.'/../lib/Actions/Console.php', |
|
28 | + 'OCA\\AdminAudit\\Actions\\Files' => __DIR__.'/..'.'/../lib/Actions/Files.php', |
|
29 | + 'OCA\\AdminAudit\\Actions\\GroupManagement' => __DIR__.'/..'.'/../lib/Actions/GroupManagement.php', |
|
30 | + 'OCA\\AdminAudit\\Actions\\Security' => __DIR__.'/..'.'/../lib/Actions/Security.php', |
|
31 | + 'OCA\\AdminAudit\\Actions\\Sharing' => __DIR__.'/..'.'/../lib/Actions/Sharing.php', |
|
32 | + 'OCA\\AdminAudit\\Actions\\Trashbin' => __DIR__.'/..'.'/../lib/Actions/Trashbin.php', |
|
33 | + 'OCA\\AdminAudit\\Actions\\UserManagement' => __DIR__.'/..'.'/../lib/Actions/UserManagement.php', |
|
34 | + 'OCA\\AdminAudit\\Actions\\Versions' => __DIR__.'/..'.'/../lib/Actions/Versions.php', |
|
35 | + 'OCA\\AdminAudit\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
36 | + 'OCA\\AdminAudit\\BackgroundJobs\\Rotate' => __DIR__.'/..'.'/../lib/BackgroundJobs/Rotate.php', |
|
37 | 37 | ); |
38 | 38 | |
39 | 39 | public static function getInitializer(ClassLoader $loader) |
40 | 40 | { |
41 | - return \Closure::bind(function () use ($loader) { |
|
41 | + return \Closure::bind(function() use ($loader) { |
|
42 | 42 | $loader->prefixLengthsPsr4 = ComposerStaticInitAdminAudit::$prefixLengthsPsr4; |
43 | 43 | $loader->prefixDirsPsr4 = ComposerStaticInitAdminAudit::$prefixDirsPsr4; |
44 | 44 | $loader->classMap = ComposerStaticInitAdminAudit::$classMap; |
@@ -6,17 +6,17 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'OCA\\AdminAudit\\Actions\\Action' => $baseDir . '/../lib/Actions/Action.php', |
|
10 | - 'OCA\\AdminAudit\\Actions\\AppManagement' => $baseDir . '/../lib/Actions/AppManagement.php', |
|
11 | - 'OCA\\AdminAudit\\Actions\\Auth' => $baseDir . '/../lib/Actions/Auth.php', |
|
12 | - 'OCA\\AdminAudit\\Actions\\Console' => $baseDir . '/../lib/Actions/Console.php', |
|
13 | - 'OCA\\AdminAudit\\Actions\\Files' => $baseDir . '/../lib/Actions/Files.php', |
|
14 | - 'OCA\\AdminAudit\\Actions\\GroupManagement' => $baseDir . '/../lib/Actions/GroupManagement.php', |
|
15 | - 'OCA\\AdminAudit\\Actions\\Security' => $baseDir . '/../lib/Actions/Security.php', |
|
16 | - 'OCA\\AdminAudit\\Actions\\Sharing' => $baseDir . '/../lib/Actions/Sharing.php', |
|
17 | - 'OCA\\AdminAudit\\Actions\\Trashbin' => $baseDir . '/../lib/Actions/Trashbin.php', |
|
18 | - 'OCA\\AdminAudit\\Actions\\UserManagement' => $baseDir . '/../lib/Actions/UserManagement.php', |
|
19 | - 'OCA\\AdminAudit\\Actions\\Versions' => $baseDir . '/../lib/Actions/Versions.php', |
|
20 | - 'OCA\\AdminAudit\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
21 | - 'OCA\\AdminAudit\\BackgroundJobs\\Rotate' => $baseDir . '/../lib/BackgroundJobs/Rotate.php', |
|
9 | + 'OCA\\AdminAudit\\Actions\\Action' => $baseDir.'/../lib/Actions/Action.php', |
|
10 | + 'OCA\\AdminAudit\\Actions\\AppManagement' => $baseDir.'/../lib/Actions/AppManagement.php', |
|
11 | + 'OCA\\AdminAudit\\Actions\\Auth' => $baseDir.'/../lib/Actions/Auth.php', |
|
12 | + 'OCA\\AdminAudit\\Actions\\Console' => $baseDir.'/../lib/Actions/Console.php', |
|
13 | + 'OCA\\AdminAudit\\Actions\\Files' => $baseDir.'/../lib/Actions/Files.php', |
|
14 | + 'OCA\\AdminAudit\\Actions\\GroupManagement' => $baseDir.'/../lib/Actions/GroupManagement.php', |
|
15 | + 'OCA\\AdminAudit\\Actions\\Security' => $baseDir.'/../lib/Actions/Security.php', |
|
16 | + 'OCA\\AdminAudit\\Actions\\Sharing' => $baseDir.'/../lib/Actions/Sharing.php', |
|
17 | + 'OCA\\AdminAudit\\Actions\\Trashbin' => $baseDir.'/../lib/Actions/Trashbin.php', |
|
18 | + 'OCA\\AdminAudit\\Actions\\UserManagement' => $baseDir.'/../lib/Actions/UserManagement.php', |
|
19 | + 'OCA\\AdminAudit\\Actions\\Versions' => $baseDir.'/../lib/Actions/Versions.php', |
|
20 | + 'OCA\\AdminAudit\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
21 | + 'OCA\\AdminAudit\\BackgroundJobs\\Rotate' => $baseDir.'/../lib/BackgroundJobs/Rotate.php', |
|
22 | 22 | ); |
@@ -153,1833 +153,1833 @@ |
||
153 | 153 | * TODO: hookup all manager classes |
154 | 154 | */ |
155 | 155 | class Server extends ServerContainer implements IServerContainer { |
156 | - /** @var string */ |
|
157 | - private $webRoot; |
|
158 | - |
|
159 | - /** |
|
160 | - * @param string $webRoot |
|
161 | - * @param \OC\Config $config |
|
162 | - */ |
|
163 | - public function __construct($webRoot, \OC\Config $config) { |
|
164 | - parent::__construct(); |
|
165 | - $this->webRoot = $webRoot; |
|
166 | - |
|
167 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
168 | - return $c; |
|
169 | - }); |
|
170 | - |
|
171 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
172 | - $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
173 | - |
|
174 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
175 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
176 | - |
|
177 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
178 | - |
|
179 | - |
|
180 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
181 | - return new PreviewManager( |
|
182 | - $c->getConfig(), |
|
183 | - $c->getRootFolder(), |
|
184 | - $c->getAppDataDir('preview'), |
|
185 | - $c->getEventDispatcher(), |
|
186 | - $c->getSession()->get('user_id') |
|
187 | - ); |
|
188 | - }); |
|
189 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
190 | - |
|
191 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
192 | - return new \OC\Preview\Watcher( |
|
193 | - $c->getAppDataDir('preview') |
|
194 | - ); |
|
195 | - }); |
|
196 | - |
|
197 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
198 | - $view = new View(); |
|
199 | - $util = new Encryption\Util( |
|
200 | - $view, |
|
201 | - $c->getUserManager(), |
|
202 | - $c->getGroupManager(), |
|
203 | - $c->getConfig() |
|
204 | - ); |
|
205 | - return new Encryption\Manager( |
|
206 | - $c->getConfig(), |
|
207 | - $c->getLogger(), |
|
208 | - $c->getL10N('core'), |
|
209 | - new View(), |
|
210 | - $util, |
|
211 | - new ArrayCache() |
|
212 | - ); |
|
213 | - }); |
|
214 | - |
|
215 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
216 | - $util = new Encryption\Util( |
|
217 | - new View(), |
|
218 | - $c->getUserManager(), |
|
219 | - $c->getGroupManager(), |
|
220 | - $c->getConfig() |
|
221 | - ); |
|
222 | - return new Encryption\File( |
|
223 | - $util, |
|
224 | - $c->getRootFolder(), |
|
225 | - $c->getShareManager() |
|
226 | - ); |
|
227 | - }); |
|
228 | - |
|
229 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
230 | - $view = new View(); |
|
231 | - $util = new Encryption\Util( |
|
232 | - $view, |
|
233 | - $c->getUserManager(), |
|
234 | - $c->getGroupManager(), |
|
235 | - $c->getConfig() |
|
236 | - ); |
|
237 | - |
|
238 | - return new Encryption\Keys\Storage($view, $util); |
|
239 | - }); |
|
240 | - $this->registerService('TagMapper', function (Server $c) { |
|
241 | - return new TagMapper($c->getDatabaseConnection()); |
|
242 | - }); |
|
243 | - |
|
244 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
245 | - $tagMapper = $c->query('TagMapper'); |
|
246 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
247 | - }); |
|
248 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
249 | - |
|
250 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
251 | - $config = $c->getConfig(); |
|
252 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
253 | - return new $factoryClass($this); |
|
254 | - }); |
|
255 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
256 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
257 | - }); |
|
258 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
259 | - |
|
260 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
261 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
262 | - }); |
|
263 | - $this->registerService('RootFolder', function (Server $c) { |
|
264 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
265 | - $view = new View(); |
|
266 | - $root = new Root( |
|
267 | - $manager, |
|
268 | - $view, |
|
269 | - null, |
|
270 | - $c->getUserMountCache(), |
|
271 | - $this->getLogger(), |
|
272 | - $this->getUserManager() |
|
273 | - ); |
|
274 | - $connector = new HookConnector($root, $view); |
|
275 | - $connector->viewToNode(); |
|
276 | - |
|
277 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
278 | - $previewConnector->connectWatcher(); |
|
279 | - |
|
280 | - return $root; |
|
281 | - }); |
|
282 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
283 | - |
|
284 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
285 | - return new LazyRoot(function () use ($c) { |
|
286 | - return $c->query('RootFolder'); |
|
287 | - }); |
|
288 | - }); |
|
289 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
290 | - |
|
291 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
292 | - $config = $c->getConfig(); |
|
293 | - return new \OC\User\Manager($config); |
|
294 | - }); |
|
295 | - $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
296 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
297 | - |
|
298 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
299 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
300 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
301 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
302 | - }); |
|
303 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
304 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
305 | - }); |
|
306 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
307 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
308 | - }); |
|
309 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
310 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
311 | - }); |
|
312 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
313 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
314 | - }); |
|
315 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
316 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
317 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
318 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
319 | - }); |
|
320 | - return $groupManager; |
|
321 | - }); |
|
322 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
323 | - |
|
324 | - $this->registerService(Store::class, function (Server $c) { |
|
325 | - $session = $c->getSession(); |
|
326 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
327 | - $tokenProvider = $c->query(IProvider::class); |
|
328 | - } else { |
|
329 | - $tokenProvider = null; |
|
330 | - } |
|
331 | - $logger = $c->getLogger(); |
|
332 | - return new Store($session, $logger, $tokenProvider); |
|
333 | - }); |
|
334 | - $this->registerAlias(IStore::class, Store::class); |
|
335 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
336 | - $dbConnection = $c->getDatabaseConnection(); |
|
337 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
338 | - }); |
|
339 | - $this->registerService(Authentication\Token\DefaultTokenProvider::class, function (Server $c) { |
|
340 | - $mapper = $c->query(Authentication\Token\DefaultTokenMapper::class); |
|
341 | - $crypto = $c->getCrypto(); |
|
342 | - $config = $c->getConfig(); |
|
343 | - $logger = $c->getLogger(); |
|
344 | - $timeFactory = new TimeFactory(); |
|
345 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
346 | - }); |
|
347 | - $this->registerAlias(IProvider::class, Authentication\Token\DefaultTokenProvider::class); |
|
348 | - |
|
349 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
350 | - $manager = $c->getUserManager(); |
|
351 | - $session = new \OC\Session\Memory(''); |
|
352 | - $timeFactory = new TimeFactory(); |
|
353 | - // Token providers might require a working database. This code |
|
354 | - // might however be called when ownCloud is not yet setup. |
|
355 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
356 | - $defaultTokenProvider = $c->query(IProvider::class); |
|
357 | - } else { |
|
358 | - $defaultTokenProvider = null; |
|
359 | - } |
|
360 | - |
|
361 | - $dispatcher = $c->getEventDispatcher(); |
|
362 | - |
|
363 | - $userSession = new \OC\User\Session( |
|
364 | - $manager, |
|
365 | - $session, |
|
366 | - $timeFactory, |
|
367 | - $defaultTokenProvider, |
|
368 | - $c->getConfig(), |
|
369 | - $c->getSecureRandom(), |
|
370 | - $c->getLockdownManager(), |
|
371 | - $c->getLogger() |
|
372 | - ); |
|
373 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
374 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
375 | - }); |
|
376 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
377 | - /** @var $user \OC\User\User */ |
|
378 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
379 | - }); |
|
380 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
381 | - /** @var $user \OC\User\User */ |
|
382 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
383 | - $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
384 | - }); |
|
385 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
386 | - /** @var $user \OC\User\User */ |
|
387 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
388 | - }); |
|
389 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
390 | - /** @var $user \OC\User\User */ |
|
391 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
392 | - }); |
|
393 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
394 | - /** @var $user \OC\User\User */ |
|
395 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
396 | - }); |
|
397 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
398 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
399 | - }); |
|
400 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
401 | - /** @var $user \OC\User\User */ |
|
402 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
403 | - }); |
|
404 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
405 | - /** @var $user \OC\User\User */ |
|
406 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
407 | - }); |
|
408 | - $userSession->listen('\OC\User', 'logout', function () { |
|
409 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
410 | - }); |
|
411 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
412 | - /** @var $user \OC\User\User */ |
|
413 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
414 | - $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
415 | - }); |
|
416 | - return $userSession; |
|
417 | - }); |
|
418 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
419 | - |
|
420 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
421 | - return new \OC\Authentication\TwoFactorAuth\Manager( |
|
422 | - $c->getAppManager(), |
|
423 | - $c->getSession(), |
|
424 | - $c->getConfig(), |
|
425 | - $c->getActivityManager(), |
|
426 | - $c->getLogger(), |
|
427 | - $c->query(IProvider::class), |
|
428 | - $c->query(ITimeFactory::class), |
|
429 | - $c->query(EventDispatcherInterface::class) |
|
430 | - ); |
|
431 | - }); |
|
432 | - |
|
433 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
434 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
435 | - |
|
436 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
437 | - return new \OC\AllConfig( |
|
438 | - $c->getSystemConfig() |
|
439 | - ); |
|
440 | - }); |
|
441 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
442 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
443 | - |
|
444 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
445 | - return new \OC\SystemConfig($config); |
|
446 | - }); |
|
447 | - |
|
448 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
449 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
450 | - }); |
|
451 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
452 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
453 | - |
|
454 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
455 | - return new \OC\L10N\Factory( |
|
456 | - $c->getConfig(), |
|
457 | - $c->getRequest(), |
|
458 | - $c->getUserSession(), |
|
459 | - \OC::$SERVERROOT |
|
460 | - ); |
|
461 | - }); |
|
462 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
463 | - |
|
464 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
465 | - $config = $c->getConfig(); |
|
466 | - $cacheFactory = $c->getMemCacheFactory(); |
|
467 | - $request = $c->getRequest(); |
|
468 | - return new \OC\URLGenerator( |
|
469 | - $config, |
|
470 | - $cacheFactory, |
|
471 | - $request |
|
472 | - ); |
|
473 | - }); |
|
474 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
475 | - |
|
476 | - $this->registerAlias('AppFetcher', AppFetcher::class); |
|
477 | - $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
478 | - |
|
479 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
480 | - return new Cache\File(); |
|
481 | - }); |
|
482 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
483 | - |
|
484 | - $this->registerService(Factory::class, function (Server $c) { |
|
485 | - |
|
486 | - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
487 | - ArrayCache::class, |
|
488 | - ArrayCache::class, |
|
489 | - ArrayCache::class |
|
490 | - ); |
|
491 | - $config = $c->getConfig(); |
|
492 | - $request = $c->getRequest(); |
|
493 | - $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
494 | - |
|
495 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
496 | - $v = \OC_App::getAppVersions(); |
|
497 | - $v['core'] = implode(',', \OC_Util::getVersion()); |
|
498 | - $version = implode(',', $v); |
|
499 | - $instanceId = \OC_Util::getInstanceId(); |
|
500 | - $path = \OC::$SERVERROOT; |
|
501 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
502 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
503 | - $config->getSystemValue('memcache.local', null), |
|
504 | - $config->getSystemValue('memcache.distributed', null), |
|
505 | - $config->getSystemValue('memcache.locking', null) |
|
506 | - ); |
|
507 | - } |
|
508 | - return $arrayCacheFactory; |
|
509 | - |
|
510 | - }); |
|
511 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
512 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
513 | - |
|
514 | - $this->registerService('RedisFactory', function (Server $c) { |
|
515 | - $systemConfig = $c->getSystemConfig(); |
|
516 | - return new RedisFactory($systemConfig); |
|
517 | - }); |
|
518 | - |
|
519 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
520 | - return new \OC\Activity\Manager( |
|
521 | - $c->getRequest(), |
|
522 | - $c->getUserSession(), |
|
523 | - $c->getConfig(), |
|
524 | - $c->query(IValidator::class) |
|
525 | - ); |
|
526 | - }); |
|
527 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
528 | - |
|
529 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
530 | - return new \OC\Activity\EventMerger( |
|
531 | - $c->getL10N('lib') |
|
532 | - ); |
|
533 | - }); |
|
534 | - $this->registerAlias(IValidator::class, Validator::class); |
|
535 | - |
|
536 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
537 | - return new AvatarManager( |
|
538 | - $c->query(\OC\User\Manager::class), |
|
539 | - $c->getAppDataDir('avatar'), |
|
540 | - $c->getL10N('lib'), |
|
541 | - $c->getLogger(), |
|
542 | - $c->getConfig() |
|
543 | - ); |
|
544 | - }); |
|
545 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
546 | - |
|
547 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
548 | - |
|
549 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
550 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
551 | - $factory = new LogFactory($c, $this->getSystemConfig()); |
|
552 | - $logger = $factory->get($logType); |
|
553 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
554 | - |
|
555 | - return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
556 | - }); |
|
557 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
558 | - |
|
559 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
560 | - return new LogFactory($c, $this->getSystemConfig()); |
|
561 | - }); |
|
562 | - |
|
563 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
564 | - $config = $c->getConfig(); |
|
565 | - return new \OC\BackgroundJob\JobList( |
|
566 | - $c->getDatabaseConnection(), |
|
567 | - $config, |
|
568 | - new TimeFactory() |
|
569 | - ); |
|
570 | - }); |
|
571 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
572 | - |
|
573 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
574 | - $cacheFactory = $c->getMemCacheFactory(); |
|
575 | - $logger = $c->getLogger(); |
|
576 | - if ($cacheFactory->isLocalCacheAvailable()) { |
|
577 | - $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
578 | - } else { |
|
579 | - $router = new \OC\Route\Router($logger); |
|
580 | - } |
|
581 | - return $router; |
|
582 | - }); |
|
583 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
584 | - |
|
585 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
586 | - return new Search(); |
|
587 | - }); |
|
588 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
589 | - |
|
590 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
591 | - return new \OC\Security\RateLimiting\Limiter( |
|
592 | - $this->getUserSession(), |
|
593 | - $this->getRequest(), |
|
594 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
595 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
596 | - ); |
|
597 | - }); |
|
598 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
599 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
600 | - $this->getMemCacheFactory(), |
|
601 | - new \OC\AppFramework\Utility\TimeFactory() |
|
602 | - ); |
|
603 | - }); |
|
604 | - |
|
605 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
606 | - return new SecureRandom(); |
|
607 | - }); |
|
608 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
609 | - |
|
610 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
611 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
612 | - }); |
|
613 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
614 | - |
|
615 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
616 | - return new Hasher($c->getConfig()); |
|
617 | - }); |
|
618 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
619 | - |
|
620 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
621 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
622 | - }); |
|
623 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
624 | - |
|
625 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
626 | - $systemConfig = $c->getSystemConfig(); |
|
627 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
628 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
629 | - if (!$factory->isValidType($type)) { |
|
630 | - throw new \OC\DatabaseException('Invalid database type'); |
|
631 | - } |
|
632 | - $connectionParams = $factory->createConnectionParams(); |
|
633 | - $connection = $factory->getConnection($type, $connectionParams); |
|
634 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
635 | - return $connection; |
|
636 | - }); |
|
637 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
638 | - |
|
639 | - |
|
640 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
641 | - $user = \OC_User::getUser(); |
|
642 | - $uid = $user ? $user : null; |
|
643 | - return new ClientService( |
|
644 | - $c->getConfig(), |
|
645 | - new \OC\Security\CertificateManager( |
|
646 | - $uid, |
|
647 | - new View(), |
|
648 | - $c->getConfig(), |
|
649 | - $c->getLogger(), |
|
650 | - $c->getSecureRandom() |
|
651 | - ) |
|
652 | - ); |
|
653 | - }); |
|
654 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
655 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
656 | - $eventLogger = new EventLogger(); |
|
657 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
658 | - // In debug mode, module is being activated by default |
|
659 | - $eventLogger->activate(); |
|
660 | - } |
|
661 | - return $eventLogger; |
|
662 | - }); |
|
663 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
664 | - |
|
665 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
666 | - $queryLogger = new QueryLogger(); |
|
667 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
668 | - // In debug mode, module is being activated by default |
|
669 | - $queryLogger->activate(); |
|
670 | - } |
|
671 | - return $queryLogger; |
|
672 | - }); |
|
673 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
674 | - |
|
675 | - $this->registerService(TempManager::class, function (Server $c) { |
|
676 | - return new TempManager( |
|
677 | - $c->getLogger(), |
|
678 | - $c->getConfig() |
|
679 | - ); |
|
680 | - }); |
|
681 | - $this->registerAlias('TempManager', TempManager::class); |
|
682 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
683 | - |
|
684 | - $this->registerService(AppManager::class, function (Server $c) { |
|
685 | - return new \OC\App\AppManager( |
|
686 | - $c->getUserSession(), |
|
687 | - $c->query(\OC\AppConfig::class), |
|
688 | - $c->getGroupManager(), |
|
689 | - $c->getMemCacheFactory(), |
|
690 | - $c->getEventDispatcher() |
|
691 | - ); |
|
692 | - }); |
|
693 | - $this->registerAlias('AppManager', AppManager::class); |
|
694 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
695 | - |
|
696 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
697 | - return new DateTimeZone( |
|
698 | - $c->getConfig(), |
|
699 | - $c->getSession() |
|
700 | - ); |
|
701 | - }); |
|
702 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
703 | - |
|
704 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
705 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
706 | - |
|
707 | - return new DateTimeFormatter( |
|
708 | - $c->getDateTimeZone()->getTimeZone(), |
|
709 | - $c->getL10N('lib', $language) |
|
710 | - ); |
|
711 | - }); |
|
712 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
713 | - |
|
714 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
715 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
716 | - $listener = new UserMountCacheListener($mountCache); |
|
717 | - $listener->listen($c->getUserManager()); |
|
718 | - return $mountCache; |
|
719 | - }); |
|
720 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
721 | - |
|
722 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
723 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
724 | - $mountCache = $c->query('UserMountCache'); |
|
725 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
726 | - |
|
727 | - // builtin providers |
|
728 | - |
|
729 | - $config = $c->getConfig(); |
|
730 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
731 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
732 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
733 | - |
|
734 | - return $manager; |
|
735 | - }); |
|
736 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
737 | - |
|
738 | - $this->registerService('IniWrapper', function ($c) { |
|
739 | - return new IniGetWrapper(); |
|
740 | - }); |
|
741 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
742 | - $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
743 | - if ($busClass) { |
|
744 | - list($app, $class) = explode('::', $busClass, 2); |
|
745 | - if ($c->getAppManager()->isInstalled($app)) { |
|
746 | - \OC_App::loadApp($app); |
|
747 | - return $c->query($class); |
|
748 | - } else { |
|
749 | - throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
750 | - } |
|
751 | - } else { |
|
752 | - $jobList = $c->getJobList(); |
|
753 | - return new CronBus($jobList); |
|
754 | - } |
|
755 | - }); |
|
756 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
757 | - return new TrustedDomainHelper($this->getConfig()); |
|
758 | - }); |
|
759 | - $this->registerService('Throttler', function (Server $c) { |
|
760 | - return new Throttler( |
|
761 | - $c->getDatabaseConnection(), |
|
762 | - new TimeFactory(), |
|
763 | - $c->getLogger(), |
|
764 | - $c->getConfig() |
|
765 | - ); |
|
766 | - }); |
|
767 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
768 | - // IConfig and IAppManager requires a working database. This code |
|
769 | - // might however be called when ownCloud is not yet setup. |
|
770 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
771 | - $config = $c->getConfig(); |
|
772 | - $appManager = $c->getAppManager(); |
|
773 | - } else { |
|
774 | - $config = null; |
|
775 | - $appManager = null; |
|
776 | - } |
|
777 | - |
|
778 | - return new Checker( |
|
779 | - new EnvironmentHelper(), |
|
780 | - new FileAccessHelper(), |
|
781 | - new AppLocator(), |
|
782 | - $config, |
|
783 | - $c->getMemCacheFactory(), |
|
784 | - $appManager, |
|
785 | - $c->getTempManager() |
|
786 | - ); |
|
787 | - }); |
|
788 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
789 | - if (isset($this['urlParams'])) { |
|
790 | - $urlParams = $this['urlParams']; |
|
791 | - } else { |
|
792 | - $urlParams = []; |
|
793 | - } |
|
794 | - |
|
795 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
796 | - && in_array('fakeinput', stream_get_wrappers()) |
|
797 | - ) { |
|
798 | - $stream = 'fakeinput://data'; |
|
799 | - } else { |
|
800 | - $stream = 'php://input'; |
|
801 | - } |
|
802 | - |
|
803 | - return new Request( |
|
804 | - [ |
|
805 | - 'get' => $_GET, |
|
806 | - 'post' => $_POST, |
|
807 | - 'files' => $_FILES, |
|
808 | - 'server' => $_SERVER, |
|
809 | - 'env' => $_ENV, |
|
810 | - 'cookies' => $_COOKIE, |
|
811 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
812 | - ? $_SERVER['REQUEST_METHOD'] |
|
813 | - : '', |
|
814 | - 'urlParams' => $urlParams, |
|
815 | - ], |
|
816 | - $this->getSecureRandom(), |
|
817 | - $this->getConfig(), |
|
818 | - $this->getCsrfTokenManager(), |
|
819 | - $stream |
|
820 | - ); |
|
821 | - }); |
|
822 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
823 | - |
|
824 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
825 | - return new Mailer( |
|
826 | - $c->getConfig(), |
|
827 | - $c->getLogger(), |
|
828 | - $c->query(Defaults::class), |
|
829 | - $c->getURLGenerator(), |
|
830 | - $c->getL10N('lib') |
|
831 | - ); |
|
832 | - }); |
|
833 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
834 | - |
|
835 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
836 | - $config = $c->getConfig(); |
|
837 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
838 | - if (is_null($factoryClass)) { |
|
839 | - throw new \Exception('ldapProviderFactory not set'); |
|
840 | - } |
|
841 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
842 | - $factory = new $factoryClass($this); |
|
843 | - return $factory->getLDAPProvider(); |
|
844 | - }); |
|
845 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
846 | - $ini = $c->getIniWrapper(); |
|
847 | - $config = $c->getConfig(); |
|
848 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
849 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
850 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
851 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
852 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
853 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
854 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
855 | - } |
|
856 | - return new DBLockingProvider( |
|
857 | - $c->getDatabaseConnection(), |
|
858 | - $c->getLogger(), |
|
859 | - new TimeFactory(), |
|
860 | - $ttl, |
|
861 | - !\OC::$CLI |
|
862 | - ); |
|
863 | - } |
|
864 | - return new NoopLockingProvider(); |
|
865 | - }); |
|
866 | - $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
867 | - |
|
868 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
869 | - return new \OC\Files\Mount\Manager(); |
|
870 | - }); |
|
871 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
872 | - |
|
873 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
874 | - return new \OC\Files\Type\Detection( |
|
875 | - $c->getURLGenerator(), |
|
876 | - \OC::$configDir, |
|
877 | - \OC::$SERVERROOT . '/resources/config/' |
|
878 | - ); |
|
879 | - }); |
|
880 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
881 | - |
|
882 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
883 | - return new \OC\Files\Type\Loader( |
|
884 | - $c->getDatabaseConnection() |
|
885 | - ); |
|
886 | - }); |
|
887 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
888 | - $this->registerService(BundleFetcher::class, function () { |
|
889 | - return new BundleFetcher($this->getL10N('lib')); |
|
890 | - }); |
|
891 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
892 | - return new Manager( |
|
893 | - $c->query(IValidator::class) |
|
894 | - ); |
|
895 | - }); |
|
896 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
897 | - |
|
898 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
899 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
900 | - $manager->registerCapability(function () use ($c) { |
|
901 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
902 | - }); |
|
903 | - $manager->registerCapability(function () use ($c) { |
|
904 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
905 | - }); |
|
906 | - return $manager; |
|
907 | - }); |
|
908 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
909 | - |
|
910 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
911 | - $config = $c->getConfig(); |
|
912 | - $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
913 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
914 | - $factory = new $factoryClass($this); |
|
915 | - $manager = $factory->getManager(); |
|
916 | - |
|
917 | - $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
918 | - $manager = $c->getUserManager(); |
|
919 | - $user = $manager->get($id); |
|
920 | - if(is_null($user)) { |
|
921 | - $l = $c->getL10N('core'); |
|
922 | - $displayName = $l->t('Unknown user'); |
|
923 | - } else { |
|
924 | - $displayName = $user->getDisplayName(); |
|
925 | - } |
|
926 | - return $displayName; |
|
927 | - }); |
|
928 | - |
|
929 | - return $manager; |
|
930 | - }); |
|
931 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
932 | - |
|
933 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
934 | - /* |
|
156 | + /** @var string */ |
|
157 | + private $webRoot; |
|
158 | + |
|
159 | + /** |
|
160 | + * @param string $webRoot |
|
161 | + * @param \OC\Config $config |
|
162 | + */ |
|
163 | + public function __construct($webRoot, \OC\Config $config) { |
|
164 | + parent::__construct(); |
|
165 | + $this->webRoot = $webRoot; |
|
166 | + |
|
167 | + $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
168 | + return $c; |
|
169 | + }); |
|
170 | + |
|
171 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
172 | + $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
173 | + |
|
174 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
175 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
176 | + |
|
177 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
178 | + |
|
179 | + |
|
180 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
181 | + return new PreviewManager( |
|
182 | + $c->getConfig(), |
|
183 | + $c->getRootFolder(), |
|
184 | + $c->getAppDataDir('preview'), |
|
185 | + $c->getEventDispatcher(), |
|
186 | + $c->getSession()->get('user_id') |
|
187 | + ); |
|
188 | + }); |
|
189 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
190 | + |
|
191 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
192 | + return new \OC\Preview\Watcher( |
|
193 | + $c->getAppDataDir('preview') |
|
194 | + ); |
|
195 | + }); |
|
196 | + |
|
197 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
198 | + $view = new View(); |
|
199 | + $util = new Encryption\Util( |
|
200 | + $view, |
|
201 | + $c->getUserManager(), |
|
202 | + $c->getGroupManager(), |
|
203 | + $c->getConfig() |
|
204 | + ); |
|
205 | + return new Encryption\Manager( |
|
206 | + $c->getConfig(), |
|
207 | + $c->getLogger(), |
|
208 | + $c->getL10N('core'), |
|
209 | + new View(), |
|
210 | + $util, |
|
211 | + new ArrayCache() |
|
212 | + ); |
|
213 | + }); |
|
214 | + |
|
215 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
216 | + $util = new Encryption\Util( |
|
217 | + new View(), |
|
218 | + $c->getUserManager(), |
|
219 | + $c->getGroupManager(), |
|
220 | + $c->getConfig() |
|
221 | + ); |
|
222 | + return new Encryption\File( |
|
223 | + $util, |
|
224 | + $c->getRootFolder(), |
|
225 | + $c->getShareManager() |
|
226 | + ); |
|
227 | + }); |
|
228 | + |
|
229 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
230 | + $view = new View(); |
|
231 | + $util = new Encryption\Util( |
|
232 | + $view, |
|
233 | + $c->getUserManager(), |
|
234 | + $c->getGroupManager(), |
|
235 | + $c->getConfig() |
|
236 | + ); |
|
237 | + |
|
238 | + return new Encryption\Keys\Storage($view, $util); |
|
239 | + }); |
|
240 | + $this->registerService('TagMapper', function (Server $c) { |
|
241 | + return new TagMapper($c->getDatabaseConnection()); |
|
242 | + }); |
|
243 | + |
|
244 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
245 | + $tagMapper = $c->query('TagMapper'); |
|
246 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
247 | + }); |
|
248 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
249 | + |
|
250 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
251 | + $config = $c->getConfig(); |
|
252 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
253 | + return new $factoryClass($this); |
|
254 | + }); |
|
255 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
256 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
257 | + }); |
|
258 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
259 | + |
|
260 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
261 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
262 | + }); |
|
263 | + $this->registerService('RootFolder', function (Server $c) { |
|
264 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
265 | + $view = new View(); |
|
266 | + $root = new Root( |
|
267 | + $manager, |
|
268 | + $view, |
|
269 | + null, |
|
270 | + $c->getUserMountCache(), |
|
271 | + $this->getLogger(), |
|
272 | + $this->getUserManager() |
|
273 | + ); |
|
274 | + $connector = new HookConnector($root, $view); |
|
275 | + $connector->viewToNode(); |
|
276 | + |
|
277 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
278 | + $previewConnector->connectWatcher(); |
|
279 | + |
|
280 | + return $root; |
|
281 | + }); |
|
282 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
283 | + |
|
284 | + $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
285 | + return new LazyRoot(function () use ($c) { |
|
286 | + return $c->query('RootFolder'); |
|
287 | + }); |
|
288 | + }); |
|
289 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
290 | + |
|
291 | + $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
292 | + $config = $c->getConfig(); |
|
293 | + return new \OC\User\Manager($config); |
|
294 | + }); |
|
295 | + $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
296 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
297 | + |
|
298 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
299 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
300 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
301 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
302 | + }); |
|
303 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
304 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
305 | + }); |
|
306 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
307 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
308 | + }); |
|
309 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
310 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
311 | + }); |
|
312 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
313 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
314 | + }); |
|
315 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
316 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
317 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
318 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
319 | + }); |
|
320 | + return $groupManager; |
|
321 | + }); |
|
322 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
323 | + |
|
324 | + $this->registerService(Store::class, function (Server $c) { |
|
325 | + $session = $c->getSession(); |
|
326 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
327 | + $tokenProvider = $c->query(IProvider::class); |
|
328 | + } else { |
|
329 | + $tokenProvider = null; |
|
330 | + } |
|
331 | + $logger = $c->getLogger(); |
|
332 | + return new Store($session, $logger, $tokenProvider); |
|
333 | + }); |
|
334 | + $this->registerAlias(IStore::class, Store::class); |
|
335 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
336 | + $dbConnection = $c->getDatabaseConnection(); |
|
337 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
338 | + }); |
|
339 | + $this->registerService(Authentication\Token\DefaultTokenProvider::class, function (Server $c) { |
|
340 | + $mapper = $c->query(Authentication\Token\DefaultTokenMapper::class); |
|
341 | + $crypto = $c->getCrypto(); |
|
342 | + $config = $c->getConfig(); |
|
343 | + $logger = $c->getLogger(); |
|
344 | + $timeFactory = new TimeFactory(); |
|
345 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
346 | + }); |
|
347 | + $this->registerAlias(IProvider::class, Authentication\Token\DefaultTokenProvider::class); |
|
348 | + |
|
349 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
350 | + $manager = $c->getUserManager(); |
|
351 | + $session = new \OC\Session\Memory(''); |
|
352 | + $timeFactory = new TimeFactory(); |
|
353 | + // Token providers might require a working database. This code |
|
354 | + // might however be called when ownCloud is not yet setup. |
|
355 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
356 | + $defaultTokenProvider = $c->query(IProvider::class); |
|
357 | + } else { |
|
358 | + $defaultTokenProvider = null; |
|
359 | + } |
|
360 | + |
|
361 | + $dispatcher = $c->getEventDispatcher(); |
|
362 | + |
|
363 | + $userSession = new \OC\User\Session( |
|
364 | + $manager, |
|
365 | + $session, |
|
366 | + $timeFactory, |
|
367 | + $defaultTokenProvider, |
|
368 | + $c->getConfig(), |
|
369 | + $c->getSecureRandom(), |
|
370 | + $c->getLockdownManager(), |
|
371 | + $c->getLogger() |
|
372 | + ); |
|
373 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
374 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
375 | + }); |
|
376 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
377 | + /** @var $user \OC\User\User */ |
|
378 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
379 | + }); |
|
380 | + $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
381 | + /** @var $user \OC\User\User */ |
|
382 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
383 | + $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
384 | + }); |
|
385 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
386 | + /** @var $user \OC\User\User */ |
|
387 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
388 | + }); |
|
389 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
390 | + /** @var $user \OC\User\User */ |
|
391 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
392 | + }); |
|
393 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
394 | + /** @var $user \OC\User\User */ |
|
395 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
396 | + }); |
|
397 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
398 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
399 | + }); |
|
400 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
401 | + /** @var $user \OC\User\User */ |
|
402 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
403 | + }); |
|
404 | + $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
405 | + /** @var $user \OC\User\User */ |
|
406 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
407 | + }); |
|
408 | + $userSession->listen('\OC\User', 'logout', function () { |
|
409 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
410 | + }); |
|
411 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
412 | + /** @var $user \OC\User\User */ |
|
413 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
414 | + $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
415 | + }); |
|
416 | + return $userSession; |
|
417 | + }); |
|
418 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
419 | + |
|
420 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
421 | + return new \OC\Authentication\TwoFactorAuth\Manager( |
|
422 | + $c->getAppManager(), |
|
423 | + $c->getSession(), |
|
424 | + $c->getConfig(), |
|
425 | + $c->getActivityManager(), |
|
426 | + $c->getLogger(), |
|
427 | + $c->query(IProvider::class), |
|
428 | + $c->query(ITimeFactory::class), |
|
429 | + $c->query(EventDispatcherInterface::class) |
|
430 | + ); |
|
431 | + }); |
|
432 | + |
|
433 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
434 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
435 | + |
|
436 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
437 | + return new \OC\AllConfig( |
|
438 | + $c->getSystemConfig() |
|
439 | + ); |
|
440 | + }); |
|
441 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
442 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
443 | + |
|
444 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
445 | + return new \OC\SystemConfig($config); |
|
446 | + }); |
|
447 | + |
|
448 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
449 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
450 | + }); |
|
451 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
452 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
453 | + |
|
454 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
455 | + return new \OC\L10N\Factory( |
|
456 | + $c->getConfig(), |
|
457 | + $c->getRequest(), |
|
458 | + $c->getUserSession(), |
|
459 | + \OC::$SERVERROOT |
|
460 | + ); |
|
461 | + }); |
|
462 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
463 | + |
|
464 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
465 | + $config = $c->getConfig(); |
|
466 | + $cacheFactory = $c->getMemCacheFactory(); |
|
467 | + $request = $c->getRequest(); |
|
468 | + return new \OC\URLGenerator( |
|
469 | + $config, |
|
470 | + $cacheFactory, |
|
471 | + $request |
|
472 | + ); |
|
473 | + }); |
|
474 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
475 | + |
|
476 | + $this->registerAlias('AppFetcher', AppFetcher::class); |
|
477 | + $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
478 | + |
|
479 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
480 | + return new Cache\File(); |
|
481 | + }); |
|
482 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
483 | + |
|
484 | + $this->registerService(Factory::class, function (Server $c) { |
|
485 | + |
|
486 | + $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
487 | + ArrayCache::class, |
|
488 | + ArrayCache::class, |
|
489 | + ArrayCache::class |
|
490 | + ); |
|
491 | + $config = $c->getConfig(); |
|
492 | + $request = $c->getRequest(); |
|
493 | + $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
494 | + |
|
495 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
496 | + $v = \OC_App::getAppVersions(); |
|
497 | + $v['core'] = implode(',', \OC_Util::getVersion()); |
|
498 | + $version = implode(',', $v); |
|
499 | + $instanceId = \OC_Util::getInstanceId(); |
|
500 | + $path = \OC::$SERVERROOT; |
|
501 | + $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
502 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
503 | + $config->getSystemValue('memcache.local', null), |
|
504 | + $config->getSystemValue('memcache.distributed', null), |
|
505 | + $config->getSystemValue('memcache.locking', null) |
|
506 | + ); |
|
507 | + } |
|
508 | + return $arrayCacheFactory; |
|
509 | + |
|
510 | + }); |
|
511 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
512 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
513 | + |
|
514 | + $this->registerService('RedisFactory', function (Server $c) { |
|
515 | + $systemConfig = $c->getSystemConfig(); |
|
516 | + return new RedisFactory($systemConfig); |
|
517 | + }); |
|
518 | + |
|
519 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
520 | + return new \OC\Activity\Manager( |
|
521 | + $c->getRequest(), |
|
522 | + $c->getUserSession(), |
|
523 | + $c->getConfig(), |
|
524 | + $c->query(IValidator::class) |
|
525 | + ); |
|
526 | + }); |
|
527 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
528 | + |
|
529 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
530 | + return new \OC\Activity\EventMerger( |
|
531 | + $c->getL10N('lib') |
|
532 | + ); |
|
533 | + }); |
|
534 | + $this->registerAlias(IValidator::class, Validator::class); |
|
535 | + |
|
536 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
537 | + return new AvatarManager( |
|
538 | + $c->query(\OC\User\Manager::class), |
|
539 | + $c->getAppDataDir('avatar'), |
|
540 | + $c->getL10N('lib'), |
|
541 | + $c->getLogger(), |
|
542 | + $c->getConfig() |
|
543 | + ); |
|
544 | + }); |
|
545 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
546 | + |
|
547 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
548 | + |
|
549 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
550 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
551 | + $factory = new LogFactory($c, $this->getSystemConfig()); |
|
552 | + $logger = $factory->get($logType); |
|
553 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
554 | + |
|
555 | + return new Log($logger, $this->getSystemConfig(), null, $registry); |
|
556 | + }); |
|
557 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
558 | + |
|
559 | + $this->registerService(ILogFactory::class, function (Server $c) { |
|
560 | + return new LogFactory($c, $this->getSystemConfig()); |
|
561 | + }); |
|
562 | + |
|
563 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
564 | + $config = $c->getConfig(); |
|
565 | + return new \OC\BackgroundJob\JobList( |
|
566 | + $c->getDatabaseConnection(), |
|
567 | + $config, |
|
568 | + new TimeFactory() |
|
569 | + ); |
|
570 | + }); |
|
571 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
572 | + |
|
573 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
574 | + $cacheFactory = $c->getMemCacheFactory(); |
|
575 | + $logger = $c->getLogger(); |
|
576 | + if ($cacheFactory->isLocalCacheAvailable()) { |
|
577 | + $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
578 | + } else { |
|
579 | + $router = new \OC\Route\Router($logger); |
|
580 | + } |
|
581 | + return $router; |
|
582 | + }); |
|
583 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
584 | + |
|
585 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
586 | + return new Search(); |
|
587 | + }); |
|
588 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
589 | + |
|
590 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
591 | + return new \OC\Security\RateLimiting\Limiter( |
|
592 | + $this->getUserSession(), |
|
593 | + $this->getRequest(), |
|
594 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
595 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
596 | + ); |
|
597 | + }); |
|
598 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
599 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
600 | + $this->getMemCacheFactory(), |
|
601 | + new \OC\AppFramework\Utility\TimeFactory() |
|
602 | + ); |
|
603 | + }); |
|
604 | + |
|
605 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
606 | + return new SecureRandom(); |
|
607 | + }); |
|
608 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
609 | + |
|
610 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
611 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
612 | + }); |
|
613 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
614 | + |
|
615 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
616 | + return new Hasher($c->getConfig()); |
|
617 | + }); |
|
618 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
619 | + |
|
620 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
621 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
622 | + }); |
|
623 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
624 | + |
|
625 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
626 | + $systemConfig = $c->getSystemConfig(); |
|
627 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
628 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
629 | + if (!$factory->isValidType($type)) { |
|
630 | + throw new \OC\DatabaseException('Invalid database type'); |
|
631 | + } |
|
632 | + $connectionParams = $factory->createConnectionParams(); |
|
633 | + $connection = $factory->getConnection($type, $connectionParams); |
|
634 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
635 | + return $connection; |
|
636 | + }); |
|
637 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
638 | + |
|
639 | + |
|
640 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
641 | + $user = \OC_User::getUser(); |
|
642 | + $uid = $user ? $user : null; |
|
643 | + return new ClientService( |
|
644 | + $c->getConfig(), |
|
645 | + new \OC\Security\CertificateManager( |
|
646 | + $uid, |
|
647 | + new View(), |
|
648 | + $c->getConfig(), |
|
649 | + $c->getLogger(), |
|
650 | + $c->getSecureRandom() |
|
651 | + ) |
|
652 | + ); |
|
653 | + }); |
|
654 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
655 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
656 | + $eventLogger = new EventLogger(); |
|
657 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
658 | + // In debug mode, module is being activated by default |
|
659 | + $eventLogger->activate(); |
|
660 | + } |
|
661 | + return $eventLogger; |
|
662 | + }); |
|
663 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
664 | + |
|
665 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
666 | + $queryLogger = new QueryLogger(); |
|
667 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
668 | + // In debug mode, module is being activated by default |
|
669 | + $queryLogger->activate(); |
|
670 | + } |
|
671 | + return $queryLogger; |
|
672 | + }); |
|
673 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
674 | + |
|
675 | + $this->registerService(TempManager::class, function (Server $c) { |
|
676 | + return new TempManager( |
|
677 | + $c->getLogger(), |
|
678 | + $c->getConfig() |
|
679 | + ); |
|
680 | + }); |
|
681 | + $this->registerAlias('TempManager', TempManager::class); |
|
682 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
683 | + |
|
684 | + $this->registerService(AppManager::class, function (Server $c) { |
|
685 | + return new \OC\App\AppManager( |
|
686 | + $c->getUserSession(), |
|
687 | + $c->query(\OC\AppConfig::class), |
|
688 | + $c->getGroupManager(), |
|
689 | + $c->getMemCacheFactory(), |
|
690 | + $c->getEventDispatcher() |
|
691 | + ); |
|
692 | + }); |
|
693 | + $this->registerAlias('AppManager', AppManager::class); |
|
694 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
695 | + |
|
696 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
697 | + return new DateTimeZone( |
|
698 | + $c->getConfig(), |
|
699 | + $c->getSession() |
|
700 | + ); |
|
701 | + }); |
|
702 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
703 | + |
|
704 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
705 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
706 | + |
|
707 | + return new DateTimeFormatter( |
|
708 | + $c->getDateTimeZone()->getTimeZone(), |
|
709 | + $c->getL10N('lib', $language) |
|
710 | + ); |
|
711 | + }); |
|
712 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
713 | + |
|
714 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
715 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
716 | + $listener = new UserMountCacheListener($mountCache); |
|
717 | + $listener->listen($c->getUserManager()); |
|
718 | + return $mountCache; |
|
719 | + }); |
|
720 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
721 | + |
|
722 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
723 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
724 | + $mountCache = $c->query('UserMountCache'); |
|
725 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
726 | + |
|
727 | + // builtin providers |
|
728 | + |
|
729 | + $config = $c->getConfig(); |
|
730 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
731 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
732 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
733 | + |
|
734 | + return $manager; |
|
735 | + }); |
|
736 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
737 | + |
|
738 | + $this->registerService('IniWrapper', function ($c) { |
|
739 | + return new IniGetWrapper(); |
|
740 | + }); |
|
741 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
742 | + $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
743 | + if ($busClass) { |
|
744 | + list($app, $class) = explode('::', $busClass, 2); |
|
745 | + if ($c->getAppManager()->isInstalled($app)) { |
|
746 | + \OC_App::loadApp($app); |
|
747 | + return $c->query($class); |
|
748 | + } else { |
|
749 | + throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
750 | + } |
|
751 | + } else { |
|
752 | + $jobList = $c->getJobList(); |
|
753 | + return new CronBus($jobList); |
|
754 | + } |
|
755 | + }); |
|
756 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
757 | + return new TrustedDomainHelper($this->getConfig()); |
|
758 | + }); |
|
759 | + $this->registerService('Throttler', function (Server $c) { |
|
760 | + return new Throttler( |
|
761 | + $c->getDatabaseConnection(), |
|
762 | + new TimeFactory(), |
|
763 | + $c->getLogger(), |
|
764 | + $c->getConfig() |
|
765 | + ); |
|
766 | + }); |
|
767 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
768 | + // IConfig and IAppManager requires a working database. This code |
|
769 | + // might however be called when ownCloud is not yet setup. |
|
770 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
771 | + $config = $c->getConfig(); |
|
772 | + $appManager = $c->getAppManager(); |
|
773 | + } else { |
|
774 | + $config = null; |
|
775 | + $appManager = null; |
|
776 | + } |
|
777 | + |
|
778 | + return new Checker( |
|
779 | + new EnvironmentHelper(), |
|
780 | + new FileAccessHelper(), |
|
781 | + new AppLocator(), |
|
782 | + $config, |
|
783 | + $c->getMemCacheFactory(), |
|
784 | + $appManager, |
|
785 | + $c->getTempManager() |
|
786 | + ); |
|
787 | + }); |
|
788 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
789 | + if (isset($this['urlParams'])) { |
|
790 | + $urlParams = $this['urlParams']; |
|
791 | + } else { |
|
792 | + $urlParams = []; |
|
793 | + } |
|
794 | + |
|
795 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
796 | + && in_array('fakeinput', stream_get_wrappers()) |
|
797 | + ) { |
|
798 | + $stream = 'fakeinput://data'; |
|
799 | + } else { |
|
800 | + $stream = 'php://input'; |
|
801 | + } |
|
802 | + |
|
803 | + return new Request( |
|
804 | + [ |
|
805 | + 'get' => $_GET, |
|
806 | + 'post' => $_POST, |
|
807 | + 'files' => $_FILES, |
|
808 | + 'server' => $_SERVER, |
|
809 | + 'env' => $_ENV, |
|
810 | + 'cookies' => $_COOKIE, |
|
811 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
812 | + ? $_SERVER['REQUEST_METHOD'] |
|
813 | + : '', |
|
814 | + 'urlParams' => $urlParams, |
|
815 | + ], |
|
816 | + $this->getSecureRandom(), |
|
817 | + $this->getConfig(), |
|
818 | + $this->getCsrfTokenManager(), |
|
819 | + $stream |
|
820 | + ); |
|
821 | + }); |
|
822 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
823 | + |
|
824 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
825 | + return new Mailer( |
|
826 | + $c->getConfig(), |
|
827 | + $c->getLogger(), |
|
828 | + $c->query(Defaults::class), |
|
829 | + $c->getURLGenerator(), |
|
830 | + $c->getL10N('lib') |
|
831 | + ); |
|
832 | + }); |
|
833 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
834 | + |
|
835 | + $this->registerService('LDAPProvider', function (Server $c) { |
|
836 | + $config = $c->getConfig(); |
|
837 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
838 | + if (is_null($factoryClass)) { |
|
839 | + throw new \Exception('ldapProviderFactory not set'); |
|
840 | + } |
|
841 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
842 | + $factory = new $factoryClass($this); |
|
843 | + return $factory->getLDAPProvider(); |
|
844 | + }); |
|
845 | + $this->registerService(ILockingProvider::class, function (Server $c) { |
|
846 | + $ini = $c->getIniWrapper(); |
|
847 | + $config = $c->getConfig(); |
|
848 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
849 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
850 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
851 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
852 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
853 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
854 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
855 | + } |
|
856 | + return new DBLockingProvider( |
|
857 | + $c->getDatabaseConnection(), |
|
858 | + $c->getLogger(), |
|
859 | + new TimeFactory(), |
|
860 | + $ttl, |
|
861 | + !\OC::$CLI |
|
862 | + ); |
|
863 | + } |
|
864 | + return new NoopLockingProvider(); |
|
865 | + }); |
|
866 | + $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
867 | + |
|
868 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
869 | + return new \OC\Files\Mount\Manager(); |
|
870 | + }); |
|
871 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
872 | + |
|
873 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
874 | + return new \OC\Files\Type\Detection( |
|
875 | + $c->getURLGenerator(), |
|
876 | + \OC::$configDir, |
|
877 | + \OC::$SERVERROOT . '/resources/config/' |
|
878 | + ); |
|
879 | + }); |
|
880 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
881 | + |
|
882 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
883 | + return new \OC\Files\Type\Loader( |
|
884 | + $c->getDatabaseConnection() |
|
885 | + ); |
|
886 | + }); |
|
887 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
888 | + $this->registerService(BundleFetcher::class, function () { |
|
889 | + return new BundleFetcher($this->getL10N('lib')); |
|
890 | + }); |
|
891 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
892 | + return new Manager( |
|
893 | + $c->query(IValidator::class) |
|
894 | + ); |
|
895 | + }); |
|
896 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
897 | + |
|
898 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
899 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
900 | + $manager->registerCapability(function () use ($c) { |
|
901 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
902 | + }); |
|
903 | + $manager->registerCapability(function () use ($c) { |
|
904 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
905 | + }); |
|
906 | + return $manager; |
|
907 | + }); |
|
908 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
909 | + |
|
910 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
911 | + $config = $c->getConfig(); |
|
912 | + $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
913 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
914 | + $factory = new $factoryClass($this); |
|
915 | + $manager = $factory->getManager(); |
|
916 | + |
|
917 | + $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
918 | + $manager = $c->getUserManager(); |
|
919 | + $user = $manager->get($id); |
|
920 | + if(is_null($user)) { |
|
921 | + $l = $c->getL10N('core'); |
|
922 | + $displayName = $l->t('Unknown user'); |
|
923 | + } else { |
|
924 | + $displayName = $user->getDisplayName(); |
|
925 | + } |
|
926 | + return $displayName; |
|
927 | + }); |
|
928 | + |
|
929 | + return $manager; |
|
930 | + }); |
|
931 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
932 | + |
|
933 | + $this->registerService('ThemingDefaults', function (Server $c) { |
|
934 | + /* |
|
935 | 935 | * Dark magic for autoloader. |
936 | 936 | * If we do a class_exists it will try to load the class which will |
937 | 937 | * make composer cache the result. Resulting in errors when enabling |
938 | 938 | * the theming app. |
939 | 939 | */ |
940 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
941 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
942 | - $classExists = true; |
|
943 | - } else { |
|
944 | - $classExists = false; |
|
945 | - } |
|
946 | - |
|
947 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
948 | - return new ThemingDefaults( |
|
949 | - $c->getConfig(), |
|
950 | - $c->getL10N('theming'), |
|
951 | - $c->getURLGenerator(), |
|
952 | - $c->getMemCacheFactory(), |
|
953 | - new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
954 | - new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator()), |
|
955 | - $c->getAppManager() |
|
956 | - ); |
|
957 | - } |
|
958 | - return new \OC_Defaults(); |
|
959 | - }); |
|
960 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
961 | - /** @var Factory $cacheFactory */ |
|
962 | - $cacheFactory = $c->query(Factory::class); |
|
963 | - return new SCSSCacher( |
|
964 | - $c->getLogger(), |
|
965 | - $c->query(\OC\Files\AppData\Factory::class), |
|
966 | - $c->getURLGenerator(), |
|
967 | - $c->getConfig(), |
|
968 | - $c->getThemingDefaults(), |
|
969 | - \OC::$SERVERROOT, |
|
970 | - $this->getMemCacheFactory() |
|
971 | - ); |
|
972 | - }); |
|
973 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
974 | - /** @var Factory $cacheFactory */ |
|
975 | - $cacheFactory = $c->query(Factory::class); |
|
976 | - return new JSCombiner( |
|
977 | - $c->getAppDataDir('js'), |
|
978 | - $c->getURLGenerator(), |
|
979 | - $this->getMemCacheFactory(), |
|
980 | - $c->getSystemConfig(), |
|
981 | - $c->getLogger() |
|
982 | - ); |
|
983 | - }); |
|
984 | - $this->registerService(EventDispatcher::class, function () { |
|
985 | - return new EventDispatcher(); |
|
986 | - }); |
|
987 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
988 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
989 | - |
|
990 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
991 | - // FIXME: Instantiiated here due to cyclic dependency |
|
992 | - $request = new Request( |
|
993 | - [ |
|
994 | - 'get' => $_GET, |
|
995 | - 'post' => $_POST, |
|
996 | - 'files' => $_FILES, |
|
997 | - 'server' => $_SERVER, |
|
998 | - 'env' => $_ENV, |
|
999 | - 'cookies' => $_COOKIE, |
|
1000 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
1001 | - ? $_SERVER['REQUEST_METHOD'] |
|
1002 | - : null, |
|
1003 | - ], |
|
1004 | - $c->getSecureRandom(), |
|
1005 | - $c->getConfig() |
|
1006 | - ); |
|
1007 | - |
|
1008 | - return new CryptoWrapper( |
|
1009 | - $c->getConfig(), |
|
1010 | - $c->getCrypto(), |
|
1011 | - $c->getSecureRandom(), |
|
1012 | - $request |
|
1013 | - ); |
|
1014 | - }); |
|
1015 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1016 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1017 | - |
|
1018 | - return new CsrfTokenManager( |
|
1019 | - $tokenGenerator, |
|
1020 | - $c->query(SessionStorage::class) |
|
1021 | - ); |
|
1022 | - }); |
|
1023 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
1024 | - return new SessionStorage($c->getSession()); |
|
1025 | - }); |
|
1026 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1027 | - return new ContentSecurityPolicyManager(); |
|
1028 | - }); |
|
1029 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1030 | - |
|
1031 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1032 | - return new ContentSecurityPolicyNonceManager( |
|
1033 | - $c->getCsrfTokenManager(), |
|
1034 | - $c->getRequest() |
|
1035 | - ); |
|
1036 | - }); |
|
1037 | - |
|
1038 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1039 | - $config = $c->getConfig(); |
|
1040 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
1041 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
1042 | - $factory = new $factoryClass($this); |
|
1043 | - |
|
1044 | - $manager = new \OC\Share20\Manager( |
|
1045 | - $c->getLogger(), |
|
1046 | - $c->getConfig(), |
|
1047 | - $c->getSecureRandom(), |
|
1048 | - $c->getHasher(), |
|
1049 | - $c->getMountManager(), |
|
1050 | - $c->getGroupManager(), |
|
1051 | - $c->getL10N('lib'), |
|
1052 | - $c->getL10NFactory(), |
|
1053 | - $factory, |
|
1054 | - $c->getUserManager(), |
|
1055 | - $c->getLazyRootFolder(), |
|
1056 | - $c->getEventDispatcher(), |
|
1057 | - $c->getMailer(), |
|
1058 | - $c->getURLGenerator(), |
|
1059 | - $c->getThemingDefaults() |
|
1060 | - ); |
|
1061 | - |
|
1062 | - return $manager; |
|
1063 | - }); |
|
1064 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1065 | - |
|
1066 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1067 | - $instance = new Collaboration\Collaborators\Search($c); |
|
1068 | - |
|
1069 | - // register default plugins |
|
1070 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1071 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1072 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1073 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1074 | - |
|
1075 | - return $instance; |
|
1076 | - }); |
|
1077 | - $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1078 | - |
|
1079 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1080 | - |
|
1081 | - $this->registerService('SettingsManager', function (Server $c) { |
|
1082 | - $manager = new \OC\Settings\Manager( |
|
1083 | - $c->getLogger(), |
|
1084 | - $c->getDatabaseConnection(), |
|
1085 | - $c->getL10N('lib'), |
|
1086 | - $c->getConfig(), |
|
1087 | - $c->getEncryptionManager(), |
|
1088 | - $c->getUserManager(), |
|
1089 | - $c->getLockingProvider(), |
|
1090 | - $c->getRequest(), |
|
1091 | - $c->getURLGenerator(), |
|
1092 | - $c->query(AccountManager::class), |
|
1093 | - $c->getGroupManager(), |
|
1094 | - $c->getL10NFactory(), |
|
1095 | - $c->getAppManager() |
|
1096 | - ); |
|
1097 | - return $manager; |
|
1098 | - }); |
|
1099 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1100 | - return new \OC\Files\AppData\Factory( |
|
1101 | - $c->getRootFolder(), |
|
1102 | - $c->getSystemConfig() |
|
1103 | - ); |
|
1104 | - }); |
|
1105 | - |
|
1106 | - $this->registerService('LockdownManager', function (Server $c) { |
|
1107 | - return new LockdownManager(function () use ($c) { |
|
1108 | - return $c->getSession(); |
|
1109 | - }); |
|
1110 | - }); |
|
1111 | - |
|
1112 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1113 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1114 | - }); |
|
1115 | - |
|
1116 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1117 | - return new CloudIdManager(); |
|
1118 | - }); |
|
1119 | - |
|
1120 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1121 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1122 | - |
|
1123 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1124 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1125 | - |
|
1126 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1127 | - return new Defaults( |
|
1128 | - $c->getThemingDefaults() |
|
1129 | - ); |
|
1130 | - }); |
|
1131 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1132 | - |
|
1133 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1134 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1135 | - }); |
|
1136 | - |
|
1137 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
1138 | - return new ShareHelper( |
|
1139 | - $c->query(\OCP\Share\IManager::class) |
|
1140 | - ); |
|
1141 | - }); |
|
1142 | - |
|
1143 | - $this->registerService(Installer::class, function(Server $c) { |
|
1144 | - return new Installer( |
|
1145 | - $c->getAppFetcher(), |
|
1146 | - $c->getHTTPClientService(), |
|
1147 | - $c->getTempManager(), |
|
1148 | - $c->getLogger(), |
|
1149 | - $c->getConfig() |
|
1150 | - ); |
|
1151 | - }); |
|
1152 | - |
|
1153 | - $this->registerService(IApiFactory::class, function(Server $c) { |
|
1154 | - return new ApiFactory($c->getHTTPClientService()); |
|
1155 | - }); |
|
1156 | - |
|
1157 | - $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1158 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
1159 | - return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1160 | - }); |
|
1161 | - |
|
1162 | - $this->registerService(IContactsStore::class, function(Server $c) { |
|
1163 | - return new ContactsStore( |
|
1164 | - $c->getContactsManager(), |
|
1165 | - $c->getConfig(), |
|
1166 | - $c->getUserManager(), |
|
1167 | - $c->getGroupManager() |
|
1168 | - ); |
|
1169 | - }); |
|
1170 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1171 | - |
|
1172 | - $this->connectDispatcher(); |
|
1173 | - } |
|
1174 | - |
|
1175 | - /** |
|
1176 | - * @return \OCP\Calendar\IManager |
|
1177 | - */ |
|
1178 | - public function getCalendarManager() { |
|
1179 | - return $this->query('CalendarManager'); |
|
1180 | - } |
|
1181 | - |
|
1182 | - private function connectDispatcher() { |
|
1183 | - $dispatcher = $this->getEventDispatcher(); |
|
1184 | - |
|
1185 | - // Delete avatar on user deletion |
|
1186 | - $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1187 | - $logger = $this->getLogger(); |
|
1188 | - $manager = $this->getAvatarManager(); |
|
1189 | - /** @var IUser $user */ |
|
1190 | - $user = $e->getSubject(); |
|
1191 | - |
|
1192 | - try { |
|
1193 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1194 | - $avatar->remove(); |
|
1195 | - } catch (NotFoundException $e) { |
|
1196 | - // no avatar to remove |
|
1197 | - } catch (\Exception $e) { |
|
1198 | - // Ignore exceptions |
|
1199 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1200 | - } |
|
1201 | - }); |
|
1202 | - |
|
1203 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1204 | - $manager = $this->getAvatarManager(); |
|
1205 | - /** @var IUser $user */ |
|
1206 | - $user = $e->getSubject(); |
|
1207 | - $feature = $e->getArgument('feature'); |
|
1208 | - $oldValue = $e->getArgument('oldValue'); |
|
1209 | - $value = $e->getArgument('value'); |
|
1210 | - |
|
1211 | - try { |
|
1212 | - $avatar = $manager->getAvatar($user->getUID()); |
|
1213 | - $avatar->userChanged($feature, $oldValue, $value); |
|
1214 | - } catch (NotFoundException $e) { |
|
1215 | - // no avatar to remove |
|
1216 | - } |
|
1217 | - }); |
|
1218 | - } |
|
1219 | - |
|
1220 | - /** |
|
1221 | - * @return \OCP\Contacts\IManager |
|
1222 | - */ |
|
1223 | - public function getContactsManager() { |
|
1224 | - return $this->query('ContactsManager'); |
|
1225 | - } |
|
1226 | - |
|
1227 | - /** |
|
1228 | - * @return \OC\Encryption\Manager |
|
1229 | - */ |
|
1230 | - public function getEncryptionManager() { |
|
1231 | - return $this->query('EncryptionManager'); |
|
1232 | - } |
|
1233 | - |
|
1234 | - /** |
|
1235 | - * @return \OC\Encryption\File |
|
1236 | - */ |
|
1237 | - public function getEncryptionFilesHelper() { |
|
1238 | - return $this->query('EncryptionFileHelper'); |
|
1239 | - } |
|
1240 | - |
|
1241 | - /** |
|
1242 | - * @return \OCP\Encryption\Keys\IStorage |
|
1243 | - */ |
|
1244 | - public function getEncryptionKeyStorage() { |
|
1245 | - return $this->query('EncryptionKeyStorage'); |
|
1246 | - } |
|
1247 | - |
|
1248 | - /** |
|
1249 | - * The current request object holding all information about the request |
|
1250 | - * currently being processed is returned from this method. |
|
1251 | - * In case the current execution was not initiated by a web request null is returned |
|
1252 | - * |
|
1253 | - * @return \OCP\IRequest |
|
1254 | - */ |
|
1255 | - public function getRequest() { |
|
1256 | - return $this->query('Request'); |
|
1257 | - } |
|
1258 | - |
|
1259 | - /** |
|
1260 | - * Returns the preview manager which can create preview images for a given file |
|
1261 | - * |
|
1262 | - * @return \OCP\IPreview |
|
1263 | - */ |
|
1264 | - public function getPreviewManager() { |
|
1265 | - return $this->query('PreviewManager'); |
|
1266 | - } |
|
1267 | - |
|
1268 | - /** |
|
1269 | - * Returns the tag manager which can get and set tags for different object types |
|
1270 | - * |
|
1271 | - * @see \OCP\ITagManager::load() |
|
1272 | - * @return \OCP\ITagManager |
|
1273 | - */ |
|
1274 | - public function getTagManager() { |
|
1275 | - return $this->query('TagManager'); |
|
1276 | - } |
|
1277 | - |
|
1278 | - /** |
|
1279 | - * Returns the system-tag manager |
|
1280 | - * |
|
1281 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1282 | - * |
|
1283 | - * @since 9.0.0 |
|
1284 | - */ |
|
1285 | - public function getSystemTagManager() { |
|
1286 | - return $this->query('SystemTagManager'); |
|
1287 | - } |
|
1288 | - |
|
1289 | - /** |
|
1290 | - * Returns the system-tag object mapper |
|
1291 | - * |
|
1292 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1293 | - * |
|
1294 | - * @since 9.0.0 |
|
1295 | - */ |
|
1296 | - public function getSystemTagObjectMapper() { |
|
1297 | - return $this->query('SystemTagObjectMapper'); |
|
1298 | - } |
|
1299 | - |
|
1300 | - /** |
|
1301 | - * Returns the avatar manager, used for avatar functionality |
|
1302 | - * |
|
1303 | - * @return \OCP\IAvatarManager |
|
1304 | - */ |
|
1305 | - public function getAvatarManager() { |
|
1306 | - return $this->query('AvatarManager'); |
|
1307 | - } |
|
1308 | - |
|
1309 | - /** |
|
1310 | - * Returns the root folder of ownCloud's data directory |
|
1311 | - * |
|
1312 | - * @return \OCP\Files\IRootFolder |
|
1313 | - */ |
|
1314 | - public function getRootFolder() { |
|
1315 | - return $this->query('LazyRootFolder'); |
|
1316 | - } |
|
1317 | - |
|
1318 | - /** |
|
1319 | - * Returns the root folder of ownCloud's data directory |
|
1320 | - * This is the lazy variant so this gets only initialized once it |
|
1321 | - * is actually used. |
|
1322 | - * |
|
1323 | - * @return \OCP\Files\IRootFolder |
|
1324 | - */ |
|
1325 | - public function getLazyRootFolder() { |
|
1326 | - return $this->query('LazyRootFolder'); |
|
1327 | - } |
|
1328 | - |
|
1329 | - /** |
|
1330 | - * Returns a view to ownCloud's files folder |
|
1331 | - * |
|
1332 | - * @param string $userId user ID |
|
1333 | - * @return \OCP\Files\Folder|null |
|
1334 | - */ |
|
1335 | - public function getUserFolder($userId = null) { |
|
1336 | - if ($userId === null) { |
|
1337 | - $user = $this->getUserSession()->getUser(); |
|
1338 | - if (!$user) { |
|
1339 | - return null; |
|
1340 | - } |
|
1341 | - $userId = $user->getUID(); |
|
1342 | - } |
|
1343 | - $root = $this->getRootFolder(); |
|
1344 | - return $root->getUserFolder($userId); |
|
1345 | - } |
|
1346 | - |
|
1347 | - /** |
|
1348 | - * Returns an app-specific view in ownClouds data directory |
|
1349 | - * |
|
1350 | - * @return \OCP\Files\Folder |
|
1351 | - * @deprecated since 9.2.0 use IAppData |
|
1352 | - */ |
|
1353 | - public function getAppFolder() { |
|
1354 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1355 | - $root = $this->getRootFolder(); |
|
1356 | - if (!$root->nodeExists($dir)) { |
|
1357 | - $folder = $root->newFolder($dir); |
|
1358 | - } else { |
|
1359 | - $folder = $root->get($dir); |
|
1360 | - } |
|
1361 | - return $folder; |
|
1362 | - } |
|
1363 | - |
|
1364 | - /** |
|
1365 | - * @return \OC\User\Manager |
|
1366 | - */ |
|
1367 | - public function getUserManager() { |
|
1368 | - return $this->query('UserManager'); |
|
1369 | - } |
|
1370 | - |
|
1371 | - /** |
|
1372 | - * @return \OC\Group\Manager |
|
1373 | - */ |
|
1374 | - public function getGroupManager() { |
|
1375 | - return $this->query('GroupManager'); |
|
1376 | - } |
|
1377 | - |
|
1378 | - /** |
|
1379 | - * @return \OC\User\Session |
|
1380 | - */ |
|
1381 | - public function getUserSession() { |
|
1382 | - return $this->query('UserSession'); |
|
1383 | - } |
|
1384 | - |
|
1385 | - /** |
|
1386 | - * @return \OCP\ISession |
|
1387 | - */ |
|
1388 | - public function getSession() { |
|
1389 | - return $this->query('UserSession')->getSession(); |
|
1390 | - } |
|
1391 | - |
|
1392 | - /** |
|
1393 | - * @param \OCP\ISession $session |
|
1394 | - */ |
|
1395 | - public function setSession(\OCP\ISession $session) { |
|
1396 | - $this->query(SessionStorage::class)->setSession($session); |
|
1397 | - $this->query('UserSession')->setSession($session); |
|
1398 | - $this->query(Store::class)->setSession($session); |
|
1399 | - } |
|
1400 | - |
|
1401 | - /** |
|
1402 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1403 | - */ |
|
1404 | - public function getTwoFactorAuthManager() { |
|
1405 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1406 | - } |
|
1407 | - |
|
1408 | - /** |
|
1409 | - * @return \OC\NavigationManager |
|
1410 | - */ |
|
1411 | - public function getNavigationManager() { |
|
1412 | - return $this->query('NavigationManager'); |
|
1413 | - } |
|
1414 | - |
|
1415 | - /** |
|
1416 | - * @return \OCP\IConfig |
|
1417 | - */ |
|
1418 | - public function getConfig() { |
|
1419 | - return $this->query('AllConfig'); |
|
1420 | - } |
|
1421 | - |
|
1422 | - /** |
|
1423 | - * @return \OC\SystemConfig |
|
1424 | - */ |
|
1425 | - public function getSystemConfig() { |
|
1426 | - return $this->query('SystemConfig'); |
|
1427 | - } |
|
1428 | - |
|
1429 | - /** |
|
1430 | - * Returns the app config manager |
|
1431 | - * |
|
1432 | - * @return \OCP\IAppConfig |
|
1433 | - */ |
|
1434 | - public function getAppConfig() { |
|
1435 | - return $this->query('AppConfig'); |
|
1436 | - } |
|
1437 | - |
|
1438 | - /** |
|
1439 | - * @return \OCP\L10N\IFactory |
|
1440 | - */ |
|
1441 | - public function getL10NFactory() { |
|
1442 | - return $this->query('L10NFactory'); |
|
1443 | - } |
|
1444 | - |
|
1445 | - /** |
|
1446 | - * get an L10N instance |
|
1447 | - * |
|
1448 | - * @param string $app appid |
|
1449 | - * @param string $lang |
|
1450 | - * @return IL10N |
|
1451 | - */ |
|
1452 | - public function getL10N($app, $lang = null) { |
|
1453 | - return $this->getL10NFactory()->get($app, $lang); |
|
1454 | - } |
|
1455 | - |
|
1456 | - /** |
|
1457 | - * @return \OCP\IURLGenerator |
|
1458 | - */ |
|
1459 | - public function getURLGenerator() { |
|
1460 | - return $this->query('URLGenerator'); |
|
1461 | - } |
|
1462 | - |
|
1463 | - /** |
|
1464 | - * @return AppFetcher |
|
1465 | - */ |
|
1466 | - public function getAppFetcher() { |
|
1467 | - return $this->query(AppFetcher::class); |
|
1468 | - } |
|
1469 | - |
|
1470 | - /** |
|
1471 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1472 | - * getMemCacheFactory() instead. |
|
1473 | - * |
|
1474 | - * @return \OCP\ICache |
|
1475 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1476 | - */ |
|
1477 | - public function getCache() { |
|
1478 | - return $this->query('UserCache'); |
|
1479 | - } |
|
1480 | - |
|
1481 | - /** |
|
1482 | - * Returns an \OCP\CacheFactory instance |
|
1483 | - * |
|
1484 | - * @return \OCP\ICacheFactory |
|
1485 | - */ |
|
1486 | - public function getMemCacheFactory() { |
|
1487 | - return $this->query('MemCacheFactory'); |
|
1488 | - } |
|
1489 | - |
|
1490 | - /** |
|
1491 | - * Returns an \OC\RedisFactory instance |
|
1492 | - * |
|
1493 | - * @return \OC\RedisFactory |
|
1494 | - */ |
|
1495 | - public function getGetRedisFactory() { |
|
1496 | - return $this->query('RedisFactory'); |
|
1497 | - } |
|
1498 | - |
|
1499 | - |
|
1500 | - /** |
|
1501 | - * Returns the current session |
|
1502 | - * |
|
1503 | - * @return \OCP\IDBConnection |
|
1504 | - */ |
|
1505 | - public function getDatabaseConnection() { |
|
1506 | - return $this->query('DatabaseConnection'); |
|
1507 | - } |
|
1508 | - |
|
1509 | - /** |
|
1510 | - * Returns the activity manager |
|
1511 | - * |
|
1512 | - * @return \OCP\Activity\IManager |
|
1513 | - */ |
|
1514 | - public function getActivityManager() { |
|
1515 | - return $this->query('ActivityManager'); |
|
1516 | - } |
|
1517 | - |
|
1518 | - /** |
|
1519 | - * Returns an job list for controlling background jobs |
|
1520 | - * |
|
1521 | - * @return \OCP\BackgroundJob\IJobList |
|
1522 | - */ |
|
1523 | - public function getJobList() { |
|
1524 | - return $this->query('JobList'); |
|
1525 | - } |
|
1526 | - |
|
1527 | - /** |
|
1528 | - * Returns a logger instance |
|
1529 | - * |
|
1530 | - * @return \OCP\ILogger |
|
1531 | - */ |
|
1532 | - public function getLogger() { |
|
1533 | - return $this->query('Logger'); |
|
1534 | - } |
|
1535 | - |
|
1536 | - /** |
|
1537 | - * @return ILogFactory |
|
1538 | - * @throws \OCP\AppFramework\QueryException |
|
1539 | - */ |
|
1540 | - public function getLogFactory() { |
|
1541 | - return $this->query(ILogFactory::class); |
|
1542 | - } |
|
1543 | - |
|
1544 | - /** |
|
1545 | - * Returns a router for generating and matching urls |
|
1546 | - * |
|
1547 | - * @return \OCP\Route\IRouter |
|
1548 | - */ |
|
1549 | - public function getRouter() { |
|
1550 | - return $this->query('Router'); |
|
1551 | - } |
|
1552 | - |
|
1553 | - /** |
|
1554 | - * Returns a search instance |
|
1555 | - * |
|
1556 | - * @return \OCP\ISearch |
|
1557 | - */ |
|
1558 | - public function getSearch() { |
|
1559 | - return $this->query('Search'); |
|
1560 | - } |
|
1561 | - |
|
1562 | - /** |
|
1563 | - * Returns a SecureRandom instance |
|
1564 | - * |
|
1565 | - * @return \OCP\Security\ISecureRandom |
|
1566 | - */ |
|
1567 | - public function getSecureRandom() { |
|
1568 | - return $this->query('SecureRandom'); |
|
1569 | - } |
|
1570 | - |
|
1571 | - /** |
|
1572 | - * Returns a Crypto instance |
|
1573 | - * |
|
1574 | - * @return \OCP\Security\ICrypto |
|
1575 | - */ |
|
1576 | - public function getCrypto() { |
|
1577 | - return $this->query('Crypto'); |
|
1578 | - } |
|
1579 | - |
|
1580 | - /** |
|
1581 | - * Returns a Hasher instance |
|
1582 | - * |
|
1583 | - * @return \OCP\Security\IHasher |
|
1584 | - */ |
|
1585 | - public function getHasher() { |
|
1586 | - return $this->query('Hasher'); |
|
1587 | - } |
|
1588 | - |
|
1589 | - /** |
|
1590 | - * Returns a CredentialsManager instance |
|
1591 | - * |
|
1592 | - * @return \OCP\Security\ICredentialsManager |
|
1593 | - */ |
|
1594 | - public function getCredentialsManager() { |
|
1595 | - return $this->query('CredentialsManager'); |
|
1596 | - } |
|
1597 | - |
|
1598 | - /** |
|
1599 | - * Get the certificate manager for the user |
|
1600 | - * |
|
1601 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1602 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1603 | - */ |
|
1604 | - public function getCertificateManager($userId = '') { |
|
1605 | - if ($userId === '') { |
|
1606 | - $userSession = $this->getUserSession(); |
|
1607 | - $user = $userSession->getUser(); |
|
1608 | - if (is_null($user)) { |
|
1609 | - return null; |
|
1610 | - } |
|
1611 | - $userId = $user->getUID(); |
|
1612 | - } |
|
1613 | - return new CertificateManager( |
|
1614 | - $userId, |
|
1615 | - new View(), |
|
1616 | - $this->getConfig(), |
|
1617 | - $this->getLogger(), |
|
1618 | - $this->getSecureRandom() |
|
1619 | - ); |
|
1620 | - } |
|
1621 | - |
|
1622 | - /** |
|
1623 | - * Returns an instance of the HTTP client service |
|
1624 | - * |
|
1625 | - * @return \OCP\Http\Client\IClientService |
|
1626 | - */ |
|
1627 | - public function getHTTPClientService() { |
|
1628 | - return $this->query('HttpClientService'); |
|
1629 | - } |
|
1630 | - |
|
1631 | - /** |
|
1632 | - * Create a new event source |
|
1633 | - * |
|
1634 | - * @return \OCP\IEventSource |
|
1635 | - */ |
|
1636 | - public function createEventSource() { |
|
1637 | - return new \OC_EventSource(); |
|
1638 | - } |
|
1639 | - |
|
1640 | - /** |
|
1641 | - * Get the active event logger |
|
1642 | - * |
|
1643 | - * The returned logger only logs data when debug mode is enabled |
|
1644 | - * |
|
1645 | - * @return \OCP\Diagnostics\IEventLogger |
|
1646 | - */ |
|
1647 | - public function getEventLogger() { |
|
1648 | - return $this->query('EventLogger'); |
|
1649 | - } |
|
1650 | - |
|
1651 | - /** |
|
1652 | - * Get the active query logger |
|
1653 | - * |
|
1654 | - * The returned logger only logs data when debug mode is enabled |
|
1655 | - * |
|
1656 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1657 | - */ |
|
1658 | - public function getQueryLogger() { |
|
1659 | - return $this->query('QueryLogger'); |
|
1660 | - } |
|
1661 | - |
|
1662 | - /** |
|
1663 | - * Get the manager for temporary files and folders |
|
1664 | - * |
|
1665 | - * @return \OCP\ITempManager |
|
1666 | - */ |
|
1667 | - public function getTempManager() { |
|
1668 | - return $this->query('TempManager'); |
|
1669 | - } |
|
1670 | - |
|
1671 | - /** |
|
1672 | - * Get the app manager |
|
1673 | - * |
|
1674 | - * @return \OCP\App\IAppManager |
|
1675 | - */ |
|
1676 | - public function getAppManager() { |
|
1677 | - return $this->query('AppManager'); |
|
1678 | - } |
|
1679 | - |
|
1680 | - /** |
|
1681 | - * Creates a new mailer |
|
1682 | - * |
|
1683 | - * @return \OCP\Mail\IMailer |
|
1684 | - */ |
|
1685 | - public function getMailer() { |
|
1686 | - return $this->query('Mailer'); |
|
1687 | - } |
|
1688 | - |
|
1689 | - /** |
|
1690 | - * Get the webroot |
|
1691 | - * |
|
1692 | - * @return string |
|
1693 | - */ |
|
1694 | - public function getWebRoot() { |
|
1695 | - return $this->webRoot; |
|
1696 | - } |
|
1697 | - |
|
1698 | - /** |
|
1699 | - * @return \OC\OCSClient |
|
1700 | - */ |
|
1701 | - public function getOcsClient() { |
|
1702 | - return $this->query('OcsClient'); |
|
1703 | - } |
|
1704 | - |
|
1705 | - /** |
|
1706 | - * @return \OCP\IDateTimeZone |
|
1707 | - */ |
|
1708 | - public function getDateTimeZone() { |
|
1709 | - return $this->query('DateTimeZone'); |
|
1710 | - } |
|
1711 | - |
|
1712 | - /** |
|
1713 | - * @return \OCP\IDateTimeFormatter |
|
1714 | - */ |
|
1715 | - public function getDateTimeFormatter() { |
|
1716 | - return $this->query('DateTimeFormatter'); |
|
1717 | - } |
|
1718 | - |
|
1719 | - /** |
|
1720 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1721 | - */ |
|
1722 | - public function getMountProviderCollection() { |
|
1723 | - return $this->query('MountConfigManager'); |
|
1724 | - } |
|
1725 | - |
|
1726 | - /** |
|
1727 | - * Get the IniWrapper |
|
1728 | - * |
|
1729 | - * @return IniGetWrapper |
|
1730 | - */ |
|
1731 | - public function getIniWrapper() { |
|
1732 | - return $this->query('IniWrapper'); |
|
1733 | - } |
|
1734 | - |
|
1735 | - /** |
|
1736 | - * @return \OCP\Command\IBus |
|
1737 | - */ |
|
1738 | - public function getCommandBus() { |
|
1739 | - return $this->query('AsyncCommandBus'); |
|
1740 | - } |
|
1741 | - |
|
1742 | - /** |
|
1743 | - * Get the trusted domain helper |
|
1744 | - * |
|
1745 | - * @return TrustedDomainHelper |
|
1746 | - */ |
|
1747 | - public function getTrustedDomainHelper() { |
|
1748 | - return $this->query('TrustedDomainHelper'); |
|
1749 | - } |
|
1750 | - |
|
1751 | - /** |
|
1752 | - * Get the locking provider |
|
1753 | - * |
|
1754 | - * @return \OCP\Lock\ILockingProvider |
|
1755 | - * @since 8.1.0 |
|
1756 | - */ |
|
1757 | - public function getLockingProvider() { |
|
1758 | - return $this->query('LockingProvider'); |
|
1759 | - } |
|
1760 | - |
|
1761 | - /** |
|
1762 | - * @return \OCP\Files\Mount\IMountManager |
|
1763 | - **/ |
|
1764 | - function getMountManager() { |
|
1765 | - return $this->query('MountManager'); |
|
1766 | - } |
|
1767 | - |
|
1768 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1769 | - function getUserMountCache() { |
|
1770 | - return $this->query('UserMountCache'); |
|
1771 | - } |
|
1772 | - |
|
1773 | - /** |
|
1774 | - * Get the MimeTypeDetector |
|
1775 | - * |
|
1776 | - * @return \OCP\Files\IMimeTypeDetector |
|
1777 | - */ |
|
1778 | - public function getMimeTypeDetector() { |
|
1779 | - return $this->query('MimeTypeDetector'); |
|
1780 | - } |
|
1781 | - |
|
1782 | - /** |
|
1783 | - * Get the MimeTypeLoader |
|
1784 | - * |
|
1785 | - * @return \OCP\Files\IMimeTypeLoader |
|
1786 | - */ |
|
1787 | - public function getMimeTypeLoader() { |
|
1788 | - return $this->query('MimeTypeLoader'); |
|
1789 | - } |
|
1790 | - |
|
1791 | - /** |
|
1792 | - * Get the manager of all the capabilities |
|
1793 | - * |
|
1794 | - * @return \OC\CapabilitiesManager |
|
1795 | - */ |
|
1796 | - public function getCapabilitiesManager() { |
|
1797 | - return $this->query('CapabilitiesManager'); |
|
1798 | - } |
|
1799 | - |
|
1800 | - /** |
|
1801 | - * Get the EventDispatcher |
|
1802 | - * |
|
1803 | - * @return EventDispatcherInterface |
|
1804 | - * @since 8.2.0 |
|
1805 | - */ |
|
1806 | - public function getEventDispatcher() { |
|
1807 | - return $this->query('EventDispatcher'); |
|
1808 | - } |
|
1809 | - |
|
1810 | - /** |
|
1811 | - * Get the Notification Manager |
|
1812 | - * |
|
1813 | - * @return \OCP\Notification\IManager |
|
1814 | - * @since 8.2.0 |
|
1815 | - */ |
|
1816 | - public function getNotificationManager() { |
|
1817 | - return $this->query('NotificationManager'); |
|
1818 | - } |
|
1819 | - |
|
1820 | - /** |
|
1821 | - * @return \OCP\Comments\ICommentsManager |
|
1822 | - */ |
|
1823 | - public function getCommentsManager() { |
|
1824 | - return $this->query('CommentsManager'); |
|
1825 | - } |
|
1826 | - |
|
1827 | - /** |
|
1828 | - * @return \OCA\Theming\ThemingDefaults |
|
1829 | - */ |
|
1830 | - public function getThemingDefaults() { |
|
1831 | - return $this->query('ThemingDefaults'); |
|
1832 | - } |
|
1833 | - |
|
1834 | - /** |
|
1835 | - * @return \OC\IntegrityCheck\Checker |
|
1836 | - */ |
|
1837 | - public function getIntegrityCodeChecker() { |
|
1838 | - return $this->query('IntegrityCodeChecker'); |
|
1839 | - } |
|
1840 | - |
|
1841 | - /** |
|
1842 | - * @return \OC\Session\CryptoWrapper |
|
1843 | - */ |
|
1844 | - public function getSessionCryptoWrapper() { |
|
1845 | - return $this->query('CryptoWrapper'); |
|
1846 | - } |
|
1847 | - |
|
1848 | - /** |
|
1849 | - * @return CsrfTokenManager |
|
1850 | - */ |
|
1851 | - public function getCsrfTokenManager() { |
|
1852 | - return $this->query('CsrfTokenManager'); |
|
1853 | - } |
|
1854 | - |
|
1855 | - /** |
|
1856 | - * @return Throttler |
|
1857 | - */ |
|
1858 | - public function getBruteForceThrottler() { |
|
1859 | - return $this->query('Throttler'); |
|
1860 | - } |
|
1861 | - |
|
1862 | - /** |
|
1863 | - * @return IContentSecurityPolicyManager |
|
1864 | - */ |
|
1865 | - public function getContentSecurityPolicyManager() { |
|
1866 | - return $this->query('ContentSecurityPolicyManager'); |
|
1867 | - } |
|
1868 | - |
|
1869 | - /** |
|
1870 | - * @return ContentSecurityPolicyNonceManager |
|
1871 | - */ |
|
1872 | - public function getContentSecurityPolicyNonceManager() { |
|
1873 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1874 | - } |
|
1875 | - |
|
1876 | - /** |
|
1877 | - * Not a public API as of 8.2, wait for 9.0 |
|
1878 | - * |
|
1879 | - * @return \OCA\Files_External\Service\BackendService |
|
1880 | - */ |
|
1881 | - public function getStoragesBackendService() { |
|
1882 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1883 | - } |
|
1884 | - |
|
1885 | - /** |
|
1886 | - * Not a public API as of 8.2, wait for 9.0 |
|
1887 | - * |
|
1888 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1889 | - */ |
|
1890 | - public function getGlobalStoragesService() { |
|
1891 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1892 | - } |
|
1893 | - |
|
1894 | - /** |
|
1895 | - * Not a public API as of 8.2, wait for 9.0 |
|
1896 | - * |
|
1897 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1898 | - */ |
|
1899 | - public function getUserGlobalStoragesService() { |
|
1900 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1901 | - } |
|
1902 | - |
|
1903 | - /** |
|
1904 | - * Not a public API as of 8.2, wait for 9.0 |
|
1905 | - * |
|
1906 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1907 | - */ |
|
1908 | - public function getUserStoragesService() { |
|
1909 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1910 | - } |
|
1911 | - |
|
1912 | - /** |
|
1913 | - * @return \OCP\Share\IManager |
|
1914 | - */ |
|
1915 | - public function getShareManager() { |
|
1916 | - return $this->query('ShareManager'); |
|
1917 | - } |
|
1918 | - |
|
1919 | - /** |
|
1920 | - * @return \OCP\Collaboration\Collaborators\ISearch |
|
1921 | - */ |
|
1922 | - public function getCollaboratorSearch() { |
|
1923 | - return $this->query('CollaboratorSearch'); |
|
1924 | - } |
|
1925 | - |
|
1926 | - /** |
|
1927 | - * @return \OCP\Collaboration\AutoComplete\IManager |
|
1928 | - */ |
|
1929 | - public function getAutoCompleteManager(){ |
|
1930 | - return $this->query(IManager::class); |
|
1931 | - } |
|
1932 | - |
|
1933 | - /** |
|
1934 | - * Returns the LDAP Provider |
|
1935 | - * |
|
1936 | - * @return \OCP\LDAP\ILDAPProvider |
|
1937 | - */ |
|
1938 | - public function getLDAPProvider() { |
|
1939 | - return $this->query('LDAPProvider'); |
|
1940 | - } |
|
1941 | - |
|
1942 | - /** |
|
1943 | - * @return \OCP\Settings\IManager |
|
1944 | - */ |
|
1945 | - public function getSettingsManager() { |
|
1946 | - return $this->query('SettingsManager'); |
|
1947 | - } |
|
1948 | - |
|
1949 | - /** |
|
1950 | - * @return \OCP\Files\IAppData |
|
1951 | - */ |
|
1952 | - public function getAppDataDir($app) { |
|
1953 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1954 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1955 | - return $factory->get($app); |
|
1956 | - } |
|
1957 | - |
|
1958 | - /** |
|
1959 | - * @return \OCP\Lockdown\ILockdownManager |
|
1960 | - */ |
|
1961 | - public function getLockdownManager() { |
|
1962 | - return $this->query('LockdownManager'); |
|
1963 | - } |
|
1964 | - |
|
1965 | - /** |
|
1966 | - * @return \OCP\Federation\ICloudIdManager |
|
1967 | - */ |
|
1968 | - public function getCloudIdManager() { |
|
1969 | - return $this->query(ICloudIdManager::class); |
|
1970 | - } |
|
1971 | - |
|
1972 | - /** |
|
1973 | - * @return \OCP\Remote\Api\IApiFactory |
|
1974 | - */ |
|
1975 | - public function getRemoteApiFactory() { |
|
1976 | - return $this->query(IApiFactory::class); |
|
1977 | - } |
|
1978 | - |
|
1979 | - /** |
|
1980 | - * @return \OCP\Remote\IInstanceFactory |
|
1981 | - */ |
|
1982 | - public function getRemoteInstanceFactory() { |
|
1983 | - return $this->query(IInstanceFactory::class); |
|
1984 | - } |
|
940 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
941 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
942 | + $classExists = true; |
|
943 | + } else { |
|
944 | + $classExists = false; |
|
945 | + } |
|
946 | + |
|
947 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
948 | + return new ThemingDefaults( |
|
949 | + $c->getConfig(), |
|
950 | + $c->getL10N('theming'), |
|
951 | + $c->getURLGenerator(), |
|
952 | + $c->getMemCacheFactory(), |
|
953 | + new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')), |
|
954 | + new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator()), |
|
955 | + $c->getAppManager() |
|
956 | + ); |
|
957 | + } |
|
958 | + return new \OC_Defaults(); |
|
959 | + }); |
|
960 | + $this->registerService(SCSSCacher::class, function (Server $c) { |
|
961 | + /** @var Factory $cacheFactory */ |
|
962 | + $cacheFactory = $c->query(Factory::class); |
|
963 | + return new SCSSCacher( |
|
964 | + $c->getLogger(), |
|
965 | + $c->query(\OC\Files\AppData\Factory::class), |
|
966 | + $c->getURLGenerator(), |
|
967 | + $c->getConfig(), |
|
968 | + $c->getThemingDefaults(), |
|
969 | + \OC::$SERVERROOT, |
|
970 | + $this->getMemCacheFactory() |
|
971 | + ); |
|
972 | + }); |
|
973 | + $this->registerService(JSCombiner::class, function (Server $c) { |
|
974 | + /** @var Factory $cacheFactory */ |
|
975 | + $cacheFactory = $c->query(Factory::class); |
|
976 | + return new JSCombiner( |
|
977 | + $c->getAppDataDir('js'), |
|
978 | + $c->getURLGenerator(), |
|
979 | + $this->getMemCacheFactory(), |
|
980 | + $c->getSystemConfig(), |
|
981 | + $c->getLogger() |
|
982 | + ); |
|
983 | + }); |
|
984 | + $this->registerService(EventDispatcher::class, function () { |
|
985 | + return new EventDispatcher(); |
|
986 | + }); |
|
987 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
988 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
989 | + |
|
990 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
991 | + // FIXME: Instantiiated here due to cyclic dependency |
|
992 | + $request = new Request( |
|
993 | + [ |
|
994 | + 'get' => $_GET, |
|
995 | + 'post' => $_POST, |
|
996 | + 'files' => $_FILES, |
|
997 | + 'server' => $_SERVER, |
|
998 | + 'env' => $_ENV, |
|
999 | + 'cookies' => $_COOKIE, |
|
1000 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
1001 | + ? $_SERVER['REQUEST_METHOD'] |
|
1002 | + : null, |
|
1003 | + ], |
|
1004 | + $c->getSecureRandom(), |
|
1005 | + $c->getConfig() |
|
1006 | + ); |
|
1007 | + |
|
1008 | + return new CryptoWrapper( |
|
1009 | + $c->getConfig(), |
|
1010 | + $c->getCrypto(), |
|
1011 | + $c->getSecureRandom(), |
|
1012 | + $request |
|
1013 | + ); |
|
1014 | + }); |
|
1015 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1016 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
1017 | + |
|
1018 | + return new CsrfTokenManager( |
|
1019 | + $tokenGenerator, |
|
1020 | + $c->query(SessionStorage::class) |
|
1021 | + ); |
|
1022 | + }); |
|
1023 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
1024 | + return new SessionStorage($c->getSession()); |
|
1025 | + }); |
|
1026 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1027 | + return new ContentSecurityPolicyManager(); |
|
1028 | + }); |
|
1029 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
1030 | + |
|
1031 | + $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1032 | + return new ContentSecurityPolicyNonceManager( |
|
1033 | + $c->getCsrfTokenManager(), |
|
1034 | + $c->getRequest() |
|
1035 | + ); |
|
1036 | + }); |
|
1037 | + |
|
1038 | + $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1039 | + $config = $c->getConfig(); |
|
1040 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
1041 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
1042 | + $factory = new $factoryClass($this); |
|
1043 | + |
|
1044 | + $manager = new \OC\Share20\Manager( |
|
1045 | + $c->getLogger(), |
|
1046 | + $c->getConfig(), |
|
1047 | + $c->getSecureRandom(), |
|
1048 | + $c->getHasher(), |
|
1049 | + $c->getMountManager(), |
|
1050 | + $c->getGroupManager(), |
|
1051 | + $c->getL10N('lib'), |
|
1052 | + $c->getL10NFactory(), |
|
1053 | + $factory, |
|
1054 | + $c->getUserManager(), |
|
1055 | + $c->getLazyRootFolder(), |
|
1056 | + $c->getEventDispatcher(), |
|
1057 | + $c->getMailer(), |
|
1058 | + $c->getURLGenerator(), |
|
1059 | + $c->getThemingDefaults() |
|
1060 | + ); |
|
1061 | + |
|
1062 | + return $manager; |
|
1063 | + }); |
|
1064 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
1065 | + |
|
1066 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
1067 | + $instance = new Collaboration\Collaborators\Search($c); |
|
1068 | + |
|
1069 | + // register default plugins |
|
1070 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
1071 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
1072 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
1073 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
1074 | + |
|
1075 | + return $instance; |
|
1076 | + }); |
|
1077 | + $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
1078 | + |
|
1079 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
1080 | + |
|
1081 | + $this->registerService('SettingsManager', function (Server $c) { |
|
1082 | + $manager = new \OC\Settings\Manager( |
|
1083 | + $c->getLogger(), |
|
1084 | + $c->getDatabaseConnection(), |
|
1085 | + $c->getL10N('lib'), |
|
1086 | + $c->getConfig(), |
|
1087 | + $c->getEncryptionManager(), |
|
1088 | + $c->getUserManager(), |
|
1089 | + $c->getLockingProvider(), |
|
1090 | + $c->getRequest(), |
|
1091 | + $c->getURLGenerator(), |
|
1092 | + $c->query(AccountManager::class), |
|
1093 | + $c->getGroupManager(), |
|
1094 | + $c->getL10NFactory(), |
|
1095 | + $c->getAppManager() |
|
1096 | + ); |
|
1097 | + return $manager; |
|
1098 | + }); |
|
1099 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1100 | + return new \OC\Files\AppData\Factory( |
|
1101 | + $c->getRootFolder(), |
|
1102 | + $c->getSystemConfig() |
|
1103 | + ); |
|
1104 | + }); |
|
1105 | + |
|
1106 | + $this->registerService('LockdownManager', function (Server $c) { |
|
1107 | + return new LockdownManager(function () use ($c) { |
|
1108 | + return $c->getSession(); |
|
1109 | + }); |
|
1110 | + }); |
|
1111 | + |
|
1112 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1113 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
1114 | + }); |
|
1115 | + |
|
1116 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1117 | + return new CloudIdManager(); |
|
1118 | + }); |
|
1119 | + |
|
1120 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1121 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1122 | + |
|
1123 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1124 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1125 | + |
|
1126 | + $this->registerService(Defaults::class, function (Server $c) { |
|
1127 | + return new Defaults( |
|
1128 | + $c->getThemingDefaults() |
|
1129 | + ); |
|
1130 | + }); |
|
1131 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1132 | + |
|
1133 | + $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1134 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1135 | + }); |
|
1136 | + |
|
1137 | + $this->registerService(IShareHelper::class, function (Server $c) { |
|
1138 | + return new ShareHelper( |
|
1139 | + $c->query(\OCP\Share\IManager::class) |
|
1140 | + ); |
|
1141 | + }); |
|
1142 | + |
|
1143 | + $this->registerService(Installer::class, function(Server $c) { |
|
1144 | + return new Installer( |
|
1145 | + $c->getAppFetcher(), |
|
1146 | + $c->getHTTPClientService(), |
|
1147 | + $c->getTempManager(), |
|
1148 | + $c->getLogger(), |
|
1149 | + $c->getConfig() |
|
1150 | + ); |
|
1151 | + }); |
|
1152 | + |
|
1153 | + $this->registerService(IApiFactory::class, function(Server $c) { |
|
1154 | + return new ApiFactory($c->getHTTPClientService()); |
|
1155 | + }); |
|
1156 | + |
|
1157 | + $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
1158 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
1159 | + return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
1160 | + }); |
|
1161 | + |
|
1162 | + $this->registerService(IContactsStore::class, function(Server $c) { |
|
1163 | + return new ContactsStore( |
|
1164 | + $c->getContactsManager(), |
|
1165 | + $c->getConfig(), |
|
1166 | + $c->getUserManager(), |
|
1167 | + $c->getGroupManager() |
|
1168 | + ); |
|
1169 | + }); |
|
1170 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
1171 | + |
|
1172 | + $this->connectDispatcher(); |
|
1173 | + } |
|
1174 | + |
|
1175 | + /** |
|
1176 | + * @return \OCP\Calendar\IManager |
|
1177 | + */ |
|
1178 | + public function getCalendarManager() { |
|
1179 | + return $this->query('CalendarManager'); |
|
1180 | + } |
|
1181 | + |
|
1182 | + private function connectDispatcher() { |
|
1183 | + $dispatcher = $this->getEventDispatcher(); |
|
1184 | + |
|
1185 | + // Delete avatar on user deletion |
|
1186 | + $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
1187 | + $logger = $this->getLogger(); |
|
1188 | + $manager = $this->getAvatarManager(); |
|
1189 | + /** @var IUser $user */ |
|
1190 | + $user = $e->getSubject(); |
|
1191 | + |
|
1192 | + try { |
|
1193 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1194 | + $avatar->remove(); |
|
1195 | + } catch (NotFoundException $e) { |
|
1196 | + // no avatar to remove |
|
1197 | + } catch (\Exception $e) { |
|
1198 | + // Ignore exceptions |
|
1199 | + $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1200 | + } |
|
1201 | + }); |
|
1202 | + |
|
1203 | + $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1204 | + $manager = $this->getAvatarManager(); |
|
1205 | + /** @var IUser $user */ |
|
1206 | + $user = $e->getSubject(); |
|
1207 | + $feature = $e->getArgument('feature'); |
|
1208 | + $oldValue = $e->getArgument('oldValue'); |
|
1209 | + $value = $e->getArgument('value'); |
|
1210 | + |
|
1211 | + try { |
|
1212 | + $avatar = $manager->getAvatar($user->getUID()); |
|
1213 | + $avatar->userChanged($feature, $oldValue, $value); |
|
1214 | + } catch (NotFoundException $e) { |
|
1215 | + // no avatar to remove |
|
1216 | + } |
|
1217 | + }); |
|
1218 | + } |
|
1219 | + |
|
1220 | + /** |
|
1221 | + * @return \OCP\Contacts\IManager |
|
1222 | + */ |
|
1223 | + public function getContactsManager() { |
|
1224 | + return $this->query('ContactsManager'); |
|
1225 | + } |
|
1226 | + |
|
1227 | + /** |
|
1228 | + * @return \OC\Encryption\Manager |
|
1229 | + */ |
|
1230 | + public function getEncryptionManager() { |
|
1231 | + return $this->query('EncryptionManager'); |
|
1232 | + } |
|
1233 | + |
|
1234 | + /** |
|
1235 | + * @return \OC\Encryption\File |
|
1236 | + */ |
|
1237 | + public function getEncryptionFilesHelper() { |
|
1238 | + return $this->query('EncryptionFileHelper'); |
|
1239 | + } |
|
1240 | + |
|
1241 | + /** |
|
1242 | + * @return \OCP\Encryption\Keys\IStorage |
|
1243 | + */ |
|
1244 | + public function getEncryptionKeyStorage() { |
|
1245 | + return $this->query('EncryptionKeyStorage'); |
|
1246 | + } |
|
1247 | + |
|
1248 | + /** |
|
1249 | + * The current request object holding all information about the request |
|
1250 | + * currently being processed is returned from this method. |
|
1251 | + * In case the current execution was not initiated by a web request null is returned |
|
1252 | + * |
|
1253 | + * @return \OCP\IRequest |
|
1254 | + */ |
|
1255 | + public function getRequest() { |
|
1256 | + return $this->query('Request'); |
|
1257 | + } |
|
1258 | + |
|
1259 | + /** |
|
1260 | + * Returns the preview manager which can create preview images for a given file |
|
1261 | + * |
|
1262 | + * @return \OCP\IPreview |
|
1263 | + */ |
|
1264 | + public function getPreviewManager() { |
|
1265 | + return $this->query('PreviewManager'); |
|
1266 | + } |
|
1267 | + |
|
1268 | + /** |
|
1269 | + * Returns the tag manager which can get and set tags for different object types |
|
1270 | + * |
|
1271 | + * @see \OCP\ITagManager::load() |
|
1272 | + * @return \OCP\ITagManager |
|
1273 | + */ |
|
1274 | + public function getTagManager() { |
|
1275 | + return $this->query('TagManager'); |
|
1276 | + } |
|
1277 | + |
|
1278 | + /** |
|
1279 | + * Returns the system-tag manager |
|
1280 | + * |
|
1281 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1282 | + * |
|
1283 | + * @since 9.0.0 |
|
1284 | + */ |
|
1285 | + public function getSystemTagManager() { |
|
1286 | + return $this->query('SystemTagManager'); |
|
1287 | + } |
|
1288 | + |
|
1289 | + /** |
|
1290 | + * Returns the system-tag object mapper |
|
1291 | + * |
|
1292 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1293 | + * |
|
1294 | + * @since 9.0.0 |
|
1295 | + */ |
|
1296 | + public function getSystemTagObjectMapper() { |
|
1297 | + return $this->query('SystemTagObjectMapper'); |
|
1298 | + } |
|
1299 | + |
|
1300 | + /** |
|
1301 | + * Returns the avatar manager, used for avatar functionality |
|
1302 | + * |
|
1303 | + * @return \OCP\IAvatarManager |
|
1304 | + */ |
|
1305 | + public function getAvatarManager() { |
|
1306 | + return $this->query('AvatarManager'); |
|
1307 | + } |
|
1308 | + |
|
1309 | + /** |
|
1310 | + * Returns the root folder of ownCloud's data directory |
|
1311 | + * |
|
1312 | + * @return \OCP\Files\IRootFolder |
|
1313 | + */ |
|
1314 | + public function getRootFolder() { |
|
1315 | + return $this->query('LazyRootFolder'); |
|
1316 | + } |
|
1317 | + |
|
1318 | + /** |
|
1319 | + * Returns the root folder of ownCloud's data directory |
|
1320 | + * This is the lazy variant so this gets only initialized once it |
|
1321 | + * is actually used. |
|
1322 | + * |
|
1323 | + * @return \OCP\Files\IRootFolder |
|
1324 | + */ |
|
1325 | + public function getLazyRootFolder() { |
|
1326 | + return $this->query('LazyRootFolder'); |
|
1327 | + } |
|
1328 | + |
|
1329 | + /** |
|
1330 | + * Returns a view to ownCloud's files folder |
|
1331 | + * |
|
1332 | + * @param string $userId user ID |
|
1333 | + * @return \OCP\Files\Folder|null |
|
1334 | + */ |
|
1335 | + public function getUserFolder($userId = null) { |
|
1336 | + if ($userId === null) { |
|
1337 | + $user = $this->getUserSession()->getUser(); |
|
1338 | + if (!$user) { |
|
1339 | + return null; |
|
1340 | + } |
|
1341 | + $userId = $user->getUID(); |
|
1342 | + } |
|
1343 | + $root = $this->getRootFolder(); |
|
1344 | + return $root->getUserFolder($userId); |
|
1345 | + } |
|
1346 | + |
|
1347 | + /** |
|
1348 | + * Returns an app-specific view in ownClouds data directory |
|
1349 | + * |
|
1350 | + * @return \OCP\Files\Folder |
|
1351 | + * @deprecated since 9.2.0 use IAppData |
|
1352 | + */ |
|
1353 | + public function getAppFolder() { |
|
1354 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1355 | + $root = $this->getRootFolder(); |
|
1356 | + if (!$root->nodeExists($dir)) { |
|
1357 | + $folder = $root->newFolder($dir); |
|
1358 | + } else { |
|
1359 | + $folder = $root->get($dir); |
|
1360 | + } |
|
1361 | + return $folder; |
|
1362 | + } |
|
1363 | + |
|
1364 | + /** |
|
1365 | + * @return \OC\User\Manager |
|
1366 | + */ |
|
1367 | + public function getUserManager() { |
|
1368 | + return $this->query('UserManager'); |
|
1369 | + } |
|
1370 | + |
|
1371 | + /** |
|
1372 | + * @return \OC\Group\Manager |
|
1373 | + */ |
|
1374 | + public function getGroupManager() { |
|
1375 | + return $this->query('GroupManager'); |
|
1376 | + } |
|
1377 | + |
|
1378 | + /** |
|
1379 | + * @return \OC\User\Session |
|
1380 | + */ |
|
1381 | + public function getUserSession() { |
|
1382 | + return $this->query('UserSession'); |
|
1383 | + } |
|
1384 | + |
|
1385 | + /** |
|
1386 | + * @return \OCP\ISession |
|
1387 | + */ |
|
1388 | + public function getSession() { |
|
1389 | + return $this->query('UserSession')->getSession(); |
|
1390 | + } |
|
1391 | + |
|
1392 | + /** |
|
1393 | + * @param \OCP\ISession $session |
|
1394 | + */ |
|
1395 | + public function setSession(\OCP\ISession $session) { |
|
1396 | + $this->query(SessionStorage::class)->setSession($session); |
|
1397 | + $this->query('UserSession')->setSession($session); |
|
1398 | + $this->query(Store::class)->setSession($session); |
|
1399 | + } |
|
1400 | + |
|
1401 | + /** |
|
1402 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1403 | + */ |
|
1404 | + public function getTwoFactorAuthManager() { |
|
1405 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1406 | + } |
|
1407 | + |
|
1408 | + /** |
|
1409 | + * @return \OC\NavigationManager |
|
1410 | + */ |
|
1411 | + public function getNavigationManager() { |
|
1412 | + return $this->query('NavigationManager'); |
|
1413 | + } |
|
1414 | + |
|
1415 | + /** |
|
1416 | + * @return \OCP\IConfig |
|
1417 | + */ |
|
1418 | + public function getConfig() { |
|
1419 | + return $this->query('AllConfig'); |
|
1420 | + } |
|
1421 | + |
|
1422 | + /** |
|
1423 | + * @return \OC\SystemConfig |
|
1424 | + */ |
|
1425 | + public function getSystemConfig() { |
|
1426 | + return $this->query('SystemConfig'); |
|
1427 | + } |
|
1428 | + |
|
1429 | + /** |
|
1430 | + * Returns the app config manager |
|
1431 | + * |
|
1432 | + * @return \OCP\IAppConfig |
|
1433 | + */ |
|
1434 | + public function getAppConfig() { |
|
1435 | + return $this->query('AppConfig'); |
|
1436 | + } |
|
1437 | + |
|
1438 | + /** |
|
1439 | + * @return \OCP\L10N\IFactory |
|
1440 | + */ |
|
1441 | + public function getL10NFactory() { |
|
1442 | + return $this->query('L10NFactory'); |
|
1443 | + } |
|
1444 | + |
|
1445 | + /** |
|
1446 | + * get an L10N instance |
|
1447 | + * |
|
1448 | + * @param string $app appid |
|
1449 | + * @param string $lang |
|
1450 | + * @return IL10N |
|
1451 | + */ |
|
1452 | + public function getL10N($app, $lang = null) { |
|
1453 | + return $this->getL10NFactory()->get($app, $lang); |
|
1454 | + } |
|
1455 | + |
|
1456 | + /** |
|
1457 | + * @return \OCP\IURLGenerator |
|
1458 | + */ |
|
1459 | + public function getURLGenerator() { |
|
1460 | + return $this->query('URLGenerator'); |
|
1461 | + } |
|
1462 | + |
|
1463 | + /** |
|
1464 | + * @return AppFetcher |
|
1465 | + */ |
|
1466 | + public function getAppFetcher() { |
|
1467 | + return $this->query(AppFetcher::class); |
|
1468 | + } |
|
1469 | + |
|
1470 | + /** |
|
1471 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1472 | + * getMemCacheFactory() instead. |
|
1473 | + * |
|
1474 | + * @return \OCP\ICache |
|
1475 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1476 | + */ |
|
1477 | + public function getCache() { |
|
1478 | + return $this->query('UserCache'); |
|
1479 | + } |
|
1480 | + |
|
1481 | + /** |
|
1482 | + * Returns an \OCP\CacheFactory instance |
|
1483 | + * |
|
1484 | + * @return \OCP\ICacheFactory |
|
1485 | + */ |
|
1486 | + public function getMemCacheFactory() { |
|
1487 | + return $this->query('MemCacheFactory'); |
|
1488 | + } |
|
1489 | + |
|
1490 | + /** |
|
1491 | + * Returns an \OC\RedisFactory instance |
|
1492 | + * |
|
1493 | + * @return \OC\RedisFactory |
|
1494 | + */ |
|
1495 | + public function getGetRedisFactory() { |
|
1496 | + return $this->query('RedisFactory'); |
|
1497 | + } |
|
1498 | + |
|
1499 | + |
|
1500 | + /** |
|
1501 | + * Returns the current session |
|
1502 | + * |
|
1503 | + * @return \OCP\IDBConnection |
|
1504 | + */ |
|
1505 | + public function getDatabaseConnection() { |
|
1506 | + return $this->query('DatabaseConnection'); |
|
1507 | + } |
|
1508 | + |
|
1509 | + /** |
|
1510 | + * Returns the activity manager |
|
1511 | + * |
|
1512 | + * @return \OCP\Activity\IManager |
|
1513 | + */ |
|
1514 | + public function getActivityManager() { |
|
1515 | + return $this->query('ActivityManager'); |
|
1516 | + } |
|
1517 | + |
|
1518 | + /** |
|
1519 | + * Returns an job list for controlling background jobs |
|
1520 | + * |
|
1521 | + * @return \OCP\BackgroundJob\IJobList |
|
1522 | + */ |
|
1523 | + public function getJobList() { |
|
1524 | + return $this->query('JobList'); |
|
1525 | + } |
|
1526 | + |
|
1527 | + /** |
|
1528 | + * Returns a logger instance |
|
1529 | + * |
|
1530 | + * @return \OCP\ILogger |
|
1531 | + */ |
|
1532 | + public function getLogger() { |
|
1533 | + return $this->query('Logger'); |
|
1534 | + } |
|
1535 | + |
|
1536 | + /** |
|
1537 | + * @return ILogFactory |
|
1538 | + * @throws \OCP\AppFramework\QueryException |
|
1539 | + */ |
|
1540 | + public function getLogFactory() { |
|
1541 | + return $this->query(ILogFactory::class); |
|
1542 | + } |
|
1543 | + |
|
1544 | + /** |
|
1545 | + * Returns a router for generating and matching urls |
|
1546 | + * |
|
1547 | + * @return \OCP\Route\IRouter |
|
1548 | + */ |
|
1549 | + public function getRouter() { |
|
1550 | + return $this->query('Router'); |
|
1551 | + } |
|
1552 | + |
|
1553 | + /** |
|
1554 | + * Returns a search instance |
|
1555 | + * |
|
1556 | + * @return \OCP\ISearch |
|
1557 | + */ |
|
1558 | + public function getSearch() { |
|
1559 | + return $this->query('Search'); |
|
1560 | + } |
|
1561 | + |
|
1562 | + /** |
|
1563 | + * Returns a SecureRandom instance |
|
1564 | + * |
|
1565 | + * @return \OCP\Security\ISecureRandom |
|
1566 | + */ |
|
1567 | + public function getSecureRandom() { |
|
1568 | + return $this->query('SecureRandom'); |
|
1569 | + } |
|
1570 | + |
|
1571 | + /** |
|
1572 | + * Returns a Crypto instance |
|
1573 | + * |
|
1574 | + * @return \OCP\Security\ICrypto |
|
1575 | + */ |
|
1576 | + public function getCrypto() { |
|
1577 | + return $this->query('Crypto'); |
|
1578 | + } |
|
1579 | + |
|
1580 | + /** |
|
1581 | + * Returns a Hasher instance |
|
1582 | + * |
|
1583 | + * @return \OCP\Security\IHasher |
|
1584 | + */ |
|
1585 | + public function getHasher() { |
|
1586 | + return $this->query('Hasher'); |
|
1587 | + } |
|
1588 | + |
|
1589 | + /** |
|
1590 | + * Returns a CredentialsManager instance |
|
1591 | + * |
|
1592 | + * @return \OCP\Security\ICredentialsManager |
|
1593 | + */ |
|
1594 | + public function getCredentialsManager() { |
|
1595 | + return $this->query('CredentialsManager'); |
|
1596 | + } |
|
1597 | + |
|
1598 | + /** |
|
1599 | + * Get the certificate manager for the user |
|
1600 | + * |
|
1601 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1602 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1603 | + */ |
|
1604 | + public function getCertificateManager($userId = '') { |
|
1605 | + if ($userId === '') { |
|
1606 | + $userSession = $this->getUserSession(); |
|
1607 | + $user = $userSession->getUser(); |
|
1608 | + if (is_null($user)) { |
|
1609 | + return null; |
|
1610 | + } |
|
1611 | + $userId = $user->getUID(); |
|
1612 | + } |
|
1613 | + return new CertificateManager( |
|
1614 | + $userId, |
|
1615 | + new View(), |
|
1616 | + $this->getConfig(), |
|
1617 | + $this->getLogger(), |
|
1618 | + $this->getSecureRandom() |
|
1619 | + ); |
|
1620 | + } |
|
1621 | + |
|
1622 | + /** |
|
1623 | + * Returns an instance of the HTTP client service |
|
1624 | + * |
|
1625 | + * @return \OCP\Http\Client\IClientService |
|
1626 | + */ |
|
1627 | + public function getHTTPClientService() { |
|
1628 | + return $this->query('HttpClientService'); |
|
1629 | + } |
|
1630 | + |
|
1631 | + /** |
|
1632 | + * Create a new event source |
|
1633 | + * |
|
1634 | + * @return \OCP\IEventSource |
|
1635 | + */ |
|
1636 | + public function createEventSource() { |
|
1637 | + return new \OC_EventSource(); |
|
1638 | + } |
|
1639 | + |
|
1640 | + /** |
|
1641 | + * Get the active event logger |
|
1642 | + * |
|
1643 | + * The returned logger only logs data when debug mode is enabled |
|
1644 | + * |
|
1645 | + * @return \OCP\Diagnostics\IEventLogger |
|
1646 | + */ |
|
1647 | + public function getEventLogger() { |
|
1648 | + return $this->query('EventLogger'); |
|
1649 | + } |
|
1650 | + |
|
1651 | + /** |
|
1652 | + * Get the active query logger |
|
1653 | + * |
|
1654 | + * The returned logger only logs data when debug mode is enabled |
|
1655 | + * |
|
1656 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1657 | + */ |
|
1658 | + public function getQueryLogger() { |
|
1659 | + return $this->query('QueryLogger'); |
|
1660 | + } |
|
1661 | + |
|
1662 | + /** |
|
1663 | + * Get the manager for temporary files and folders |
|
1664 | + * |
|
1665 | + * @return \OCP\ITempManager |
|
1666 | + */ |
|
1667 | + public function getTempManager() { |
|
1668 | + return $this->query('TempManager'); |
|
1669 | + } |
|
1670 | + |
|
1671 | + /** |
|
1672 | + * Get the app manager |
|
1673 | + * |
|
1674 | + * @return \OCP\App\IAppManager |
|
1675 | + */ |
|
1676 | + public function getAppManager() { |
|
1677 | + return $this->query('AppManager'); |
|
1678 | + } |
|
1679 | + |
|
1680 | + /** |
|
1681 | + * Creates a new mailer |
|
1682 | + * |
|
1683 | + * @return \OCP\Mail\IMailer |
|
1684 | + */ |
|
1685 | + public function getMailer() { |
|
1686 | + return $this->query('Mailer'); |
|
1687 | + } |
|
1688 | + |
|
1689 | + /** |
|
1690 | + * Get the webroot |
|
1691 | + * |
|
1692 | + * @return string |
|
1693 | + */ |
|
1694 | + public function getWebRoot() { |
|
1695 | + return $this->webRoot; |
|
1696 | + } |
|
1697 | + |
|
1698 | + /** |
|
1699 | + * @return \OC\OCSClient |
|
1700 | + */ |
|
1701 | + public function getOcsClient() { |
|
1702 | + return $this->query('OcsClient'); |
|
1703 | + } |
|
1704 | + |
|
1705 | + /** |
|
1706 | + * @return \OCP\IDateTimeZone |
|
1707 | + */ |
|
1708 | + public function getDateTimeZone() { |
|
1709 | + return $this->query('DateTimeZone'); |
|
1710 | + } |
|
1711 | + |
|
1712 | + /** |
|
1713 | + * @return \OCP\IDateTimeFormatter |
|
1714 | + */ |
|
1715 | + public function getDateTimeFormatter() { |
|
1716 | + return $this->query('DateTimeFormatter'); |
|
1717 | + } |
|
1718 | + |
|
1719 | + /** |
|
1720 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1721 | + */ |
|
1722 | + public function getMountProviderCollection() { |
|
1723 | + return $this->query('MountConfigManager'); |
|
1724 | + } |
|
1725 | + |
|
1726 | + /** |
|
1727 | + * Get the IniWrapper |
|
1728 | + * |
|
1729 | + * @return IniGetWrapper |
|
1730 | + */ |
|
1731 | + public function getIniWrapper() { |
|
1732 | + return $this->query('IniWrapper'); |
|
1733 | + } |
|
1734 | + |
|
1735 | + /** |
|
1736 | + * @return \OCP\Command\IBus |
|
1737 | + */ |
|
1738 | + public function getCommandBus() { |
|
1739 | + return $this->query('AsyncCommandBus'); |
|
1740 | + } |
|
1741 | + |
|
1742 | + /** |
|
1743 | + * Get the trusted domain helper |
|
1744 | + * |
|
1745 | + * @return TrustedDomainHelper |
|
1746 | + */ |
|
1747 | + public function getTrustedDomainHelper() { |
|
1748 | + return $this->query('TrustedDomainHelper'); |
|
1749 | + } |
|
1750 | + |
|
1751 | + /** |
|
1752 | + * Get the locking provider |
|
1753 | + * |
|
1754 | + * @return \OCP\Lock\ILockingProvider |
|
1755 | + * @since 8.1.0 |
|
1756 | + */ |
|
1757 | + public function getLockingProvider() { |
|
1758 | + return $this->query('LockingProvider'); |
|
1759 | + } |
|
1760 | + |
|
1761 | + /** |
|
1762 | + * @return \OCP\Files\Mount\IMountManager |
|
1763 | + **/ |
|
1764 | + function getMountManager() { |
|
1765 | + return $this->query('MountManager'); |
|
1766 | + } |
|
1767 | + |
|
1768 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1769 | + function getUserMountCache() { |
|
1770 | + return $this->query('UserMountCache'); |
|
1771 | + } |
|
1772 | + |
|
1773 | + /** |
|
1774 | + * Get the MimeTypeDetector |
|
1775 | + * |
|
1776 | + * @return \OCP\Files\IMimeTypeDetector |
|
1777 | + */ |
|
1778 | + public function getMimeTypeDetector() { |
|
1779 | + return $this->query('MimeTypeDetector'); |
|
1780 | + } |
|
1781 | + |
|
1782 | + /** |
|
1783 | + * Get the MimeTypeLoader |
|
1784 | + * |
|
1785 | + * @return \OCP\Files\IMimeTypeLoader |
|
1786 | + */ |
|
1787 | + public function getMimeTypeLoader() { |
|
1788 | + return $this->query('MimeTypeLoader'); |
|
1789 | + } |
|
1790 | + |
|
1791 | + /** |
|
1792 | + * Get the manager of all the capabilities |
|
1793 | + * |
|
1794 | + * @return \OC\CapabilitiesManager |
|
1795 | + */ |
|
1796 | + public function getCapabilitiesManager() { |
|
1797 | + return $this->query('CapabilitiesManager'); |
|
1798 | + } |
|
1799 | + |
|
1800 | + /** |
|
1801 | + * Get the EventDispatcher |
|
1802 | + * |
|
1803 | + * @return EventDispatcherInterface |
|
1804 | + * @since 8.2.0 |
|
1805 | + */ |
|
1806 | + public function getEventDispatcher() { |
|
1807 | + return $this->query('EventDispatcher'); |
|
1808 | + } |
|
1809 | + |
|
1810 | + /** |
|
1811 | + * Get the Notification Manager |
|
1812 | + * |
|
1813 | + * @return \OCP\Notification\IManager |
|
1814 | + * @since 8.2.0 |
|
1815 | + */ |
|
1816 | + public function getNotificationManager() { |
|
1817 | + return $this->query('NotificationManager'); |
|
1818 | + } |
|
1819 | + |
|
1820 | + /** |
|
1821 | + * @return \OCP\Comments\ICommentsManager |
|
1822 | + */ |
|
1823 | + public function getCommentsManager() { |
|
1824 | + return $this->query('CommentsManager'); |
|
1825 | + } |
|
1826 | + |
|
1827 | + /** |
|
1828 | + * @return \OCA\Theming\ThemingDefaults |
|
1829 | + */ |
|
1830 | + public function getThemingDefaults() { |
|
1831 | + return $this->query('ThemingDefaults'); |
|
1832 | + } |
|
1833 | + |
|
1834 | + /** |
|
1835 | + * @return \OC\IntegrityCheck\Checker |
|
1836 | + */ |
|
1837 | + public function getIntegrityCodeChecker() { |
|
1838 | + return $this->query('IntegrityCodeChecker'); |
|
1839 | + } |
|
1840 | + |
|
1841 | + /** |
|
1842 | + * @return \OC\Session\CryptoWrapper |
|
1843 | + */ |
|
1844 | + public function getSessionCryptoWrapper() { |
|
1845 | + return $this->query('CryptoWrapper'); |
|
1846 | + } |
|
1847 | + |
|
1848 | + /** |
|
1849 | + * @return CsrfTokenManager |
|
1850 | + */ |
|
1851 | + public function getCsrfTokenManager() { |
|
1852 | + return $this->query('CsrfTokenManager'); |
|
1853 | + } |
|
1854 | + |
|
1855 | + /** |
|
1856 | + * @return Throttler |
|
1857 | + */ |
|
1858 | + public function getBruteForceThrottler() { |
|
1859 | + return $this->query('Throttler'); |
|
1860 | + } |
|
1861 | + |
|
1862 | + /** |
|
1863 | + * @return IContentSecurityPolicyManager |
|
1864 | + */ |
|
1865 | + public function getContentSecurityPolicyManager() { |
|
1866 | + return $this->query('ContentSecurityPolicyManager'); |
|
1867 | + } |
|
1868 | + |
|
1869 | + /** |
|
1870 | + * @return ContentSecurityPolicyNonceManager |
|
1871 | + */ |
|
1872 | + public function getContentSecurityPolicyNonceManager() { |
|
1873 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1874 | + } |
|
1875 | + |
|
1876 | + /** |
|
1877 | + * Not a public API as of 8.2, wait for 9.0 |
|
1878 | + * |
|
1879 | + * @return \OCA\Files_External\Service\BackendService |
|
1880 | + */ |
|
1881 | + public function getStoragesBackendService() { |
|
1882 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1883 | + } |
|
1884 | + |
|
1885 | + /** |
|
1886 | + * Not a public API as of 8.2, wait for 9.0 |
|
1887 | + * |
|
1888 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1889 | + */ |
|
1890 | + public function getGlobalStoragesService() { |
|
1891 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1892 | + } |
|
1893 | + |
|
1894 | + /** |
|
1895 | + * Not a public API as of 8.2, wait for 9.0 |
|
1896 | + * |
|
1897 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1898 | + */ |
|
1899 | + public function getUserGlobalStoragesService() { |
|
1900 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1901 | + } |
|
1902 | + |
|
1903 | + /** |
|
1904 | + * Not a public API as of 8.2, wait for 9.0 |
|
1905 | + * |
|
1906 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1907 | + */ |
|
1908 | + public function getUserStoragesService() { |
|
1909 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1910 | + } |
|
1911 | + |
|
1912 | + /** |
|
1913 | + * @return \OCP\Share\IManager |
|
1914 | + */ |
|
1915 | + public function getShareManager() { |
|
1916 | + return $this->query('ShareManager'); |
|
1917 | + } |
|
1918 | + |
|
1919 | + /** |
|
1920 | + * @return \OCP\Collaboration\Collaborators\ISearch |
|
1921 | + */ |
|
1922 | + public function getCollaboratorSearch() { |
|
1923 | + return $this->query('CollaboratorSearch'); |
|
1924 | + } |
|
1925 | + |
|
1926 | + /** |
|
1927 | + * @return \OCP\Collaboration\AutoComplete\IManager |
|
1928 | + */ |
|
1929 | + public function getAutoCompleteManager(){ |
|
1930 | + return $this->query(IManager::class); |
|
1931 | + } |
|
1932 | + |
|
1933 | + /** |
|
1934 | + * Returns the LDAP Provider |
|
1935 | + * |
|
1936 | + * @return \OCP\LDAP\ILDAPProvider |
|
1937 | + */ |
|
1938 | + public function getLDAPProvider() { |
|
1939 | + return $this->query('LDAPProvider'); |
|
1940 | + } |
|
1941 | + |
|
1942 | + /** |
|
1943 | + * @return \OCP\Settings\IManager |
|
1944 | + */ |
|
1945 | + public function getSettingsManager() { |
|
1946 | + return $this->query('SettingsManager'); |
|
1947 | + } |
|
1948 | + |
|
1949 | + /** |
|
1950 | + * @return \OCP\Files\IAppData |
|
1951 | + */ |
|
1952 | + public function getAppDataDir($app) { |
|
1953 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1954 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1955 | + return $factory->get($app); |
|
1956 | + } |
|
1957 | + |
|
1958 | + /** |
|
1959 | + * @return \OCP\Lockdown\ILockdownManager |
|
1960 | + */ |
|
1961 | + public function getLockdownManager() { |
|
1962 | + return $this->query('LockdownManager'); |
|
1963 | + } |
|
1964 | + |
|
1965 | + /** |
|
1966 | + * @return \OCP\Federation\ICloudIdManager |
|
1967 | + */ |
|
1968 | + public function getCloudIdManager() { |
|
1969 | + return $this->query(ICloudIdManager::class); |
|
1970 | + } |
|
1971 | + |
|
1972 | + /** |
|
1973 | + * @return \OCP\Remote\Api\IApiFactory |
|
1974 | + */ |
|
1975 | + public function getRemoteApiFactory() { |
|
1976 | + return $this->query(IApiFactory::class); |
|
1977 | + } |
|
1978 | + |
|
1979 | + /** |
|
1980 | + * @return \OCP\Remote\IInstanceFactory |
|
1981 | + */ |
|
1982 | + public function getRemoteInstanceFactory() { |
|
1983 | + return $this->query(IInstanceFactory::class); |
|
1984 | + } |
|
1985 | 1985 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | parent::__construct(); |
165 | 165 | $this->webRoot = $webRoot; |
166 | 166 | |
167 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
167 | + $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
168 | 168 | return $c; |
169 | 169 | }); |
170 | 170 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $this->registerAlias(IActionFactory::class, ActionFactory::class); |
178 | 178 | |
179 | 179 | |
180 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
180 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
181 | 181 | return new PreviewManager( |
182 | 182 | $c->getConfig(), |
183 | 183 | $c->getRootFolder(), |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | }); |
189 | 189 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
190 | 190 | |
191 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
191 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
192 | 192 | return new \OC\Preview\Watcher( |
193 | 193 | $c->getAppDataDir('preview') |
194 | 194 | ); |
195 | 195 | }); |
196 | 196 | |
197 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
197 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
198 | 198 | $view = new View(); |
199 | 199 | $util = new Encryption\Util( |
200 | 200 | $view, |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | ); |
213 | 213 | }); |
214 | 214 | |
215 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
215 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
216 | 216 | $util = new Encryption\Util( |
217 | 217 | new View(), |
218 | 218 | $c->getUserManager(), |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | ); |
227 | 227 | }); |
228 | 228 | |
229 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
229 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
230 | 230 | $view = new View(); |
231 | 231 | $util = new Encryption\Util( |
232 | 232 | $view, |
@@ -237,30 +237,30 @@ discard block |
||
237 | 237 | |
238 | 238 | return new Encryption\Keys\Storage($view, $util); |
239 | 239 | }); |
240 | - $this->registerService('TagMapper', function (Server $c) { |
|
240 | + $this->registerService('TagMapper', function(Server $c) { |
|
241 | 241 | return new TagMapper($c->getDatabaseConnection()); |
242 | 242 | }); |
243 | 243 | |
244 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
244 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
245 | 245 | $tagMapper = $c->query('TagMapper'); |
246 | 246 | return new TagManager($tagMapper, $c->getUserSession()); |
247 | 247 | }); |
248 | 248 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
249 | 249 | |
250 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
250 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
251 | 251 | $config = $c->getConfig(); |
252 | 252 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
253 | 253 | return new $factoryClass($this); |
254 | 254 | }); |
255 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
255 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
256 | 256 | return $c->query('SystemTagManagerFactory')->getManager(); |
257 | 257 | }); |
258 | 258 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
259 | 259 | |
260 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
260 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
261 | 261 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
262 | 262 | }); |
263 | - $this->registerService('RootFolder', function (Server $c) { |
|
263 | + $this->registerService('RootFolder', function(Server $c) { |
|
264 | 264 | $manager = \OC\Files\Filesystem::getMountManager(null); |
265 | 265 | $view = new View(); |
266 | 266 | $root = new Root( |
@@ -281,38 +281,38 @@ discard block |
||
281 | 281 | }); |
282 | 282 | $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
283 | 283 | |
284 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
285 | - return new LazyRoot(function () use ($c) { |
|
284 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
285 | + return new LazyRoot(function() use ($c) { |
|
286 | 286 | return $c->query('RootFolder'); |
287 | 287 | }); |
288 | 288 | }); |
289 | 289 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
290 | 290 | |
291 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
291 | + $this->registerService(\OC\User\Manager::class, function(Server $c) { |
|
292 | 292 | $config = $c->getConfig(); |
293 | 293 | return new \OC\User\Manager($config); |
294 | 294 | }); |
295 | 295 | $this->registerAlias('UserManager', \OC\User\Manager::class); |
296 | 296 | $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
297 | 297 | |
298 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
298 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
299 | 299 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
300 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
300 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
301 | 301 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
302 | 302 | }); |
303 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
303 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
304 | 304 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
305 | 305 | }); |
306 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
306 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
307 | 307 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
308 | 308 | }); |
309 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
309 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
310 | 310 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
311 | 311 | }); |
312 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
312 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
313 | 313 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
314 | 314 | }); |
315 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
315 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
316 | 316 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
317 | 317 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
318 | 318 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | }); |
322 | 322 | $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
323 | 323 | |
324 | - $this->registerService(Store::class, function (Server $c) { |
|
324 | + $this->registerService(Store::class, function(Server $c) { |
|
325 | 325 | $session = $c->getSession(); |
326 | 326 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
327 | 327 | $tokenProvider = $c->query(IProvider::class); |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | return new Store($session, $logger, $tokenProvider); |
333 | 333 | }); |
334 | 334 | $this->registerAlias(IStore::class, Store::class); |
335 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
335 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function(Server $c) { |
|
336 | 336 | $dbConnection = $c->getDatabaseConnection(); |
337 | 337 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
338 | 338 | }); |
339 | - $this->registerService(Authentication\Token\DefaultTokenProvider::class, function (Server $c) { |
|
339 | + $this->registerService(Authentication\Token\DefaultTokenProvider::class, function(Server $c) { |
|
340 | 340 | $mapper = $c->query(Authentication\Token\DefaultTokenMapper::class); |
341 | 341 | $crypto = $c->getCrypto(); |
342 | 342 | $config = $c->getConfig(); |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | }); |
347 | 347 | $this->registerAlias(IProvider::class, Authentication\Token\DefaultTokenProvider::class); |
348 | 348 | |
349 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
349 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
350 | 350 | $manager = $c->getUserManager(); |
351 | 351 | $session = new \OC\Session\Memory(''); |
352 | 352 | $timeFactory = new TimeFactory(); |
@@ -370,45 +370,45 @@ discard block |
||
370 | 370 | $c->getLockdownManager(), |
371 | 371 | $c->getLogger() |
372 | 372 | ); |
373 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
373 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
374 | 374 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
375 | 375 | }); |
376 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
376 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
377 | 377 | /** @var $user \OC\User\User */ |
378 | 378 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
379 | 379 | }); |
380 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
380 | + $userSession->listen('\OC\User', 'preDelete', function($user) use ($dispatcher) { |
|
381 | 381 | /** @var $user \OC\User\User */ |
382 | 382 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
383 | 383 | $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
384 | 384 | }); |
385 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
385 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
386 | 386 | /** @var $user \OC\User\User */ |
387 | 387 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
388 | 388 | }); |
389 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
389 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
390 | 390 | /** @var $user \OC\User\User */ |
391 | 391 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
392 | 392 | }); |
393 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
393 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
394 | 394 | /** @var $user \OC\User\User */ |
395 | 395 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
396 | 396 | }); |
397 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
397 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
398 | 398 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
399 | 399 | }); |
400 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
400 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
401 | 401 | /** @var $user \OC\User\User */ |
402 | 402 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
403 | 403 | }); |
404 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
404 | + $userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) { |
|
405 | 405 | /** @var $user \OC\User\User */ |
406 | 406 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
407 | 407 | }); |
408 | - $userSession->listen('\OC\User', 'logout', function () { |
|
408 | + $userSession->listen('\OC\User', 'logout', function() { |
|
409 | 409 | \OC_Hook::emit('OC_User', 'logout', array()); |
410 | 410 | }); |
411 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
411 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
412 | 412 | /** @var $user \OC\User\User */ |
413 | 413 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
414 | 414 | $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | }); |
418 | 418 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
419 | 419 | |
420 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
420 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
421 | 421 | return new \OC\Authentication\TwoFactorAuth\Manager( |
422 | 422 | $c->getAppManager(), |
423 | 423 | $c->getSession(), |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
434 | 434 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
435 | 435 | |
436 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
436 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
437 | 437 | return new \OC\AllConfig( |
438 | 438 | $c->getSystemConfig() |
439 | 439 | ); |
@@ -441,17 +441,17 @@ discard block |
||
441 | 441 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
442 | 442 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
443 | 443 | |
444 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
444 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
445 | 445 | return new \OC\SystemConfig($config); |
446 | 446 | }); |
447 | 447 | |
448 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
448 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
449 | 449 | return new \OC\AppConfig($c->getDatabaseConnection()); |
450 | 450 | }); |
451 | 451 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
452 | 452 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
453 | 453 | |
454 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
454 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
455 | 455 | return new \OC\L10N\Factory( |
456 | 456 | $c->getConfig(), |
457 | 457 | $c->getRequest(), |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | }); |
462 | 462 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
463 | 463 | |
464 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
464 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
465 | 465 | $config = $c->getConfig(); |
466 | 466 | $cacheFactory = $c->getMemCacheFactory(); |
467 | 467 | $request = $c->getRequest(); |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | $this->registerAlias('AppFetcher', AppFetcher::class); |
477 | 477 | $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
478 | 478 | |
479 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
479 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
480 | 480 | return new Cache\File(); |
481 | 481 | }); |
482 | 482 | $this->registerAlias('UserCache', \OCP\ICache::class); |
483 | 483 | |
484 | - $this->registerService(Factory::class, function (Server $c) { |
|
484 | + $this->registerService(Factory::class, function(Server $c) { |
|
485 | 485 | |
486 | 486 | $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
487 | 487 | ArrayCache::class, |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $version = implode(',', $v); |
499 | 499 | $instanceId = \OC_Util::getInstanceId(); |
500 | 500 | $path = \OC::$SERVERROOT; |
501 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
501 | + $prefix = md5($instanceId.'-'.$version.'-'.$path); |
|
502 | 502 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
503 | 503 | $config->getSystemValue('memcache.local', null), |
504 | 504 | $config->getSystemValue('memcache.distributed', null), |
@@ -511,12 +511,12 @@ discard block |
||
511 | 511 | $this->registerAlias('MemCacheFactory', Factory::class); |
512 | 512 | $this->registerAlias(ICacheFactory::class, Factory::class); |
513 | 513 | |
514 | - $this->registerService('RedisFactory', function (Server $c) { |
|
514 | + $this->registerService('RedisFactory', function(Server $c) { |
|
515 | 515 | $systemConfig = $c->getSystemConfig(); |
516 | 516 | return new RedisFactory($systemConfig); |
517 | 517 | }); |
518 | 518 | |
519 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
519 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
520 | 520 | return new \OC\Activity\Manager( |
521 | 521 | $c->getRequest(), |
522 | 522 | $c->getUserSession(), |
@@ -526,14 +526,14 @@ discard block |
||
526 | 526 | }); |
527 | 527 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
528 | 528 | |
529 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
529 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
530 | 530 | return new \OC\Activity\EventMerger( |
531 | 531 | $c->getL10N('lib') |
532 | 532 | ); |
533 | 533 | }); |
534 | 534 | $this->registerAlias(IValidator::class, Validator::class); |
535 | 535 | |
536 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
536 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
537 | 537 | return new AvatarManager( |
538 | 538 | $c->query(\OC\User\Manager::class), |
539 | 539 | $c->getAppDataDir('avatar'), |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | |
547 | 547 | $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
548 | 548 | |
549 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
549 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
550 | 550 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
551 | 551 | $factory = new LogFactory($c, $this->getSystemConfig()); |
552 | 552 | $logger = $factory->get($logType); |
@@ -556,11 +556,11 @@ discard block |
||
556 | 556 | }); |
557 | 557 | $this->registerAlias('Logger', \OCP\ILogger::class); |
558 | 558 | |
559 | - $this->registerService(ILogFactory::class, function (Server $c) { |
|
559 | + $this->registerService(ILogFactory::class, function(Server $c) { |
|
560 | 560 | return new LogFactory($c, $this->getSystemConfig()); |
561 | 561 | }); |
562 | 562 | |
563 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
563 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
564 | 564 | $config = $c->getConfig(); |
565 | 565 | return new \OC\BackgroundJob\JobList( |
566 | 566 | $c->getDatabaseConnection(), |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | }); |
571 | 571 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
572 | 572 | |
573 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
573 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
574 | 574 | $cacheFactory = $c->getMemCacheFactory(); |
575 | 575 | $logger = $c->getLogger(); |
576 | 576 | if ($cacheFactory->isLocalCacheAvailable()) { |
@@ -582,12 +582,12 @@ discard block |
||
582 | 582 | }); |
583 | 583 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
584 | 584 | |
585 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
585 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
586 | 586 | return new Search(); |
587 | 587 | }); |
588 | 588 | $this->registerAlias('Search', \OCP\ISearch::class); |
589 | 589 | |
590 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function (Server $c) { |
|
590 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function(Server $c) { |
|
591 | 591 | return new \OC\Security\RateLimiting\Limiter( |
592 | 592 | $this->getUserSession(), |
593 | 593 | $this->getRequest(), |
@@ -595,34 +595,34 @@ discard block |
||
595 | 595 | $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
596 | 596 | ); |
597 | 597 | }); |
598 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
598 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
599 | 599 | return new \OC\Security\RateLimiting\Backend\MemoryCache( |
600 | 600 | $this->getMemCacheFactory(), |
601 | 601 | new \OC\AppFramework\Utility\TimeFactory() |
602 | 602 | ); |
603 | 603 | }); |
604 | 604 | |
605 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
605 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
606 | 606 | return new SecureRandom(); |
607 | 607 | }); |
608 | 608 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
609 | 609 | |
610 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
610 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
611 | 611 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
612 | 612 | }); |
613 | 613 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
614 | 614 | |
615 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
615 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
616 | 616 | return new Hasher($c->getConfig()); |
617 | 617 | }); |
618 | 618 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
619 | 619 | |
620 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
620 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
621 | 621 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
622 | 622 | }); |
623 | 623 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
624 | 624 | |
625 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
625 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
626 | 626 | $systemConfig = $c->getSystemConfig(); |
627 | 627 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
628 | 628 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
638 | 638 | |
639 | 639 | |
640 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
640 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
641 | 641 | $user = \OC_User::getUser(); |
642 | 642 | $uid = $user ? $user : null; |
643 | 643 | return new ClientService( |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | ); |
653 | 653 | }); |
654 | 654 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
655 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
655 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
656 | 656 | $eventLogger = new EventLogger(); |
657 | 657 | if ($c->getSystemConfig()->getValue('debug', false)) { |
658 | 658 | // In debug mode, module is being activated by default |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | }); |
663 | 663 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
664 | 664 | |
665 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
665 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
666 | 666 | $queryLogger = new QueryLogger(); |
667 | 667 | if ($c->getSystemConfig()->getValue('debug', false)) { |
668 | 668 | // In debug mode, module is being activated by default |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | }); |
673 | 673 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
674 | 674 | |
675 | - $this->registerService(TempManager::class, function (Server $c) { |
|
675 | + $this->registerService(TempManager::class, function(Server $c) { |
|
676 | 676 | return new TempManager( |
677 | 677 | $c->getLogger(), |
678 | 678 | $c->getConfig() |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | $this->registerAlias('TempManager', TempManager::class); |
682 | 682 | $this->registerAlias(ITempManager::class, TempManager::class); |
683 | 683 | |
684 | - $this->registerService(AppManager::class, function (Server $c) { |
|
684 | + $this->registerService(AppManager::class, function(Server $c) { |
|
685 | 685 | return new \OC\App\AppManager( |
686 | 686 | $c->getUserSession(), |
687 | 687 | $c->query(\OC\AppConfig::class), |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | $this->registerAlias('AppManager', AppManager::class); |
694 | 694 | $this->registerAlias(IAppManager::class, AppManager::class); |
695 | 695 | |
696 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
696 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
697 | 697 | return new DateTimeZone( |
698 | 698 | $c->getConfig(), |
699 | 699 | $c->getSession() |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | }); |
702 | 702 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
703 | 703 | |
704 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
704 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
705 | 705 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
706 | 706 | |
707 | 707 | return new DateTimeFormatter( |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | }); |
712 | 712 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
713 | 713 | |
714 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
714 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
715 | 715 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
716 | 716 | $listener = new UserMountCacheListener($mountCache); |
717 | 717 | $listener->listen($c->getUserManager()); |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | }); |
720 | 720 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
721 | 721 | |
722 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
722 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
723 | 723 | $loader = \OC\Files\Filesystem::getLoader(); |
724 | 724 | $mountCache = $c->query('UserMountCache'); |
725 | 725 | $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
@@ -735,10 +735,10 @@ discard block |
||
735 | 735 | }); |
736 | 736 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
737 | 737 | |
738 | - $this->registerService('IniWrapper', function ($c) { |
|
738 | + $this->registerService('IniWrapper', function($c) { |
|
739 | 739 | return new IniGetWrapper(); |
740 | 740 | }); |
741 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
741 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
742 | 742 | $busClass = $c->getConfig()->getSystemValue('commandbus'); |
743 | 743 | if ($busClass) { |
744 | 744 | list($app, $class) = explode('::', $busClass, 2); |
@@ -753,10 +753,10 @@ discard block |
||
753 | 753 | return new CronBus($jobList); |
754 | 754 | } |
755 | 755 | }); |
756 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
756 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
757 | 757 | return new TrustedDomainHelper($this->getConfig()); |
758 | 758 | }); |
759 | - $this->registerService('Throttler', function (Server $c) { |
|
759 | + $this->registerService('Throttler', function(Server $c) { |
|
760 | 760 | return new Throttler( |
761 | 761 | $c->getDatabaseConnection(), |
762 | 762 | new TimeFactory(), |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | $c->getConfig() |
765 | 765 | ); |
766 | 766 | }); |
767 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
767 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
768 | 768 | // IConfig and IAppManager requires a working database. This code |
769 | 769 | // might however be called when ownCloud is not yet setup. |
770 | 770 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | $c->getTempManager() |
786 | 786 | ); |
787 | 787 | }); |
788 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
788 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
789 | 789 | if (isset($this['urlParams'])) { |
790 | 790 | $urlParams = $this['urlParams']; |
791 | 791 | } else { |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | }); |
822 | 822 | $this->registerAlias('Request', \OCP\IRequest::class); |
823 | 823 | |
824 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
824 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
825 | 825 | return new Mailer( |
826 | 826 | $c->getConfig(), |
827 | 827 | $c->getLogger(), |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | }); |
833 | 833 | $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
834 | 834 | |
835 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
835 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
836 | 836 | $config = $c->getConfig(); |
837 | 837 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
838 | 838 | if (is_null($factoryClass)) { |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | $factory = new $factoryClass($this); |
843 | 843 | return $factory->getLDAPProvider(); |
844 | 844 | }); |
845 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
845 | + $this->registerService(ILockingProvider::class, function(Server $c) { |
|
846 | 846 | $ini = $c->getIniWrapper(); |
847 | 847 | $config = $c->getConfig(); |
848 | 848 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -865,49 +865,49 @@ discard block |
||
865 | 865 | }); |
866 | 866 | $this->registerAlias('LockingProvider', ILockingProvider::class); |
867 | 867 | |
868 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
868 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
869 | 869 | return new \OC\Files\Mount\Manager(); |
870 | 870 | }); |
871 | 871 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
872 | 872 | |
873 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
873 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
874 | 874 | return new \OC\Files\Type\Detection( |
875 | 875 | $c->getURLGenerator(), |
876 | 876 | \OC::$configDir, |
877 | - \OC::$SERVERROOT . '/resources/config/' |
|
877 | + \OC::$SERVERROOT.'/resources/config/' |
|
878 | 878 | ); |
879 | 879 | }); |
880 | 880 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
881 | 881 | |
882 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
882 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
883 | 883 | return new \OC\Files\Type\Loader( |
884 | 884 | $c->getDatabaseConnection() |
885 | 885 | ); |
886 | 886 | }); |
887 | 887 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
888 | - $this->registerService(BundleFetcher::class, function () { |
|
888 | + $this->registerService(BundleFetcher::class, function() { |
|
889 | 889 | return new BundleFetcher($this->getL10N('lib')); |
890 | 890 | }); |
891 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
891 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
892 | 892 | return new Manager( |
893 | 893 | $c->query(IValidator::class) |
894 | 894 | ); |
895 | 895 | }); |
896 | 896 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
897 | 897 | |
898 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
898 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
899 | 899 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
900 | - $manager->registerCapability(function () use ($c) { |
|
900 | + $manager->registerCapability(function() use ($c) { |
|
901 | 901 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
902 | 902 | }); |
903 | - $manager->registerCapability(function () use ($c) { |
|
903 | + $manager->registerCapability(function() use ($c) { |
|
904 | 904 | return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
905 | 905 | }); |
906 | 906 | return $manager; |
907 | 907 | }); |
908 | 908 | $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
909 | 909 | |
910 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
910 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
911 | 911 | $config = $c->getConfig(); |
912 | 912 | $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
913 | 913 | /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
918 | 918 | $manager = $c->getUserManager(); |
919 | 919 | $user = $manager->get($id); |
920 | - if(is_null($user)) { |
|
920 | + if (is_null($user)) { |
|
921 | 921 | $l = $c->getL10N('core'); |
922 | 922 | $displayName = $l->t('Unknown user'); |
923 | 923 | } else { |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | }); |
931 | 931 | $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
932 | 932 | |
933 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
933 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
934 | 934 | /* |
935 | 935 | * Dark magic for autoloader. |
936 | 936 | * If we do a class_exists it will try to load the class which will |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | } |
958 | 958 | return new \OC_Defaults(); |
959 | 959 | }); |
960 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
960 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
961 | 961 | /** @var Factory $cacheFactory */ |
962 | 962 | $cacheFactory = $c->query(Factory::class); |
963 | 963 | return new SCSSCacher( |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | $this->getMemCacheFactory() |
971 | 971 | ); |
972 | 972 | }); |
973 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
973 | + $this->registerService(JSCombiner::class, function(Server $c) { |
|
974 | 974 | /** @var Factory $cacheFactory */ |
975 | 975 | $cacheFactory = $c->query(Factory::class); |
976 | 976 | return new JSCombiner( |
@@ -981,13 +981,13 @@ discard block |
||
981 | 981 | $c->getLogger() |
982 | 982 | ); |
983 | 983 | }); |
984 | - $this->registerService(EventDispatcher::class, function () { |
|
984 | + $this->registerService(EventDispatcher::class, function() { |
|
985 | 985 | return new EventDispatcher(); |
986 | 986 | }); |
987 | 987 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
988 | 988 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
989 | 989 | |
990 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
990 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
991 | 991 | // FIXME: Instantiiated here due to cyclic dependency |
992 | 992 | $request = new Request( |
993 | 993 | [ |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | $request |
1013 | 1013 | ); |
1014 | 1014 | }); |
1015 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
1015 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
1016 | 1016 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
1017 | 1017 | |
1018 | 1018 | return new CsrfTokenManager( |
@@ -1020,22 +1020,22 @@ discard block |
||
1020 | 1020 | $c->query(SessionStorage::class) |
1021 | 1021 | ); |
1022 | 1022 | }); |
1023 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
1023 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
1024 | 1024 | return new SessionStorage($c->getSession()); |
1025 | 1025 | }); |
1026 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
1026 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
1027 | 1027 | return new ContentSecurityPolicyManager(); |
1028 | 1028 | }); |
1029 | 1029 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
1030 | 1030 | |
1031 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
1031 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
1032 | 1032 | return new ContentSecurityPolicyNonceManager( |
1033 | 1033 | $c->getCsrfTokenManager(), |
1034 | 1034 | $c->getRequest() |
1035 | 1035 | ); |
1036 | 1036 | }); |
1037 | 1037 | |
1038 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
1038 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
1039 | 1039 | $config = $c->getConfig(); |
1040 | 1040 | $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
1041 | 1041 | /** @var \OCP\Share\IProviderFactory $factory */ |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | |
1079 | 1079 | $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
1080 | 1080 | |
1081 | - $this->registerService('SettingsManager', function (Server $c) { |
|
1081 | + $this->registerService('SettingsManager', function(Server $c) { |
|
1082 | 1082 | $manager = new \OC\Settings\Manager( |
1083 | 1083 | $c->getLogger(), |
1084 | 1084 | $c->getDatabaseConnection(), |
@@ -1096,24 +1096,24 @@ discard block |
||
1096 | 1096 | ); |
1097 | 1097 | return $manager; |
1098 | 1098 | }); |
1099 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
1099 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
1100 | 1100 | return new \OC\Files\AppData\Factory( |
1101 | 1101 | $c->getRootFolder(), |
1102 | 1102 | $c->getSystemConfig() |
1103 | 1103 | ); |
1104 | 1104 | }); |
1105 | 1105 | |
1106 | - $this->registerService('LockdownManager', function (Server $c) { |
|
1107 | - return new LockdownManager(function () use ($c) { |
|
1106 | + $this->registerService('LockdownManager', function(Server $c) { |
|
1107 | + return new LockdownManager(function() use ($c) { |
|
1108 | 1108 | return $c->getSession(); |
1109 | 1109 | }); |
1110 | 1110 | }); |
1111 | 1111 | |
1112 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
1112 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) { |
|
1113 | 1113 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
1114 | 1114 | }); |
1115 | 1115 | |
1116 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
1116 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
1117 | 1117 | return new CloudIdManager(); |
1118 | 1118 | }); |
1119 | 1119 | |
@@ -1123,18 +1123,18 @@ discard block |
||
1123 | 1123 | $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
1124 | 1124 | $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
1125 | 1125 | |
1126 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1126 | + $this->registerService(Defaults::class, function(Server $c) { |
|
1127 | 1127 | return new Defaults( |
1128 | 1128 | $c->getThemingDefaults() |
1129 | 1129 | ); |
1130 | 1130 | }); |
1131 | 1131 | $this->registerAlias('Defaults', \OCP\Defaults::class); |
1132 | 1132 | |
1133 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
1133 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
1134 | 1134 | return $c->query(\OCP\IUserSession::class)->getSession(); |
1135 | 1135 | }); |
1136 | 1136 | |
1137 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
1137 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
1138 | 1138 | return new ShareHelper( |
1139 | 1139 | $c->query(\OCP\Share\IManager::class) |
1140 | 1140 | ); |
@@ -1196,11 +1196,11 @@ discard block |
||
1196 | 1196 | // no avatar to remove |
1197 | 1197 | } catch (\Exception $e) { |
1198 | 1198 | // Ignore exceptions |
1199 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
1199 | + $logger->info('Could not cleanup avatar of '.$user->getUID()); |
|
1200 | 1200 | } |
1201 | 1201 | }); |
1202 | 1202 | |
1203 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
1203 | + $dispatcher->addListener('OCP\IUser::changeUser', function(GenericEvent $e) { |
|
1204 | 1204 | $manager = $this->getAvatarManager(); |
1205 | 1205 | /** @var IUser $user */ |
1206 | 1206 | $user = $e->getSubject(); |
@@ -1351,7 +1351,7 @@ discard block |
||
1351 | 1351 | * @deprecated since 9.2.0 use IAppData |
1352 | 1352 | */ |
1353 | 1353 | public function getAppFolder() { |
1354 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1354 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
1355 | 1355 | $root = $this->getRootFolder(); |
1356 | 1356 | if (!$root->nodeExists($dir)) { |
1357 | 1357 | $folder = $root->newFolder($dir); |
@@ -1926,7 +1926,7 @@ discard block |
||
1926 | 1926 | /** |
1927 | 1927 | * @return \OCP\Collaboration\AutoComplete\IManager |
1928 | 1928 | */ |
1929 | - public function getAutoCompleteManager(){ |
|
1929 | + public function getAutoCompleteManager() { |
|
1930 | 1930 | return $this->query(IManager::class); |
1931 | 1931 | } |
1932 | 1932 |
@@ -31,48 +31,48 @@ |
||
31 | 31 | use OCP\Log\IWriter; |
32 | 32 | |
33 | 33 | class LogFactory implements ILogFactory { |
34 | - /** @var IServerContainer */ |
|
35 | - private $c; |
|
36 | - /** @var SystemConfig */ |
|
37 | - private $systemConfig; |
|
34 | + /** @var IServerContainer */ |
|
35 | + private $c; |
|
36 | + /** @var SystemConfig */ |
|
37 | + private $systemConfig; |
|
38 | 38 | |
39 | - public function __construct(IServerContainer $c, SystemConfig $systemConfig) { |
|
40 | - $this->c = $c; |
|
41 | - $this->systemConfig = $systemConfig; |
|
42 | - } |
|
39 | + public function __construct(IServerContainer $c, SystemConfig $systemConfig) { |
|
40 | + $this->c = $c; |
|
41 | + $this->systemConfig = $systemConfig; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @throws \OCP\AppFramework\QueryException |
|
46 | - */ |
|
47 | - public function get(string $type):IWriter { |
|
48 | - switch (strtolower($type)) { |
|
49 | - case 'errorlog': |
|
50 | - return new Errorlog(); |
|
51 | - case 'syslog': |
|
52 | - return $this->c->resolve(Syslog::class); |
|
53 | - case 'file': |
|
54 | - return $this->buildLogFile(); |
|
44 | + /** |
|
45 | + * @throws \OCP\AppFramework\QueryException |
|
46 | + */ |
|
47 | + public function get(string $type):IWriter { |
|
48 | + switch (strtolower($type)) { |
|
49 | + case 'errorlog': |
|
50 | + return new Errorlog(); |
|
51 | + case 'syslog': |
|
52 | + return $this->c->resolve(Syslog::class); |
|
53 | + case 'file': |
|
54 | + return $this->buildLogFile(); |
|
55 | 55 | |
56 | - // Backwards compatibility for old and fallback for unknown log types |
|
57 | - case 'owncloud': |
|
58 | - case 'nextcloud': |
|
59 | - default: |
|
60 | - return $this->buildLogFile(); |
|
61 | - } |
|
62 | - } |
|
56 | + // Backwards compatibility for old and fallback for unknown log types |
|
57 | + case 'owncloud': |
|
58 | + case 'nextcloud': |
|
59 | + default: |
|
60 | + return $this->buildLogFile(); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - public function getCustomLogger(string $path):ILogger { |
|
65 | - $log = $this->buildLogFile($path); |
|
66 | - return new Log($log, $this->systemConfig); |
|
67 | - } |
|
64 | + public function getCustomLogger(string $path):ILogger { |
|
65 | + $log = $this->buildLogFile($path); |
|
66 | + return new Log($log, $this->systemConfig); |
|
67 | + } |
|
68 | 68 | |
69 | - protected function buildLogFile(string $logFile = ''):File { |
|
70 | - $defaultLogFile = $this->systemConfig->getValue('datadirectory', \OC::$SERVERROOT.'/data').'/nextcloud.log'; |
|
71 | - if($logFile === '') { |
|
72 | - $logFile = $this->systemConfig->getValue('logfile', $defaultLogFile); |
|
73 | - } |
|
74 | - $fallback = $defaultLogFile !== $logFile ? $defaultLogFile : ''; |
|
69 | + protected function buildLogFile(string $logFile = ''):File { |
|
70 | + $defaultLogFile = $this->systemConfig->getValue('datadirectory', \OC::$SERVERROOT.'/data').'/nextcloud.log'; |
|
71 | + if($logFile === '') { |
|
72 | + $logFile = $this->systemConfig->getValue('logfile', $defaultLogFile); |
|
73 | + } |
|
74 | + $fallback = $defaultLogFile !== $logFile ? $defaultLogFile : ''; |
|
75 | 75 | |
76 | - return new File($logFile, $fallback, $this->systemConfig); |
|
77 | - } |
|
76 | + return new File($logFile, $fallback, $this->systemConfig); |
|
77 | + } |
|
78 | 78 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | |
69 | 69 | protected function buildLogFile(string $logFile = ''):File { |
70 | 70 | $defaultLogFile = $this->systemConfig->getValue('datadirectory', \OC::$SERVERROOT.'/data').'/nextcloud.log'; |
71 | - if($logFile === '') { |
|
71 | + if ($logFile === '') { |
|
72 | 72 | $logFile = $this->systemConfig->getValue('logfile', $defaultLogFile); |
73 | 73 | } |
74 | 74 | $fallback = $defaultLogFile !== $logFile ? $defaultLogFile : ''; |
@@ -48,159 +48,159 @@ |
||
48 | 48 | */ |
49 | 49 | |
50 | 50 | class File implements IWriter, IFileBased { |
51 | - /** @var string */ |
|
52 | - protected $logFile; |
|
53 | - /** @var SystemConfig */ |
|
54 | - private $config; |
|
51 | + /** @var string */ |
|
52 | + protected $logFile; |
|
53 | + /** @var SystemConfig */ |
|
54 | + private $config; |
|
55 | 55 | |
56 | - public function __construct(string $path, string $fallbackPath = '', SystemConfig $config) { |
|
57 | - $this->logFile = $path; |
|
58 | - if (!file_exists($this->logFile)) { |
|
59 | - if( |
|
60 | - ( |
|
61 | - !is_writable(dirname($this->logFile)) |
|
62 | - || !touch($this->logFile) |
|
63 | - ) |
|
64 | - && $fallbackPath !== '' |
|
65 | - ) { |
|
66 | - $this->logFile = $fallbackPath; |
|
67 | - } |
|
68 | - } |
|
69 | - $this->config = $config; |
|
70 | - } |
|
56 | + public function __construct(string $path, string $fallbackPath = '', SystemConfig $config) { |
|
57 | + $this->logFile = $path; |
|
58 | + if (!file_exists($this->logFile)) { |
|
59 | + if( |
|
60 | + ( |
|
61 | + !is_writable(dirname($this->logFile)) |
|
62 | + || !touch($this->logFile) |
|
63 | + ) |
|
64 | + && $fallbackPath !== '' |
|
65 | + ) { |
|
66 | + $this->logFile = $fallbackPath; |
|
67 | + } |
|
68 | + } |
|
69 | + $this->config = $config; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * write a message in the log |
|
74 | - * @param string $app |
|
75 | - * @param string|array $message |
|
76 | - * @param int $level |
|
77 | - */ |
|
78 | - public function write(string $app, $message, int $level) { |
|
79 | - // default to ISO8601 |
|
80 | - $format = $this->config->getValue('logdateformat', \DateTime::ATOM); |
|
81 | - $logTimeZone = $this->config->getValue('logtimezone', 'UTC'); |
|
82 | - try { |
|
83 | - $timezone = new \DateTimeZone($logTimeZone); |
|
84 | - } catch (\Exception $e) { |
|
85 | - $timezone = new \DateTimeZone('UTC'); |
|
86 | - } |
|
87 | - $time = \DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", "")); |
|
88 | - if ($time === false) { |
|
89 | - $time = new \DateTime(null, $timezone); |
|
90 | - } else { |
|
91 | - // apply timezone if $time is created from UNIX timestamp |
|
92 | - $time->setTimezone($timezone); |
|
93 | - } |
|
94 | - $request = \OC::$server->getRequest(); |
|
95 | - $reqId = $request->getId(); |
|
96 | - $remoteAddr = $request->getRemoteAddress(); |
|
97 | - // remove username/passwords from URLs before writing the to the log file |
|
98 | - $time = $time->format($format); |
|
99 | - $url = ($request->getRequestUri() !== '') ? $request->getRequestUri() : '--'; |
|
100 | - $method = is_string($request->getMethod()) ? $request->getMethod() : '--'; |
|
101 | - if($this->config->getValue('installed', false)) { |
|
102 | - $user = \OC_User::getUser() ? \OC_User::getUser() : '--'; |
|
103 | - } else { |
|
104 | - $user = '--'; |
|
105 | - } |
|
106 | - $userAgent = $request->getHeader('User-Agent'); |
|
107 | - if ($userAgent === '') { |
|
108 | - $userAgent = '--'; |
|
109 | - } |
|
110 | - $version = $this->config->getValue('version', ''); |
|
111 | - $entry = compact( |
|
112 | - 'reqId', |
|
113 | - 'level', |
|
114 | - 'time', |
|
115 | - 'remoteAddr', |
|
116 | - 'user', |
|
117 | - 'app', |
|
118 | - 'method', |
|
119 | - 'url', |
|
120 | - 'message', |
|
121 | - 'userAgent', |
|
122 | - 'version' |
|
123 | - ); |
|
124 | - // PHP's json_encode only accept proper UTF-8 strings, loop over all |
|
125 | - // elements to ensure that they are properly UTF-8 compliant or convert |
|
126 | - // them manually. |
|
127 | - foreach($entry as $key => $value) { |
|
128 | - if(is_string($value)) { |
|
129 | - $testEncode = json_encode($value); |
|
130 | - if($testEncode === false) { |
|
131 | - $entry[$key] = utf8_encode($value); |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - $entry = json_encode($entry, JSON_PARTIAL_OUTPUT_ON_ERROR); |
|
136 | - $handle = @fopen($this->logFile, 'a'); |
|
137 | - if ((fileperms($this->logFile) & 0777) != 0640) { |
|
138 | - @chmod($this->logFile, 0640); |
|
139 | - } |
|
140 | - if ($handle) { |
|
141 | - fwrite($handle, $entry."\n"); |
|
142 | - fclose($handle); |
|
143 | - } else { |
|
144 | - // Fall back to error_log |
|
145 | - error_log($entry); |
|
146 | - } |
|
147 | - if (php_sapi_name() === 'cli-server') { |
|
148 | - error_log($message, 4); |
|
149 | - } |
|
150 | - } |
|
72 | + /** |
|
73 | + * write a message in the log |
|
74 | + * @param string $app |
|
75 | + * @param string|array $message |
|
76 | + * @param int $level |
|
77 | + */ |
|
78 | + public function write(string $app, $message, int $level) { |
|
79 | + // default to ISO8601 |
|
80 | + $format = $this->config->getValue('logdateformat', \DateTime::ATOM); |
|
81 | + $logTimeZone = $this->config->getValue('logtimezone', 'UTC'); |
|
82 | + try { |
|
83 | + $timezone = new \DateTimeZone($logTimeZone); |
|
84 | + } catch (\Exception $e) { |
|
85 | + $timezone = new \DateTimeZone('UTC'); |
|
86 | + } |
|
87 | + $time = \DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", "")); |
|
88 | + if ($time === false) { |
|
89 | + $time = new \DateTime(null, $timezone); |
|
90 | + } else { |
|
91 | + // apply timezone if $time is created from UNIX timestamp |
|
92 | + $time->setTimezone($timezone); |
|
93 | + } |
|
94 | + $request = \OC::$server->getRequest(); |
|
95 | + $reqId = $request->getId(); |
|
96 | + $remoteAddr = $request->getRemoteAddress(); |
|
97 | + // remove username/passwords from URLs before writing the to the log file |
|
98 | + $time = $time->format($format); |
|
99 | + $url = ($request->getRequestUri() !== '') ? $request->getRequestUri() : '--'; |
|
100 | + $method = is_string($request->getMethod()) ? $request->getMethod() : '--'; |
|
101 | + if($this->config->getValue('installed', false)) { |
|
102 | + $user = \OC_User::getUser() ? \OC_User::getUser() : '--'; |
|
103 | + } else { |
|
104 | + $user = '--'; |
|
105 | + } |
|
106 | + $userAgent = $request->getHeader('User-Agent'); |
|
107 | + if ($userAgent === '') { |
|
108 | + $userAgent = '--'; |
|
109 | + } |
|
110 | + $version = $this->config->getValue('version', ''); |
|
111 | + $entry = compact( |
|
112 | + 'reqId', |
|
113 | + 'level', |
|
114 | + 'time', |
|
115 | + 'remoteAddr', |
|
116 | + 'user', |
|
117 | + 'app', |
|
118 | + 'method', |
|
119 | + 'url', |
|
120 | + 'message', |
|
121 | + 'userAgent', |
|
122 | + 'version' |
|
123 | + ); |
|
124 | + // PHP's json_encode only accept proper UTF-8 strings, loop over all |
|
125 | + // elements to ensure that they are properly UTF-8 compliant or convert |
|
126 | + // them manually. |
|
127 | + foreach($entry as $key => $value) { |
|
128 | + if(is_string($value)) { |
|
129 | + $testEncode = json_encode($value); |
|
130 | + if($testEncode === false) { |
|
131 | + $entry[$key] = utf8_encode($value); |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + $entry = json_encode($entry, JSON_PARTIAL_OUTPUT_ON_ERROR); |
|
136 | + $handle = @fopen($this->logFile, 'a'); |
|
137 | + if ((fileperms($this->logFile) & 0777) != 0640) { |
|
138 | + @chmod($this->logFile, 0640); |
|
139 | + } |
|
140 | + if ($handle) { |
|
141 | + fwrite($handle, $entry."\n"); |
|
142 | + fclose($handle); |
|
143 | + } else { |
|
144 | + // Fall back to error_log |
|
145 | + error_log($entry); |
|
146 | + } |
|
147 | + if (php_sapi_name() === 'cli-server') { |
|
148 | + error_log($message, 4); |
|
149 | + } |
|
150 | + } |
|
151 | 151 | |
152 | - /** |
|
153 | - * get entries from the log in reverse chronological order |
|
154 | - * @param int $limit |
|
155 | - * @param int $offset |
|
156 | - * @return array |
|
157 | - */ |
|
158 | - public function getEntries(int $limit=50, int $offset=0):array { |
|
159 | - $minLevel = $this->config->getValue("loglevel", ILogger::WARN); |
|
160 | - $entries = array(); |
|
161 | - $handle = @fopen($this->logFile, 'rb'); |
|
162 | - if ($handle) { |
|
163 | - fseek($handle, 0, SEEK_END); |
|
164 | - $pos = ftell($handle); |
|
165 | - $line = ''; |
|
166 | - $entriesCount = 0; |
|
167 | - $lines = 0; |
|
168 | - // Loop through each character of the file looking for new lines |
|
169 | - while ($pos >= 0 && ($limit === null ||$entriesCount < $limit)) { |
|
170 | - fseek($handle, $pos); |
|
171 | - $ch = fgetc($handle); |
|
172 | - if ($ch == "\n" || $pos == 0) { |
|
173 | - if ($line != '') { |
|
174 | - // Add the first character if at the start of the file, |
|
175 | - // because it doesn't hit the else in the loop |
|
176 | - if ($pos == 0) { |
|
177 | - $line = $ch.$line; |
|
178 | - } |
|
179 | - $entry = json_decode($line); |
|
180 | - // Add the line as an entry if it is passed the offset and is equal or above the log level |
|
181 | - if ($entry->level >= $minLevel) { |
|
182 | - $lines++; |
|
183 | - if ($lines > $offset) { |
|
184 | - $entries[] = $entry; |
|
185 | - $entriesCount++; |
|
186 | - } |
|
187 | - } |
|
188 | - $line = ''; |
|
189 | - } |
|
190 | - } else { |
|
191 | - $line = $ch.$line; |
|
192 | - } |
|
193 | - $pos--; |
|
194 | - } |
|
195 | - fclose($handle); |
|
196 | - } |
|
197 | - return $entries; |
|
198 | - } |
|
152 | + /** |
|
153 | + * get entries from the log in reverse chronological order |
|
154 | + * @param int $limit |
|
155 | + * @param int $offset |
|
156 | + * @return array |
|
157 | + */ |
|
158 | + public function getEntries(int $limit=50, int $offset=0):array { |
|
159 | + $minLevel = $this->config->getValue("loglevel", ILogger::WARN); |
|
160 | + $entries = array(); |
|
161 | + $handle = @fopen($this->logFile, 'rb'); |
|
162 | + if ($handle) { |
|
163 | + fseek($handle, 0, SEEK_END); |
|
164 | + $pos = ftell($handle); |
|
165 | + $line = ''; |
|
166 | + $entriesCount = 0; |
|
167 | + $lines = 0; |
|
168 | + // Loop through each character of the file looking for new lines |
|
169 | + while ($pos >= 0 && ($limit === null ||$entriesCount < $limit)) { |
|
170 | + fseek($handle, $pos); |
|
171 | + $ch = fgetc($handle); |
|
172 | + if ($ch == "\n" || $pos == 0) { |
|
173 | + if ($line != '') { |
|
174 | + // Add the first character if at the start of the file, |
|
175 | + // because it doesn't hit the else in the loop |
|
176 | + if ($pos == 0) { |
|
177 | + $line = $ch.$line; |
|
178 | + } |
|
179 | + $entry = json_decode($line); |
|
180 | + // Add the line as an entry if it is passed the offset and is equal or above the log level |
|
181 | + if ($entry->level >= $minLevel) { |
|
182 | + $lines++; |
|
183 | + if ($lines > $offset) { |
|
184 | + $entries[] = $entry; |
|
185 | + $entriesCount++; |
|
186 | + } |
|
187 | + } |
|
188 | + $line = ''; |
|
189 | + } |
|
190 | + } else { |
|
191 | + $line = $ch.$line; |
|
192 | + } |
|
193 | + $pos--; |
|
194 | + } |
|
195 | + fclose($handle); |
|
196 | + } |
|
197 | + return $entries; |
|
198 | + } |
|
199 | 199 | |
200 | - /** |
|
201 | - * @return string |
|
202 | - */ |
|
203 | - public function getLogFilePath():string { |
|
204 | - return $this->logFile; |
|
205 | - } |
|
200 | + /** |
|
201 | + * @return string |
|
202 | + */ |
|
203 | + public function getLogFilePath():string { |
|
204 | + return $this->logFile; |
|
205 | + } |
|
206 | 206 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function __construct(string $path, string $fallbackPath = '', SystemConfig $config) { |
57 | 57 | $this->logFile = $path; |
58 | 58 | if (!file_exists($this->logFile)) { |
59 | - if( |
|
59 | + if ( |
|
60 | 60 | ( |
61 | 61 | !is_writable(dirname($this->logFile)) |
62 | 62 | || !touch($this->logFile) |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $time = $time->format($format); |
99 | 99 | $url = ($request->getRequestUri() !== '') ? $request->getRequestUri() : '--'; |
100 | 100 | $method = is_string($request->getMethod()) ? $request->getMethod() : '--'; |
101 | - if($this->config->getValue('installed', false)) { |
|
101 | + if ($this->config->getValue('installed', false)) { |
|
102 | 102 | $user = \OC_User::getUser() ? \OC_User::getUser() : '--'; |
103 | 103 | } else { |
104 | 104 | $user = '--'; |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | // PHP's json_encode only accept proper UTF-8 strings, loop over all |
125 | 125 | // elements to ensure that they are properly UTF-8 compliant or convert |
126 | 126 | // them manually. |
127 | - foreach($entry as $key => $value) { |
|
128 | - if(is_string($value)) { |
|
127 | + foreach ($entry as $key => $value) { |
|
128 | + if (is_string($value)) { |
|
129 | 129 | $testEncode = json_encode($value); |
130 | - if($testEncode === false) { |
|
130 | + if ($testEncode === false) { |
|
131 | 131 | $entry[$key] = utf8_encode($value); |
132 | 132 | } |
133 | 133 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param int $offset |
156 | 156 | * @return array |
157 | 157 | */ |
158 | - public function getEntries(int $limit=50, int $offset=0):array { |
|
158 | + public function getEntries(int $limit = 50, int $offset = 0):array { |
|
159 | 159 | $minLevel = $this->config->getValue("loglevel", ILogger::WARN); |
160 | 160 | $entries = array(); |
161 | 161 | $handle = @fopen($this->logFile, 'rb'); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $entriesCount = 0; |
167 | 167 | $lines = 0; |
168 | 168 | // Loop through each character of the file looking for new lines |
169 | - while ($pos >= 0 && ($limit === null ||$entriesCount < $limit)) { |
|
169 | + while ($pos >= 0 && ($limit === null || $entriesCount < $limit)) { |
|
170 | 170 | fseek($handle, $pos); |
171 | 171 | $ch = fgetc($handle); |
172 | 172 | if ($ch == "\n" || $pos == 0) { |