@@ -41,244 +41,244 @@ |
||
| 41 | 41 | |
| 42 | 42 | class ChangePasswordController extends Controller { |
| 43 | 43 | |
| 44 | - /** @var string */ |
|
| 45 | - private $userId; |
|
| 44 | + /** @var string */ |
|
| 45 | + private $userId; |
|
| 46 | 46 | |
| 47 | - /** @var UserManager */ |
|
| 48 | - private $userManager; |
|
| 47 | + /** @var UserManager */ |
|
| 48 | + private $userManager; |
|
| 49 | 49 | |
| 50 | - /** @var IL10N */ |
|
| 51 | - private $l; |
|
| 50 | + /** @var IL10N */ |
|
| 51 | + private $l; |
|
| 52 | 52 | |
| 53 | - /** @var GroupManager */ |
|
| 54 | - private $groupManager; |
|
| 53 | + /** @var GroupManager */ |
|
| 54 | + private $groupManager; |
|
| 55 | 55 | |
| 56 | - /** @var Session */ |
|
| 57 | - private $userSession; |
|
| 56 | + /** @var Session */ |
|
| 57 | + private $userSession; |
|
| 58 | 58 | |
| 59 | - /** @var IAppManager */ |
|
| 60 | - private $appManager; |
|
| 59 | + /** @var IAppManager */ |
|
| 60 | + private $appManager; |
|
| 61 | 61 | |
| 62 | - public function __construct(string $appName, |
|
| 63 | - IRequest $request, |
|
| 64 | - string $userId, |
|
| 65 | - UserManager $userManager, |
|
| 66 | - IUserSession $userSession, |
|
| 67 | - GroupManager $groupManager, |
|
| 68 | - IAppManager $appManager, |
|
| 69 | - IL10N $l) { |
|
| 70 | - parent::__construct($appName, $request); |
|
| 62 | + public function __construct(string $appName, |
|
| 63 | + IRequest $request, |
|
| 64 | + string $userId, |
|
| 65 | + UserManager $userManager, |
|
| 66 | + IUserSession $userSession, |
|
| 67 | + GroupManager $groupManager, |
|
| 68 | + IAppManager $appManager, |
|
| 69 | + IL10N $l) { |
|
| 70 | + parent::__construct($appName, $request); |
|
| 71 | 71 | |
| 72 | - $this->userId = $userId; |
|
| 73 | - $this->userManager = $userManager; |
|
| 74 | - $this->userSession = $userSession; |
|
| 75 | - $this->groupManager = $groupManager; |
|
| 76 | - $this->appManager = $appManager; |
|
| 77 | - $this->l = $l; |
|
| 78 | - } |
|
| 72 | + $this->userId = $userId; |
|
| 73 | + $this->userManager = $userManager; |
|
| 74 | + $this->userSession = $userSession; |
|
| 75 | + $this->groupManager = $groupManager; |
|
| 76 | + $this->appManager = $appManager; |
|
| 77 | + $this->l = $l; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @NoAdminRequired |
|
| 82 | - * @NoSubadminRequired |
|
| 83 | - * @BruteForceProtection(action=changePersonalPassword) |
|
| 84 | - * |
|
| 85 | - * @param string $oldpassword |
|
| 86 | - * @param string $newpassword |
|
| 87 | - * |
|
| 88 | - * @return JSONResponse |
|
| 89 | - */ |
|
| 90 | - public function changePersonalPassword(string $oldpassword = '', string $newpassword = null): JSONResponse { |
|
| 91 | - /** @var IUser $user */ |
|
| 92 | - $user = $this->userManager->checkPassword($this->userId, $oldpassword); |
|
| 93 | - if ($user === false) { |
|
| 94 | - $response = new JSONResponse([ |
|
| 95 | - 'status' => 'error', |
|
| 96 | - 'data' => [ |
|
| 97 | - 'message' => $this->l->t('Wrong password'), |
|
| 98 | - ], |
|
| 99 | - ]); |
|
| 100 | - $response->throttle(); |
|
| 101 | - return $response; |
|
| 102 | - } |
|
| 80 | + /** |
|
| 81 | + * @NoAdminRequired |
|
| 82 | + * @NoSubadminRequired |
|
| 83 | + * @BruteForceProtection(action=changePersonalPassword) |
|
| 84 | + * |
|
| 85 | + * @param string $oldpassword |
|
| 86 | + * @param string $newpassword |
|
| 87 | + * |
|
| 88 | + * @return JSONResponse |
|
| 89 | + */ |
|
| 90 | + public function changePersonalPassword(string $oldpassword = '', string $newpassword = null): JSONResponse { |
|
| 91 | + /** @var IUser $user */ |
|
| 92 | + $user = $this->userManager->checkPassword($this->userId, $oldpassword); |
|
| 93 | + if ($user === false) { |
|
| 94 | + $response = new JSONResponse([ |
|
| 95 | + 'status' => 'error', |
|
| 96 | + 'data' => [ |
|
| 97 | + 'message' => $this->l->t('Wrong password'), |
|
| 98 | + ], |
|
| 99 | + ]); |
|
| 100 | + $response->throttle(); |
|
| 101 | + return $response; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - try { |
|
| 105 | - if ($newpassword === null || $user->setPassword($newpassword) === false) { |
|
| 106 | - return new JSONResponse([ |
|
| 107 | - 'status' => 'error' |
|
| 108 | - ]); |
|
| 109 | - } |
|
| 110 | - // password policy app throws exception |
|
| 111 | - } catch(HintException $e) { |
|
| 112 | - return new JSONResponse([ |
|
| 113 | - 'status' => 'error', |
|
| 114 | - 'data' => [ |
|
| 115 | - 'message' => $e->getHint(), |
|
| 116 | - ], |
|
| 117 | - ]); |
|
| 118 | - } |
|
| 104 | + try { |
|
| 105 | + if ($newpassword === null || $user->setPassword($newpassword) === false) { |
|
| 106 | + return new JSONResponse([ |
|
| 107 | + 'status' => 'error' |
|
| 108 | + ]); |
|
| 109 | + } |
|
| 110 | + // password policy app throws exception |
|
| 111 | + } catch(HintException $e) { |
|
| 112 | + return new JSONResponse([ |
|
| 113 | + 'status' => 'error', |
|
| 114 | + 'data' => [ |
|
| 115 | + 'message' => $e->getHint(), |
|
| 116 | + ], |
|
| 117 | + ]); |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - $this->userSession->updateSessionTokenPassword($newpassword); |
|
| 120 | + $this->userSession->updateSessionTokenPassword($newpassword); |
|
| 121 | 121 | |
| 122 | - return new JSONResponse([ |
|
| 123 | - 'status' => 'success', |
|
| 124 | - 'data' => [ |
|
| 125 | - 'message' => $this->l->t('Saved'), |
|
| 126 | - ], |
|
| 127 | - ]); |
|
| 128 | - } |
|
| 122 | + return new JSONResponse([ |
|
| 123 | + 'status' => 'success', |
|
| 124 | + 'data' => [ |
|
| 125 | + 'message' => $this->l->t('Saved'), |
|
| 126 | + ], |
|
| 127 | + ]); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * @NoAdminRequired |
|
| 132 | - * @PasswordConfirmationRequired |
|
| 133 | - * |
|
| 134 | - * @param string $username |
|
| 135 | - * @param string $password |
|
| 136 | - * @param string $recoveryPassword |
|
| 137 | - * |
|
| 138 | - * @return JSONResponse |
|
| 139 | - */ |
|
| 140 | - public function changeUserPassword(string $username = null, string $password = null, string $recoveryPassword = null): JSONResponse { |
|
| 141 | - if ($username === null) { |
|
| 142 | - return new JSONResponse([ |
|
| 143 | - 'status' => 'error', |
|
| 144 | - 'data' => [ |
|
| 145 | - 'message' => $this->l->t('No user supplied'), |
|
| 146 | - ], |
|
| 147 | - ]); |
|
| 148 | - } |
|
| 130 | + /** |
|
| 131 | + * @NoAdminRequired |
|
| 132 | + * @PasswordConfirmationRequired |
|
| 133 | + * |
|
| 134 | + * @param string $username |
|
| 135 | + * @param string $password |
|
| 136 | + * @param string $recoveryPassword |
|
| 137 | + * |
|
| 138 | + * @return JSONResponse |
|
| 139 | + */ |
|
| 140 | + public function changeUserPassword(string $username = null, string $password = null, string $recoveryPassword = null): JSONResponse { |
|
| 141 | + if ($username === null) { |
|
| 142 | + return new JSONResponse([ |
|
| 143 | + 'status' => 'error', |
|
| 144 | + 'data' => [ |
|
| 145 | + 'message' => $this->l->t('No user supplied'), |
|
| 146 | + ], |
|
| 147 | + ]); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - if ($password === null) { |
|
| 151 | - return new JSONResponse([ |
|
| 152 | - 'status' => 'error', |
|
| 153 | - 'data' => [ |
|
| 154 | - 'message' => $this->l->t('Unable to change password'), |
|
| 155 | - ], |
|
| 156 | - ]); |
|
| 157 | - } |
|
| 150 | + if ($password === null) { |
|
| 151 | + return new JSONResponse([ |
|
| 152 | + 'status' => 'error', |
|
| 153 | + 'data' => [ |
|
| 154 | + 'message' => $this->l->t('Unable to change password'), |
|
| 155 | + ], |
|
| 156 | + ]); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - $currentUser = $this->userSession->getUser(); |
|
| 160 | - $targetUser = $this->userManager->get($username); |
|
| 161 | - if ($currentUser === null || $targetUser === null || |
|
| 162 | - !($this->groupManager->isAdmin($this->userId) || |
|
| 163 | - $this->groupManager->getSubAdmin()->isUserAccessible($currentUser, $targetUser)) |
|
| 164 | - ) { |
|
| 165 | - return new JSONResponse([ |
|
| 166 | - 'status' => 'error', |
|
| 167 | - 'data' => [ |
|
| 168 | - 'message' => $this->l->t('Authentication error'), |
|
| 169 | - ], |
|
| 170 | - ]); |
|
| 171 | - } |
|
| 159 | + $currentUser = $this->userSession->getUser(); |
|
| 160 | + $targetUser = $this->userManager->get($username); |
|
| 161 | + if ($currentUser === null || $targetUser === null || |
|
| 162 | + !($this->groupManager->isAdmin($this->userId) || |
|
| 163 | + $this->groupManager->getSubAdmin()->isUserAccessible($currentUser, $targetUser)) |
|
| 164 | + ) { |
|
| 165 | + return new JSONResponse([ |
|
| 166 | + 'status' => 'error', |
|
| 167 | + 'data' => [ |
|
| 168 | + 'message' => $this->l->t('Authentication error'), |
|
| 169 | + ], |
|
| 170 | + ]); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - if ($this->appManager->isEnabledForUser('encryption')) { |
|
| 174 | - //handle the recovery case |
|
| 175 | - $crypt = new \OCA\Encryption\Crypto\Crypt( |
|
| 176 | - \OC::$server->getLogger(), |
|
| 177 | - \OC::$server->getUserSession(), |
|
| 178 | - \OC::$server->getConfig(), |
|
| 179 | - \OC::$server->getL10N('encryption')); |
|
| 180 | - $keyStorage = \OC::$server->getEncryptionKeyStorage(); |
|
| 181 | - $util = new \OCA\Encryption\Util( |
|
| 182 | - new \OC\Files\View(), |
|
| 183 | - $crypt, |
|
| 184 | - \OC::$server->getLogger(), |
|
| 185 | - \OC::$server->getUserSession(), |
|
| 186 | - \OC::$server->getConfig(), |
|
| 187 | - \OC::$server->getUserManager()); |
|
| 188 | - $keyManager = new \OCA\Encryption\KeyManager( |
|
| 189 | - $keyStorage, |
|
| 190 | - $crypt, |
|
| 191 | - \OC::$server->getConfig(), |
|
| 192 | - \OC::$server->getUserSession(), |
|
| 193 | - new \OCA\Encryption\Session(\OC::$server->getSession()), |
|
| 194 | - \OC::$server->getLogger(), |
|
| 195 | - $util); |
|
| 196 | - $recovery = new \OCA\Encryption\Recovery( |
|
| 197 | - \OC::$server->getUserSession(), |
|
| 198 | - $crypt, |
|
| 199 | - \OC::$server->getSecureRandom(), |
|
| 200 | - $keyManager, |
|
| 201 | - \OC::$server->getConfig(), |
|
| 202 | - $keyStorage, |
|
| 203 | - \OC::$server->getEncryptionFilesHelper(), |
|
| 204 | - new \OC\Files\View()); |
|
| 205 | - $recoveryAdminEnabled = $recovery->isRecoveryKeyEnabled(); |
|
| 173 | + if ($this->appManager->isEnabledForUser('encryption')) { |
|
| 174 | + //handle the recovery case |
|
| 175 | + $crypt = new \OCA\Encryption\Crypto\Crypt( |
|
| 176 | + \OC::$server->getLogger(), |
|
| 177 | + \OC::$server->getUserSession(), |
|
| 178 | + \OC::$server->getConfig(), |
|
| 179 | + \OC::$server->getL10N('encryption')); |
|
| 180 | + $keyStorage = \OC::$server->getEncryptionKeyStorage(); |
|
| 181 | + $util = new \OCA\Encryption\Util( |
|
| 182 | + new \OC\Files\View(), |
|
| 183 | + $crypt, |
|
| 184 | + \OC::$server->getLogger(), |
|
| 185 | + \OC::$server->getUserSession(), |
|
| 186 | + \OC::$server->getConfig(), |
|
| 187 | + \OC::$server->getUserManager()); |
|
| 188 | + $keyManager = new \OCA\Encryption\KeyManager( |
|
| 189 | + $keyStorage, |
|
| 190 | + $crypt, |
|
| 191 | + \OC::$server->getConfig(), |
|
| 192 | + \OC::$server->getUserSession(), |
|
| 193 | + new \OCA\Encryption\Session(\OC::$server->getSession()), |
|
| 194 | + \OC::$server->getLogger(), |
|
| 195 | + $util); |
|
| 196 | + $recovery = new \OCA\Encryption\Recovery( |
|
| 197 | + \OC::$server->getUserSession(), |
|
| 198 | + $crypt, |
|
| 199 | + \OC::$server->getSecureRandom(), |
|
| 200 | + $keyManager, |
|
| 201 | + \OC::$server->getConfig(), |
|
| 202 | + $keyStorage, |
|
| 203 | + \OC::$server->getEncryptionFilesHelper(), |
|
| 204 | + new \OC\Files\View()); |
|
| 205 | + $recoveryAdminEnabled = $recovery->isRecoveryKeyEnabled(); |
|
| 206 | 206 | |
| 207 | - $validRecoveryPassword = false; |
|
| 208 | - $recoveryEnabledForUser = false; |
|
| 209 | - if ($recoveryAdminEnabled) { |
|
| 210 | - $validRecoveryPassword = $keyManager->checkRecoveryPassword($recoveryPassword); |
|
| 211 | - $recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser($username); |
|
| 212 | - } |
|
| 207 | + $validRecoveryPassword = false; |
|
| 208 | + $recoveryEnabledForUser = false; |
|
| 209 | + if ($recoveryAdminEnabled) { |
|
| 210 | + $validRecoveryPassword = $keyManager->checkRecoveryPassword($recoveryPassword); |
|
| 211 | + $recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser($username); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - if ($recoveryEnabledForUser && $recoveryPassword === '') { |
|
| 215 | - return new JSONResponse([ |
|
| 216 | - 'status' => 'error', |
|
| 217 | - 'data' => [ |
|
| 218 | - 'message' => $this->l->t('Please provide an admin recovery password; otherwise, all user data will be lost.'), |
|
| 219 | - ] |
|
| 220 | - ]); |
|
| 221 | - } elseif ($recoveryEnabledForUser && ! $validRecoveryPassword) { |
|
| 222 | - return new JSONResponse([ |
|
| 223 | - 'status' => 'error', |
|
| 224 | - 'data' => [ |
|
| 225 | - 'message' => $this->l->t('Wrong admin recovery password. Please check the password and try again.'), |
|
| 226 | - ] |
|
| 227 | - ]); |
|
| 228 | - } else { // now we know that everything is fine regarding the recovery password, let's try to change the password |
|
| 229 | - try { |
|
| 230 | - $result = $targetUser->setPassword($password, $recoveryPassword); |
|
| 231 | - // password policy app throws exception |
|
| 232 | - } catch(HintException $e) { |
|
| 233 | - return new JSONResponse([ |
|
| 234 | - 'status' => 'error', |
|
| 235 | - 'data' => [ |
|
| 236 | - 'message' => $e->getHint(), |
|
| 237 | - ], |
|
| 238 | - ]); |
|
| 239 | - } |
|
| 240 | - if (!$result && $recoveryEnabledForUser) { |
|
| 241 | - return new JSONResponse([ |
|
| 242 | - 'status' => 'error', |
|
| 243 | - 'data' => [ |
|
| 244 | - 'message' => $this->l->t('Backend doesn\'t support password change, but the user\'s encryption key was updated.'), |
|
| 245 | - ] |
|
| 246 | - ]); |
|
| 247 | - } elseif (!$result && !$recoveryEnabledForUser) { |
|
| 248 | - return new JSONResponse([ |
|
| 249 | - 'status' => 'error', |
|
| 250 | - 'data' => [ |
|
| 251 | - 'message' => $this->l->t('Unable to change password'), |
|
| 252 | - ] |
|
| 253 | - ]); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - } else { |
|
| 257 | - try { |
|
| 258 | - if ($targetUser->setPassword($password) === false) { |
|
| 259 | - return new JSONResponse([ |
|
| 260 | - 'status' => 'error', |
|
| 261 | - 'data' => [ |
|
| 262 | - 'message' => $this->l->t('Unable to change password'), |
|
| 263 | - ], |
|
| 264 | - ]); |
|
| 265 | - } |
|
| 266 | - // password policy app throws exception |
|
| 267 | - } catch(HintException $e) { |
|
| 268 | - return new JSONResponse([ |
|
| 269 | - 'status' => 'error', |
|
| 270 | - 'data' => [ |
|
| 271 | - 'message' => $e->getHint(), |
|
| 272 | - ], |
|
| 273 | - ]); |
|
| 274 | - } |
|
| 275 | - } |
|
| 214 | + if ($recoveryEnabledForUser && $recoveryPassword === '') { |
|
| 215 | + return new JSONResponse([ |
|
| 216 | + 'status' => 'error', |
|
| 217 | + 'data' => [ |
|
| 218 | + 'message' => $this->l->t('Please provide an admin recovery password; otherwise, all user data will be lost.'), |
|
| 219 | + ] |
|
| 220 | + ]); |
|
| 221 | + } elseif ($recoveryEnabledForUser && ! $validRecoveryPassword) { |
|
| 222 | + return new JSONResponse([ |
|
| 223 | + 'status' => 'error', |
|
| 224 | + 'data' => [ |
|
| 225 | + 'message' => $this->l->t('Wrong admin recovery password. Please check the password and try again.'), |
|
| 226 | + ] |
|
| 227 | + ]); |
|
| 228 | + } else { // now we know that everything is fine regarding the recovery password, let's try to change the password |
|
| 229 | + try { |
|
| 230 | + $result = $targetUser->setPassword($password, $recoveryPassword); |
|
| 231 | + // password policy app throws exception |
|
| 232 | + } catch(HintException $e) { |
|
| 233 | + return new JSONResponse([ |
|
| 234 | + 'status' => 'error', |
|
| 235 | + 'data' => [ |
|
| 236 | + 'message' => $e->getHint(), |
|
| 237 | + ], |
|
| 238 | + ]); |
|
| 239 | + } |
|
| 240 | + if (!$result && $recoveryEnabledForUser) { |
|
| 241 | + return new JSONResponse([ |
|
| 242 | + 'status' => 'error', |
|
| 243 | + 'data' => [ |
|
| 244 | + 'message' => $this->l->t('Backend doesn\'t support password change, but the user\'s encryption key was updated.'), |
|
| 245 | + ] |
|
| 246 | + ]); |
|
| 247 | + } elseif (!$result && !$recoveryEnabledForUser) { |
|
| 248 | + return new JSONResponse([ |
|
| 249 | + 'status' => 'error', |
|
| 250 | + 'data' => [ |
|
| 251 | + 'message' => $this->l->t('Unable to change password'), |
|
| 252 | + ] |
|
| 253 | + ]); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + } else { |
|
| 257 | + try { |
|
| 258 | + if ($targetUser->setPassword($password) === false) { |
|
| 259 | + return new JSONResponse([ |
|
| 260 | + 'status' => 'error', |
|
| 261 | + 'data' => [ |
|
| 262 | + 'message' => $this->l->t('Unable to change password'), |
|
| 263 | + ], |
|
| 264 | + ]); |
|
| 265 | + } |
|
| 266 | + // password policy app throws exception |
|
| 267 | + } catch(HintException $e) { |
|
| 268 | + return new JSONResponse([ |
|
| 269 | + 'status' => 'error', |
|
| 270 | + 'data' => [ |
|
| 271 | + 'message' => $e->getHint(), |
|
| 272 | + ], |
|
| 273 | + ]); |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - return new JSONResponse([ |
|
| 278 | - 'status' => 'success', |
|
| 279 | - 'data' => [ |
|
| 280 | - 'username' => $username, |
|
| 281 | - ], |
|
| 282 | - ]); |
|
| 283 | - } |
|
| 277 | + return new JSONResponse([ |
|
| 278 | + 'status' => 'success', |
|
| 279 | + 'data' => [ |
|
| 280 | + 'username' => $username, |
|
| 281 | + ], |
|
| 282 | + ]); |
|
| 283 | + } |
|
| 284 | 284 | } |
@@ -29,17 +29,13 @@ |
||
| 29 | 29 | |
| 30 | 30 | namespace OCA\FederatedFileSharing\Controller; |
| 31 | 31 | |
| 32 | -use OC\Files\Filesystem; |
|
| 33 | 32 | use OC\HintException; |
| 34 | -use OC\Share\Helper; |
|
| 35 | 33 | use OCA\FederatedFileSharing\AddressHandler; |
| 36 | 34 | use OCA\FederatedFileSharing\FederatedShareProvider; |
| 37 | -use OCA\Files_Sharing\External\Manager; |
|
| 38 | 35 | use OCP\AppFramework\Controller; |
| 39 | 36 | use OCP\AppFramework\Http; |
| 40 | 37 | use OCP\AppFramework\Http\JSONResponse; |
| 41 | 38 | use OCP\Federation\ICloudIdManager; |
| 42 | -use OCP\Files\StorageInvalidException; |
|
| 43 | 39 | use OCP\Http\Client\IClientService; |
| 44 | 40 | use OCP\IL10N; |
| 45 | 41 | use OCP\IRequest; |
@@ -57,177 +57,177 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | class MountPublicLinkController extends Controller { |
| 59 | 59 | |
| 60 | - /** @var FederatedShareProvider */ |
|
| 61 | - private $federatedShareProvider; |
|
| 62 | - |
|
| 63 | - /** @var AddressHandler */ |
|
| 64 | - private $addressHandler; |
|
| 65 | - |
|
| 66 | - /** @var IManager */ |
|
| 67 | - private $shareManager; |
|
| 68 | - |
|
| 69 | - /** @var ISession */ |
|
| 70 | - private $session; |
|
| 71 | - |
|
| 72 | - /** @var IL10N */ |
|
| 73 | - private $l; |
|
| 74 | - |
|
| 75 | - /** @var IUserSession */ |
|
| 76 | - private $userSession; |
|
| 77 | - |
|
| 78 | - /** @var IClientService */ |
|
| 79 | - private $clientService; |
|
| 80 | - |
|
| 81 | - /** @var ICloudIdManager */ |
|
| 82 | - private $cloudIdManager; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * MountPublicLinkController constructor. |
|
| 86 | - * |
|
| 87 | - * @param string $appName |
|
| 88 | - * @param IRequest $request |
|
| 89 | - * @param FederatedShareProvider $federatedShareProvider |
|
| 90 | - * @param IManager $shareManager |
|
| 91 | - * @param AddressHandler $addressHandler |
|
| 92 | - * @param ISession $session |
|
| 93 | - * @param IL10N $l |
|
| 94 | - * @param IUserSession $userSession |
|
| 95 | - * @param IClientService $clientService |
|
| 96 | - * @param ICloudIdManager $cloudIdManager |
|
| 97 | - */ |
|
| 98 | - public function __construct($appName, |
|
| 99 | - IRequest $request, |
|
| 100 | - FederatedShareProvider $federatedShareProvider, |
|
| 101 | - IManager $shareManager, |
|
| 102 | - AddressHandler $addressHandler, |
|
| 103 | - ISession $session, |
|
| 104 | - IL10N $l, |
|
| 105 | - IUserSession $userSession, |
|
| 106 | - IClientService $clientService, |
|
| 107 | - ICloudIdManager $cloudIdManager |
|
| 108 | - ) { |
|
| 109 | - parent::__construct($appName, $request); |
|
| 110 | - |
|
| 111 | - $this->federatedShareProvider = $federatedShareProvider; |
|
| 112 | - $this->shareManager = $shareManager; |
|
| 113 | - $this->addressHandler = $addressHandler; |
|
| 114 | - $this->session = $session; |
|
| 115 | - $this->l = $l; |
|
| 116 | - $this->userSession = $userSession; |
|
| 117 | - $this->clientService = $clientService; |
|
| 118 | - $this->cloudIdManager = $cloudIdManager; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * send federated share to a user of a public link |
|
| 123 | - * |
|
| 124 | - * @NoCSRFRequired |
|
| 125 | - * @PublicPage |
|
| 126 | - * @BruteForceProtection(action=publicLink2FederatedShare) |
|
| 127 | - * |
|
| 128 | - * @param string $shareWith |
|
| 129 | - * @param string $token |
|
| 130 | - * @param string $password |
|
| 131 | - * @return JSONResponse |
|
| 132 | - */ |
|
| 133 | - public function createFederatedShare($shareWith, $token, $password = '') { |
|
| 134 | - |
|
| 135 | - if (!$this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) { |
|
| 136 | - return new JSONResponse( |
|
| 137 | - ['message' => 'This server doesn\'t support outgoing federated shares'], |
|
| 138 | - Http::STATUS_BAD_REQUEST |
|
| 139 | - ); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - try { |
|
| 143 | - list(, $server) = $this->addressHandler->splitUserRemote($shareWith); |
|
| 144 | - $share = $this->shareManager->getShareByToken($token); |
|
| 145 | - } catch (HintException $e) { |
|
| 146 | - return new JSONResponse(['message' => $e->getHint()], Http::STATUS_BAD_REQUEST); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - // make sure that user is authenticated in case of a password protected link |
|
| 150 | - $storedPassword = $share->getPassword(); |
|
| 151 | - $authenticated = $this->session->get('public_link_authenticated') === $share->getId() || |
|
| 152 | - $this->shareManager->checkPassword($share, $password); |
|
| 153 | - if (!empty($storedPassword) && !$authenticated ) { |
|
| 154 | - $response = new JSONResponse( |
|
| 155 | - ['message' => 'No permission to access the share'], |
|
| 156 | - Http::STATUS_BAD_REQUEST |
|
| 157 | - ); |
|
| 158 | - $response->throttle(); |
|
| 159 | - return $response; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - $share->setSharedWith($shareWith); |
|
| 163 | - |
|
| 164 | - try { |
|
| 165 | - $this->federatedShareProvider->create($share); |
|
| 166 | - } catch (\Exception $e) { |
|
| 167 | - \OC::$server->getLogger()->logException($e, [ |
|
| 168 | - 'level' => \OCP\Util::WARN, |
|
| 169 | - 'app' => 'federatedfilesharing', |
|
| 170 | - ]); |
|
| 171 | - return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - return new JSONResponse(['remoteUrl' => $server]); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * ask other server to get a federated share |
|
| 179 | - * |
|
| 180 | - * @NoAdminRequired |
|
| 181 | - * |
|
| 182 | - * @param string $token |
|
| 183 | - * @param string $remote |
|
| 184 | - * @param string $password |
|
| 185 | - * @param string $owner (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
| 186 | - * @param string $ownerDisplayName (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
| 187 | - * @param string $name (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
| 188 | - * @return JSONResponse |
|
| 189 | - */ |
|
| 190 | - public function askForFederatedShare($token, $remote, $password = '', $owner = '', $ownerDisplayName = '', $name = '') { |
|
| 191 | - // check if server admin allows to mount public links from other servers |
|
| 192 | - if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() === false) { |
|
| 193 | - return new JSONResponse(['message' => $this->l->t('Server to server sharing is not enabled on this server')], Http::STATUS_BAD_REQUEST); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - $cloudId = $this->cloudIdManager->getCloudId($this->userSession->getUser()->getUID(), $this->addressHandler->generateRemoteURL()); |
|
| 197 | - |
|
| 198 | - $httpClient = $this->clientService->newClient(); |
|
| 199 | - |
|
| 200 | - try { |
|
| 201 | - $response = $httpClient->post($remote . '/index.php/apps/federatedfilesharing/createFederatedShare', |
|
| 202 | - [ |
|
| 203 | - 'body' => |
|
| 204 | - [ |
|
| 205 | - 'token' => $token, |
|
| 206 | - 'shareWith' => rtrim($cloudId->getId(), '/'), |
|
| 207 | - 'password' => $password |
|
| 208 | - ], |
|
| 209 | - 'connect_timeout' => 10, |
|
| 210 | - ] |
|
| 211 | - ); |
|
| 212 | - } catch (\Exception $e) { |
|
| 213 | - if (empty($password)) { |
|
| 214 | - $message = $this->l->t("Couldn't establish a federated share."); |
|
| 215 | - } else { |
|
| 216 | - $message = $this->l->t("Couldn't establish a federated share, maybe the password was wrong."); |
|
| 217 | - } |
|
| 218 | - return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - $body = $response->getBody(); |
|
| 222 | - $result = json_decode($body, true); |
|
| 223 | - |
|
| 224 | - if (is_array($result) && isset($result['remoteUrl'])) { |
|
| 225 | - return new JSONResponse(['message' => $this->l->t('Federated Share request sent, you will receive an invitation. Check your notifications.')]); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // if we doesn't get the expected response we assume that we try to add |
|
| 229 | - // a federated share from a Nextcloud <= 9 server |
|
| 230 | - $message = $this->l->t("Couldn't establish a federated share, it looks like the server to federate with is too old (Nextcloud <= 9)."); |
|
| 231 | - return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST); |
|
| 232 | - } |
|
| 60 | + /** @var FederatedShareProvider */ |
|
| 61 | + private $federatedShareProvider; |
|
| 62 | + |
|
| 63 | + /** @var AddressHandler */ |
|
| 64 | + private $addressHandler; |
|
| 65 | + |
|
| 66 | + /** @var IManager */ |
|
| 67 | + private $shareManager; |
|
| 68 | + |
|
| 69 | + /** @var ISession */ |
|
| 70 | + private $session; |
|
| 71 | + |
|
| 72 | + /** @var IL10N */ |
|
| 73 | + private $l; |
|
| 74 | + |
|
| 75 | + /** @var IUserSession */ |
|
| 76 | + private $userSession; |
|
| 77 | + |
|
| 78 | + /** @var IClientService */ |
|
| 79 | + private $clientService; |
|
| 80 | + |
|
| 81 | + /** @var ICloudIdManager */ |
|
| 82 | + private $cloudIdManager; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * MountPublicLinkController constructor. |
|
| 86 | + * |
|
| 87 | + * @param string $appName |
|
| 88 | + * @param IRequest $request |
|
| 89 | + * @param FederatedShareProvider $federatedShareProvider |
|
| 90 | + * @param IManager $shareManager |
|
| 91 | + * @param AddressHandler $addressHandler |
|
| 92 | + * @param ISession $session |
|
| 93 | + * @param IL10N $l |
|
| 94 | + * @param IUserSession $userSession |
|
| 95 | + * @param IClientService $clientService |
|
| 96 | + * @param ICloudIdManager $cloudIdManager |
|
| 97 | + */ |
|
| 98 | + public function __construct($appName, |
|
| 99 | + IRequest $request, |
|
| 100 | + FederatedShareProvider $federatedShareProvider, |
|
| 101 | + IManager $shareManager, |
|
| 102 | + AddressHandler $addressHandler, |
|
| 103 | + ISession $session, |
|
| 104 | + IL10N $l, |
|
| 105 | + IUserSession $userSession, |
|
| 106 | + IClientService $clientService, |
|
| 107 | + ICloudIdManager $cloudIdManager |
|
| 108 | + ) { |
|
| 109 | + parent::__construct($appName, $request); |
|
| 110 | + |
|
| 111 | + $this->federatedShareProvider = $federatedShareProvider; |
|
| 112 | + $this->shareManager = $shareManager; |
|
| 113 | + $this->addressHandler = $addressHandler; |
|
| 114 | + $this->session = $session; |
|
| 115 | + $this->l = $l; |
|
| 116 | + $this->userSession = $userSession; |
|
| 117 | + $this->clientService = $clientService; |
|
| 118 | + $this->cloudIdManager = $cloudIdManager; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * send federated share to a user of a public link |
|
| 123 | + * |
|
| 124 | + * @NoCSRFRequired |
|
| 125 | + * @PublicPage |
|
| 126 | + * @BruteForceProtection(action=publicLink2FederatedShare) |
|
| 127 | + * |
|
| 128 | + * @param string $shareWith |
|
| 129 | + * @param string $token |
|
| 130 | + * @param string $password |
|
| 131 | + * @return JSONResponse |
|
| 132 | + */ |
|
| 133 | + public function createFederatedShare($shareWith, $token, $password = '') { |
|
| 134 | + |
|
| 135 | + if (!$this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) { |
|
| 136 | + return new JSONResponse( |
|
| 137 | + ['message' => 'This server doesn\'t support outgoing federated shares'], |
|
| 138 | + Http::STATUS_BAD_REQUEST |
|
| 139 | + ); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + try { |
|
| 143 | + list(, $server) = $this->addressHandler->splitUserRemote($shareWith); |
|
| 144 | + $share = $this->shareManager->getShareByToken($token); |
|
| 145 | + } catch (HintException $e) { |
|
| 146 | + return new JSONResponse(['message' => $e->getHint()], Http::STATUS_BAD_REQUEST); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + // make sure that user is authenticated in case of a password protected link |
|
| 150 | + $storedPassword = $share->getPassword(); |
|
| 151 | + $authenticated = $this->session->get('public_link_authenticated') === $share->getId() || |
|
| 152 | + $this->shareManager->checkPassword($share, $password); |
|
| 153 | + if (!empty($storedPassword) && !$authenticated ) { |
|
| 154 | + $response = new JSONResponse( |
|
| 155 | + ['message' => 'No permission to access the share'], |
|
| 156 | + Http::STATUS_BAD_REQUEST |
|
| 157 | + ); |
|
| 158 | + $response->throttle(); |
|
| 159 | + return $response; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + $share->setSharedWith($shareWith); |
|
| 163 | + |
|
| 164 | + try { |
|
| 165 | + $this->federatedShareProvider->create($share); |
|
| 166 | + } catch (\Exception $e) { |
|
| 167 | + \OC::$server->getLogger()->logException($e, [ |
|
| 168 | + 'level' => \OCP\Util::WARN, |
|
| 169 | + 'app' => 'federatedfilesharing', |
|
| 170 | + ]); |
|
| 171 | + return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + return new JSONResponse(['remoteUrl' => $server]); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * ask other server to get a federated share |
|
| 179 | + * |
|
| 180 | + * @NoAdminRequired |
|
| 181 | + * |
|
| 182 | + * @param string $token |
|
| 183 | + * @param string $remote |
|
| 184 | + * @param string $password |
|
| 185 | + * @param string $owner (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
| 186 | + * @param string $ownerDisplayName (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
| 187 | + * @param string $name (only for legacy reasons, can be removed with legacyMountPublicLink()) |
|
| 188 | + * @return JSONResponse |
|
| 189 | + */ |
|
| 190 | + public function askForFederatedShare($token, $remote, $password = '', $owner = '', $ownerDisplayName = '', $name = '') { |
|
| 191 | + // check if server admin allows to mount public links from other servers |
|
| 192 | + if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() === false) { |
|
| 193 | + return new JSONResponse(['message' => $this->l->t('Server to server sharing is not enabled on this server')], Http::STATUS_BAD_REQUEST); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + $cloudId = $this->cloudIdManager->getCloudId($this->userSession->getUser()->getUID(), $this->addressHandler->generateRemoteURL()); |
|
| 197 | + |
|
| 198 | + $httpClient = $this->clientService->newClient(); |
|
| 199 | + |
|
| 200 | + try { |
|
| 201 | + $response = $httpClient->post($remote . '/index.php/apps/federatedfilesharing/createFederatedShare', |
|
| 202 | + [ |
|
| 203 | + 'body' => |
|
| 204 | + [ |
|
| 205 | + 'token' => $token, |
|
| 206 | + 'shareWith' => rtrim($cloudId->getId(), '/'), |
|
| 207 | + 'password' => $password |
|
| 208 | + ], |
|
| 209 | + 'connect_timeout' => 10, |
|
| 210 | + ] |
|
| 211 | + ); |
|
| 212 | + } catch (\Exception $e) { |
|
| 213 | + if (empty($password)) { |
|
| 214 | + $message = $this->l->t("Couldn't establish a federated share."); |
|
| 215 | + } else { |
|
| 216 | + $message = $this->l->t("Couldn't establish a federated share, maybe the password was wrong."); |
|
| 217 | + } |
|
| 218 | + return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + $body = $response->getBody(); |
|
| 222 | + $result = json_decode($body, true); |
|
| 223 | + |
|
| 224 | + if (is_array($result) && isset($result['remoteUrl'])) { |
|
| 225 | + return new JSONResponse(['message' => $this->l->t('Federated Share request sent, you will receive an invitation. Check your notifications.')]); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // if we doesn't get the expected response we assume that we try to add |
|
| 229 | + // a federated share from a Nextcloud <= 9 server |
|
| 230 | + $message = $this->l->t("Couldn't establish a federated share, it looks like the server to federate with is too old (Nextcloud <= 9)."); |
|
| 231 | + return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST); |
|
| 232 | + } |
|
| 233 | 233 | } |
@@ -65,1440 +65,1440 @@ |
||
| 65 | 65 | use OCP\IUser; |
| 66 | 66 | |
| 67 | 67 | class OC_Util { |
| 68 | - public static $scripts = array(); |
|
| 69 | - public static $styles = array(); |
|
| 70 | - public static $headers = array(); |
|
| 71 | - private static $rootMounted = false; |
|
| 72 | - private static $fsSetup = false; |
|
| 73 | - |
|
| 74 | - /** @var array Local cache of version.php */ |
|
| 75 | - private static $versionCache = null; |
|
| 76 | - |
|
| 77 | - protected static function getAppManager() { |
|
| 78 | - return \OC::$server->getAppManager(); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - private static function initLocalStorageRootFS() { |
|
| 82 | - // mount local file backend as root |
|
| 83 | - $configDataDirectory = \OC::$server->getSystemConfig()->getValue("datadirectory", OC::$SERVERROOT . "/data"); |
|
| 84 | - //first set up the local "root" storage |
|
| 85 | - \OC\Files\Filesystem::initMountManager(); |
|
| 86 | - if (!self::$rootMounted) { |
|
| 87 | - \OC\Files\Filesystem::mount('\OC\Files\Storage\Local', array('datadir' => $configDataDirectory), '/'); |
|
| 88 | - self::$rootMounted = true; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * mounting an object storage as the root fs will in essence remove the |
|
| 94 | - * necessity of a data folder being present. |
|
| 95 | - * TODO make home storage aware of this and use the object storage instead of local disk access |
|
| 96 | - * |
|
| 97 | - * @param array $config containing 'class' and optional 'arguments' |
|
| 98 | - * @suppress PhanDeprecatedFunction |
|
| 99 | - */ |
|
| 100 | - private static function initObjectStoreRootFS($config) { |
|
| 101 | - // check misconfiguration |
|
| 102 | - if (empty($config['class'])) { |
|
| 103 | - \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR); |
|
| 104 | - } |
|
| 105 | - if (!isset($config['arguments'])) { |
|
| 106 | - $config['arguments'] = array(); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - // instantiate object store implementation |
|
| 110 | - $name = $config['class']; |
|
| 111 | - if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
| 112 | - $segments = explode('\\', $name); |
|
| 113 | - OC_App::loadApp(strtolower($segments[1])); |
|
| 114 | - } |
|
| 115 | - $config['arguments']['objectstore'] = new $config['class']($config['arguments']); |
|
| 116 | - // mount with plain / root object store implementation |
|
| 117 | - $config['class'] = '\OC\Files\ObjectStore\ObjectStoreStorage'; |
|
| 118 | - |
|
| 119 | - // mount object storage as root |
|
| 120 | - \OC\Files\Filesystem::initMountManager(); |
|
| 121 | - if (!self::$rootMounted) { |
|
| 122 | - \OC\Files\Filesystem::mount($config['class'], $config['arguments'], '/'); |
|
| 123 | - self::$rootMounted = true; |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * mounting an object storage as the root fs will in essence remove the |
|
| 129 | - * necessity of a data folder being present. |
|
| 130 | - * |
|
| 131 | - * @param array $config containing 'class' and optional 'arguments' |
|
| 132 | - * @suppress PhanDeprecatedFunction |
|
| 133 | - */ |
|
| 134 | - private static function initObjectStoreMultibucketRootFS($config) { |
|
| 135 | - // check misconfiguration |
|
| 136 | - if (empty($config['class'])) { |
|
| 137 | - \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR); |
|
| 138 | - } |
|
| 139 | - if (!isset($config['arguments'])) { |
|
| 140 | - $config['arguments'] = array(); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // instantiate object store implementation |
|
| 144 | - $name = $config['class']; |
|
| 145 | - if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
| 146 | - $segments = explode('\\', $name); |
|
| 147 | - OC_App::loadApp(strtolower($segments[1])); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - if (!isset($config['arguments']['bucket'])) { |
|
| 151 | - $config['arguments']['bucket'] = ''; |
|
| 152 | - } |
|
| 153 | - // put the root FS always in first bucket for multibucket configuration |
|
| 154 | - $config['arguments']['bucket'] .= '0'; |
|
| 155 | - |
|
| 156 | - $config['arguments']['objectstore'] = new $config['class']($config['arguments']); |
|
| 157 | - // mount with plain / root object store implementation |
|
| 158 | - $config['class'] = '\OC\Files\ObjectStore\ObjectStoreStorage'; |
|
| 159 | - |
|
| 160 | - // mount object storage as root |
|
| 161 | - \OC\Files\Filesystem::initMountManager(); |
|
| 162 | - if (!self::$rootMounted) { |
|
| 163 | - \OC\Files\Filesystem::mount($config['class'], $config['arguments'], '/'); |
|
| 164 | - self::$rootMounted = true; |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Can be set up |
|
| 170 | - * |
|
| 171 | - * @param string $user |
|
| 172 | - * @return boolean |
|
| 173 | - * @description configure the initial filesystem based on the configuration |
|
| 174 | - * @suppress PhanDeprecatedFunction |
|
| 175 | - * @suppress PhanAccessMethodInternal |
|
| 176 | - */ |
|
| 177 | - public static function setupFS($user = '') { |
|
| 178 | - //setting up the filesystem twice can only lead to trouble |
|
| 179 | - if (self::$fsSetup) { |
|
| 180 | - return false; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - \OC::$server->getEventLogger()->start('setup_fs', 'Setup filesystem'); |
|
| 184 | - |
|
| 185 | - // If we are not forced to load a specific user we load the one that is logged in |
|
| 186 | - if ($user === null) { |
|
| 187 | - $user = ''; |
|
| 188 | - } else if ($user == "" && \OC::$server->getUserSession()->isLoggedIn()) { |
|
| 189 | - $user = OC_User::getUser(); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - // load all filesystem apps before, so no setup-hook gets lost |
|
| 193 | - OC_App::loadApps(array('filesystem')); |
|
| 194 | - |
|
| 195 | - // the filesystem will finish when $user is not empty, |
|
| 196 | - // mark fs setup here to avoid doing the setup from loading |
|
| 197 | - // OC_Filesystem |
|
| 198 | - if ($user != '') { |
|
| 199 | - self::$fsSetup = true; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - \OC\Files\Filesystem::initMountManager(); |
|
| 203 | - |
|
| 204 | - \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
| 205 | - \OC\Files\Filesystem::addStorageWrapper('mount_options', function ($mountPoint, \OCP\Files\Storage $storage, \OCP\Files\Mount\IMountPoint $mount) { |
|
| 206 | - if ($storage->instanceOfStorage('\OC\Files\Storage\Common')) { |
|
| 207 | - /** @var \OC\Files\Storage\Common $storage */ |
|
| 208 | - $storage->setMountOptions($mount->getOptions()); |
|
| 209 | - } |
|
| 210 | - return $storage; |
|
| 211 | - }); |
|
| 212 | - |
|
| 213 | - \OC\Files\Filesystem::addStorageWrapper('enable_sharing', function ($mountPoint, \OCP\Files\Storage\IStorage $storage, \OCP\Files\Mount\IMountPoint $mount) { |
|
| 214 | - if (!$mount->getOption('enable_sharing', true)) { |
|
| 215 | - return new \OC\Files\Storage\Wrapper\PermissionsMask([ |
|
| 216 | - 'storage' => $storage, |
|
| 217 | - 'mask' => \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE |
|
| 218 | - ]); |
|
| 219 | - } |
|
| 220 | - return $storage; |
|
| 221 | - }); |
|
| 222 | - |
|
| 223 | - // install storage availability wrapper, before most other wrappers |
|
| 224 | - \OC\Files\Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, \OCP\Files\Storage\IStorage $storage) { |
|
| 225 | - if (!$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage') && !$storage->isLocal()) { |
|
| 226 | - return new \OC\Files\Storage\Wrapper\Availability(['storage' => $storage]); |
|
| 227 | - } |
|
| 228 | - return $storage; |
|
| 229 | - }); |
|
| 230 | - |
|
| 231 | - \OC\Files\Filesystem::addStorageWrapper('oc_encoding', function ($mountPoint, \OCP\Files\Storage $storage, \OCP\Files\Mount\IMountPoint $mount) { |
|
| 232 | - if ($mount->getOption('encoding_compatibility', false) && !$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage') && !$storage->isLocal()) { |
|
| 233 | - return new \OC\Files\Storage\Wrapper\Encoding(['storage' => $storage]); |
|
| 234 | - } |
|
| 235 | - return $storage; |
|
| 236 | - }); |
|
| 237 | - |
|
| 238 | - \OC\Files\Filesystem::addStorageWrapper('oc_quota', function ($mountPoint, $storage) { |
|
| 239 | - // set up quota for home storages, even for other users |
|
| 240 | - // which can happen when using sharing |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * @var \OC\Files\Storage\Storage $storage |
|
| 244 | - */ |
|
| 245 | - if ($storage->instanceOfStorage('\OC\Files\Storage\Home') |
|
| 246 | - || $storage->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage') |
|
| 247 | - ) { |
|
| 248 | - /** @var \OC\Files\Storage\Home $storage */ |
|
| 249 | - if (is_object($storage->getUser())) { |
|
| 250 | - $user = $storage->getUser()->getUID(); |
|
| 251 | - $quota = OC_Util::getUserQuota($user); |
|
| 252 | - if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) { |
|
| 253 | - return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota, 'root' => 'files')); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - return $storage; |
|
| 259 | - }); |
|
| 260 | - |
|
| 261 | - OC_Hook::emit('OC_Filesystem', 'preSetup', array('user' => $user)); |
|
| 262 | - \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(true); |
|
| 263 | - |
|
| 264 | - //check if we are using an object storage |
|
| 265 | - $objectStore = \OC::$server->getSystemConfig()->getValue('objectstore', null); |
|
| 266 | - $objectStoreMultibucket = \OC::$server->getSystemConfig()->getValue('objectstore_multibucket', null); |
|
| 267 | - |
|
| 268 | - // use the same order as in ObjectHomeMountProvider |
|
| 269 | - if (isset($objectStoreMultibucket)) { |
|
| 270 | - self::initObjectStoreMultibucketRootFS($objectStoreMultibucket); |
|
| 271 | - } elseif (isset($objectStore)) { |
|
| 272 | - self::initObjectStoreRootFS($objectStore); |
|
| 273 | - } else { |
|
| 274 | - self::initLocalStorageRootFS(); |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - if ($user != '' && !\OC::$server->getUserManager()->userExists($user)) { |
|
| 278 | - \OC::$server->getEventLogger()->end('setup_fs'); |
|
| 279 | - return false; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - //if we aren't logged in, there is no use to set up the filesystem |
|
| 283 | - if ($user != "") { |
|
| 284 | - |
|
| 285 | - $userDir = '/' . $user . '/files'; |
|
| 286 | - |
|
| 287 | - //jail the user into his "home" directory |
|
| 288 | - \OC\Files\Filesystem::init($user, $userDir); |
|
| 289 | - |
|
| 290 | - OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $userDir)); |
|
| 291 | - } |
|
| 292 | - \OC::$server->getEventLogger()->end('setup_fs'); |
|
| 293 | - return true; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * check if a password is required for each public link |
|
| 298 | - * |
|
| 299 | - * @return boolean |
|
| 300 | - * @suppress PhanDeprecatedFunction |
|
| 301 | - */ |
|
| 302 | - public static function isPublicLinkPasswordRequired() { |
|
| 303 | - $enforcePassword = \OC::$server->getConfig()->getAppValue('core', 'shareapi_enforce_links_password', 'no'); |
|
| 304 | - return $enforcePassword === 'yes'; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - /** |
|
| 308 | - * check if sharing is disabled for the current user |
|
| 309 | - * @param IConfig $config |
|
| 310 | - * @param IGroupManager $groupManager |
|
| 311 | - * @param IUser|null $user |
|
| 312 | - * @return bool |
|
| 313 | - */ |
|
| 314 | - public static function isSharingDisabledForUser(IConfig $config, IGroupManager $groupManager, $user) { |
|
| 315 | - if ($config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') { |
|
| 316 | - $groupsList = $config->getAppValue('core', 'shareapi_exclude_groups_list', ''); |
|
| 317 | - $excludedGroups = json_decode($groupsList); |
|
| 318 | - if (is_null($excludedGroups)) { |
|
| 319 | - $excludedGroups = explode(',', $groupsList); |
|
| 320 | - $newValue = json_encode($excludedGroups); |
|
| 321 | - $config->setAppValue('core', 'shareapi_exclude_groups_list', $newValue); |
|
| 322 | - } |
|
| 323 | - $usersGroups = $groupManager->getUserGroupIds($user); |
|
| 324 | - if (!empty($usersGroups)) { |
|
| 325 | - $remainingGroups = array_diff($usersGroups, $excludedGroups); |
|
| 326 | - // if the user is only in groups which are disabled for sharing then |
|
| 327 | - // sharing is also disabled for the user |
|
| 328 | - if (empty($remainingGroups)) { |
|
| 329 | - return true; |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - } |
|
| 333 | - return false; |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * check if share API enforces a default expire date |
|
| 338 | - * |
|
| 339 | - * @return boolean |
|
| 340 | - * @suppress PhanDeprecatedFunction |
|
| 341 | - */ |
|
| 342 | - public static function isDefaultExpireDateEnforced() { |
|
| 343 | - $isDefaultExpireDateEnabled = \OC::$server->getConfig()->getAppValue('core', 'shareapi_default_expire_date', 'no'); |
|
| 344 | - $enforceDefaultExpireDate = false; |
|
| 345 | - if ($isDefaultExpireDateEnabled === 'yes') { |
|
| 346 | - $value = \OC::$server->getConfig()->getAppValue('core', 'shareapi_enforce_expire_date', 'no'); |
|
| 347 | - $enforceDefaultExpireDate = $value === 'yes'; |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - return $enforceDefaultExpireDate; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * Get the quota of a user |
|
| 355 | - * |
|
| 356 | - * @param string $userId |
|
| 357 | - * @return float Quota bytes |
|
| 358 | - */ |
|
| 359 | - public static function getUserQuota($userId) { |
|
| 360 | - $user = \OC::$server->getUserManager()->get($userId); |
|
| 361 | - if (is_null($user)) { |
|
| 362 | - return \OCP\Files\FileInfo::SPACE_UNLIMITED; |
|
| 363 | - } |
|
| 364 | - $userQuota = $user->getQuota(); |
|
| 365 | - if($userQuota === 'none') { |
|
| 366 | - return \OCP\Files\FileInfo::SPACE_UNLIMITED; |
|
| 367 | - } |
|
| 368 | - return OC_Helper::computerFileSize($userQuota); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * copies the skeleton to the users /files |
|
| 373 | - * |
|
| 374 | - * @param String $userId |
|
| 375 | - * @param \OCP\Files\Folder $userDirectory |
|
| 376 | - * @throws \RuntimeException |
|
| 377 | - * @suppress PhanDeprecatedFunction |
|
| 378 | - */ |
|
| 379 | - public static function copySkeleton($userId, \OCP\Files\Folder $userDirectory) { |
|
| 380 | - |
|
| 381 | - $plainSkeletonDirectory = \OC::$server->getConfig()->getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton'); |
|
| 382 | - $userLang = \OC::$server->getL10NFactory()->findLanguage(); |
|
| 383 | - $skeletonDirectory = str_replace('{lang}', $userLang, $plainSkeletonDirectory); |
|
| 384 | - |
|
| 385 | - if (!file_exists($skeletonDirectory)) { |
|
| 386 | - $dialectStart = strpos($userLang, '_'); |
|
| 387 | - if ($dialectStart !== false) { |
|
| 388 | - $skeletonDirectory = str_replace('{lang}', substr($userLang, 0, $dialectStart), $plainSkeletonDirectory); |
|
| 389 | - } |
|
| 390 | - if ($dialectStart === false || !file_exists($skeletonDirectory)) { |
|
| 391 | - $skeletonDirectory = str_replace('{lang}', 'default', $plainSkeletonDirectory); |
|
| 392 | - } |
|
| 393 | - if (!file_exists($skeletonDirectory)) { |
|
| 394 | - $skeletonDirectory = ''; |
|
| 395 | - } |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - $instanceId = \OC::$server->getConfig()->getSystemValue('instanceid', ''); |
|
| 399 | - |
|
| 400 | - if ($instanceId === null) { |
|
| 401 | - throw new \RuntimeException('no instance id!'); |
|
| 402 | - } |
|
| 403 | - $appdata = 'appdata_' . $instanceId; |
|
| 404 | - if ($userId === $appdata) { |
|
| 405 | - throw new \RuntimeException('username is reserved name: ' . $appdata); |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - if (!empty($skeletonDirectory)) { |
|
| 409 | - \OCP\Util::writeLog( |
|
| 410 | - 'files_skeleton', |
|
| 411 | - 'copying skeleton for '.$userId.' from '.$skeletonDirectory.' to '.$userDirectory->getFullPath('/'), |
|
| 412 | - \OCP\Util::DEBUG |
|
| 413 | - ); |
|
| 414 | - self::copyr($skeletonDirectory, $userDirectory); |
|
| 415 | - // update the file cache |
|
| 416 | - $userDirectory->getStorage()->getScanner()->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE); |
|
| 417 | - } |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * copies a directory recursively by using streams |
|
| 422 | - * |
|
| 423 | - * @param string $source |
|
| 424 | - * @param \OCP\Files\Folder $target |
|
| 425 | - * @return void |
|
| 426 | - */ |
|
| 427 | - public static function copyr($source, \OCP\Files\Folder $target) { |
|
| 428 | - $logger = \OC::$server->getLogger(); |
|
| 429 | - |
|
| 430 | - // Verify if folder exists |
|
| 431 | - $dir = opendir($source); |
|
| 432 | - if($dir === false) { |
|
| 433 | - $logger->error(sprintf('Could not opendir "%s"', $source), ['app' => 'core']); |
|
| 434 | - return; |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - // Copy the files |
|
| 438 | - while (false !== ($file = readdir($dir))) { |
|
| 439 | - if (!\OC\Files\Filesystem::isIgnoredDir($file)) { |
|
| 440 | - if (is_dir($source . '/' . $file)) { |
|
| 441 | - $child = $target->newFolder($file); |
|
| 442 | - self::copyr($source . '/' . $file, $child); |
|
| 443 | - } else { |
|
| 444 | - $child = $target->newFile($file); |
|
| 445 | - $sourceStream = fopen($source . '/' . $file, 'r'); |
|
| 446 | - if($sourceStream === false) { |
|
| 447 | - $logger->error(sprintf('Could not fopen "%s"', $source . '/' . $file), ['app' => 'core']); |
|
| 448 | - closedir($dir); |
|
| 449 | - return; |
|
| 450 | - } |
|
| 451 | - stream_copy_to_stream($sourceStream, $child->fopen('w')); |
|
| 452 | - } |
|
| 453 | - } |
|
| 454 | - } |
|
| 455 | - closedir($dir); |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - /** |
|
| 459 | - * @return void |
|
| 460 | - * @suppress PhanUndeclaredMethod |
|
| 461 | - */ |
|
| 462 | - public static function tearDownFS() { |
|
| 463 | - \OC\Files\Filesystem::tearDown(); |
|
| 464 | - \OC::$server->getRootFolder()->clearCache(); |
|
| 465 | - self::$fsSetup = false; |
|
| 466 | - self::$rootMounted = false; |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - /** |
|
| 470 | - * get the current installed version of ownCloud |
|
| 471 | - * |
|
| 472 | - * @return array |
|
| 473 | - */ |
|
| 474 | - public static function getVersion() { |
|
| 475 | - OC_Util::loadVersion(); |
|
| 476 | - return self::$versionCache['OC_Version']; |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - /** |
|
| 480 | - * get the current installed version string of ownCloud |
|
| 481 | - * |
|
| 482 | - * @return string |
|
| 483 | - */ |
|
| 484 | - public static function getVersionString() { |
|
| 485 | - OC_Util::loadVersion(); |
|
| 486 | - return self::$versionCache['OC_VersionString']; |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - /** |
|
| 490 | - * @deprecated the value is of no use anymore |
|
| 491 | - * @return string |
|
| 492 | - */ |
|
| 493 | - public static function getEditionString() { |
|
| 494 | - return ''; |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - /** |
|
| 498 | - * @description get the update channel of the current installed of ownCloud. |
|
| 499 | - * @return string |
|
| 500 | - */ |
|
| 501 | - public static function getChannel() { |
|
| 502 | - OC_Util::loadVersion(); |
|
| 503 | - return \OC::$server->getConfig()->getSystemValue('updater.release.channel', self::$versionCache['OC_Channel']); |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - /** |
|
| 507 | - * @description get the build number of the current installed of ownCloud. |
|
| 508 | - * @return string |
|
| 509 | - */ |
|
| 510 | - public static function getBuild() { |
|
| 511 | - OC_Util::loadVersion(); |
|
| 512 | - return self::$versionCache['OC_Build']; |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - /** |
|
| 516 | - * @description load the version.php into the session as cache |
|
| 517 | - * @suppress PhanUndeclaredVariable |
|
| 518 | - */ |
|
| 519 | - private static function loadVersion() { |
|
| 520 | - if (self::$versionCache !== null) { |
|
| 521 | - return; |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - $timestamp = filemtime(OC::$SERVERROOT . '/version.php'); |
|
| 525 | - require OC::$SERVERROOT . '/version.php'; |
|
| 526 | - /** @var $timestamp int */ |
|
| 527 | - self::$versionCache['OC_Version_Timestamp'] = $timestamp; |
|
| 528 | - /** @var $OC_Version string */ |
|
| 529 | - self::$versionCache['OC_Version'] = $OC_Version; |
|
| 530 | - /** @var $OC_VersionString string */ |
|
| 531 | - self::$versionCache['OC_VersionString'] = $OC_VersionString; |
|
| 532 | - /** @var $OC_Build string */ |
|
| 533 | - self::$versionCache['OC_Build'] = $OC_Build; |
|
| 534 | - |
|
| 535 | - /** @var $OC_Channel string */ |
|
| 536 | - self::$versionCache['OC_Channel'] = $OC_Channel; |
|
| 537 | - } |
|
| 538 | - |
|
| 539 | - /** |
|
| 540 | - * generates a path for JS/CSS files. If no application is provided it will create the path for core. |
|
| 541 | - * |
|
| 542 | - * @param string $application application to get the files from |
|
| 543 | - * @param string $directory directory within this application (css, js, vendor, etc) |
|
| 544 | - * @param string $file the file inside of the above folder |
|
| 545 | - * @return string the path |
|
| 546 | - */ |
|
| 547 | - private static function generatePath($application, $directory, $file) { |
|
| 548 | - if (is_null($file)) { |
|
| 549 | - $file = $application; |
|
| 550 | - $application = ""; |
|
| 551 | - } |
|
| 552 | - if (!empty($application)) { |
|
| 553 | - return "$application/$directory/$file"; |
|
| 554 | - } else { |
|
| 555 | - return "$directory/$file"; |
|
| 556 | - } |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * add a javascript file |
|
| 561 | - * |
|
| 562 | - * @param string $application application id |
|
| 563 | - * @param string|null $file filename |
|
| 564 | - * @param bool $prepend prepend the Script to the beginning of the list |
|
| 565 | - * @return void |
|
| 566 | - */ |
|
| 567 | - public static function addScript($application, $file = null, $prepend = false) { |
|
| 568 | - $path = OC_Util::generatePath($application, 'js', $file); |
|
| 569 | - |
|
| 570 | - // core js files need separate handling |
|
| 571 | - if ($application !== 'core' && $file !== null) { |
|
| 572 | - self::addTranslations ( $application ); |
|
| 573 | - } |
|
| 574 | - self::addExternalResource($application, $prepend, $path, "script"); |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - /** |
|
| 578 | - * add a javascript file from the vendor sub folder |
|
| 579 | - * |
|
| 580 | - * @param string $application application id |
|
| 581 | - * @param string|null $file filename |
|
| 582 | - * @param bool $prepend prepend the Script to the beginning of the list |
|
| 583 | - * @return void |
|
| 584 | - */ |
|
| 585 | - public static function addVendorScript($application, $file = null, $prepend = false) { |
|
| 586 | - $path = OC_Util::generatePath($application, 'vendor', $file); |
|
| 587 | - self::addExternalResource($application, $prepend, $path, "script"); |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - /** |
|
| 591 | - * add a translation JS file |
|
| 592 | - * |
|
| 593 | - * @param string $application application id |
|
| 594 | - * @param string|null $languageCode language code, defaults to the current language |
|
| 595 | - * @param bool|null $prepend prepend the Script to the beginning of the list |
|
| 596 | - */ |
|
| 597 | - public static function addTranslations($application, $languageCode = null, $prepend = false) { |
|
| 598 | - if (is_null($languageCode)) { |
|
| 599 | - $languageCode = \OC::$server->getL10NFactory()->findLanguage($application); |
|
| 600 | - } |
|
| 601 | - if (!empty($application)) { |
|
| 602 | - $path = "$application/l10n/$languageCode"; |
|
| 603 | - } else { |
|
| 604 | - $path = "l10n/$languageCode"; |
|
| 605 | - } |
|
| 606 | - self::addExternalResource($application, $prepend, $path, "script"); |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - /** |
|
| 610 | - * add a css file |
|
| 611 | - * |
|
| 612 | - * @param string $application application id |
|
| 613 | - * @param string|null $file filename |
|
| 614 | - * @param bool $prepend prepend the Style to the beginning of the list |
|
| 615 | - * @return void |
|
| 616 | - */ |
|
| 617 | - public static function addStyle($application, $file = null, $prepend = false) { |
|
| 618 | - $path = OC_Util::generatePath($application, 'css', $file); |
|
| 619 | - self::addExternalResource($application, $prepend, $path, "style"); |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - /** |
|
| 623 | - * add a css file from the vendor sub folder |
|
| 624 | - * |
|
| 625 | - * @param string $application application id |
|
| 626 | - * @param string|null $file filename |
|
| 627 | - * @param bool $prepend prepend the Style to the beginning of the list |
|
| 628 | - * @return void |
|
| 629 | - */ |
|
| 630 | - public static function addVendorStyle($application, $file = null, $prepend = false) { |
|
| 631 | - $path = OC_Util::generatePath($application, 'vendor', $file); |
|
| 632 | - self::addExternalResource($application, $prepend, $path, "style"); |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - /** |
|
| 636 | - * add an external resource css/js file |
|
| 637 | - * |
|
| 638 | - * @param string $application application id |
|
| 639 | - * @param bool $prepend prepend the file to the beginning of the list |
|
| 640 | - * @param string $path |
|
| 641 | - * @param string $type (script or style) |
|
| 642 | - * @return void |
|
| 643 | - */ |
|
| 644 | - private static function addExternalResource($application, $prepend, $path, $type = "script") { |
|
| 645 | - |
|
| 646 | - if ($type === "style") { |
|
| 647 | - if (!in_array($path, self::$styles)) { |
|
| 648 | - if ($prepend === true) { |
|
| 649 | - array_unshift ( self::$styles, $path ); |
|
| 650 | - } else { |
|
| 651 | - self::$styles[] = $path; |
|
| 652 | - } |
|
| 653 | - } |
|
| 654 | - } elseif ($type === "script") { |
|
| 655 | - if (!in_array($path, self::$scripts)) { |
|
| 656 | - if ($prepend === true) { |
|
| 657 | - array_unshift ( self::$scripts, $path ); |
|
| 658 | - } else { |
|
| 659 | - self::$scripts [] = $path; |
|
| 660 | - } |
|
| 661 | - } |
|
| 662 | - } |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - /** |
|
| 666 | - * Add a custom element to the header |
|
| 667 | - * If $text is null then the element will be written as empty element. |
|
| 668 | - * So use "" to get a closing tag. |
|
| 669 | - * @param string $tag tag name of the element |
|
| 670 | - * @param array $attributes array of attributes for the element |
|
| 671 | - * @param string $text the text content for the element |
|
| 672 | - */ |
|
| 673 | - public static function addHeader($tag, $attributes, $text=null) { |
|
| 674 | - self::$headers[] = array( |
|
| 675 | - 'tag' => $tag, |
|
| 676 | - 'attributes' => $attributes, |
|
| 677 | - 'text' => $text |
|
| 678 | - ); |
|
| 679 | - } |
|
| 680 | - |
|
| 681 | - /** |
|
| 682 | - * check if the current server configuration is suitable for ownCloud |
|
| 683 | - * |
|
| 684 | - * @param \OC\SystemConfig $config |
|
| 685 | - * @return array arrays with error messages and hints |
|
| 686 | - */ |
|
| 687 | - public static function checkServer(\OC\SystemConfig $config) { |
|
| 688 | - $l = \OC::$server->getL10N('lib'); |
|
| 689 | - $errors = array(); |
|
| 690 | - $CONFIG_DATADIRECTORY = $config->getValue('datadirectory', OC::$SERVERROOT . '/data'); |
|
| 691 | - |
|
| 692 | - if (!self::needUpgrade($config) && $config->getValue('installed', false)) { |
|
| 693 | - // this check needs to be done every time |
|
| 694 | - $errors = self::checkDataDirectoryValidity($CONFIG_DATADIRECTORY); |
|
| 695 | - } |
|
| 696 | - |
|
| 697 | - // Assume that if checkServer() succeeded before in this session, then all is fine. |
|
| 698 | - if (\OC::$server->getSession()->exists('checkServer_succeeded') && \OC::$server->getSession()->get('checkServer_succeeded')) { |
|
| 699 | - return $errors; |
|
| 700 | - } |
|
| 701 | - |
|
| 702 | - $webServerRestart = false; |
|
| 703 | - $setup = new \OC\Setup( |
|
| 704 | - $config, |
|
| 705 | - \OC::$server->getIniWrapper(), |
|
| 706 | - \OC::$server->getL10N('lib'), |
|
| 707 | - \OC::$server->query(\OCP\Defaults::class), |
|
| 708 | - \OC::$server->getLogger(), |
|
| 709 | - \OC::$server->getSecureRandom(), |
|
| 710 | - \OC::$server->query(\OC\Installer::class) |
|
| 711 | - ); |
|
| 712 | - |
|
| 713 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 714 | - |
|
| 715 | - $availableDatabases = $setup->getSupportedDatabases(); |
|
| 716 | - if (empty($availableDatabases)) { |
|
| 717 | - $errors[] = array( |
|
| 718 | - 'error' => $l->t('No database drivers (sqlite, mysql, or postgresql) installed.'), |
|
| 719 | - 'hint' => '' //TODO: sane hint |
|
| 720 | - ); |
|
| 721 | - $webServerRestart = true; |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - // Check if config folder is writable. |
|
| 725 | - if(!OC_Helper::isReadOnlyConfigEnabled()) { |
|
| 726 | - if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) { |
|
| 727 | - $errors[] = array( |
|
| 728 | - 'error' => $l->t('Cannot write into "config" directory'), |
|
| 729 | - 'hint' => $l->t('This can usually be fixed by giving the webserver write access to the config directory. See %s', |
|
| 730 | - [$urlGenerator->linkToDocs('admin-dir_permissions')]) |
|
| 731 | - ); |
|
| 732 | - } |
|
| 733 | - } |
|
| 734 | - |
|
| 735 | - // Check if there is a writable install folder. |
|
| 736 | - if ($config->getValue('appstoreenabled', true)) { |
|
| 737 | - if (OC_App::getInstallPath() === null |
|
| 738 | - || !is_writable(OC_App::getInstallPath()) |
|
| 739 | - || !is_readable(OC_App::getInstallPath()) |
|
| 740 | - ) { |
|
| 741 | - $errors[] = array( |
|
| 742 | - 'error' => $l->t('Cannot write into "apps" directory'), |
|
| 743 | - 'hint' => $l->t('This can usually be fixed by giving the webserver write access to the apps directory' |
|
| 744 | - . ' or disabling the appstore in the config file. See %s', |
|
| 745 | - [$urlGenerator->linkToDocs('admin-dir_permissions')]) |
|
| 746 | - ); |
|
| 747 | - } |
|
| 748 | - } |
|
| 749 | - // Create root dir. |
|
| 750 | - if ($config->getValue('installed', false)) { |
|
| 751 | - if (!is_dir($CONFIG_DATADIRECTORY)) { |
|
| 752 | - $success = @mkdir($CONFIG_DATADIRECTORY); |
|
| 753 | - if ($success) { |
|
| 754 | - $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); |
|
| 755 | - } else { |
|
| 756 | - $errors[] = [ |
|
| 757 | - 'error' => $l->t('Cannot create "data" directory'), |
|
| 758 | - 'hint' => $l->t('This can usually be fixed by giving the webserver write access to the root directory. See %s', |
|
| 759 | - [$urlGenerator->linkToDocs('admin-dir_permissions')]) |
|
| 760 | - ]; |
|
| 761 | - } |
|
| 762 | - } else if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { |
|
| 763 | - //common hint for all file permissions error messages |
|
| 764 | - $permissionsHint = $l->t('Permissions can usually be fixed by giving the webserver write access to the root directory. See %s.', |
|
| 765 | - [$urlGenerator->linkToDocs('admin-dir_permissions')]); |
|
| 766 | - $errors[] = [ |
|
| 767 | - 'error' => 'Your data directory is not writable', |
|
| 768 | - 'hint' => $permissionsHint |
|
| 769 | - ]; |
|
| 770 | - } else { |
|
| 771 | - $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); |
|
| 772 | - } |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - if (!OC_Util::isSetLocaleWorking()) { |
|
| 776 | - $errors[] = array( |
|
| 777 | - 'error' => $l->t('Setting locale to %s failed', |
|
| 778 | - array('en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/' |
|
| 779 | - . 'pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8')), |
|
| 780 | - 'hint' => $l->t('Please install one of these locales on your system and restart your webserver.') |
|
| 781 | - ); |
|
| 782 | - } |
|
| 783 | - |
|
| 784 | - // Contains the dependencies that should be checked against |
|
| 785 | - // classes = class_exists |
|
| 786 | - // functions = function_exists |
|
| 787 | - // defined = defined |
|
| 788 | - // ini = ini_get |
|
| 789 | - // If the dependency is not found the missing module name is shown to the EndUser |
|
| 790 | - // When adding new checks always verify that they pass on Travis as well |
|
| 791 | - // for ini settings, see https://github.com/owncloud/administration/blob/master/travis-ci/custom.ini |
|
| 792 | - $dependencies = array( |
|
| 793 | - 'classes' => array( |
|
| 794 | - 'ZipArchive' => 'zip', |
|
| 795 | - 'DOMDocument' => 'dom', |
|
| 796 | - 'XMLWriter' => 'XMLWriter', |
|
| 797 | - 'XMLReader' => 'XMLReader', |
|
| 798 | - ), |
|
| 799 | - 'functions' => [ |
|
| 800 | - 'xml_parser_create' => 'libxml', |
|
| 801 | - 'mb_strcut' => 'mb multibyte', |
|
| 802 | - 'ctype_digit' => 'ctype', |
|
| 803 | - 'json_encode' => 'JSON', |
|
| 804 | - 'gd_info' => 'GD', |
|
| 805 | - 'gzencode' => 'zlib', |
|
| 806 | - 'iconv' => 'iconv', |
|
| 807 | - 'simplexml_load_string' => 'SimpleXML', |
|
| 808 | - 'hash' => 'HASH Message Digest Framework', |
|
| 809 | - 'curl_init' => 'cURL', |
|
| 810 | - 'openssl_verify' => 'OpenSSL', |
|
| 811 | - ], |
|
| 812 | - 'defined' => array( |
|
| 813 | - 'PDO::ATTR_DRIVER_NAME' => 'PDO' |
|
| 814 | - ), |
|
| 815 | - 'ini' => [ |
|
| 816 | - 'default_charset' => 'UTF-8', |
|
| 817 | - ], |
|
| 818 | - ); |
|
| 819 | - $missingDependencies = array(); |
|
| 820 | - $invalidIniSettings = []; |
|
| 821 | - $moduleHint = $l->t('Please ask your server administrator to install the module.'); |
|
| 822 | - |
|
| 823 | - /** |
|
| 824 | - * FIXME: The dependency check does not work properly on HHVM on the moment |
|
| 825 | - * and prevents installation. Once HHVM is more compatible with our |
|
| 826 | - * approach to check for these values we should re-enable those |
|
| 827 | - * checks. |
|
| 828 | - */ |
|
| 829 | - $iniWrapper = \OC::$server->getIniWrapper(); |
|
| 830 | - if (!self::runningOnHhvm()) { |
|
| 831 | - foreach ($dependencies['classes'] as $class => $module) { |
|
| 832 | - if (!class_exists($class)) { |
|
| 833 | - $missingDependencies[] = $module; |
|
| 834 | - } |
|
| 835 | - } |
|
| 836 | - foreach ($dependencies['functions'] as $function => $module) { |
|
| 837 | - if (!function_exists($function)) { |
|
| 838 | - $missingDependencies[] = $module; |
|
| 839 | - } |
|
| 840 | - } |
|
| 841 | - foreach ($dependencies['defined'] as $defined => $module) { |
|
| 842 | - if (!defined($defined)) { |
|
| 843 | - $missingDependencies[] = $module; |
|
| 844 | - } |
|
| 845 | - } |
|
| 846 | - foreach ($dependencies['ini'] as $setting => $expected) { |
|
| 847 | - if (is_bool($expected)) { |
|
| 848 | - if ($iniWrapper->getBool($setting) !== $expected) { |
|
| 849 | - $invalidIniSettings[] = [$setting, $expected]; |
|
| 850 | - } |
|
| 851 | - } |
|
| 852 | - if (is_int($expected)) { |
|
| 853 | - if ($iniWrapper->getNumeric($setting) !== $expected) { |
|
| 854 | - $invalidIniSettings[] = [$setting, $expected]; |
|
| 855 | - } |
|
| 856 | - } |
|
| 857 | - if (is_string($expected)) { |
|
| 858 | - if (strtolower($iniWrapper->getString($setting)) !== strtolower($expected)) { |
|
| 859 | - $invalidIniSettings[] = [$setting, $expected]; |
|
| 860 | - } |
|
| 861 | - } |
|
| 862 | - } |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - foreach($missingDependencies as $missingDependency) { |
|
| 866 | - $errors[] = array( |
|
| 867 | - 'error' => $l->t('PHP module %s not installed.', array($missingDependency)), |
|
| 868 | - 'hint' => $moduleHint |
|
| 869 | - ); |
|
| 870 | - $webServerRestart = true; |
|
| 871 | - } |
|
| 872 | - foreach($invalidIniSettings as $setting) { |
|
| 873 | - if(is_bool($setting[1])) { |
|
| 874 | - $setting[1] = $setting[1] ? 'on' : 'off'; |
|
| 875 | - } |
|
| 876 | - $errors[] = [ |
|
| 877 | - 'error' => $l->t('PHP setting "%s" is not set to "%s".', [$setting[0], var_export($setting[1], true)]), |
|
| 878 | - 'hint' => $l->t('Adjusting this setting in php.ini will make Nextcloud run again') |
|
| 879 | - ]; |
|
| 880 | - $webServerRestart = true; |
|
| 881 | - } |
|
| 882 | - |
|
| 883 | - /** |
|
| 884 | - * The mbstring.func_overload check can only be performed if the mbstring |
|
| 885 | - * module is installed as it will return null if the checking setting is |
|
| 886 | - * not available and thus a check on the boolean value fails. |
|
| 887 | - * |
|
| 888 | - * TODO: Should probably be implemented in the above generic dependency |
|
| 889 | - * check somehow in the long-term. |
|
| 890 | - */ |
|
| 891 | - if($iniWrapper->getBool('mbstring.func_overload') !== null && |
|
| 892 | - $iniWrapper->getBool('mbstring.func_overload') === true) { |
|
| 893 | - $errors[] = array( |
|
| 894 | - 'error' => $l->t('mbstring.func_overload is set to "%s" instead of the expected value "0"', [$iniWrapper->getString('mbstring.func_overload')]), |
|
| 895 | - 'hint' => $l->t('To fix this issue set <code>mbstring.func_overload</code> to <code>0</code> in your php.ini') |
|
| 896 | - ); |
|
| 897 | - } |
|
| 898 | - |
|
| 899 | - if(function_exists('xml_parser_create') && |
|
| 900 | - LIBXML_LOADED_VERSION < 20700 ) { |
|
| 901 | - $version = LIBXML_LOADED_VERSION; |
|
| 902 | - $major = floor($version/10000); |
|
| 903 | - $version -= ($major * 10000); |
|
| 904 | - $minor = floor($version/100); |
|
| 905 | - $version -= ($minor * 100); |
|
| 906 | - $patch = $version; |
|
| 907 | - $errors[] = array( |
|
| 908 | - 'error' => $l->t('libxml2 2.7.0 is at least required. Currently %s is installed.', [$major . '.' . $minor . '.' . $patch]), |
|
| 909 | - 'hint' => $l->t('To fix this issue update your libxml2 version and restart your web server.') |
|
| 910 | - ); |
|
| 911 | - } |
|
| 912 | - |
|
| 913 | - if (!self::isAnnotationsWorking()) { |
|
| 914 | - $errors[] = array( |
|
| 915 | - 'error' => $l->t('PHP is apparently set up to strip inline doc blocks. This will make several core apps inaccessible.'), |
|
| 916 | - 'hint' => $l->t('This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator.') |
|
| 917 | - ); |
|
| 918 | - } |
|
| 919 | - |
|
| 920 | - if (!\OC::$CLI && $webServerRestart) { |
|
| 921 | - $errors[] = array( |
|
| 922 | - 'error' => $l->t('PHP modules have been installed, but they are still listed as missing?'), |
|
| 923 | - 'hint' => $l->t('Please ask your server administrator to restart the web server.') |
|
| 924 | - ); |
|
| 925 | - } |
|
| 926 | - |
|
| 927 | - $errors = array_merge($errors, self::checkDatabaseVersion()); |
|
| 928 | - |
|
| 929 | - // Cache the result of this function |
|
| 930 | - \OC::$server->getSession()->set('checkServer_succeeded', count($errors) == 0); |
|
| 931 | - |
|
| 932 | - return $errors; |
|
| 933 | - } |
|
| 934 | - |
|
| 935 | - /** |
|
| 936 | - * Check the database version |
|
| 937 | - * |
|
| 938 | - * @return array errors array |
|
| 939 | - */ |
|
| 940 | - public static function checkDatabaseVersion() { |
|
| 941 | - $l = \OC::$server->getL10N('lib'); |
|
| 942 | - $errors = array(); |
|
| 943 | - $dbType = \OC::$server->getSystemConfig()->getValue('dbtype', 'sqlite'); |
|
| 944 | - if ($dbType === 'pgsql') { |
|
| 945 | - // check PostgreSQL version |
|
| 946 | - try { |
|
| 947 | - $result = \OC_DB::executeAudited('SHOW SERVER_VERSION'); |
|
| 948 | - $data = $result->fetchRow(); |
|
| 949 | - if (isset($data['server_version'])) { |
|
| 950 | - $version = $data['server_version']; |
|
| 951 | - if (version_compare($version, '9.0.0', '<')) { |
|
| 952 | - $errors[] = array( |
|
| 953 | - 'error' => $l->t('PostgreSQL >= 9 required'), |
|
| 954 | - 'hint' => $l->t('Please upgrade your database version') |
|
| 955 | - ); |
|
| 956 | - } |
|
| 957 | - } |
|
| 958 | - } catch (\Doctrine\DBAL\DBALException $e) { |
|
| 959 | - $logger = \OC::$server->getLogger(); |
|
| 960 | - $logger->warning('Error occurred while checking PostgreSQL version, assuming >= 9'); |
|
| 961 | - $logger->logException($e); |
|
| 962 | - } |
|
| 963 | - } |
|
| 964 | - return $errors; |
|
| 965 | - } |
|
| 966 | - |
|
| 967 | - /** |
|
| 968 | - * Check for correct file permissions of data directory |
|
| 969 | - * |
|
| 970 | - * @param string $dataDirectory |
|
| 971 | - * @return array arrays with error messages and hints |
|
| 972 | - */ |
|
| 973 | - public static function checkDataDirectoryPermissions($dataDirectory) { |
|
| 974 | - if(\OC::$server->getConfig()->getSystemValue('check_data_directory_permissions', true) === false) { |
|
| 975 | - return []; |
|
| 976 | - } |
|
| 977 | - $l = \OC::$server->getL10N('lib'); |
|
| 978 | - $errors = []; |
|
| 979 | - $permissionsModHint = $l->t('Please change the permissions to 0770 so that the directory' |
|
| 980 | - . ' cannot be listed by other users.'); |
|
| 981 | - $perms = substr(decoct(@fileperms($dataDirectory)), -3); |
|
| 982 | - if (substr($perms, -1) !== '0') { |
|
| 983 | - chmod($dataDirectory, 0770); |
|
| 984 | - clearstatcache(); |
|
| 985 | - $perms = substr(decoct(@fileperms($dataDirectory)), -3); |
|
| 986 | - if ($perms[2] !== '0') { |
|
| 987 | - $errors[] = [ |
|
| 988 | - 'error' => $l->t('Your data directory is readable by other users'), |
|
| 989 | - 'hint' => $permissionsModHint |
|
| 990 | - ]; |
|
| 991 | - } |
|
| 992 | - } |
|
| 993 | - return $errors; |
|
| 994 | - } |
|
| 995 | - |
|
| 996 | - /** |
|
| 997 | - * Check that the data directory exists and is valid by |
|
| 998 | - * checking the existence of the ".ocdata" file. |
|
| 999 | - * |
|
| 1000 | - * @param string $dataDirectory data directory path |
|
| 1001 | - * @return array errors found |
|
| 1002 | - */ |
|
| 1003 | - public static function checkDataDirectoryValidity($dataDirectory) { |
|
| 1004 | - $l = \OC::$server->getL10N('lib'); |
|
| 1005 | - $errors = []; |
|
| 1006 | - if ($dataDirectory[0] !== '/') { |
|
| 1007 | - $errors[] = [ |
|
| 1008 | - 'error' => $l->t('Your data directory must be an absolute path'), |
|
| 1009 | - 'hint' => $l->t('Check the value of "datadirectory" in your configuration') |
|
| 1010 | - ]; |
|
| 1011 | - } |
|
| 1012 | - if (!file_exists($dataDirectory . '/.ocdata')) { |
|
| 1013 | - $errors[] = [ |
|
| 1014 | - 'error' => $l->t('Your data directory is invalid'), |
|
| 1015 | - 'hint' => $l->t('Ensure there is a file called ".ocdata"' . |
|
| 1016 | - ' in the root of the data directory.') |
|
| 1017 | - ]; |
|
| 1018 | - } |
|
| 1019 | - return $errors; |
|
| 1020 | - } |
|
| 1021 | - |
|
| 1022 | - /** |
|
| 1023 | - * Check if the user is logged in, redirects to home if not. With |
|
| 1024 | - * redirect URL parameter to the request URI. |
|
| 1025 | - * |
|
| 1026 | - * @return void |
|
| 1027 | - */ |
|
| 1028 | - public static function checkLoggedIn() { |
|
| 1029 | - // Check if we are a user |
|
| 1030 | - if (!\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 1031 | - header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute( |
|
| 1032 | - 'core.login.showLoginForm', |
|
| 1033 | - [ |
|
| 1034 | - 'redirect_url' => \OC::$server->getRequest()->getRequestUri(), |
|
| 1035 | - ] |
|
| 1036 | - ) |
|
| 1037 | - ); |
|
| 1038 | - exit(); |
|
| 1039 | - } |
|
| 1040 | - // Redirect to 2FA challenge selection if 2FA challenge was not solved yet |
|
| 1041 | - if (\OC::$server->getTwoFactorAuthManager()->needsSecondFactor(\OC::$server->getUserSession()->getUser())) { |
|
| 1042 | - header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.selectChallenge')); |
|
| 1043 | - exit(); |
|
| 1044 | - } |
|
| 1045 | - } |
|
| 1046 | - |
|
| 1047 | - /** |
|
| 1048 | - * Check if the user is a admin, redirects to home if not |
|
| 1049 | - * |
|
| 1050 | - * @return void |
|
| 1051 | - */ |
|
| 1052 | - public static function checkAdminUser() { |
|
| 1053 | - OC_Util::checkLoggedIn(); |
|
| 1054 | - if (!OC_User::isAdminUser(OC_User::getUser())) { |
|
| 1055 | - header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php')); |
|
| 1056 | - exit(); |
|
| 1057 | - } |
|
| 1058 | - } |
|
| 1059 | - |
|
| 1060 | - /** |
|
| 1061 | - * Check if the user is a subadmin, redirects to home if not |
|
| 1062 | - * |
|
| 1063 | - * @return null|boolean $groups where the current user is subadmin |
|
| 1064 | - */ |
|
| 1065 | - public static function checkSubAdminUser() { |
|
| 1066 | - OC_Util::checkLoggedIn(); |
|
| 1067 | - $userObject = \OC::$server->getUserSession()->getUser(); |
|
| 1068 | - $isSubAdmin = false; |
|
| 1069 | - if($userObject !== null) { |
|
| 1070 | - $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
|
| 1071 | - } |
|
| 1072 | - |
|
| 1073 | - if (!$isSubAdmin) { |
|
| 1074 | - header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php')); |
|
| 1075 | - exit(); |
|
| 1076 | - } |
|
| 1077 | - return true; |
|
| 1078 | - } |
|
| 1079 | - |
|
| 1080 | - /** |
|
| 1081 | - * Returns the URL of the default page |
|
| 1082 | - * based on the system configuration and |
|
| 1083 | - * the apps visible for the current user |
|
| 1084 | - * |
|
| 1085 | - * @return string URL |
|
| 1086 | - * @suppress PhanDeprecatedFunction |
|
| 1087 | - */ |
|
| 1088 | - public static function getDefaultPageUrl() { |
|
| 1089 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 1090 | - // Deny the redirect if the URL contains a @ |
|
| 1091 | - // This prevents unvalidated redirects like ?redirect_url=:[email protected] |
|
| 1092 | - if (isset($_REQUEST['redirect_url']) && strpos($_REQUEST['redirect_url'], '@') === false) { |
|
| 1093 | - $location = $urlGenerator->getAbsoluteURL(urldecode($_REQUEST['redirect_url'])); |
|
| 1094 | - } else { |
|
| 1095 | - $defaultPage = \OC::$server->getConfig()->getAppValue('core', 'defaultpage'); |
|
| 1096 | - if ($defaultPage) { |
|
| 1097 | - $location = $urlGenerator->getAbsoluteURL($defaultPage); |
|
| 1098 | - } else { |
|
| 1099 | - $appId = 'files'; |
|
| 1100 | - $config = \OC::$server->getConfig(); |
|
| 1101 | - $defaultApps = explode(',', $config->getSystemValue('defaultapp', 'files')); |
|
| 1102 | - // find the first app that is enabled for the current user |
|
| 1103 | - foreach ($defaultApps as $defaultApp) { |
|
| 1104 | - $defaultApp = OC_App::cleanAppId(strip_tags($defaultApp)); |
|
| 1105 | - if (static::getAppManager()->isEnabledForUser($defaultApp)) { |
|
| 1106 | - $appId = $defaultApp; |
|
| 1107 | - break; |
|
| 1108 | - } |
|
| 1109 | - } |
|
| 1110 | - |
|
| 1111 | - if($config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true') { |
|
| 1112 | - $location = $urlGenerator->getAbsoluteURL('/apps/' . $appId . '/'); |
|
| 1113 | - } else { |
|
| 1114 | - $location = $urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/'); |
|
| 1115 | - } |
|
| 1116 | - } |
|
| 1117 | - } |
|
| 1118 | - return $location; |
|
| 1119 | - } |
|
| 1120 | - |
|
| 1121 | - /** |
|
| 1122 | - * Redirect to the user default page |
|
| 1123 | - * |
|
| 1124 | - * @return void |
|
| 1125 | - */ |
|
| 1126 | - public static function redirectToDefaultPage() { |
|
| 1127 | - $location = self::getDefaultPageUrl(); |
|
| 1128 | - header('Location: ' . $location); |
|
| 1129 | - exit(); |
|
| 1130 | - } |
|
| 1131 | - |
|
| 1132 | - /** |
|
| 1133 | - * get an id unique for this instance |
|
| 1134 | - * |
|
| 1135 | - * @return string |
|
| 1136 | - */ |
|
| 1137 | - public static function getInstanceId() { |
|
| 1138 | - $id = \OC::$server->getSystemConfig()->getValue('instanceid', null); |
|
| 1139 | - if (is_null($id)) { |
|
| 1140 | - // We need to guarantee at least one letter in instanceid so it can be used as the session_name |
|
| 1141 | - $id = 'oc' . \OC::$server->getSecureRandom()->generate(10, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); |
|
| 1142 | - \OC::$server->getSystemConfig()->setValue('instanceid', $id); |
|
| 1143 | - } |
|
| 1144 | - return $id; |
|
| 1145 | - } |
|
| 1146 | - |
|
| 1147 | - /** |
|
| 1148 | - * Public function to sanitize HTML |
|
| 1149 | - * |
|
| 1150 | - * This function is used to sanitize HTML and should be applied on any |
|
| 1151 | - * string or array of strings before displaying it on a web page. |
|
| 1152 | - * |
|
| 1153 | - * @param string|array $value |
|
| 1154 | - * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter. |
|
| 1155 | - */ |
|
| 1156 | - public static function sanitizeHTML($value) { |
|
| 1157 | - if (is_array($value)) { |
|
| 1158 | - $value = array_map(function($value) { |
|
| 1159 | - return self::sanitizeHTML($value); |
|
| 1160 | - }, $value); |
|
| 1161 | - } else { |
|
| 1162 | - // Specify encoding for PHP<5.4 |
|
| 1163 | - $value = htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8'); |
|
| 1164 | - } |
|
| 1165 | - return $value; |
|
| 1166 | - } |
|
| 1167 | - |
|
| 1168 | - /** |
|
| 1169 | - * Public function to encode url parameters |
|
| 1170 | - * |
|
| 1171 | - * This function is used to encode path to file before output. |
|
| 1172 | - * Encoding is done according to RFC 3986 with one exception: |
|
| 1173 | - * Character '/' is preserved as is. |
|
| 1174 | - * |
|
| 1175 | - * @param string $component part of URI to encode |
|
| 1176 | - * @return string |
|
| 1177 | - */ |
|
| 1178 | - public static function encodePath($component) { |
|
| 1179 | - $encoded = rawurlencode($component); |
|
| 1180 | - $encoded = str_replace('%2F', '/', $encoded); |
|
| 1181 | - return $encoded; |
|
| 1182 | - } |
|
| 1183 | - |
|
| 1184 | - |
|
| 1185 | - public function createHtaccessTestFile(\OCP\IConfig $config) { |
|
| 1186 | - // php dev server does not support htaccess |
|
| 1187 | - if (php_sapi_name() === 'cli-server') { |
|
| 1188 | - return false; |
|
| 1189 | - } |
|
| 1190 | - |
|
| 1191 | - // testdata |
|
| 1192 | - $fileName = '/htaccesstest.txt'; |
|
| 1193 | - $testContent = 'This is used for testing whether htaccess is properly enabled to disallow access from the outside. This file can be safely removed.'; |
|
| 1194 | - |
|
| 1195 | - // creating a test file |
|
| 1196 | - $testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName; |
|
| 1197 | - |
|
| 1198 | - if (file_exists($testFile)) {// already running this test, possible recursive call |
|
| 1199 | - return false; |
|
| 1200 | - } |
|
| 1201 | - |
|
| 1202 | - $fp = @fopen($testFile, 'w'); |
|
| 1203 | - if (!$fp) { |
|
| 1204 | - throw new OC\HintException('Can\'t create test file to check for working .htaccess file.', |
|
| 1205 | - 'Make sure it is possible for the webserver to write to ' . $testFile); |
|
| 1206 | - } |
|
| 1207 | - fwrite($fp, $testContent); |
|
| 1208 | - fclose($fp); |
|
| 1209 | - |
|
| 1210 | - return $testContent; |
|
| 1211 | - } |
|
| 1212 | - |
|
| 1213 | - /** |
|
| 1214 | - * Check if the .htaccess file is working |
|
| 1215 | - * @param \OCP\IConfig $config |
|
| 1216 | - * @return bool |
|
| 1217 | - * @throws Exception |
|
| 1218 | - * @throws \OC\HintException If the test file can't get written. |
|
| 1219 | - */ |
|
| 1220 | - public function isHtaccessWorking(\OCP\IConfig $config) { |
|
| 1221 | - |
|
| 1222 | - if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) { |
|
| 1223 | - return true; |
|
| 1224 | - } |
|
| 1225 | - |
|
| 1226 | - $testContent = $this->createHtaccessTestFile($config); |
|
| 1227 | - if ($testContent === false) { |
|
| 1228 | - return false; |
|
| 1229 | - } |
|
| 1230 | - |
|
| 1231 | - $fileName = '/htaccesstest.txt'; |
|
| 1232 | - $testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName; |
|
| 1233 | - |
|
| 1234 | - // accessing the file via http |
|
| 1235 | - $url = \OC::$server->getURLGenerator()->getAbsoluteURL(OC::$WEBROOT . '/data' . $fileName); |
|
| 1236 | - try { |
|
| 1237 | - $content = \OC::$server->getHTTPClientService()->newClient()->get($url)->getBody(); |
|
| 1238 | - } catch (\Exception $e) { |
|
| 1239 | - $content = false; |
|
| 1240 | - } |
|
| 1241 | - |
|
| 1242 | - // cleanup |
|
| 1243 | - @unlink($testFile); |
|
| 1244 | - |
|
| 1245 | - /* |
|
| 68 | + public static $scripts = array(); |
|
| 69 | + public static $styles = array(); |
|
| 70 | + public static $headers = array(); |
|
| 71 | + private static $rootMounted = false; |
|
| 72 | + private static $fsSetup = false; |
|
| 73 | + |
|
| 74 | + /** @var array Local cache of version.php */ |
|
| 75 | + private static $versionCache = null; |
|
| 76 | + |
|
| 77 | + protected static function getAppManager() { |
|
| 78 | + return \OC::$server->getAppManager(); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + private static function initLocalStorageRootFS() { |
|
| 82 | + // mount local file backend as root |
|
| 83 | + $configDataDirectory = \OC::$server->getSystemConfig()->getValue("datadirectory", OC::$SERVERROOT . "/data"); |
|
| 84 | + //first set up the local "root" storage |
|
| 85 | + \OC\Files\Filesystem::initMountManager(); |
|
| 86 | + if (!self::$rootMounted) { |
|
| 87 | + \OC\Files\Filesystem::mount('\OC\Files\Storage\Local', array('datadir' => $configDataDirectory), '/'); |
|
| 88 | + self::$rootMounted = true; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * mounting an object storage as the root fs will in essence remove the |
|
| 94 | + * necessity of a data folder being present. |
|
| 95 | + * TODO make home storage aware of this and use the object storage instead of local disk access |
|
| 96 | + * |
|
| 97 | + * @param array $config containing 'class' and optional 'arguments' |
|
| 98 | + * @suppress PhanDeprecatedFunction |
|
| 99 | + */ |
|
| 100 | + private static function initObjectStoreRootFS($config) { |
|
| 101 | + // check misconfiguration |
|
| 102 | + if (empty($config['class'])) { |
|
| 103 | + \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR); |
|
| 104 | + } |
|
| 105 | + if (!isset($config['arguments'])) { |
|
| 106 | + $config['arguments'] = array(); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + // instantiate object store implementation |
|
| 110 | + $name = $config['class']; |
|
| 111 | + if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
| 112 | + $segments = explode('\\', $name); |
|
| 113 | + OC_App::loadApp(strtolower($segments[1])); |
|
| 114 | + } |
|
| 115 | + $config['arguments']['objectstore'] = new $config['class']($config['arguments']); |
|
| 116 | + // mount with plain / root object store implementation |
|
| 117 | + $config['class'] = '\OC\Files\ObjectStore\ObjectStoreStorage'; |
|
| 118 | + |
|
| 119 | + // mount object storage as root |
|
| 120 | + \OC\Files\Filesystem::initMountManager(); |
|
| 121 | + if (!self::$rootMounted) { |
|
| 122 | + \OC\Files\Filesystem::mount($config['class'], $config['arguments'], '/'); |
|
| 123 | + self::$rootMounted = true; |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * mounting an object storage as the root fs will in essence remove the |
|
| 129 | + * necessity of a data folder being present. |
|
| 130 | + * |
|
| 131 | + * @param array $config containing 'class' and optional 'arguments' |
|
| 132 | + * @suppress PhanDeprecatedFunction |
|
| 133 | + */ |
|
| 134 | + private static function initObjectStoreMultibucketRootFS($config) { |
|
| 135 | + // check misconfiguration |
|
| 136 | + if (empty($config['class'])) { |
|
| 137 | + \OCP\Util::writeLog('files', 'No class given for objectstore', \OCP\Util::ERROR); |
|
| 138 | + } |
|
| 139 | + if (!isset($config['arguments'])) { |
|
| 140 | + $config['arguments'] = array(); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // instantiate object store implementation |
|
| 144 | + $name = $config['class']; |
|
| 145 | + if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { |
|
| 146 | + $segments = explode('\\', $name); |
|
| 147 | + OC_App::loadApp(strtolower($segments[1])); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + if (!isset($config['arguments']['bucket'])) { |
|
| 151 | + $config['arguments']['bucket'] = ''; |
|
| 152 | + } |
|
| 153 | + // put the root FS always in first bucket for multibucket configuration |
|
| 154 | + $config['arguments']['bucket'] .= '0'; |
|
| 155 | + |
|
| 156 | + $config['arguments']['objectstore'] = new $config['class']($config['arguments']); |
|
| 157 | + // mount with plain / root object store implementation |
|
| 158 | + $config['class'] = '\OC\Files\ObjectStore\ObjectStoreStorage'; |
|
| 159 | + |
|
| 160 | + // mount object storage as root |
|
| 161 | + \OC\Files\Filesystem::initMountManager(); |
|
| 162 | + if (!self::$rootMounted) { |
|
| 163 | + \OC\Files\Filesystem::mount($config['class'], $config['arguments'], '/'); |
|
| 164 | + self::$rootMounted = true; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Can be set up |
|
| 170 | + * |
|
| 171 | + * @param string $user |
|
| 172 | + * @return boolean |
|
| 173 | + * @description configure the initial filesystem based on the configuration |
|
| 174 | + * @suppress PhanDeprecatedFunction |
|
| 175 | + * @suppress PhanAccessMethodInternal |
|
| 176 | + */ |
|
| 177 | + public static function setupFS($user = '') { |
|
| 178 | + //setting up the filesystem twice can only lead to trouble |
|
| 179 | + if (self::$fsSetup) { |
|
| 180 | + return false; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + \OC::$server->getEventLogger()->start('setup_fs', 'Setup filesystem'); |
|
| 184 | + |
|
| 185 | + // If we are not forced to load a specific user we load the one that is logged in |
|
| 186 | + if ($user === null) { |
|
| 187 | + $user = ''; |
|
| 188 | + } else if ($user == "" && \OC::$server->getUserSession()->isLoggedIn()) { |
|
| 189 | + $user = OC_User::getUser(); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + // load all filesystem apps before, so no setup-hook gets lost |
|
| 193 | + OC_App::loadApps(array('filesystem')); |
|
| 194 | + |
|
| 195 | + // the filesystem will finish when $user is not empty, |
|
| 196 | + // mark fs setup here to avoid doing the setup from loading |
|
| 197 | + // OC_Filesystem |
|
| 198 | + if ($user != '') { |
|
| 199 | + self::$fsSetup = true; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + \OC\Files\Filesystem::initMountManager(); |
|
| 203 | + |
|
| 204 | + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false); |
|
| 205 | + \OC\Files\Filesystem::addStorageWrapper('mount_options', function ($mountPoint, \OCP\Files\Storage $storage, \OCP\Files\Mount\IMountPoint $mount) { |
|
| 206 | + if ($storage->instanceOfStorage('\OC\Files\Storage\Common')) { |
|
| 207 | + /** @var \OC\Files\Storage\Common $storage */ |
|
| 208 | + $storage->setMountOptions($mount->getOptions()); |
|
| 209 | + } |
|
| 210 | + return $storage; |
|
| 211 | + }); |
|
| 212 | + |
|
| 213 | + \OC\Files\Filesystem::addStorageWrapper('enable_sharing', function ($mountPoint, \OCP\Files\Storage\IStorage $storage, \OCP\Files\Mount\IMountPoint $mount) { |
|
| 214 | + if (!$mount->getOption('enable_sharing', true)) { |
|
| 215 | + return new \OC\Files\Storage\Wrapper\PermissionsMask([ |
|
| 216 | + 'storage' => $storage, |
|
| 217 | + 'mask' => \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE |
|
| 218 | + ]); |
|
| 219 | + } |
|
| 220 | + return $storage; |
|
| 221 | + }); |
|
| 222 | + |
|
| 223 | + // install storage availability wrapper, before most other wrappers |
|
| 224 | + \OC\Files\Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, \OCP\Files\Storage\IStorage $storage) { |
|
| 225 | + if (!$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage') && !$storage->isLocal()) { |
|
| 226 | + return new \OC\Files\Storage\Wrapper\Availability(['storage' => $storage]); |
|
| 227 | + } |
|
| 228 | + return $storage; |
|
| 229 | + }); |
|
| 230 | + |
|
| 231 | + \OC\Files\Filesystem::addStorageWrapper('oc_encoding', function ($mountPoint, \OCP\Files\Storage $storage, \OCP\Files\Mount\IMountPoint $mount) { |
|
| 232 | + if ($mount->getOption('encoding_compatibility', false) && !$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage') && !$storage->isLocal()) { |
|
| 233 | + return new \OC\Files\Storage\Wrapper\Encoding(['storage' => $storage]); |
|
| 234 | + } |
|
| 235 | + return $storage; |
|
| 236 | + }); |
|
| 237 | + |
|
| 238 | + \OC\Files\Filesystem::addStorageWrapper('oc_quota', function ($mountPoint, $storage) { |
|
| 239 | + // set up quota for home storages, even for other users |
|
| 240 | + // which can happen when using sharing |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * @var \OC\Files\Storage\Storage $storage |
|
| 244 | + */ |
|
| 245 | + if ($storage->instanceOfStorage('\OC\Files\Storage\Home') |
|
| 246 | + || $storage->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage') |
|
| 247 | + ) { |
|
| 248 | + /** @var \OC\Files\Storage\Home $storage */ |
|
| 249 | + if (is_object($storage->getUser())) { |
|
| 250 | + $user = $storage->getUser()->getUID(); |
|
| 251 | + $quota = OC_Util::getUserQuota($user); |
|
| 252 | + if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) { |
|
| 253 | + return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota, 'root' => 'files')); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + return $storage; |
|
| 259 | + }); |
|
| 260 | + |
|
| 261 | + OC_Hook::emit('OC_Filesystem', 'preSetup', array('user' => $user)); |
|
| 262 | + \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(true); |
|
| 263 | + |
|
| 264 | + //check if we are using an object storage |
|
| 265 | + $objectStore = \OC::$server->getSystemConfig()->getValue('objectstore', null); |
|
| 266 | + $objectStoreMultibucket = \OC::$server->getSystemConfig()->getValue('objectstore_multibucket', null); |
|
| 267 | + |
|
| 268 | + // use the same order as in ObjectHomeMountProvider |
|
| 269 | + if (isset($objectStoreMultibucket)) { |
|
| 270 | + self::initObjectStoreMultibucketRootFS($objectStoreMultibucket); |
|
| 271 | + } elseif (isset($objectStore)) { |
|
| 272 | + self::initObjectStoreRootFS($objectStore); |
|
| 273 | + } else { |
|
| 274 | + self::initLocalStorageRootFS(); |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + if ($user != '' && !\OC::$server->getUserManager()->userExists($user)) { |
|
| 278 | + \OC::$server->getEventLogger()->end('setup_fs'); |
|
| 279 | + return false; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + //if we aren't logged in, there is no use to set up the filesystem |
|
| 283 | + if ($user != "") { |
|
| 284 | + |
|
| 285 | + $userDir = '/' . $user . '/files'; |
|
| 286 | + |
|
| 287 | + //jail the user into his "home" directory |
|
| 288 | + \OC\Files\Filesystem::init($user, $userDir); |
|
| 289 | + |
|
| 290 | + OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $userDir)); |
|
| 291 | + } |
|
| 292 | + \OC::$server->getEventLogger()->end('setup_fs'); |
|
| 293 | + return true; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * check if a password is required for each public link |
|
| 298 | + * |
|
| 299 | + * @return boolean |
|
| 300 | + * @suppress PhanDeprecatedFunction |
|
| 301 | + */ |
|
| 302 | + public static function isPublicLinkPasswordRequired() { |
|
| 303 | + $enforcePassword = \OC::$server->getConfig()->getAppValue('core', 'shareapi_enforce_links_password', 'no'); |
|
| 304 | + return $enforcePassword === 'yes'; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + /** |
|
| 308 | + * check if sharing is disabled for the current user |
|
| 309 | + * @param IConfig $config |
|
| 310 | + * @param IGroupManager $groupManager |
|
| 311 | + * @param IUser|null $user |
|
| 312 | + * @return bool |
|
| 313 | + */ |
|
| 314 | + public static function isSharingDisabledForUser(IConfig $config, IGroupManager $groupManager, $user) { |
|
| 315 | + if ($config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes') { |
|
| 316 | + $groupsList = $config->getAppValue('core', 'shareapi_exclude_groups_list', ''); |
|
| 317 | + $excludedGroups = json_decode($groupsList); |
|
| 318 | + if (is_null($excludedGroups)) { |
|
| 319 | + $excludedGroups = explode(',', $groupsList); |
|
| 320 | + $newValue = json_encode($excludedGroups); |
|
| 321 | + $config->setAppValue('core', 'shareapi_exclude_groups_list', $newValue); |
|
| 322 | + } |
|
| 323 | + $usersGroups = $groupManager->getUserGroupIds($user); |
|
| 324 | + if (!empty($usersGroups)) { |
|
| 325 | + $remainingGroups = array_diff($usersGroups, $excludedGroups); |
|
| 326 | + // if the user is only in groups which are disabled for sharing then |
|
| 327 | + // sharing is also disabled for the user |
|
| 328 | + if (empty($remainingGroups)) { |
|
| 329 | + return true; |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + } |
|
| 333 | + return false; |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * check if share API enforces a default expire date |
|
| 338 | + * |
|
| 339 | + * @return boolean |
|
| 340 | + * @suppress PhanDeprecatedFunction |
|
| 341 | + */ |
|
| 342 | + public static function isDefaultExpireDateEnforced() { |
|
| 343 | + $isDefaultExpireDateEnabled = \OC::$server->getConfig()->getAppValue('core', 'shareapi_default_expire_date', 'no'); |
|
| 344 | + $enforceDefaultExpireDate = false; |
|
| 345 | + if ($isDefaultExpireDateEnabled === 'yes') { |
|
| 346 | + $value = \OC::$server->getConfig()->getAppValue('core', 'shareapi_enforce_expire_date', 'no'); |
|
| 347 | + $enforceDefaultExpireDate = $value === 'yes'; |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + return $enforceDefaultExpireDate; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * Get the quota of a user |
|
| 355 | + * |
|
| 356 | + * @param string $userId |
|
| 357 | + * @return float Quota bytes |
|
| 358 | + */ |
|
| 359 | + public static function getUserQuota($userId) { |
|
| 360 | + $user = \OC::$server->getUserManager()->get($userId); |
|
| 361 | + if (is_null($user)) { |
|
| 362 | + return \OCP\Files\FileInfo::SPACE_UNLIMITED; |
|
| 363 | + } |
|
| 364 | + $userQuota = $user->getQuota(); |
|
| 365 | + if($userQuota === 'none') { |
|
| 366 | + return \OCP\Files\FileInfo::SPACE_UNLIMITED; |
|
| 367 | + } |
|
| 368 | + return OC_Helper::computerFileSize($userQuota); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * copies the skeleton to the users /files |
|
| 373 | + * |
|
| 374 | + * @param String $userId |
|
| 375 | + * @param \OCP\Files\Folder $userDirectory |
|
| 376 | + * @throws \RuntimeException |
|
| 377 | + * @suppress PhanDeprecatedFunction |
|
| 378 | + */ |
|
| 379 | + public static function copySkeleton($userId, \OCP\Files\Folder $userDirectory) { |
|
| 380 | + |
|
| 381 | + $plainSkeletonDirectory = \OC::$server->getConfig()->getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton'); |
|
| 382 | + $userLang = \OC::$server->getL10NFactory()->findLanguage(); |
|
| 383 | + $skeletonDirectory = str_replace('{lang}', $userLang, $plainSkeletonDirectory); |
|
| 384 | + |
|
| 385 | + if (!file_exists($skeletonDirectory)) { |
|
| 386 | + $dialectStart = strpos($userLang, '_'); |
|
| 387 | + if ($dialectStart !== false) { |
|
| 388 | + $skeletonDirectory = str_replace('{lang}', substr($userLang, 0, $dialectStart), $plainSkeletonDirectory); |
|
| 389 | + } |
|
| 390 | + if ($dialectStart === false || !file_exists($skeletonDirectory)) { |
|
| 391 | + $skeletonDirectory = str_replace('{lang}', 'default', $plainSkeletonDirectory); |
|
| 392 | + } |
|
| 393 | + if (!file_exists($skeletonDirectory)) { |
|
| 394 | + $skeletonDirectory = ''; |
|
| 395 | + } |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + $instanceId = \OC::$server->getConfig()->getSystemValue('instanceid', ''); |
|
| 399 | + |
|
| 400 | + if ($instanceId === null) { |
|
| 401 | + throw new \RuntimeException('no instance id!'); |
|
| 402 | + } |
|
| 403 | + $appdata = 'appdata_' . $instanceId; |
|
| 404 | + if ($userId === $appdata) { |
|
| 405 | + throw new \RuntimeException('username is reserved name: ' . $appdata); |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + if (!empty($skeletonDirectory)) { |
|
| 409 | + \OCP\Util::writeLog( |
|
| 410 | + 'files_skeleton', |
|
| 411 | + 'copying skeleton for '.$userId.' from '.$skeletonDirectory.' to '.$userDirectory->getFullPath('/'), |
|
| 412 | + \OCP\Util::DEBUG |
|
| 413 | + ); |
|
| 414 | + self::copyr($skeletonDirectory, $userDirectory); |
|
| 415 | + // update the file cache |
|
| 416 | + $userDirectory->getStorage()->getScanner()->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE); |
|
| 417 | + } |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * copies a directory recursively by using streams |
|
| 422 | + * |
|
| 423 | + * @param string $source |
|
| 424 | + * @param \OCP\Files\Folder $target |
|
| 425 | + * @return void |
|
| 426 | + */ |
|
| 427 | + public static function copyr($source, \OCP\Files\Folder $target) { |
|
| 428 | + $logger = \OC::$server->getLogger(); |
|
| 429 | + |
|
| 430 | + // Verify if folder exists |
|
| 431 | + $dir = opendir($source); |
|
| 432 | + if($dir === false) { |
|
| 433 | + $logger->error(sprintf('Could not opendir "%s"', $source), ['app' => 'core']); |
|
| 434 | + return; |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + // Copy the files |
|
| 438 | + while (false !== ($file = readdir($dir))) { |
|
| 439 | + if (!\OC\Files\Filesystem::isIgnoredDir($file)) { |
|
| 440 | + if (is_dir($source . '/' . $file)) { |
|
| 441 | + $child = $target->newFolder($file); |
|
| 442 | + self::copyr($source . '/' . $file, $child); |
|
| 443 | + } else { |
|
| 444 | + $child = $target->newFile($file); |
|
| 445 | + $sourceStream = fopen($source . '/' . $file, 'r'); |
|
| 446 | + if($sourceStream === false) { |
|
| 447 | + $logger->error(sprintf('Could not fopen "%s"', $source . '/' . $file), ['app' => 'core']); |
|
| 448 | + closedir($dir); |
|
| 449 | + return; |
|
| 450 | + } |
|
| 451 | + stream_copy_to_stream($sourceStream, $child->fopen('w')); |
|
| 452 | + } |
|
| 453 | + } |
|
| 454 | + } |
|
| 455 | + closedir($dir); |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + /** |
|
| 459 | + * @return void |
|
| 460 | + * @suppress PhanUndeclaredMethod |
|
| 461 | + */ |
|
| 462 | + public static function tearDownFS() { |
|
| 463 | + \OC\Files\Filesystem::tearDown(); |
|
| 464 | + \OC::$server->getRootFolder()->clearCache(); |
|
| 465 | + self::$fsSetup = false; |
|
| 466 | + self::$rootMounted = false; |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + /** |
|
| 470 | + * get the current installed version of ownCloud |
|
| 471 | + * |
|
| 472 | + * @return array |
|
| 473 | + */ |
|
| 474 | + public static function getVersion() { |
|
| 475 | + OC_Util::loadVersion(); |
|
| 476 | + return self::$versionCache['OC_Version']; |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + /** |
|
| 480 | + * get the current installed version string of ownCloud |
|
| 481 | + * |
|
| 482 | + * @return string |
|
| 483 | + */ |
|
| 484 | + public static function getVersionString() { |
|
| 485 | + OC_Util::loadVersion(); |
|
| 486 | + return self::$versionCache['OC_VersionString']; |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + /** |
|
| 490 | + * @deprecated the value is of no use anymore |
|
| 491 | + * @return string |
|
| 492 | + */ |
|
| 493 | + public static function getEditionString() { |
|
| 494 | + return ''; |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + /** |
|
| 498 | + * @description get the update channel of the current installed of ownCloud. |
|
| 499 | + * @return string |
|
| 500 | + */ |
|
| 501 | + public static function getChannel() { |
|
| 502 | + OC_Util::loadVersion(); |
|
| 503 | + return \OC::$server->getConfig()->getSystemValue('updater.release.channel', self::$versionCache['OC_Channel']); |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + /** |
|
| 507 | + * @description get the build number of the current installed of ownCloud. |
|
| 508 | + * @return string |
|
| 509 | + */ |
|
| 510 | + public static function getBuild() { |
|
| 511 | + OC_Util::loadVersion(); |
|
| 512 | + return self::$versionCache['OC_Build']; |
|
| 513 | + } |
|
| 514 | + |
|
| 515 | + /** |
|
| 516 | + * @description load the version.php into the session as cache |
|
| 517 | + * @suppress PhanUndeclaredVariable |
|
| 518 | + */ |
|
| 519 | + private static function loadVersion() { |
|
| 520 | + if (self::$versionCache !== null) { |
|
| 521 | + return; |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + $timestamp = filemtime(OC::$SERVERROOT . '/version.php'); |
|
| 525 | + require OC::$SERVERROOT . '/version.php'; |
|
| 526 | + /** @var $timestamp int */ |
|
| 527 | + self::$versionCache['OC_Version_Timestamp'] = $timestamp; |
|
| 528 | + /** @var $OC_Version string */ |
|
| 529 | + self::$versionCache['OC_Version'] = $OC_Version; |
|
| 530 | + /** @var $OC_VersionString string */ |
|
| 531 | + self::$versionCache['OC_VersionString'] = $OC_VersionString; |
|
| 532 | + /** @var $OC_Build string */ |
|
| 533 | + self::$versionCache['OC_Build'] = $OC_Build; |
|
| 534 | + |
|
| 535 | + /** @var $OC_Channel string */ |
|
| 536 | + self::$versionCache['OC_Channel'] = $OC_Channel; |
|
| 537 | + } |
|
| 538 | + |
|
| 539 | + /** |
|
| 540 | + * generates a path for JS/CSS files. If no application is provided it will create the path for core. |
|
| 541 | + * |
|
| 542 | + * @param string $application application to get the files from |
|
| 543 | + * @param string $directory directory within this application (css, js, vendor, etc) |
|
| 544 | + * @param string $file the file inside of the above folder |
|
| 545 | + * @return string the path |
|
| 546 | + */ |
|
| 547 | + private static function generatePath($application, $directory, $file) { |
|
| 548 | + if (is_null($file)) { |
|
| 549 | + $file = $application; |
|
| 550 | + $application = ""; |
|
| 551 | + } |
|
| 552 | + if (!empty($application)) { |
|
| 553 | + return "$application/$directory/$file"; |
|
| 554 | + } else { |
|
| 555 | + return "$directory/$file"; |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * add a javascript file |
|
| 561 | + * |
|
| 562 | + * @param string $application application id |
|
| 563 | + * @param string|null $file filename |
|
| 564 | + * @param bool $prepend prepend the Script to the beginning of the list |
|
| 565 | + * @return void |
|
| 566 | + */ |
|
| 567 | + public static function addScript($application, $file = null, $prepend = false) { |
|
| 568 | + $path = OC_Util::generatePath($application, 'js', $file); |
|
| 569 | + |
|
| 570 | + // core js files need separate handling |
|
| 571 | + if ($application !== 'core' && $file !== null) { |
|
| 572 | + self::addTranslations ( $application ); |
|
| 573 | + } |
|
| 574 | + self::addExternalResource($application, $prepend, $path, "script"); |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + /** |
|
| 578 | + * add a javascript file from the vendor sub folder |
|
| 579 | + * |
|
| 580 | + * @param string $application application id |
|
| 581 | + * @param string|null $file filename |
|
| 582 | + * @param bool $prepend prepend the Script to the beginning of the list |
|
| 583 | + * @return void |
|
| 584 | + */ |
|
| 585 | + public static function addVendorScript($application, $file = null, $prepend = false) { |
|
| 586 | + $path = OC_Util::generatePath($application, 'vendor', $file); |
|
| 587 | + self::addExternalResource($application, $prepend, $path, "script"); |
|
| 588 | + } |
|
| 589 | + |
|
| 590 | + /** |
|
| 591 | + * add a translation JS file |
|
| 592 | + * |
|
| 593 | + * @param string $application application id |
|
| 594 | + * @param string|null $languageCode language code, defaults to the current language |
|
| 595 | + * @param bool|null $prepend prepend the Script to the beginning of the list |
|
| 596 | + */ |
|
| 597 | + public static function addTranslations($application, $languageCode = null, $prepend = false) { |
|
| 598 | + if (is_null($languageCode)) { |
|
| 599 | + $languageCode = \OC::$server->getL10NFactory()->findLanguage($application); |
|
| 600 | + } |
|
| 601 | + if (!empty($application)) { |
|
| 602 | + $path = "$application/l10n/$languageCode"; |
|
| 603 | + } else { |
|
| 604 | + $path = "l10n/$languageCode"; |
|
| 605 | + } |
|
| 606 | + self::addExternalResource($application, $prepend, $path, "script"); |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * add a css file |
|
| 611 | + * |
|
| 612 | + * @param string $application application id |
|
| 613 | + * @param string|null $file filename |
|
| 614 | + * @param bool $prepend prepend the Style to the beginning of the list |
|
| 615 | + * @return void |
|
| 616 | + */ |
|
| 617 | + public static function addStyle($application, $file = null, $prepend = false) { |
|
| 618 | + $path = OC_Util::generatePath($application, 'css', $file); |
|
| 619 | + self::addExternalResource($application, $prepend, $path, "style"); |
|
| 620 | + } |
|
| 621 | + |
|
| 622 | + /** |
|
| 623 | + * add a css file from the vendor sub folder |
|
| 624 | + * |
|
| 625 | + * @param string $application application id |
|
| 626 | + * @param string|null $file filename |
|
| 627 | + * @param bool $prepend prepend the Style to the beginning of the list |
|
| 628 | + * @return void |
|
| 629 | + */ |
|
| 630 | + public static function addVendorStyle($application, $file = null, $prepend = false) { |
|
| 631 | + $path = OC_Util::generatePath($application, 'vendor', $file); |
|
| 632 | + self::addExternalResource($application, $prepend, $path, "style"); |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + /** |
|
| 636 | + * add an external resource css/js file |
|
| 637 | + * |
|
| 638 | + * @param string $application application id |
|
| 639 | + * @param bool $prepend prepend the file to the beginning of the list |
|
| 640 | + * @param string $path |
|
| 641 | + * @param string $type (script or style) |
|
| 642 | + * @return void |
|
| 643 | + */ |
|
| 644 | + private static function addExternalResource($application, $prepend, $path, $type = "script") { |
|
| 645 | + |
|
| 646 | + if ($type === "style") { |
|
| 647 | + if (!in_array($path, self::$styles)) { |
|
| 648 | + if ($prepend === true) { |
|
| 649 | + array_unshift ( self::$styles, $path ); |
|
| 650 | + } else { |
|
| 651 | + self::$styles[] = $path; |
|
| 652 | + } |
|
| 653 | + } |
|
| 654 | + } elseif ($type === "script") { |
|
| 655 | + if (!in_array($path, self::$scripts)) { |
|
| 656 | + if ($prepend === true) { |
|
| 657 | + array_unshift ( self::$scripts, $path ); |
|
| 658 | + } else { |
|
| 659 | + self::$scripts [] = $path; |
|
| 660 | + } |
|
| 661 | + } |
|
| 662 | + } |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + /** |
|
| 666 | + * Add a custom element to the header |
|
| 667 | + * If $text is null then the element will be written as empty element. |
|
| 668 | + * So use "" to get a closing tag. |
|
| 669 | + * @param string $tag tag name of the element |
|
| 670 | + * @param array $attributes array of attributes for the element |
|
| 671 | + * @param string $text the text content for the element |
|
| 672 | + */ |
|
| 673 | + public static function addHeader($tag, $attributes, $text=null) { |
|
| 674 | + self::$headers[] = array( |
|
| 675 | + 'tag' => $tag, |
|
| 676 | + 'attributes' => $attributes, |
|
| 677 | + 'text' => $text |
|
| 678 | + ); |
|
| 679 | + } |
|
| 680 | + |
|
| 681 | + /** |
|
| 682 | + * check if the current server configuration is suitable for ownCloud |
|
| 683 | + * |
|
| 684 | + * @param \OC\SystemConfig $config |
|
| 685 | + * @return array arrays with error messages and hints |
|
| 686 | + */ |
|
| 687 | + public static function checkServer(\OC\SystemConfig $config) { |
|
| 688 | + $l = \OC::$server->getL10N('lib'); |
|
| 689 | + $errors = array(); |
|
| 690 | + $CONFIG_DATADIRECTORY = $config->getValue('datadirectory', OC::$SERVERROOT . '/data'); |
|
| 691 | + |
|
| 692 | + if (!self::needUpgrade($config) && $config->getValue('installed', false)) { |
|
| 693 | + // this check needs to be done every time |
|
| 694 | + $errors = self::checkDataDirectoryValidity($CONFIG_DATADIRECTORY); |
|
| 695 | + } |
|
| 696 | + |
|
| 697 | + // Assume that if checkServer() succeeded before in this session, then all is fine. |
|
| 698 | + if (\OC::$server->getSession()->exists('checkServer_succeeded') && \OC::$server->getSession()->get('checkServer_succeeded')) { |
|
| 699 | + return $errors; |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + $webServerRestart = false; |
|
| 703 | + $setup = new \OC\Setup( |
|
| 704 | + $config, |
|
| 705 | + \OC::$server->getIniWrapper(), |
|
| 706 | + \OC::$server->getL10N('lib'), |
|
| 707 | + \OC::$server->query(\OCP\Defaults::class), |
|
| 708 | + \OC::$server->getLogger(), |
|
| 709 | + \OC::$server->getSecureRandom(), |
|
| 710 | + \OC::$server->query(\OC\Installer::class) |
|
| 711 | + ); |
|
| 712 | + |
|
| 713 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 714 | + |
|
| 715 | + $availableDatabases = $setup->getSupportedDatabases(); |
|
| 716 | + if (empty($availableDatabases)) { |
|
| 717 | + $errors[] = array( |
|
| 718 | + 'error' => $l->t('No database drivers (sqlite, mysql, or postgresql) installed.'), |
|
| 719 | + 'hint' => '' //TODO: sane hint |
|
| 720 | + ); |
|
| 721 | + $webServerRestart = true; |
|
| 722 | + } |
|
| 723 | + |
|
| 724 | + // Check if config folder is writable. |
|
| 725 | + if(!OC_Helper::isReadOnlyConfigEnabled()) { |
|
| 726 | + if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) { |
|
| 727 | + $errors[] = array( |
|
| 728 | + 'error' => $l->t('Cannot write into "config" directory'), |
|
| 729 | + 'hint' => $l->t('This can usually be fixed by giving the webserver write access to the config directory. See %s', |
|
| 730 | + [$urlGenerator->linkToDocs('admin-dir_permissions')]) |
|
| 731 | + ); |
|
| 732 | + } |
|
| 733 | + } |
|
| 734 | + |
|
| 735 | + // Check if there is a writable install folder. |
|
| 736 | + if ($config->getValue('appstoreenabled', true)) { |
|
| 737 | + if (OC_App::getInstallPath() === null |
|
| 738 | + || !is_writable(OC_App::getInstallPath()) |
|
| 739 | + || !is_readable(OC_App::getInstallPath()) |
|
| 740 | + ) { |
|
| 741 | + $errors[] = array( |
|
| 742 | + 'error' => $l->t('Cannot write into "apps" directory'), |
|
| 743 | + 'hint' => $l->t('This can usually be fixed by giving the webserver write access to the apps directory' |
|
| 744 | + . ' or disabling the appstore in the config file. See %s', |
|
| 745 | + [$urlGenerator->linkToDocs('admin-dir_permissions')]) |
|
| 746 | + ); |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | + // Create root dir. |
|
| 750 | + if ($config->getValue('installed', false)) { |
|
| 751 | + if (!is_dir($CONFIG_DATADIRECTORY)) { |
|
| 752 | + $success = @mkdir($CONFIG_DATADIRECTORY); |
|
| 753 | + if ($success) { |
|
| 754 | + $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); |
|
| 755 | + } else { |
|
| 756 | + $errors[] = [ |
|
| 757 | + 'error' => $l->t('Cannot create "data" directory'), |
|
| 758 | + 'hint' => $l->t('This can usually be fixed by giving the webserver write access to the root directory. See %s', |
|
| 759 | + [$urlGenerator->linkToDocs('admin-dir_permissions')]) |
|
| 760 | + ]; |
|
| 761 | + } |
|
| 762 | + } else if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { |
|
| 763 | + //common hint for all file permissions error messages |
|
| 764 | + $permissionsHint = $l->t('Permissions can usually be fixed by giving the webserver write access to the root directory. See %s.', |
|
| 765 | + [$urlGenerator->linkToDocs('admin-dir_permissions')]); |
|
| 766 | + $errors[] = [ |
|
| 767 | + 'error' => 'Your data directory is not writable', |
|
| 768 | + 'hint' => $permissionsHint |
|
| 769 | + ]; |
|
| 770 | + } else { |
|
| 771 | + $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + if (!OC_Util::isSetLocaleWorking()) { |
|
| 776 | + $errors[] = array( |
|
| 777 | + 'error' => $l->t('Setting locale to %s failed', |
|
| 778 | + array('en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/' |
|
| 779 | + . 'pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8')), |
|
| 780 | + 'hint' => $l->t('Please install one of these locales on your system and restart your webserver.') |
|
| 781 | + ); |
|
| 782 | + } |
|
| 783 | + |
|
| 784 | + // Contains the dependencies that should be checked against |
|
| 785 | + // classes = class_exists |
|
| 786 | + // functions = function_exists |
|
| 787 | + // defined = defined |
|
| 788 | + // ini = ini_get |
|
| 789 | + // If the dependency is not found the missing module name is shown to the EndUser |
|
| 790 | + // When adding new checks always verify that they pass on Travis as well |
|
| 791 | + // for ini settings, see https://github.com/owncloud/administration/blob/master/travis-ci/custom.ini |
|
| 792 | + $dependencies = array( |
|
| 793 | + 'classes' => array( |
|
| 794 | + 'ZipArchive' => 'zip', |
|
| 795 | + 'DOMDocument' => 'dom', |
|
| 796 | + 'XMLWriter' => 'XMLWriter', |
|
| 797 | + 'XMLReader' => 'XMLReader', |
|
| 798 | + ), |
|
| 799 | + 'functions' => [ |
|
| 800 | + 'xml_parser_create' => 'libxml', |
|
| 801 | + 'mb_strcut' => 'mb multibyte', |
|
| 802 | + 'ctype_digit' => 'ctype', |
|
| 803 | + 'json_encode' => 'JSON', |
|
| 804 | + 'gd_info' => 'GD', |
|
| 805 | + 'gzencode' => 'zlib', |
|
| 806 | + 'iconv' => 'iconv', |
|
| 807 | + 'simplexml_load_string' => 'SimpleXML', |
|
| 808 | + 'hash' => 'HASH Message Digest Framework', |
|
| 809 | + 'curl_init' => 'cURL', |
|
| 810 | + 'openssl_verify' => 'OpenSSL', |
|
| 811 | + ], |
|
| 812 | + 'defined' => array( |
|
| 813 | + 'PDO::ATTR_DRIVER_NAME' => 'PDO' |
|
| 814 | + ), |
|
| 815 | + 'ini' => [ |
|
| 816 | + 'default_charset' => 'UTF-8', |
|
| 817 | + ], |
|
| 818 | + ); |
|
| 819 | + $missingDependencies = array(); |
|
| 820 | + $invalidIniSettings = []; |
|
| 821 | + $moduleHint = $l->t('Please ask your server administrator to install the module.'); |
|
| 822 | + |
|
| 823 | + /** |
|
| 824 | + * FIXME: The dependency check does not work properly on HHVM on the moment |
|
| 825 | + * and prevents installation. Once HHVM is more compatible with our |
|
| 826 | + * approach to check for these values we should re-enable those |
|
| 827 | + * checks. |
|
| 828 | + */ |
|
| 829 | + $iniWrapper = \OC::$server->getIniWrapper(); |
|
| 830 | + if (!self::runningOnHhvm()) { |
|
| 831 | + foreach ($dependencies['classes'] as $class => $module) { |
|
| 832 | + if (!class_exists($class)) { |
|
| 833 | + $missingDependencies[] = $module; |
|
| 834 | + } |
|
| 835 | + } |
|
| 836 | + foreach ($dependencies['functions'] as $function => $module) { |
|
| 837 | + if (!function_exists($function)) { |
|
| 838 | + $missingDependencies[] = $module; |
|
| 839 | + } |
|
| 840 | + } |
|
| 841 | + foreach ($dependencies['defined'] as $defined => $module) { |
|
| 842 | + if (!defined($defined)) { |
|
| 843 | + $missingDependencies[] = $module; |
|
| 844 | + } |
|
| 845 | + } |
|
| 846 | + foreach ($dependencies['ini'] as $setting => $expected) { |
|
| 847 | + if (is_bool($expected)) { |
|
| 848 | + if ($iniWrapper->getBool($setting) !== $expected) { |
|
| 849 | + $invalidIniSettings[] = [$setting, $expected]; |
|
| 850 | + } |
|
| 851 | + } |
|
| 852 | + if (is_int($expected)) { |
|
| 853 | + if ($iniWrapper->getNumeric($setting) !== $expected) { |
|
| 854 | + $invalidIniSettings[] = [$setting, $expected]; |
|
| 855 | + } |
|
| 856 | + } |
|
| 857 | + if (is_string($expected)) { |
|
| 858 | + if (strtolower($iniWrapper->getString($setting)) !== strtolower($expected)) { |
|
| 859 | + $invalidIniSettings[] = [$setting, $expected]; |
|
| 860 | + } |
|
| 861 | + } |
|
| 862 | + } |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + foreach($missingDependencies as $missingDependency) { |
|
| 866 | + $errors[] = array( |
|
| 867 | + 'error' => $l->t('PHP module %s not installed.', array($missingDependency)), |
|
| 868 | + 'hint' => $moduleHint |
|
| 869 | + ); |
|
| 870 | + $webServerRestart = true; |
|
| 871 | + } |
|
| 872 | + foreach($invalidIniSettings as $setting) { |
|
| 873 | + if(is_bool($setting[1])) { |
|
| 874 | + $setting[1] = $setting[1] ? 'on' : 'off'; |
|
| 875 | + } |
|
| 876 | + $errors[] = [ |
|
| 877 | + 'error' => $l->t('PHP setting "%s" is not set to "%s".', [$setting[0], var_export($setting[1], true)]), |
|
| 878 | + 'hint' => $l->t('Adjusting this setting in php.ini will make Nextcloud run again') |
|
| 879 | + ]; |
|
| 880 | + $webServerRestart = true; |
|
| 881 | + } |
|
| 882 | + |
|
| 883 | + /** |
|
| 884 | + * The mbstring.func_overload check can only be performed if the mbstring |
|
| 885 | + * module is installed as it will return null if the checking setting is |
|
| 886 | + * not available and thus a check on the boolean value fails. |
|
| 887 | + * |
|
| 888 | + * TODO: Should probably be implemented in the above generic dependency |
|
| 889 | + * check somehow in the long-term. |
|
| 890 | + */ |
|
| 891 | + if($iniWrapper->getBool('mbstring.func_overload') !== null && |
|
| 892 | + $iniWrapper->getBool('mbstring.func_overload') === true) { |
|
| 893 | + $errors[] = array( |
|
| 894 | + 'error' => $l->t('mbstring.func_overload is set to "%s" instead of the expected value "0"', [$iniWrapper->getString('mbstring.func_overload')]), |
|
| 895 | + 'hint' => $l->t('To fix this issue set <code>mbstring.func_overload</code> to <code>0</code> in your php.ini') |
|
| 896 | + ); |
|
| 897 | + } |
|
| 898 | + |
|
| 899 | + if(function_exists('xml_parser_create') && |
|
| 900 | + LIBXML_LOADED_VERSION < 20700 ) { |
|
| 901 | + $version = LIBXML_LOADED_VERSION; |
|
| 902 | + $major = floor($version/10000); |
|
| 903 | + $version -= ($major * 10000); |
|
| 904 | + $minor = floor($version/100); |
|
| 905 | + $version -= ($minor * 100); |
|
| 906 | + $patch = $version; |
|
| 907 | + $errors[] = array( |
|
| 908 | + 'error' => $l->t('libxml2 2.7.0 is at least required. Currently %s is installed.', [$major . '.' . $minor . '.' . $patch]), |
|
| 909 | + 'hint' => $l->t('To fix this issue update your libxml2 version and restart your web server.') |
|
| 910 | + ); |
|
| 911 | + } |
|
| 912 | + |
|
| 913 | + if (!self::isAnnotationsWorking()) { |
|
| 914 | + $errors[] = array( |
|
| 915 | + 'error' => $l->t('PHP is apparently set up to strip inline doc blocks. This will make several core apps inaccessible.'), |
|
| 916 | + 'hint' => $l->t('This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator.') |
|
| 917 | + ); |
|
| 918 | + } |
|
| 919 | + |
|
| 920 | + if (!\OC::$CLI && $webServerRestart) { |
|
| 921 | + $errors[] = array( |
|
| 922 | + 'error' => $l->t('PHP modules have been installed, but they are still listed as missing?'), |
|
| 923 | + 'hint' => $l->t('Please ask your server administrator to restart the web server.') |
|
| 924 | + ); |
|
| 925 | + } |
|
| 926 | + |
|
| 927 | + $errors = array_merge($errors, self::checkDatabaseVersion()); |
|
| 928 | + |
|
| 929 | + // Cache the result of this function |
|
| 930 | + \OC::$server->getSession()->set('checkServer_succeeded', count($errors) == 0); |
|
| 931 | + |
|
| 932 | + return $errors; |
|
| 933 | + } |
|
| 934 | + |
|
| 935 | + /** |
|
| 936 | + * Check the database version |
|
| 937 | + * |
|
| 938 | + * @return array errors array |
|
| 939 | + */ |
|
| 940 | + public static function checkDatabaseVersion() { |
|
| 941 | + $l = \OC::$server->getL10N('lib'); |
|
| 942 | + $errors = array(); |
|
| 943 | + $dbType = \OC::$server->getSystemConfig()->getValue('dbtype', 'sqlite'); |
|
| 944 | + if ($dbType === 'pgsql') { |
|
| 945 | + // check PostgreSQL version |
|
| 946 | + try { |
|
| 947 | + $result = \OC_DB::executeAudited('SHOW SERVER_VERSION'); |
|
| 948 | + $data = $result->fetchRow(); |
|
| 949 | + if (isset($data['server_version'])) { |
|
| 950 | + $version = $data['server_version']; |
|
| 951 | + if (version_compare($version, '9.0.0', '<')) { |
|
| 952 | + $errors[] = array( |
|
| 953 | + 'error' => $l->t('PostgreSQL >= 9 required'), |
|
| 954 | + 'hint' => $l->t('Please upgrade your database version') |
|
| 955 | + ); |
|
| 956 | + } |
|
| 957 | + } |
|
| 958 | + } catch (\Doctrine\DBAL\DBALException $e) { |
|
| 959 | + $logger = \OC::$server->getLogger(); |
|
| 960 | + $logger->warning('Error occurred while checking PostgreSQL version, assuming >= 9'); |
|
| 961 | + $logger->logException($e); |
|
| 962 | + } |
|
| 963 | + } |
|
| 964 | + return $errors; |
|
| 965 | + } |
|
| 966 | + |
|
| 967 | + /** |
|
| 968 | + * Check for correct file permissions of data directory |
|
| 969 | + * |
|
| 970 | + * @param string $dataDirectory |
|
| 971 | + * @return array arrays with error messages and hints |
|
| 972 | + */ |
|
| 973 | + public static function checkDataDirectoryPermissions($dataDirectory) { |
|
| 974 | + if(\OC::$server->getConfig()->getSystemValue('check_data_directory_permissions', true) === false) { |
|
| 975 | + return []; |
|
| 976 | + } |
|
| 977 | + $l = \OC::$server->getL10N('lib'); |
|
| 978 | + $errors = []; |
|
| 979 | + $permissionsModHint = $l->t('Please change the permissions to 0770 so that the directory' |
|
| 980 | + . ' cannot be listed by other users.'); |
|
| 981 | + $perms = substr(decoct(@fileperms($dataDirectory)), -3); |
|
| 982 | + if (substr($perms, -1) !== '0') { |
|
| 983 | + chmod($dataDirectory, 0770); |
|
| 984 | + clearstatcache(); |
|
| 985 | + $perms = substr(decoct(@fileperms($dataDirectory)), -3); |
|
| 986 | + if ($perms[2] !== '0') { |
|
| 987 | + $errors[] = [ |
|
| 988 | + 'error' => $l->t('Your data directory is readable by other users'), |
|
| 989 | + 'hint' => $permissionsModHint |
|
| 990 | + ]; |
|
| 991 | + } |
|
| 992 | + } |
|
| 993 | + return $errors; |
|
| 994 | + } |
|
| 995 | + |
|
| 996 | + /** |
|
| 997 | + * Check that the data directory exists and is valid by |
|
| 998 | + * checking the existence of the ".ocdata" file. |
|
| 999 | + * |
|
| 1000 | + * @param string $dataDirectory data directory path |
|
| 1001 | + * @return array errors found |
|
| 1002 | + */ |
|
| 1003 | + public static function checkDataDirectoryValidity($dataDirectory) { |
|
| 1004 | + $l = \OC::$server->getL10N('lib'); |
|
| 1005 | + $errors = []; |
|
| 1006 | + if ($dataDirectory[0] !== '/') { |
|
| 1007 | + $errors[] = [ |
|
| 1008 | + 'error' => $l->t('Your data directory must be an absolute path'), |
|
| 1009 | + 'hint' => $l->t('Check the value of "datadirectory" in your configuration') |
|
| 1010 | + ]; |
|
| 1011 | + } |
|
| 1012 | + if (!file_exists($dataDirectory . '/.ocdata')) { |
|
| 1013 | + $errors[] = [ |
|
| 1014 | + 'error' => $l->t('Your data directory is invalid'), |
|
| 1015 | + 'hint' => $l->t('Ensure there is a file called ".ocdata"' . |
|
| 1016 | + ' in the root of the data directory.') |
|
| 1017 | + ]; |
|
| 1018 | + } |
|
| 1019 | + return $errors; |
|
| 1020 | + } |
|
| 1021 | + |
|
| 1022 | + /** |
|
| 1023 | + * Check if the user is logged in, redirects to home if not. With |
|
| 1024 | + * redirect URL parameter to the request URI. |
|
| 1025 | + * |
|
| 1026 | + * @return void |
|
| 1027 | + */ |
|
| 1028 | + public static function checkLoggedIn() { |
|
| 1029 | + // Check if we are a user |
|
| 1030 | + if (!\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 1031 | + header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute( |
|
| 1032 | + 'core.login.showLoginForm', |
|
| 1033 | + [ |
|
| 1034 | + 'redirect_url' => \OC::$server->getRequest()->getRequestUri(), |
|
| 1035 | + ] |
|
| 1036 | + ) |
|
| 1037 | + ); |
|
| 1038 | + exit(); |
|
| 1039 | + } |
|
| 1040 | + // Redirect to 2FA challenge selection if 2FA challenge was not solved yet |
|
| 1041 | + if (\OC::$server->getTwoFactorAuthManager()->needsSecondFactor(\OC::$server->getUserSession()->getUser())) { |
|
| 1042 | + header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.selectChallenge')); |
|
| 1043 | + exit(); |
|
| 1044 | + } |
|
| 1045 | + } |
|
| 1046 | + |
|
| 1047 | + /** |
|
| 1048 | + * Check if the user is a admin, redirects to home if not |
|
| 1049 | + * |
|
| 1050 | + * @return void |
|
| 1051 | + */ |
|
| 1052 | + public static function checkAdminUser() { |
|
| 1053 | + OC_Util::checkLoggedIn(); |
|
| 1054 | + if (!OC_User::isAdminUser(OC_User::getUser())) { |
|
| 1055 | + header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php')); |
|
| 1056 | + exit(); |
|
| 1057 | + } |
|
| 1058 | + } |
|
| 1059 | + |
|
| 1060 | + /** |
|
| 1061 | + * Check if the user is a subadmin, redirects to home if not |
|
| 1062 | + * |
|
| 1063 | + * @return null|boolean $groups where the current user is subadmin |
|
| 1064 | + */ |
|
| 1065 | + public static function checkSubAdminUser() { |
|
| 1066 | + OC_Util::checkLoggedIn(); |
|
| 1067 | + $userObject = \OC::$server->getUserSession()->getUser(); |
|
| 1068 | + $isSubAdmin = false; |
|
| 1069 | + if($userObject !== null) { |
|
| 1070 | + $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
|
| 1071 | + } |
|
| 1072 | + |
|
| 1073 | + if (!$isSubAdmin) { |
|
| 1074 | + header('Location: ' . \OCP\Util::linkToAbsolute('', 'index.php')); |
|
| 1075 | + exit(); |
|
| 1076 | + } |
|
| 1077 | + return true; |
|
| 1078 | + } |
|
| 1079 | + |
|
| 1080 | + /** |
|
| 1081 | + * Returns the URL of the default page |
|
| 1082 | + * based on the system configuration and |
|
| 1083 | + * the apps visible for the current user |
|
| 1084 | + * |
|
| 1085 | + * @return string URL |
|
| 1086 | + * @suppress PhanDeprecatedFunction |
|
| 1087 | + */ |
|
| 1088 | + public static function getDefaultPageUrl() { |
|
| 1089 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 1090 | + // Deny the redirect if the URL contains a @ |
|
| 1091 | + // This prevents unvalidated redirects like ?redirect_url=:[email protected] |
|
| 1092 | + if (isset($_REQUEST['redirect_url']) && strpos($_REQUEST['redirect_url'], '@') === false) { |
|
| 1093 | + $location = $urlGenerator->getAbsoluteURL(urldecode($_REQUEST['redirect_url'])); |
|
| 1094 | + } else { |
|
| 1095 | + $defaultPage = \OC::$server->getConfig()->getAppValue('core', 'defaultpage'); |
|
| 1096 | + if ($defaultPage) { |
|
| 1097 | + $location = $urlGenerator->getAbsoluteURL($defaultPage); |
|
| 1098 | + } else { |
|
| 1099 | + $appId = 'files'; |
|
| 1100 | + $config = \OC::$server->getConfig(); |
|
| 1101 | + $defaultApps = explode(',', $config->getSystemValue('defaultapp', 'files')); |
|
| 1102 | + // find the first app that is enabled for the current user |
|
| 1103 | + foreach ($defaultApps as $defaultApp) { |
|
| 1104 | + $defaultApp = OC_App::cleanAppId(strip_tags($defaultApp)); |
|
| 1105 | + if (static::getAppManager()->isEnabledForUser($defaultApp)) { |
|
| 1106 | + $appId = $defaultApp; |
|
| 1107 | + break; |
|
| 1108 | + } |
|
| 1109 | + } |
|
| 1110 | + |
|
| 1111 | + if($config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true') { |
|
| 1112 | + $location = $urlGenerator->getAbsoluteURL('/apps/' . $appId . '/'); |
|
| 1113 | + } else { |
|
| 1114 | + $location = $urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/'); |
|
| 1115 | + } |
|
| 1116 | + } |
|
| 1117 | + } |
|
| 1118 | + return $location; |
|
| 1119 | + } |
|
| 1120 | + |
|
| 1121 | + /** |
|
| 1122 | + * Redirect to the user default page |
|
| 1123 | + * |
|
| 1124 | + * @return void |
|
| 1125 | + */ |
|
| 1126 | + public static function redirectToDefaultPage() { |
|
| 1127 | + $location = self::getDefaultPageUrl(); |
|
| 1128 | + header('Location: ' . $location); |
|
| 1129 | + exit(); |
|
| 1130 | + } |
|
| 1131 | + |
|
| 1132 | + /** |
|
| 1133 | + * get an id unique for this instance |
|
| 1134 | + * |
|
| 1135 | + * @return string |
|
| 1136 | + */ |
|
| 1137 | + public static function getInstanceId() { |
|
| 1138 | + $id = \OC::$server->getSystemConfig()->getValue('instanceid', null); |
|
| 1139 | + if (is_null($id)) { |
|
| 1140 | + // We need to guarantee at least one letter in instanceid so it can be used as the session_name |
|
| 1141 | + $id = 'oc' . \OC::$server->getSecureRandom()->generate(10, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); |
|
| 1142 | + \OC::$server->getSystemConfig()->setValue('instanceid', $id); |
|
| 1143 | + } |
|
| 1144 | + return $id; |
|
| 1145 | + } |
|
| 1146 | + |
|
| 1147 | + /** |
|
| 1148 | + * Public function to sanitize HTML |
|
| 1149 | + * |
|
| 1150 | + * This function is used to sanitize HTML and should be applied on any |
|
| 1151 | + * string or array of strings before displaying it on a web page. |
|
| 1152 | + * |
|
| 1153 | + * @param string|array $value |
|
| 1154 | + * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter. |
|
| 1155 | + */ |
|
| 1156 | + public static function sanitizeHTML($value) { |
|
| 1157 | + if (is_array($value)) { |
|
| 1158 | + $value = array_map(function($value) { |
|
| 1159 | + return self::sanitizeHTML($value); |
|
| 1160 | + }, $value); |
|
| 1161 | + } else { |
|
| 1162 | + // Specify encoding for PHP<5.4 |
|
| 1163 | + $value = htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8'); |
|
| 1164 | + } |
|
| 1165 | + return $value; |
|
| 1166 | + } |
|
| 1167 | + |
|
| 1168 | + /** |
|
| 1169 | + * Public function to encode url parameters |
|
| 1170 | + * |
|
| 1171 | + * This function is used to encode path to file before output. |
|
| 1172 | + * Encoding is done according to RFC 3986 with one exception: |
|
| 1173 | + * Character '/' is preserved as is. |
|
| 1174 | + * |
|
| 1175 | + * @param string $component part of URI to encode |
|
| 1176 | + * @return string |
|
| 1177 | + */ |
|
| 1178 | + public static function encodePath($component) { |
|
| 1179 | + $encoded = rawurlencode($component); |
|
| 1180 | + $encoded = str_replace('%2F', '/', $encoded); |
|
| 1181 | + return $encoded; |
|
| 1182 | + } |
|
| 1183 | + |
|
| 1184 | + |
|
| 1185 | + public function createHtaccessTestFile(\OCP\IConfig $config) { |
|
| 1186 | + // php dev server does not support htaccess |
|
| 1187 | + if (php_sapi_name() === 'cli-server') { |
|
| 1188 | + return false; |
|
| 1189 | + } |
|
| 1190 | + |
|
| 1191 | + // testdata |
|
| 1192 | + $fileName = '/htaccesstest.txt'; |
|
| 1193 | + $testContent = 'This is used for testing whether htaccess is properly enabled to disallow access from the outside. This file can be safely removed.'; |
|
| 1194 | + |
|
| 1195 | + // creating a test file |
|
| 1196 | + $testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName; |
|
| 1197 | + |
|
| 1198 | + if (file_exists($testFile)) {// already running this test, possible recursive call |
|
| 1199 | + return false; |
|
| 1200 | + } |
|
| 1201 | + |
|
| 1202 | + $fp = @fopen($testFile, 'w'); |
|
| 1203 | + if (!$fp) { |
|
| 1204 | + throw new OC\HintException('Can\'t create test file to check for working .htaccess file.', |
|
| 1205 | + 'Make sure it is possible for the webserver to write to ' . $testFile); |
|
| 1206 | + } |
|
| 1207 | + fwrite($fp, $testContent); |
|
| 1208 | + fclose($fp); |
|
| 1209 | + |
|
| 1210 | + return $testContent; |
|
| 1211 | + } |
|
| 1212 | + |
|
| 1213 | + /** |
|
| 1214 | + * Check if the .htaccess file is working |
|
| 1215 | + * @param \OCP\IConfig $config |
|
| 1216 | + * @return bool |
|
| 1217 | + * @throws Exception |
|
| 1218 | + * @throws \OC\HintException If the test file can't get written. |
|
| 1219 | + */ |
|
| 1220 | + public function isHtaccessWorking(\OCP\IConfig $config) { |
|
| 1221 | + |
|
| 1222 | + if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) { |
|
| 1223 | + return true; |
|
| 1224 | + } |
|
| 1225 | + |
|
| 1226 | + $testContent = $this->createHtaccessTestFile($config); |
|
| 1227 | + if ($testContent === false) { |
|
| 1228 | + return false; |
|
| 1229 | + } |
|
| 1230 | + |
|
| 1231 | + $fileName = '/htaccesstest.txt'; |
|
| 1232 | + $testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName; |
|
| 1233 | + |
|
| 1234 | + // accessing the file via http |
|
| 1235 | + $url = \OC::$server->getURLGenerator()->getAbsoluteURL(OC::$WEBROOT . '/data' . $fileName); |
|
| 1236 | + try { |
|
| 1237 | + $content = \OC::$server->getHTTPClientService()->newClient()->get($url)->getBody(); |
|
| 1238 | + } catch (\Exception $e) { |
|
| 1239 | + $content = false; |
|
| 1240 | + } |
|
| 1241 | + |
|
| 1242 | + // cleanup |
|
| 1243 | + @unlink($testFile); |
|
| 1244 | + |
|
| 1245 | + /* |
|
| 1246 | 1246 | * If the content is not equal to test content our .htaccess |
| 1247 | 1247 | * is working as required |
| 1248 | 1248 | */ |
| 1249 | - return $content !== $testContent; |
|
| 1250 | - } |
|
| 1251 | - |
|
| 1252 | - /** |
|
| 1253 | - * Check if the setlocal call does not work. This can happen if the right |
|
| 1254 | - * local packages are not available on the server. |
|
| 1255 | - * |
|
| 1256 | - * @return bool |
|
| 1257 | - */ |
|
| 1258 | - public static function isSetLocaleWorking() { |
|
| 1259 | - \Patchwork\Utf8\Bootup::initLocale(); |
|
| 1260 | - if ('' === basename('§')) { |
|
| 1261 | - return false; |
|
| 1262 | - } |
|
| 1263 | - return true; |
|
| 1264 | - } |
|
| 1265 | - |
|
| 1266 | - /** |
|
| 1267 | - * Check if it's possible to get the inline annotations |
|
| 1268 | - * |
|
| 1269 | - * @return bool |
|
| 1270 | - */ |
|
| 1271 | - public static function isAnnotationsWorking() { |
|
| 1272 | - $reflection = new \ReflectionMethod(__METHOD__); |
|
| 1273 | - $docs = $reflection->getDocComment(); |
|
| 1274 | - |
|
| 1275 | - return (is_string($docs) && strlen($docs) > 50); |
|
| 1276 | - } |
|
| 1277 | - |
|
| 1278 | - /** |
|
| 1279 | - * Check if the PHP module fileinfo is loaded. |
|
| 1280 | - * |
|
| 1281 | - * @return bool |
|
| 1282 | - */ |
|
| 1283 | - public static function fileInfoLoaded() { |
|
| 1284 | - return function_exists('finfo_open'); |
|
| 1285 | - } |
|
| 1286 | - |
|
| 1287 | - /** |
|
| 1288 | - * clear all levels of output buffering |
|
| 1289 | - * |
|
| 1290 | - * @return void |
|
| 1291 | - */ |
|
| 1292 | - public static function obEnd() { |
|
| 1293 | - while (ob_get_level()) { |
|
| 1294 | - ob_end_clean(); |
|
| 1295 | - } |
|
| 1296 | - } |
|
| 1297 | - |
|
| 1298 | - /** |
|
| 1299 | - * Checks whether the server is running on Mac OS X |
|
| 1300 | - * |
|
| 1301 | - * @return bool true if running on Mac OS X, false otherwise |
|
| 1302 | - */ |
|
| 1303 | - public static function runningOnMac() { |
|
| 1304 | - return (strtoupper(substr(PHP_OS, 0, 6)) === 'DARWIN'); |
|
| 1305 | - } |
|
| 1306 | - |
|
| 1307 | - /** |
|
| 1308 | - * Checks whether server is running on HHVM |
|
| 1309 | - * |
|
| 1310 | - * @return bool True if running on HHVM, false otherwise |
|
| 1311 | - */ |
|
| 1312 | - public static function runningOnHhvm() { |
|
| 1313 | - return defined('HHVM_VERSION'); |
|
| 1314 | - } |
|
| 1315 | - |
|
| 1316 | - /** |
|
| 1317 | - * Handles the case that there may not be a theme, then check if a "default" |
|
| 1318 | - * theme exists and take that one |
|
| 1319 | - * |
|
| 1320 | - * @return string the theme |
|
| 1321 | - */ |
|
| 1322 | - public static function getTheme() { |
|
| 1323 | - $theme = \OC::$server->getSystemConfig()->getValue("theme", ''); |
|
| 1324 | - |
|
| 1325 | - if ($theme === '') { |
|
| 1326 | - if (is_dir(OC::$SERVERROOT . '/themes/default')) { |
|
| 1327 | - $theme = 'default'; |
|
| 1328 | - } |
|
| 1329 | - } |
|
| 1330 | - |
|
| 1331 | - return $theme; |
|
| 1332 | - } |
|
| 1333 | - |
|
| 1334 | - /** |
|
| 1335 | - * Clear a single file from the opcode cache |
|
| 1336 | - * This is useful for writing to the config file |
|
| 1337 | - * in case the opcode cache does not re-validate files |
|
| 1338 | - * Returns true if successful, false if unsuccessful: |
|
| 1339 | - * caller should fall back on clearing the entire cache |
|
| 1340 | - * with clearOpcodeCache() if unsuccessful |
|
| 1341 | - * |
|
| 1342 | - * @param string $path the path of the file to clear from the cache |
|
| 1343 | - * @return bool true if underlying function returns true, otherwise false |
|
| 1344 | - */ |
|
| 1345 | - public static function deleteFromOpcodeCache($path) { |
|
| 1346 | - $ret = false; |
|
| 1347 | - if ($path) { |
|
| 1348 | - // APC >= 3.1.1 |
|
| 1349 | - if (function_exists('apc_delete_file')) { |
|
| 1350 | - $ret = @apc_delete_file($path); |
|
| 1351 | - } |
|
| 1352 | - // Zend OpCache >= 7.0.0, PHP >= 5.5.0 |
|
| 1353 | - if (function_exists('opcache_invalidate')) { |
|
| 1354 | - $ret = opcache_invalidate($path); |
|
| 1355 | - } |
|
| 1356 | - } |
|
| 1357 | - return $ret; |
|
| 1358 | - } |
|
| 1359 | - |
|
| 1360 | - /** |
|
| 1361 | - * Clear the opcode cache if one exists |
|
| 1362 | - * This is necessary for writing to the config file |
|
| 1363 | - * in case the opcode cache does not re-validate files |
|
| 1364 | - * |
|
| 1365 | - * @return void |
|
| 1366 | - * @suppress PhanDeprecatedFunction |
|
| 1367 | - * @suppress PhanUndeclaredConstant |
|
| 1368 | - */ |
|
| 1369 | - public static function clearOpcodeCache() { |
|
| 1370 | - // APC |
|
| 1371 | - if (function_exists('apc_clear_cache')) { |
|
| 1372 | - apc_clear_cache(); |
|
| 1373 | - } |
|
| 1374 | - // Zend Opcache |
|
| 1375 | - if (function_exists('accelerator_reset')) { |
|
| 1376 | - accelerator_reset(); |
|
| 1377 | - } |
|
| 1378 | - // XCache |
|
| 1379 | - if (function_exists('xcache_clear_cache')) { |
|
| 1380 | - if (\OC::$server->getIniWrapper()->getBool('xcache.admin.enable_auth')) { |
|
| 1381 | - \OCP\Util::writeLog('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled.', \OCP\Util::WARN); |
|
| 1382 | - } else { |
|
| 1383 | - @xcache_clear_cache(XC_TYPE_PHP, 0); |
|
| 1384 | - } |
|
| 1385 | - } |
|
| 1386 | - // Opcache (PHP >= 5.5) |
|
| 1387 | - if (function_exists('opcache_reset')) { |
|
| 1388 | - opcache_reset(); |
|
| 1389 | - } |
|
| 1390 | - } |
|
| 1391 | - |
|
| 1392 | - /** |
|
| 1393 | - * Normalize a unicode string |
|
| 1394 | - * |
|
| 1395 | - * @param string $value a not normalized string |
|
| 1396 | - * @return bool|string |
|
| 1397 | - */ |
|
| 1398 | - public static function normalizeUnicode($value) { |
|
| 1399 | - if(Normalizer::isNormalized($value)) { |
|
| 1400 | - return $value; |
|
| 1401 | - } |
|
| 1402 | - |
|
| 1403 | - $normalizedValue = Normalizer::normalize($value); |
|
| 1404 | - if ($normalizedValue === null || $normalizedValue === false) { |
|
| 1405 | - \OC::$server->getLogger()->warning('normalizing failed for "' . $value . '"', ['app' => 'core']); |
|
| 1406 | - return $value; |
|
| 1407 | - } |
|
| 1408 | - |
|
| 1409 | - return $normalizedValue; |
|
| 1410 | - } |
|
| 1411 | - |
|
| 1412 | - /** |
|
| 1413 | - * A human readable string is generated based on version and build number |
|
| 1414 | - * |
|
| 1415 | - * @return string |
|
| 1416 | - */ |
|
| 1417 | - public static function getHumanVersion() { |
|
| 1418 | - $version = OC_Util::getVersionString(); |
|
| 1419 | - $build = OC_Util::getBuild(); |
|
| 1420 | - if (!empty($build) and OC_Util::getChannel() === 'daily') { |
|
| 1421 | - $version .= ' Build:' . $build; |
|
| 1422 | - } |
|
| 1423 | - return $version; |
|
| 1424 | - } |
|
| 1425 | - |
|
| 1426 | - /** |
|
| 1427 | - * Returns whether the given file name is valid |
|
| 1428 | - * |
|
| 1429 | - * @param string $file file name to check |
|
| 1430 | - * @return bool true if the file name is valid, false otherwise |
|
| 1431 | - * @deprecated use \OC\Files\View::verifyPath() |
|
| 1432 | - */ |
|
| 1433 | - public static function isValidFileName($file) { |
|
| 1434 | - $trimmed = trim($file); |
|
| 1435 | - if ($trimmed === '') { |
|
| 1436 | - return false; |
|
| 1437 | - } |
|
| 1438 | - if (\OC\Files\Filesystem::isIgnoredDir($trimmed)) { |
|
| 1439 | - return false; |
|
| 1440 | - } |
|
| 1441 | - |
|
| 1442 | - // detect part files |
|
| 1443 | - if (preg_match('/' . \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX . '/', $trimmed) !== 0) { |
|
| 1444 | - return false; |
|
| 1445 | - } |
|
| 1446 | - |
|
| 1447 | - foreach (str_split($trimmed) as $char) { |
|
| 1448 | - if (strpos(\OCP\Constants::FILENAME_INVALID_CHARS, $char) !== false) { |
|
| 1449 | - return false; |
|
| 1450 | - } |
|
| 1451 | - } |
|
| 1452 | - return true; |
|
| 1453 | - } |
|
| 1454 | - |
|
| 1455 | - /** |
|
| 1456 | - * Check whether the instance needs to perform an upgrade, |
|
| 1457 | - * either when the core version is higher or any app requires |
|
| 1458 | - * an upgrade. |
|
| 1459 | - * |
|
| 1460 | - * @param \OC\SystemConfig $config |
|
| 1461 | - * @return bool whether the core or any app needs an upgrade |
|
| 1462 | - * @throws \OC\HintException When the upgrade from the given version is not allowed |
|
| 1463 | - */ |
|
| 1464 | - public static function needUpgrade(\OC\SystemConfig $config) { |
|
| 1465 | - if ($config->getValue('installed', false)) { |
|
| 1466 | - $installedVersion = $config->getValue('version', '0.0.0'); |
|
| 1467 | - $currentVersion = implode('.', \OCP\Util::getVersion()); |
|
| 1468 | - $versionDiff = version_compare($currentVersion, $installedVersion); |
|
| 1469 | - if ($versionDiff > 0) { |
|
| 1470 | - return true; |
|
| 1471 | - } else if ($config->getValue('debug', false) && $versionDiff < 0) { |
|
| 1472 | - // downgrade with debug |
|
| 1473 | - $installedMajor = explode('.', $installedVersion); |
|
| 1474 | - $installedMajor = $installedMajor[0] . '.' . $installedMajor[1]; |
|
| 1475 | - $currentMajor = explode('.', $currentVersion); |
|
| 1476 | - $currentMajor = $currentMajor[0] . '.' . $currentMajor[1]; |
|
| 1477 | - if ($installedMajor === $currentMajor) { |
|
| 1478 | - // Same major, allow downgrade for developers |
|
| 1479 | - return true; |
|
| 1480 | - } else { |
|
| 1481 | - // downgrade attempt, throw exception |
|
| 1482 | - throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')'); |
|
| 1483 | - } |
|
| 1484 | - } else if ($versionDiff < 0) { |
|
| 1485 | - // downgrade attempt, throw exception |
|
| 1486 | - throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')'); |
|
| 1487 | - } |
|
| 1488 | - |
|
| 1489 | - // also check for upgrades for apps (independently from the user) |
|
| 1490 | - $apps = \OC_App::getEnabledApps(false, true); |
|
| 1491 | - $shouldUpgrade = false; |
|
| 1492 | - foreach ($apps as $app) { |
|
| 1493 | - if (\OC_App::shouldUpgrade($app)) { |
|
| 1494 | - $shouldUpgrade = true; |
|
| 1495 | - break; |
|
| 1496 | - } |
|
| 1497 | - } |
|
| 1498 | - return $shouldUpgrade; |
|
| 1499 | - } else { |
|
| 1500 | - return false; |
|
| 1501 | - } |
|
| 1502 | - } |
|
| 1249 | + return $content !== $testContent; |
|
| 1250 | + } |
|
| 1251 | + |
|
| 1252 | + /** |
|
| 1253 | + * Check if the setlocal call does not work. This can happen if the right |
|
| 1254 | + * local packages are not available on the server. |
|
| 1255 | + * |
|
| 1256 | + * @return bool |
|
| 1257 | + */ |
|
| 1258 | + public static function isSetLocaleWorking() { |
|
| 1259 | + \Patchwork\Utf8\Bootup::initLocale(); |
|
| 1260 | + if ('' === basename('§')) { |
|
| 1261 | + return false; |
|
| 1262 | + } |
|
| 1263 | + return true; |
|
| 1264 | + } |
|
| 1265 | + |
|
| 1266 | + /** |
|
| 1267 | + * Check if it's possible to get the inline annotations |
|
| 1268 | + * |
|
| 1269 | + * @return bool |
|
| 1270 | + */ |
|
| 1271 | + public static function isAnnotationsWorking() { |
|
| 1272 | + $reflection = new \ReflectionMethod(__METHOD__); |
|
| 1273 | + $docs = $reflection->getDocComment(); |
|
| 1274 | + |
|
| 1275 | + return (is_string($docs) && strlen($docs) > 50); |
|
| 1276 | + } |
|
| 1277 | + |
|
| 1278 | + /** |
|
| 1279 | + * Check if the PHP module fileinfo is loaded. |
|
| 1280 | + * |
|
| 1281 | + * @return bool |
|
| 1282 | + */ |
|
| 1283 | + public static function fileInfoLoaded() { |
|
| 1284 | + return function_exists('finfo_open'); |
|
| 1285 | + } |
|
| 1286 | + |
|
| 1287 | + /** |
|
| 1288 | + * clear all levels of output buffering |
|
| 1289 | + * |
|
| 1290 | + * @return void |
|
| 1291 | + */ |
|
| 1292 | + public static function obEnd() { |
|
| 1293 | + while (ob_get_level()) { |
|
| 1294 | + ob_end_clean(); |
|
| 1295 | + } |
|
| 1296 | + } |
|
| 1297 | + |
|
| 1298 | + /** |
|
| 1299 | + * Checks whether the server is running on Mac OS X |
|
| 1300 | + * |
|
| 1301 | + * @return bool true if running on Mac OS X, false otherwise |
|
| 1302 | + */ |
|
| 1303 | + public static function runningOnMac() { |
|
| 1304 | + return (strtoupper(substr(PHP_OS, 0, 6)) === 'DARWIN'); |
|
| 1305 | + } |
|
| 1306 | + |
|
| 1307 | + /** |
|
| 1308 | + * Checks whether server is running on HHVM |
|
| 1309 | + * |
|
| 1310 | + * @return bool True if running on HHVM, false otherwise |
|
| 1311 | + */ |
|
| 1312 | + public static function runningOnHhvm() { |
|
| 1313 | + return defined('HHVM_VERSION'); |
|
| 1314 | + } |
|
| 1315 | + |
|
| 1316 | + /** |
|
| 1317 | + * Handles the case that there may not be a theme, then check if a "default" |
|
| 1318 | + * theme exists and take that one |
|
| 1319 | + * |
|
| 1320 | + * @return string the theme |
|
| 1321 | + */ |
|
| 1322 | + public static function getTheme() { |
|
| 1323 | + $theme = \OC::$server->getSystemConfig()->getValue("theme", ''); |
|
| 1324 | + |
|
| 1325 | + if ($theme === '') { |
|
| 1326 | + if (is_dir(OC::$SERVERROOT . '/themes/default')) { |
|
| 1327 | + $theme = 'default'; |
|
| 1328 | + } |
|
| 1329 | + } |
|
| 1330 | + |
|
| 1331 | + return $theme; |
|
| 1332 | + } |
|
| 1333 | + |
|
| 1334 | + /** |
|
| 1335 | + * Clear a single file from the opcode cache |
|
| 1336 | + * This is useful for writing to the config file |
|
| 1337 | + * in case the opcode cache does not re-validate files |
|
| 1338 | + * Returns true if successful, false if unsuccessful: |
|
| 1339 | + * caller should fall back on clearing the entire cache |
|
| 1340 | + * with clearOpcodeCache() if unsuccessful |
|
| 1341 | + * |
|
| 1342 | + * @param string $path the path of the file to clear from the cache |
|
| 1343 | + * @return bool true if underlying function returns true, otherwise false |
|
| 1344 | + */ |
|
| 1345 | + public static function deleteFromOpcodeCache($path) { |
|
| 1346 | + $ret = false; |
|
| 1347 | + if ($path) { |
|
| 1348 | + // APC >= 3.1.1 |
|
| 1349 | + if (function_exists('apc_delete_file')) { |
|
| 1350 | + $ret = @apc_delete_file($path); |
|
| 1351 | + } |
|
| 1352 | + // Zend OpCache >= 7.0.0, PHP >= 5.5.0 |
|
| 1353 | + if (function_exists('opcache_invalidate')) { |
|
| 1354 | + $ret = opcache_invalidate($path); |
|
| 1355 | + } |
|
| 1356 | + } |
|
| 1357 | + return $ret; |
|
| 1358 | + } |
|
| 1359 | + |
|
| 1360 | + /** |
|
| 1361 | + * Clear the opcode cache if one exists |
|
| 1362 | + * This is necessary for writing to the config file |
|
| 1363 | + * in case the opcode cache does not re-validate files |
|
| 1364 | + * |
|
| 1365 | + * @return void |
|
| 1366 | + * @suppress PhanDeprecatedFunction |
|
| 1367 | + * @suppress PhanUndeclaredConstant |
|
| 1368 | + */ |
|
| 1369 | + public static function clearOpcodeCache() { |
|
| 1370 | + // APC |
|
| 1371 | + if (function_exists('apc_clear_cache')) { |
|
| 1372 | + apc_clear_cache(); |
|
| 1373 | + } |
|
| 1374 | + // Zend Opcache |
|
| 1375 | + if (function_exists('accelerator_reset')) { |
|
| 1376 | + accelerator_reset(); |
|
| 1377 | + } |
|
| 1378 | + // XCache |
|
| 1379 | + if (function_exists('xcache_clear_cache')) { |
|
| 1380 | + if (\OC::$server->getIniWrapper()->getBool('xcache.admin.enable_auth')) { |
|
| 1381 | + \OCP\Util::writeLog('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled.', \OCP\Util::WARN); |
|
| 1382 | + } else { |
|
| 1383 | + @xcache_clear_cache(XC_TYPE_PHP, 0); |
|
| 1384 | + } |
|
| 1385 | + } |
|
| 1386 | + // Opcache (PHP >= 5.5) |
|
| 1387 | + if (function_exists('opcache_reset')) { |
|
| 1388 | + opcache_reset(); |
|
| 1389 | + } |
|
| 1390 | + } |
|
| 1391 | + |
|
| 1392 | + /** |
|
| 1393 | + * Normalize a unicode string |
|
| 1394 | + * |
|
| 1395 | + * @param string $value a not normalized string |
|
| 1396 | + * @return bool|string |
|
| 1397 | + */ |
|
| 1398 | + public static function normalizeUnicode($value) { |
|
| 1399 | + if(Normalizer::isNormalized($value)) { |
|
| 1400 | + return $value; |
|
| 1401 | + } |
|
| 1402 | + |
|
| 1403 | + $normalizedValue = Normalizer::normalize($value); |
|
| 1404 | + if ($normalizedValue === null || $normalizedValue === false) { |
|
| 1405 | + \OC::$server->getLogger()->warning('normalizing failed for "' . $value . '"', ['app' => 'core']); |
|
| 1406 | + return $value; |
|
| 1407 | + } |
|
| 1408 | + |
|
| 1409 | + return $normalizedValue; |
|
| 1410 | + } |
|
| 1411 | + |
|
| 1412 | + /** |
|
| 1413 | + * A human readable string is generated based on version and build number |
|
| 1414 | + * |
|
| 1415 | + * @return string |
|
| 1416 | + */ |
|
| 1417 | + public static function getHumanVersion() { |
|
| 1418 | + $version = OC_Util::getVersionString(); |
|
| 1419 | + $build = OC_Util::getBuild(); |
|
| 1420 | + if (!empty($build) and OC_Util::getChannel() === 'daily') { |
|
| 1421 | + $version .= ' Build:' . $build; |
|
| 1422 | + } |
|
| 1423 | + return $version; |
|
| 1424 | + } |
|
| 1425 | + |
|
| 1426 | + /** |
|
| 1427 | + * Returns whether the given file name is valid |
|
| 1428 | + * |
|
| 1429 | + * @param string $file file name to check |
|
| 1430 | + * @return bool true if the file name is valid, false otherwise |
|
| 1431 | + * @deprecated use \OC\Files\View::verifyPath() |
|
| 1432 | + */ |
|
| 1433 | + public static function isValidFileName($file) { |
|
| 1434 | + $trimmed = trim($file); |
|
| 1435 | + if ($trimmed === '') { |
|
| 1436 | + return false; |
|
| 1437 | + } |
|
| 1438 | + if (\OC\Files\Filesystem::isIgnoredDir($trimmed)) { |
|
| 1439 | + return false; |
|
| 1440 | + } |
|
| 1441 | + |
|
| 1442 | + // detect part files |
|
| 1443 | + if (preg_match('/' . \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX . '/', $trimmed) !== 0) { |
|
| 1444 | + return false; |
|
| 1445 | + } |
|
| 1446 | + |
|
| 1447 | + foreach (str_split($trimmed) as $char) { |
|
| 1448 | + if (strpos(\OCP\Constants::FILENAME_INVALID_CHARS, $char) !== false) { |
|
| 1449 | + return false; |
|
| 1450 | + } |
|
| 1451 | + } |
|
| 1452 | + return true; |
|
| 1453 | + } |
|
| 1454 | + |
|
| 1455 | + /** |
|
| 1456 | + * Check whether the instance needs to perform an upgrade, |
|
| 1457 | + * either when the core version is higher or any app requires |
|
| 1458 | + * an upgrade. |
|
| 1459 | + * |
|
| 1460 | + * @param \OC\SystemConfig $config |
|
| 1461 | + * @return bool whether the core or any app needs an upgrade |
|
| 1462 | + * @throws \OC\HintException When the upgrade from the given version is not allowed |
|
| 1463 | + */ |
|
| 1464 | + public static function needUpgrade(\OC\SystemConfig $config) { |
|
| 1465 | + if ($config->getValue('installed', false)) { |
|
| 1466 | + $installedVersion = $config->getValue('version', '0.0.0'); |
|
| 1467 | + $currentVersion = implode('.', \OCP\Util::getVersion()); |
|
| 1468 | + $versionDiff = version_compare($currentVersion, $installedVersion); |
|
| 1469 | + if ($versionDiff > 0) { |
|
| 1470 | + return true; |
|
| 1471 | + } else if ($config->getValue('debug', false) && $versionDiff < 0) { |
|
| 1472 | + // downgrade with debug |
|
| 1473 | + $installedMajor = explode('.', $installedVersion); |
|
| 1474 | + $installedMajor = $installedMajor[0] . '.' . $installedMajor[1]; |
|
| 1475 | + $currentMajor = explode('.', $currentVersion); |
|
| 1476 | + $currentMajor = $currentMajor[0] . '.' . $currentMajor[1]; |
|
| 1477 | + if ($installedMajor === $currentMajor) { |
|
| 1478 | + // Same major, allow downgrade for developers |
|
| 1479 | + return true; |
|
| 1480 | + } else { |
|
| 1481 | + // downgrade attempt, throw exception |
|
| 1482 | + throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')'); |
|
| 1483 | + } |
|
| 1484 | + } else if ($versionDiff < 0) { |
|
| 1485 | + // downgrade attempt, throw exception |
|
| 1486 | + throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')'); |
|
| 1487 | + } |
|
| 1488 | + |
|
| 1489 | + // also check for upgrades for apps (independently from the user) |
|
| 1490 | + $apps = \OC_App::getEnabledApps(false, true); |
|
| 1491 | + $shouldUpgrade = false; |
|
| 1492 | + foreach ($apps as $app) { |
|
| 1493 | + if (\OC_App::shouldUpgrade($app)) { |
|
| 1494 | + $shouldUpgrade = true; |
|
| 1495 | + break; |
|
| 1496 | + } |
|
| 1497 | + } |
|
| 1498 | + return $shouldUpgrade; |
|
| 1499 | + } else { |
|
| 1500 | + return false; |
|
| 1501 | + } |
|
| 1502 | + } |
|
| 1503 | 1503 | |
| 1504 | 1504 | } |
@@ -31,101 +31,101 @@ discard block |
||
| 31 | 31 | <p class="settings-hint"><?php p($l->t('It\'s important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the Tips & Tricks section and the documentation for more information.'));?></p> |
| 32 | 32 | <ul> |
| 33 | 33 | <?php |
| 34 | - // is php setup properly to query system environment variables like getenv('PATH') |
|
| 35 | - if ($_['getenvServerNotWorking']) { |
|
| 36 | - ?> |
|
| 34 | + // is php setup properly to query system environment variables like getenv('PATH') |
|
| 35 | + if ($_['getenvServerNotWorking']) { |
|
| 36 | + ?> |
|
| 37 | 37 | <li> |
| 38 | 38 | <?php p($l->t('PHP does not seem to be setup properly to query system environment variables. The test with getenv("PATH") only returns an empty response.')); ?><br> |
| 39 | 39 | <?php print_unescaped($l->t('Please check the <a target="_blank" rel="noreferrer noopener" href="%s">installation documentation ↗</a> for PHP configuration notes and the PHP configuration of your server, especially when using php-fpm.', link_to_docs('admin-php-fpm'))); ?> |
| 40 | 40 | </li> |
| 41 | 41 | <?php |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - // is read only config enabled |
|
| 45 | - if ($_['readOnlyConfigEnabled']) { |
|
| 46 | - ?> |
|
| 44 | + // is read only config enabled |
|
| 45 | + if ($_['readOnlyConfigEnabled']) { |
|
| 46 | + ?> |
|
| 47 | 47 | <li> |
| 48 | 48 | <?php p($l->t('The Read-Only config has been enabled. This prevents setting some configurations via the web-interface. Furthermore, the file needs to be made writable manually for every update.')); ?> |
| 49 | 49 | </li> |
| 50 | 50 | <?php |
| 51 | - } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - // Are doc blocks accessible? |
|
| 54 | - if (!$_['isAnnotationsWorking']) { |
|
| 55 | - ?> |
|
| 53 | + // Are doc blocks accessible? |
|
| 54 | + if (!$_['isAnnotationsWorking']) { |
|
| 55 | + ?> |
|
| 56 | 56 | <li> |
| 57 | 57 | <?php p($l->t('PHP is apparently set up to strip inline doc blocks. This will make several core apps inaccessible.')); ?><br> |
| 58 | 58 | <?php p($l->t('This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator.')); ?> |
| 59 | 59 | </li> |
| 60 | 60 | <?php |
| 61 | - } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - // Is the Transaction isolation level READ_COMMITTED? |
|
| 64 | - if ($_['invalidTransactionIsolationLevel']) { |
|
| 65 | - ?> |
|
| 63 | + // Is the Transaction isolation level READ_COMMITTED? |
|
| 64 | + if ($_['invalidTransactionIsolationLevel']) { |
|
| 65 | + ?> |
|
| 66 | 66 | <li> |
| 67 | 67 | <?php p($l->t('Your database does not run with "READ COMMITTED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.')); ?> |
| 68 | 68 | </li> |
| 69 | 69 | <?php |
| 70 | - } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - // Warning if memcache is outdated |
|
| 73 | - foreach ($_['OutdatedCacheWarning'] as $php_module => $data) { |
|
| 74 | - ?> |
|
| 72 | + // Warning if memcache is outdated |
|
| 73 | + foreach ($_['OutdatedCacheWarning'] as $php_module => $data) { |
|
| 74 | + ?> |
|
| 75 | 75 | <li> |
| 76 | 76 | <?php p($l->t('%1$s below version %2$s is installed, for stability and performance reasons it is recommended to update to a newer %1$s version.', $data)); ?> |
| 77 | 77 | </li> |
| 78 | 78 | <?php |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // if module fileinfo available? |
|
| 82 | - if (!$_['has_fileinfo']) { |
|
| 83 | - ?> |
|
| 81 | + // if module fileinfo available? |
|
| 82 | + if (!$_['has_fileinfo']) { |
|
| 83 | + ?> |
|
| 84 | 84 | <li> |
| 85 | 85 | <?php p($l->t('The PHP module \'fileinfo\' is missing. It is strongly recommended to enable this module to get the best results with MIME type detection.')); ?> |
| 86 | 86 | </li> |
| 87 | 87 | <?php |
| 88 | - } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - // locking configured optimally? |
|
| 91 | - if ($_['fileLockingType'] === 'none') { |
|
| 92 | - ?> |
|
| 90 | + // locking configured optimally? |
|
| 91 | + if ($_['fileLockingType'] === 'none') { |
|
| 92 | + ?> |
|
| 93 | 93 | <li> |
| 94 | 94 | <?php print_unescaped($l->t('Transactional file locking is disabled, this might lead to issues with race conditions. Enable \'filelocking.enabled\' in config.php to avoid these problems. See the <a target="_blank" rel="noreferrer noopener" href="%s">documentation ↗</a> for more information.', link_to_docs('admin-transactional-locking'))); ?> |
| 95 | 95 | </li> |
| 96 | 96 | <?php |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - // is locale working ? |
|
| 100 | - if (!$_['isLocaleWorking']) { |
|
| 101 | - ?> |
|
| 99 | + // is locale working ? |
|
| 100 | + if (!$_['isLocaleWorking']) { |
|
| 101 | + ?> |
|
| 102 | 102 | <li> |
| 103 | 103 | <?php |
| 104 | - $locales = 'en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8'; |
|
| 105 | - p($l->t('System locale can not be set to a one which supports UTF-8.')); |
|
| 106 | - ?> |
|
| 104 | + $locales = 'en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8'; |
|
| 105 | + p($l->t('System locale can not be set to a one which supports UTF-8.')); |
|
| 106 | + ?> |
|
| 107 | 107 | <br> |
| 108 | 108 | <?php |
| 109 | - p($l->t('This means that there might be problems with certain characters in filenames.')); |
|
| 110 | - ?> |
|
| 109 | + p($l->t('This means that there might be problems with certain characters in filenames.')); |
|
| 110 | + ?> |
|
| 111 | 111 | <br> |
| 112 | 112 | <?php |
| 113 | - p($l->t('It is strongly proposed to install the required packages on your system to support one of the following locales: %s.', [$locales])); |
|
| 114 | - ?> |
|
| 113 | + p($l->t('It is strongly proposed to install the required packages on your system to support one of the following locales: %s.', [$locales])); |
|
| 114 | + ?> |
|
| 115 | 115 | </li> |
| 116 | 116 | <?php |
| 117 | - } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - if ($_['suggestedOverwriteCliUrl']) { |
|
| 120 | - ?> |
|
| 119 | + if ($_['suggestedOverwriteCliUrl']) { |
|
| 120 | + ?> |
|
| 121 | 121 | <li> |
| 122 | 122 | <?php p($l->t('If your installation is not installed at the root of the domain and uses system Cron, there can be issues with the URL generation. To avoid these problems, please set the "overwrite.cli.url" option in your config.php file to the webroot path of your installation (Suggested: "%s")', $_['suggestedOverwriteCliUrl'])); ?> |
| 123 | 123 | </li> |
| 124 | 124 | <?php |
| 125 | - } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - if ($_['cronErrors']) { |
|
| 128 | - ?> |
|
| 127 | + if ($_['cronErrors']) { |
|
| 128 | + ?> |
|
| 129 | 129 | <li> |
| 130 | 130 | <?php p($l->t('It was not possible to execute the cron job via CLI. The following technical errors have appeared:')); ?> |
| 131 | 131 | <br> |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | </ol> |
| 137 | 137 | </li> |
| 138 | 138 | <?php |
| 139 | - } |
|
| 140 | - ?> |
|
| 139 | + } |
|
| 140 | + ?> |
|
| 141 | 141 | </ul> |
| 142 | 142 | |
| 143 | 143 | <div id="postsetupchecks" data-check-wellknown="<?php if($_['checkForWorkingWellKnownSetup']) { p('true'); } else { p('false'); } ?>"> |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | <h2 class="inlineblock"><?php p($l->t('Background jobs'));?></h2> |
| 159 | 159 | <p class="cronlog inlineblock"> |
| 160 | 160 | <?php if ($_['lastcron'] !== false): |
| 161 | - $relative_time = relative_modified_date($_['lastcron']); |
|
| 161 | + $relative_time = relative_modified_date($_['lastcron']); |
|
| 162 | 162 | |
| 163 | - $formatter = \OC::$server->getDateTimeFormatter(); |
|
| 164 | - $absolute_time = $formatter->formatDateTime($_['lastcron'], 'long', 'long'); |
|
| 165 | - if (time() - $_['lastcron'] <= 3600): ?> |
|
| 163 | + $formatter = \OC::$server->getDateTimeFormatter(); |
|
| 164 | + $absolute_time = $formatter->formatDateTime($_['lastcron'], 'long', 'long'); |
|
| 165 | + if (time() - $_['lastcron'] <= 3600): ?> |
|
| 166 | 166 | <span class="status success"></span> |
| 167 | 167 | <span class="crondate" title="<?php p($absolute_time);?>"> |
| 168 | 168 | <?php p($l->t("Last job ran %s.", [$relative_time]));?> |
@@ -173,10 +173,10 @@ discard block |
||
| 173 | 173 | <?php p($l->t("Last job execution ran %s. Something seems wrong.", [$relative_time]));?> |
| 174 | 174 | </span> |
| 175 | 175 | <?php endif; |
| 176 | - else: ?> |
|
| 176 | + else: ?> |
|
| 177 | 177 | <span class="status error"></span> |
| 178 | 178 | <?php p($l->t("Background job didn’t run yet!")); |
| 179 | - endif; ?> |
|
| 179 | + endif; ?> |
|
| 180 | 180 | </p> |
| 181 | 181 | <a target="_blank" rel="noreferrer noopener" class="icon-info" |
| 182 | 182 | title="<?php p($l->t('Open documentation'));?>" |
@@ -186,38 +186,38 @@ discard block |
||
| 186 | 186 | <p> |
| 187 | 187 | <input type="radio" name="mode" value="ajax" class="radio" |
| 188 | 188 | id="backgroundjobs_ajax" <?php if ($_['backgroundjobs_mode'] === "ajax") { |
| 189 | - print_unescaped('checked="checked"'); |
|
| 190 | - } ?>> |
|
| 189 | + print_unescaped('checked="checked"'); |
|
| 190 | + } ?>> |
|
| 191 | 191 | <label for="backgroundjobs_ajax">AJAX</label><br/> |
| 192 | 192 | <em><?php p($l->t("Execute one task with each page loaded")); ?></em> |
| 193 | 193 | </p> |
| 194 | 194 | <p> |
| 195 | 195 | <input type="radio" name="mode" value="webcron" class="radio" |
| 196 | 196 | id="backgroundjobs_webcron" <?php if ($_['backgroundjobs_mode'] === "webcron") { |
| 197 | - print_unescaped('checked="checked"'); |
|
| 198 | - } ?>> |
|
| 197 | + print_unescaped('checked="checked"'); |
|
| 198 | + } ?>> |
|
| 199 | 199 | <label for="backgroundjobs_webcron">Webcron</label><br/> |
| 200 | 200 | <em><?php p($l->t("cron.php is registered at a webcron service to call cron.php every 15 minutes over HTTP.")); ?></em> |
| 201 | 201 | </p> |
| 202 | 202 | <p> |
| 203 | 203 | <input type="radio" name="mode" value="cron" class="radio" |
| 204 | 204 | id="backgroundjobs_cron" <?php if ($_['backgroundjobs_mode'] === "cron") { |
| 205 | - print_unescaped('checked="checked"'); |
|
| 206 | - } |
|
| 207 | - if (!$_['cli_based_cron_possible']) { |
|
| 208 | - print_unescaped('disabled'); |
|
| 209 | - }?>> |
|
| 205 | + print_unescaped('checked="checked"'); |
|
| 206 | + } |
|
| 207 | + if (!$_['cli_based_cron_possible']) { |
|
| 208 | + print_unescaped('disabled'); |
|
| 209 | + }?>> |
|
| 210 | 210 | <label for="backgroundjobs_cron">Cron</label><br/> |
| 211 | 211 | <em><?php p($l->t("Use system cron service to call the cron.php file every 15 minutes.")); ?> |
| 212 | 212 | <?php if($_['cli_based_cron_possible']) { |
| 213 | - p($l->t('The cron.php needs to be executed by the system user "%s".', [$_['cli_based_cron_user']])); |
|
| 214 | - } else { |
|
| 215 | - print_unescaped(str_replace( |
|
| 216 | - ['{linkstart}', '{linkend}'], |
|
| 217 | - ['<a href="http://php.net/manual/en/book.posix.php">', ' ↗</a>'], |
|
| 218 | - $l->t('To run this you need the PHP POSIX extension. See {linkstart}PHP documentation{linkend} for more details.') |
|
| 219 | - )); |
|
| 220 | - } ?></em> |
|
| 213 | + p($l->t('The cron.php needs to be executed by the system user "%s".', [$_['cli_based_cron_user']])); |
|
| 214 | + } else { |
|
| 215 | + print_unescaped(str_replace( |
|
| 216 | + ['{linkstart}', '{linkend}'], |
|
| 217 | + ['<a href="http://php.net/manual/en/book.posix.php">', ' ↗</a>'], |
|
| 218 | + $l->t('To run this you need the PHP POSIX extension. See {linkstart}PHP documentation{linkend} for more details.') |
|
| 219 | + )); |
|
| 220 | + } ?></em> |
|
| 221 | 221 | |
| 222 | 222 | </p> |
| 223 | 223 | </div> |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | ?> |
| 28 | 28 | |
| 29 | 29 | <div id="security-warning" class="section"> |
| 30 | - <h2><?php p($l->t('Security & setup warnings'));?></h2> |
|
| 31 | - <p class="settings-hint"><?php p($l->t('It\'s important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the Tips & Tricks section and the documentation for more information.'));?></p> |
|
| 30 | + <h2><?php p($l->t('Security & setup warnings')); ?></h2> |
|
| 31 | + <p class="settings-hint"><?php p($l->t('It\'s important for the security and performance of your instance that everything is configured correctly. To help you with that we are doing some automatic checks. Please see the Tips & Tricks section and the documentation for more information.')); ?></p> |
|
| 32 | 32 | <ul> |
| 33 | 33 | <?php |
| 34 | 34 | // is php setup properly to query system environment variables like getenv('PATH') |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | <?php p($l->t('It was not possible to execute the cron job via CLI. The following technical errors have appeared:')); ?> |
| 131 | 131 | <br> |
| 132 | 132 | <ol> |
| 133 | - <?php foreach(json_decode($_['cronErrors']) as $error) { if(isset($error->error)) {?> |
|
| 133 | + <?php foreach (json_decode($_['cronErrors']) as $error) { if (isset($error->error)) {?> |
|
| 134 | 134 | <li><?php p($error->error) ?> <?php p($error->hint) ?></li> |
| 135 | 135 | <?php }} ?> |
| 136 | 136 | </ol> |
@@ -140,22 +140,22 @@ discard block |
||
| 140 | 140 | ?> |
| 141 | 141 | </ul> |
| 142 | 142 | |
| 143 | - <div id="postsetupchecks" data-check-wellknown="<?php if($_['checkForWorkingWellKnownSetup']) { p('true'); } else { p('false'); } ?>"> |
|
| 143 | + <div id="postsetupchecks" data-check-wellknown="<?php if ($_['checkForWorkingWellKnownSetup']) { p('true'); } else { p('false'); } ?>"> |
|
| 144 | 144 | <div class="loading"></div> |
| 145 | 145 | <ul class="errors hidden"></ul> |
| 146 | 146 | <ul class="warnings hidden"></ul> |
| 147 | 147 | <ul class="info hidden"></ul> |
| 148 | 148 | <p class="hint hidden"> |
| 149 | - <?php print_unescaped($l->t('Please double check the <a target="_blank" rel="noreferrer noopener" href="%s">installation guides ↗</a>, and check for any errors or warnings in the <a href="%s">log</a>.', [link_to_docs('admin-install'), \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => 'logging'])] )); ?> |
|
| 149 | + <?php print_unescaped($l->t('Please double check the <a target="_blank" rel="noreferrer noopener" href="%s">installation guides ↗</a>, and check for any errors or warnings in the <a href="%s">log</a>.', [link_to_docs('admin-install'), \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => 'logging'])])); ?> |
|
| 150 | 150 | </p> |
| 151 | 151 | </div> |
| 152 | 152 | <div id="security-warning-state"> |
| 153 | - <span class="hidden icon-checkmark"><?php p($l->t('All checks passed.'));?></span> |
|
| 153 | + <span class="hidden icon-checkmark"><?php p($l->t('All checks passed.')); ?></span> |
|
| 154 | 154 | </div> |
| 155 | 155 | </div> |
| 156 | 156 | |
| 157 | 157 | <div class="section" id="backgroundjobs"> |
| 158 | - <h2 class="inlineblock"><?php p($l->t('Background jobs'));?></h2> |
|
| 158 | + <h2 class="inlineblock"><?php p($l->t('Background jobs')); ?></h2> |
|
| 159 | 159 | <p class="cronlog inlineblock"> |
| 160 | 160 | <?php if ($_['lastcron'] !== false): |
| 161 | 161 | $relative_time = relative_modified_date($_['lastcron']); |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | $absolute_time = $formatter->formatDateTime($_['lastcron'], 'long', 'long'); |
| 165 | 165 | if (time() - $_['lastcron'] <= 3600): ?> |
| 166 | 166 | <span class="status success"></span> |
| 167 | - <span class="crondate" title="<?php p($absolute_time);?>"> |
|
| 168 | - <?php p($l->t("Last job ran %s.", [$relative_time]));?> |
|
| 167 | + <span class="crondate" title="<?php p($absolute_time); ?>"> |
|
| 168 | + <?php p($l->t("Last job ran %s.", [$relative_time])); ?> |
|
| 169 | 169 | </span> |
| 170 | 170 | <?php else: ?> |
| 171 | 171 | <span class="status error"></span> |
| 172 | - <span class="crondate" title="<?php p($absolute_time);?>"> |
|
| 173 | - <?php p($l->t("Last job execution ran %s. Something seems wrong.", [$relative_time]));?> |
|
| 172 | + <span class="crondate" title="<?php p($absolute_time); ?>"> |
|
| 173 | + <?php p($l->t("Last job execution ran %s. Something seems wrong.", [$relative_time])); ?> |
|
| 174 | 174 | </span> |
| 175 | 175 | <?php endif; |
| 176 | 176 | else: ?> |
@@ -179,10 +179,10 @@ discard block |
||
| 179 | 179 | endif; ?> |
| 180 | 180 | </p> |
| 181 | 181 | <a target="_blank" rel="noreferrer noopener" class="icon-info" |
| 182 | - title="<?php p($l->t('Open documentation'));?>" |
|
| 182 | + title="<?php p($l->t('Open documentation')); ?>" |
|
| 183 | 183 | href="<?php p(link_to_docs('admin-background-jobs')); ?>"></a> |
| 184 | 184 | |
| 185 | - <p class="settings-hint"><?php p($l->t('For optimal performance it\'s important to configure background jobs correctly. For bigger instances \'Cron\' is the recommended setting. Please see the documentation for more information.'));?></p> |
|
| 185 | + <p class="settings-hint"><?php p($l->t('For optimal performance it\'s important to configure background jobs correctly. For bigger instances \'Cron\' is the recommended setting. Please see the documentation for more information.')); ?></p> |
|
| 186 | 186 | <p> |
| 187 | 187 | <input type="radio" name="mode" value="ajax" class="radio" |
| 188 | 188 | id="backgroundjobs_ajax" <?php if ($_['backgroundjobs_mode'] === "ajax") { |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | }?>> |
| 210 | 210 | <label for="backgroundjobs_cron">Cron</label><br/> |
| 211 | 211 | <em><?php p($l->t("Use system cron service to call the cron.php file every 15 minutes.")); ?> |
| 212 | - <?php if($_['cli_based_cron_possible']) { |
|
| 212 | + <?php if ($_['cli_based_cron_possible']) { |
|
| 213 | 213 | p($l->t('The cron.php needs to be executed by the system user "%s".', [$_['cli_based_cron_user']])); |
| 214 | 214 | } else { |
| 215 | 215 | print_unescaped(str_replace( |
@@ -224,6 +224,6 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | <div class="section"> |
| 226 | 226 | <!-- should be the last part, so Updater can follow if enabled (it has no heading therefore). --> |
| 227 | - <h2><?php p($l->t('Version'));?></h2> |
|
| 227 | + <h2><?php p($l->t('Version')); ?></h2> |
|
| 228 | 228 | <p><strong><a href="<?php print_unescaped($theme->getBaseUrl()); ?>" rel="noreferrer noopener" target="_blank"><?php p($theme->getTitle()); ?></a> <?php p(OC_Util::getHumanVersion()) ?></strong></p> |
| 229 | 229 | </div> |
@@ -57,530 +57,530 @@ |
||
| 57 | 57 | * @since 4.0.0 |
| 58 | 58 | */ |
| 59 | 59 | class Util { |
| 60 | - // consts for Logging |
|
| 61 | - const DEBUG=0; |
|
| 62 | - const INFO=1; |
|
| 63 | - const WARN=2; |
|
| 64 | - const ERROR=3; |
|
| 65 | - const FATAL=4; |
|
| 66 | - |
|
| 67 | - /** \OCP\Share\IManager */ |
|
| 68 | - private static $shareManager; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * get the current installed version of ownCloud |
|
| 72 | - * @return array |
|
| 73 | - * @since 4.0.0 |
|
| 74 | - */ |
|
| 75 | - public static function getVersion() { |
|
| 76 | - return \OC_Util::getVersion(); |
|
| 77 | - } |
|
| 60 | + // consts for Logging |
|
| 61 | + const DEBUG=0; |
|
| 62 | + const INFO=1; |
|
| 63 | + const WARN=2; |
|
| 64 | + const ERROR=3; |
|
| 65 | + const FATAL=4; |
|
| 66 | + |
|
| 67 | + /** \OCP\Share\IManager */ |
|
| 68 | + private static $shareManager; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * get the current installed version of ownCloud |
|
| 72 | + * @return array |
|
| 73 | + * @since 4.0.0 |
|
| 74 | + */ |
|
| 75 | + public static function getVersion() { |
|
| 76 | + return \OC_Util::getVersion(); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Set current update channel |
|
| 81 | - * @param string $channel |
|
| 82 | - * @since 8.1.0 |
|
| 83 | - */ |
|
| 84 | - public static function setChannel($channel) { |
|
| 85 | - \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel); |
|
| 86 | - } |
|
| 79 | + /** |
|
| 80 | + * Set current update channel |
|
| 81 | + * @param string $channel |
|
| 82 | + * @since 8.1.0 |
|
| 83 | + */ |
|
| 84 | + public static function setChannel($channel) { |
|
| 85 | + \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Get current update channel |
|
| 90 | - * @return string |
|
| 91 | - * @since 8.1.0 |
|
| 92 | - */ |
|
| 93 | - public static function getChannel() { |
|
| 94 | - return \OC_Util::getChannel(); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * write a message in the log |
|
| 99 | - * @param string $app |
|
| 100 | - * @param string $message |
|
| 101 | - * @param int $level |
|
| 102 | - * @since 4.0.0 |
|
| 103 | - * @deprecated 13.0.0 use log of \OCP\ILogger |
|
| 104 | - */ |
|
| 105 | - public static function writeLog( $app, $message, $level ) { |
|
| 106 | - $context = ['app' => $app]; |
|
| 107 | - \OC::$server->getLogger()->log($level, $message, $context); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * write exception into the log |
|
| 112 | - * @param string $app app name |
|
| 113 | - * @param \Exception $ex exception to log |
|
| 114 | - * @param int $level log level, defaults to \OCP\Util::FATAL |
|
| 115 | - * @since ....0.0 - parameter $level was added in 7.0.0 |
|
| 116 | - * @deprecated 8.2.0 use logException of \OCP\ILogger |
|
| 117 | - */ |
|
| 118 | - public static function logException( $app, \Exception $ex, $level = \OCP\Util::FATAL ) { |
|
| 119 | - \OC::$server->getLogger()->logException($ex, ['app' => $app]); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * check if sharing is disabled for the current user |
|
| 124 | - * |
|
| 125 | - * @return boolean |
|
| 126 | - * @since 7.0.0 |
|
| 127 | - * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser |
|
| 128 | - */ |
|
| 129 | - public static function isSharingDisabledForUser() { |
|
| 130 | - if (self::$shareManager === null) { |
|
| 131 | - self::$shareManager = \OC::$server->getShareManager(); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - $user = \OC::$server->getUserSession()->getUser(); |
|
| 135 | - if ($user !== null) { |
|
| 136 | - $user = $user->getUID(); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - return self::$shareManager->sharingDisabledForUser($user); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * get l10n object |
|
| 144 | - * @param string $application |
|
| 145 | - * @param string|null $language |
|
| 146 | - * @return \OCP\IL10N |
|
| 147 | - * @since 6.0.0 - parameter $language was added in 8.0.0 |
|
| 148 | - */ |
|
| 149 | - public static function getL10N($application, $language = null) { |
|
| 150 | - return \OC::$server->getL10N($application, $language); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * add a css file |
|
| 155 | - * @param string $application |
|
| 156 | - * @param string $file |
|
| 157 | - * @since 4.0.0 |
|
| 158 | - */ |
|
| 159 | - public static function addStyle( $application, $file = null ) { |
|
| 160 | - \OC_Util::addStyle( $application, $file ); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * add a javascript file |
|
| 165 | - * @param string $application |
|
| 166 | - * @param string $file |
|
| 167 | - * @since 4.0.0 |
|
| 168 | - */ |
|
| 169 | - public static function addScript( $application, $file = null ) { |
|
| 170 | - \OC_Util::addScript( $application, $file ); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Add a translation JS file |
|
| 175 | - * @param string $application application id |
|
| 176 | - * @param string $languageCode language code, defaults to the current locale |
|
| 177 | - * @since 8.0.0 |
|
| 178 | - */ |
|
| 179 | - public static function addTranslations($application, $languageCode = null) { |
|
| 180 | - \OC_Util::addTranslations($application, $languageCode); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * Add a custom element to the header |
|
| 185 | - * If $text is null then the element will be written as empty element. |
|
| 186 | - * So use "" to get a closing tag. |
|
| 187 | - * @param string $tag tag name of the element |
|
| 188 | - * @param array $attributes array of attributes for the element |
|
| 189 | - * @param string $text the text content for the element |
|
| 190 | - * @since 4.0.0 |
|
| 191 | - */ |
|
| 192 | - public static function addHeader($tag, $attributes, $text=null) { |
|
| 193 | - \OC_Util::addHeader($tag, $attributes, $text); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Creates an absolute url to the given app and file. |
|
| 198 | - * @param string $app app |
|
| 199 | - * @param string $file file |
|
| 200 | - * @param array $args array with param=>value, will be appended to the returned url |
|
| 201 | - * The value of $args will be urlencoded |
|
| 202 | - * @return string the url |
|
| 203 | - * @since 4.0.0 - parameter $args was added in 4.5.0 |
|
| 204 | - */ |
|
| 205 | - public static function linkToAbsolute( $app, $file, $args = array() ) { |
|
| 206 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 207 | - return $urlGenerator->getAbsoluteURL( |
|
| 208 | - $urlGenerator->linkTo($app, $file, $args) |
|
| 209 | - ); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * Creates an absolute url for remote use. |
|
| 214 | - * @param string $service id |
|
| 215 | - * @return string the url |
|
| 216 | - * @since 4.0.0 |
|
| 217 | - */ |
|
| 218 | - public static function linkToRemote( $service ) { |
|
| 219 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 220 | - $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; |
|
| 221 | - return $urlGenerator->getAbsoluteURL( |
|
| 222 | - $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') |
|
| 223 | - ); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Creates an absolute url for public use |
|
| 228 | - * @param string $service id |
|
| 229 | - * @return string the url |
|
| 230 | - * @since 4.5.0 |
|
| 231 | - */ |
|
| 232 | - public static function linkToPublic($service) { |
|
| 233 | - return \OC_Helper::linkToPublic($service); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * Creates an url using a defined route |
|
| 238 | - * @param string $route |
|
| 239 | - * @param array $parameters |
|
| 240 | - * @internal param array $args with param=>value, will be appended to the returned url |
|
| 241 | - * @return string the url |
|
| 242 | - * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->linkToRoute($route, $parameters) |
|
| 243 | - * @since 5.0.0 |
|
| 244 | - */ |
|
| 245 | - public static function linkToRoute( $route, $parameters = array() ) { |
|
| 246 | - return \OC::$server->getURLGenerator()->linkToRoute($route, $parameters); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * Creates an url to the given app and file |
|
| 251 | - * @param string $app app |
|
| 252 | - * @param string $file file |
|
| 253 | - * @param array $args array with param=>value, will be appended to the returned url |
|
| 254 | - * The value of $args will be urlencoded |
|
| 255 | - * @return string the url |
|
| 256 | - * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->linkTo($app, $file, $args) |
|
| 257 | - * @since 4.0.0 - parameter $args was added in 4.5.0 |
|
| 258 | - */ |
|
| 259 | - public static function linkTo( $app, $file, $args = array() ) { |
|
| 260 | - return \OC::$server->getURLGenerator()->linkTo($app, $file, $args); |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * Returns the server host name without an eventual port number |
|
| 265 | - * @return string the server hostname |
|
| 266 | - * @since 5.0.0 |
|
| 267 | - */ |
|
| 268 | - public static function getServerHostName() { |
|
| 269 | - $host_name = \OC::$server->getRequest()->getServerHost(); |
|
| 270 | - // strip away port number (if existing) |
|
| 271 | - $colon_pos = strpos($host_name, ':'); |
|
| 272 | - if ($colon_pos != FALSE) { |
|
| 273 | - $host_name = substr($host_name, 0, $colon_pos); |
|
| 274 | - } |
|
| 275 | - return $host_name; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * Returns the default email address |
|
| 280 | - * @param string $user_part the user part of the address |
|
| 281 | - * @return string the default email address |
|
| 282 | - * |
|
| 283 | - * Assembles a default email address (using the server hostname |
|
| 284 | - * and the given user part, and returns it |
|
| 285 | - * Example: when given lostpassword-noreply as $user_part param, |
|
| 286 | - * and is currently accessed via http(s)://example.com/, |
|
| 287 | - * it would return '[email protected]' |
|
| 288 | - * |
|
| 289 | - * If the configuration value 'mail_from_address' is set in |
|
| 290 | - * config.php, this value will override the $user_part that |
|
| 291 | - * is passed to this function |
|
| 292 | - * @since 5.0.0 |
|
| 293 | - */ |
|
| 294 | - public static function getDefaultEmailAddress($user_part) { |
|
| 295 | - $config = \OC::$server->getConfig(); |
|
| 296 | - $user_part = $config->getSystemValue('mail_from_address', $user_part); |
|
| 297 | - $host_name = self::getServerHostName(); |
|
| 298 | - $host_name = $config->getSystemValue('mail_domain', $host_name); |
|
| 299 | - $defaultEmailAddress = $user_part.'@'.$host_name; |
|
| 300 | - |
|
| 301 | - $mailer = \OC::$server->getMailer(); |
|
| 302 | - if ($mailer->validateMailAddress($defaultEmailAddress)) { |
|
| 303 | - return $defaultEmailAddress; |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain' |
|
| 307 | - return $user_part.'@localhost.localdomain'; |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * Creates path to an image |
|
| 312 | - * @param string $app app |
|
| 313 | - * @param string $image image name |
|
| 314 | - * @return string the url |
|
| 315 | - * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->imagePath($app, $image) |
|
| 316 | - * @since 4.0.0 |
|
| 317 | - */ |
|
| 318 | - public static function imagePath( $app, $image ) { |
|
| 319 | - return \OC::$server->getURLGenerator()->imagePath($app, $image); |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * Make a human file size (2048 to 2 kB) |
|
| 324 | - * @param int $bytes file size in bytes |
|
| 325 | - * @return string a human readable file size |
|
| 326 | - * @since 4.0.0 |
|
| 327 | - */ |
|
| 328 | - public static function humanFileSize($bytes) { |
|
| 329 | - return \OC_Helper::humanFileSize($bytes); |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * Make a computer file size (2 kB to 2048) |
|
| 334 | - * @param string $str file size in a fancy format |
|
| 335 | - * @return float a file size in bytes |
|
| 336 | - * |
|
| 337 | - * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418 |
|
| 338 | - * @since 4.0.0 |
|
| 339 | - */ |
|
| 340 | - public static function computerFileSize($str) { |
|
| 341 | - return \OC_Helper::computerFileSize($str); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * connects a function to a hook |
|
| 346 | - * |
|
| 347 | - * @param string $signalClass class name of emitter |
|
| 348 | - * @param string $signalName name of signal |
|
| 349 | - * @param string|object $slotClass class name of slot |
|
| 350 | - * @param string $slotName name of slot |
|
| 351 | - * @return bool |
|
| 352 | - * |
|
| 353 | - * This function makes it very easy to connect to use hooks. |
|
| 354 | - * |
|
| 355 | - * TODO: write example |
|
| 356 | - * @since 4.0.0 |
|
| 357 | - */ |
|
| 358 | - static public function connectHook($signalClass, $signalName, $slotClass, $slotName) { |
|
| 359 | - return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * Emits a signal. To get data from the slot use references! |
|
| 364 | - * @param string $signalclass class name of emitter |
|
| 365 | - * @param string $signalname name of signal |
|
| 366 | - * @param array $params default: array() array with additional data |
|
| 367 | - * @return bool true if slots exists or false if not |
|
| 368 | - * |
|
| 369 | - * TODO: write example |
|
| 370 | - * @since 4.0.0 |
|
| 371 | - */ |
|
| 372 | - static public function emitHook($signalclass, $signalname, $params = array()) { |
|
| 373 | - return \OC_Hook::emit($signalclass, $signalname, $params); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare |
|
| 378 | - * multiple OC_Template elements which invoke `callRegister`. If the value |
|
| 379 | - * would not be cached these unit-tests would fail. |
|
| 380 | - * @var string |
|
| 381 | - */ |
|
| 382 | - private static $token = ''; |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * Register an get/post call. This is important to prevent CSRF attacks |
|
| 386 | - * @since 4.5.0 |
|
| 387 | - */ |
|
| 388 | - public static function callRegister() { |
|
| 389 | - if(self::$token === '') { |
|
| 390 | - self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue(); |
|
| 391 | - } |
|
| 392 | - return self::$token; |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * Check an ajax get/post call if the request token is valid. exit if not. |
|
| 397 | - * @since 4.5.0 |
|
| 398 | - * @deprecated 9.0.0 Use annotations based on the app framework. |
|
| 399 | - */ |
|
| 400 | - public static function callCheck() { |
|
| 401 | - if(!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
| 402 | - header('Location: '.\OC::$WEBROOT); |
|
| 403 | - exit(); |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - if (!\OC::$server->getRequest()->passesCSRFCheck()) { |
|
| 407 | - exit(); |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * Used to sanitize HTML |
|
| 413 | - * |
|
| 414 | - * This function is used to sanitize HTML and should be applied on any |
|
| 415 | - * string or array of strings before displaying it on a web page. |
|
| 416 | - * |
|
| 417 | - * @param string|array $value |
|
| 418 | - * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter. |
|
| 419 | - * @since 4.5.0 |
|
| 420 | - */ |
|
| 421 | - public static function sanitizeHTML($value) { |
|
| 422 | - return \OC_Util::sanitizeHTML($value); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * Public function to encode url parameters |
|
| 427 | - * |
|
| 428 | - * This function is used to encode path to file before output. |
|
| 429 | - * Encoding is done according to RFC 3986 with one exception: |
|
| 430 | - * Character '/' is preserved as is. |
|
| 431 | - * |
|
| 432 | - * @param string $component part of URI to encode |
|
| 433 | - * @return string |
|
| 434 | - * @since 6.0.0 |
|
| 435 | - */ |
|
| 436 | - public static function encodePath($component) { |
|
| 437 | - return \OC_Util::encodePath($component); |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - /** |
|
| 441 | - * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is. |
|
| 442 | - * |
|
| 443 | - * @param array $input The array to work on |
|
| 444 | - * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default) |
|
| 445 | - * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 |
|
| 446 | - * @return array |
|
| 447 | - * @since 4.5.0 |
|
| 448 | - */ |
|
| 449 | - public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') { |
|
| 450 | - return \OC_Helper::mb_array_change_key_case($input, $case, $encoding); |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - /** |
|
| 454 | - * replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement. |
|
| 455 | - * |
|
| 456 | - * @param string $string The input string. Opposite to the PHP build-in function does not accept an array. |
|
| 457 | - * @param string $replacement The replacement string. |
|
| 458 | - * @param int $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string. |
|
| 459 | - * @param int $length Length of the part to be replaced |
|
| 460 | - * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 |
|
| 461 | - * @return string |
|
| 462 | - * @since 4.5.0 |
|
| 463 | - * @deprecated 8.2.0 Use substr_replace() instead. |
|
| 464 | - */ |
|
| 465 | - public static function mb_substr_replace($string, $replacement, $start, $length = null, $encoding = 'UTF-8') { |
|
| 466 | - return substr_replace($string, $replacement, $start, $length); |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - /** |
|
| 470 | - * Replace all occurrences of the search string with the replacement string |
|
| 471 | - * |
|
| 472 | - * @param string $search The value being searched for, otherwise known as the needle. String. |
|
| 473 | - * @param string $replace The replacement string. |
|
| 474 | - * @param string $subject The string or array being searched and replaced on, otherwise known as the haystack. |
|
| 475 | - * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 |
|
| 476 | - * @param int $count If passed, this will be set to the number of replacements performed. |
|
| 477 | - * @return string |
|
| 478 | - * @since 4.5.0 |
|
| 479 | - * @deprecated 8.2.0 Use str_replace() instead. |
|
| 480 | - */ |
|
| 481 | - public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) { |
|
| 482 | - return str_replace($search, $replace, $subject, $count); |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - /** |
|
| 486 | - * performs a search in a nested array |
|
| 487 | - * |
|
| 488 | - * @param array $haystack the array to be searched |
|
| 489 | - * @param string $needle the search string |
|
| 490 | - * @param mixed $index optional, only search this key name |
|
| 491 | - * @return mixed the key of the matching field, otherwise false |
|
| 492 | - * @since 4.5.0 |
|
| 493 | - */ |
|
| 494 | - public static function recursiveArraySearch($haystack, $needle, $index = null) { |
|
| 495 | - return \OC_Helper::recursiveArraySearch($haystack, $needle, $index); |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - /** |
|
| 499 | - * calculates the maximum upload size respecting system settings, free space and user quota |
|
| 500 | - * |
|
| 501 | - * @param string $dir the current folder where the user currently operates |
|
| 502 | - * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly |
|
| 503 | - * @return int number of bytes representing |
|
| 504 | - * @since 5.0.0 |
|
| 505 | - */ |
|
| 506 | - public static function maxUploadFilesize($dir, $free = null) { |
|
| 507 | - return \OC_Helper::maxUploadFilesize($dir, $free); |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - /** |
|
| 511 | - * Calculate free space left within user quota |
|
| 512 | - * @param string $dir the current folder where the user currently operates |
|
| 513 | - * @return int number of bytes representing |
|
| 514 | - * @since 7.0.0 |
|
| 515 | - */ |
|
| 516 | - public static function freeSpace($dir) { |
|
| 517 | - return \OC_Helper::freeSpace($dir); |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - /** |
|
| 521 | - * Calculate PHP upload limit |
|
| 522 | - * |
|
| 523 | - * @return int number of bytes representing |
|
| 524 | - * @since 7.0.0 |
|
| 525 | - */ |
|
| 526 | - public static function uploadLimit() { |
|
| 527 | - return \OC_Helper::uploadLimit(); |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - /** |
|
| 531 | - * Returns whether the given file name is valid |
|
| 532 | - * @param string $file file name to check |
|
| 533 | - * @return bool true if the file name is valid, false otherwise |
|
| 534 | - * @deprecated 8.1.0 use \OC\Files\View::verifyPath() |
|
| 535 | - * @since 7.0.0 |
|
| 536 | - * @suppress PhanDeprecatedFunction |
|
| 537 | - */ |
|
| 538 | - public static function isValidFileName($file) { |
|
| 539 | - return \OC_Util::isValidFileName($file); |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - /** |
|
| 543 | - * Compare two strings to provide a natural sort |
|
| 544 | - * @param string $a first string to compare |
|
| 545 | - * @param string $b second string to compare |
|
| 546 | - * @return int -1 if $b comes before $a, 1 if $a comes before $b |
|
| 547 | - * or 0 if the strings are identical |
|
| 548 | - * @since 7.0.0 |
|
| 549 | - */ |
|
| 550 | - public static function naturalSortCompare($a, $b) { |
|
| 551 | - return \OC\NaturalSort::getInstance()->compare($a, $b); |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - /** |
|
| 555 | - * check if a password is required for each public link |
|
| 556 | - * @return boolean |
|
| 557 | - * @since 7.0.0 |
|
| 558 | - */ |
|
| 559 | - public static function isPublicLinkPasswordRequired() { |
|
| 560 | - return \OC_Util::isPublicLinkPasswordRequired(); |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - /** |
|
| 564 | - * check if share API enforces a default expire date |
|
| 565 | - * @return boolean |
|
| 566 | - * @since 8.0.0 |
|
| 567 | - */ |
|
| 568 | - public static function isDefaultExpireDateEnforced() { |
|
| 569 | - return \OC_Util::isDefaultExpireDateEnforced(); |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - protected static $needUpgradeCache = null; |
|
| 573 | - |
|
| 574 | - /** |
|
| 575 | - * Checks whether the current version needs upgrade. |
|
| 576 | - * |
|
| 577 | - * @return bool true if upgrade is needed, false otherwise |
|
| 578 | - * @since 7.0.0 |
|
| 579 | - */ |
|
| 580 | - public static function needUpgrade() { |
|
| 581 | - if (!isset(self::$needUpgradeCache)) { |
|
| 582 | - self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getSystemConfig()); |
|
| 583 | - } |
|
| 584 | - return self::$needUpgradeCache; |
|
| 585 | - } |
|
| 88 | + /** |
|
| 89 | + * Get current update channel |
|
| 90 | + * @return string |
|
| 91 | + * @since 8.1.0 |
|
| 92 | + */ |
|
| 93 | + public static function getChannel() { |
|
| 94 | + return \OC_Util::getChannel(); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * write a message in the log |
|
| 99 | + * @param string $app |
|
| 100 | + * @param string $message |
|
| 101 | + * @param int $level |
|
| 102 | + * @since 4.0.0 |
|
| 103 | + * @deprecated 13.0.0 use log of \OCP\ILogger |
|
| 104 | + */ |
|
| 105 | + public static function writeLog( $app, $message, $level ) { |
|
| 106 | + $context = ['app' => $app]; |
|
| 107 | + \OC::$server->getLogger()->log($level, $message, $context); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * write exception into the log |
|
| 112 | + * @param string $app app name |
|
| 113 | + * @param \Exception $ex exception to log |
|
| 114 | + * @param int $level log level, defaults to \OCP\Util::FATAL |
|
| 115 | + * @since ....0.0 - parameter $level was added in 7.0.0 |
|
| 116 | + * @deprecated 8.2.0 use logException of \OCP\ILogger |
|
| 117 | + */ |
|
| 118 | + public static function logException( $app, \Exception $ex, $level = \OCP\Util::FATAL ) { |
|
| 119 | + \OC::$server->getLogger()->logException($ex, ['app' => $app]); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * check if sharing is disabled for the current user |
|
| 124 | + * |
|
| 125 | + * @return boolean |
|
| 126 | + * @since 7.0.0 |
|
| 127 | + * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser |
|
| 128 | + */ |
|
| 129 | + public static function isSharingDisabledForUser() { |
|
| 130 | + if (self::$shareManager === null) { |
|
| 131 | + self::$shareManager = \OC::$server->getShareManager(); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + $user = \OC::$server->getUserSession()->getUser(); |
|
| 135 | + if ($user !== null) { |
|
| 136 | + $user = $user->getUID(); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + return self::$shareManager->sharingDisabledForUser($user); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * get l10n object |
|
| 144 | + * @param string $application |
|
| 145 | + * @param string|null $language |
|
| 146 | + * @return \OCP\IL10N |
|
| 147 | + * @since 6.0.0 - parameter $language was added in 8.0.0 |
|
| 148 | + */ |
|
| 149 | + public static function getL10N($application, $language = null) { |
|
| 150 | + return \OC::$server->getL10N($application, $language); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * add a css file |
|
| 155 | + * @param string $application |
|
| 156 | + * @param string $file |
|
| 157 | + * @since 4.0.0 |
|
| 158 | + */ |
|
| 159 | + public static function addStyle( $application, $file = null ) { |
|
| 160 | + \OC_Util::addStyle( $application, $file ); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * add a javascript file |
|
| 165 | + * @param string $application |
|
| 166 | + * @param string $file |
|
| 167 | + * @since 4.0.0 |
|
| 168 | + */ |
|
| 169 | + public static function addScript( $application, $file = null ) { |
|
| 170 | + \OC_Util::addScript( $application, $file ); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Add a translation JS file |
|
| 175 | + * @param string $application application id |
|
| 176 | + * @param string $languageCode language code, defaults to the current locale |
|
| 177 | + * @since 8.0.0 |
|
| 178 | + */ |
|
| 179 | + public static function addTranslations($application, $languageCode = null) { |
|
| 180 | + \OC_Util::addTranslations($application, $languageCode); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * Add a custom element to the header |
|
| 185 | + * If $text is null then the element will be written as empty element. |
|
| 186 | + * So use "" to get a closing tag. |
|
| 187 | + * @param string $tag tag name of the element |
|
| 188 | + * @param array $attributes array of attributes for the element |
|
| 189 | + * @param string $text the text content for the element |
|
| 190 | + * @since 4.0.0 |
|
| 191 | + */ |
|
| 192 | + public static function addHeader($tag, $attributes, $text=null) { |
|
| 193 | + \OC_Util::addHeader($tag, $attributes, $text); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Creates an absolute url to the given app and file. |
|
| 198 | + * @param string $app app |
|
| 199 | + * @param string $file file |
|
| 200 | + * @param array $args array with param=>value, will be appended to the returned url |
|
| 201 | + * The value of $args will be urlencoded |
|
| 202 | + * @return string the url |
|
| 203 | + * @since 4.0.0 - parameter $args was added in 4.5.0 |
|
| 204 | + */ |
|
| 205 | + public static function linkToAbsolute( $app, $file, $args = array() ) { |
|
| 206 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 207 | + return $urlGenerator->getAbsoluteURL( |
|
| 208 | + $urlGenerator->linkTo($app, $file, $args) |
|
| 209 | + ); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * Creates an absolute url for remote use. |
|
| 214 | + * @param string $service id |
|
| 215 | + * @return string the url |
|
| 216 | + * @since 4.0.0 |
|
| 217 | + */ |
|
| 218 | + public static function linkToRemote( $service ) { |
|
| 219 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 220 | + $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; |
|
| 221 | + return $urlGenerator->getAbsoluteURL( |
|
| 222 | + $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') |
|
| 223 | + ); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Creates an absolute url for public use |
|
| 228 | + * @param string $service id |
|
| 229 | + * @return string the url |
|
| 230 | + * @since 4.5.0 |
|
| 231 | + */ |
|
| 232 | + public static function linkToPublic($service) { |
|
| 233 | + return \OC_Helper::linkToPublic($service); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * Creates an url using a defined route |
|
| 238 | + * @param string $route |
|
| 239 | + * @param array $parameters |
|
| 240 | + * @internal param array $args with param=>value, will be appended to the returned url |
|
| 241 | + * @return string the url |
|
| 242 | + * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->linkToRoute($route, $parameters) |
|
| 243 | + * @since 5.0.0 |
|
| 244 | + */ |
|
| 245 | + public static function linkToRoute( $route, $parameters = array() ) { |
|
| 246 | + return \OC::$server->getURLGenerator()->linkToRoute($route, $parameters); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * Creates an url to the given app and file |
|
| 251 | + * @param string $app app |
|
| 252 | + * @param string $file file |
|
| 253 | + * @param array $args array with param=>value, will be appended to the returned url |
|
| 254 | + * The value of $args will be urlencoded |
|
| 255 | + * @return string the url |
|
| 256 | + * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->linkTo($app, $file, $args) |
|
| 257 | + * @since 4.0.0 - parameter $args was added in 4.5.0 |
|
| 258 | + */ |
|
| 259 | + public static function linkTo( $app, $file, $args = array() ) { |
|
| 260 | + return \OC::$server->getURLGenerator()->linkTo($app, $file, $args); |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * Returns the server host name without an eventual port number |
|
| 265 | + * @return string the server hostname |
|
| 266 | + * @since 5.0.0 |
|
| 267 | + */ |
|
| 268 | + public static function getServerHostName() { |
|
| 269 | + $host_name = \OC::$server->getRequest()->getServerHost(); |
|
| 270 | + // strip away port number (if existing) |
|
| 271 | + $colon_pos = strpos($host_name, ':'); |
|
| 272 | + if ($colon_pos != FALSE) { |
|
| 273 | + $host_name = substr($host_name, 0, $colon_pos); |
|
| 274 | + } |
|
| 275 | + return $host_name; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * Returns the default email address |
|
| 280 | + * @param string $user_part the user part of the address |
|
| 281 | + * @return string the default email address |
|
| 282 | + * |
|
| 283 | + * Assembles a default email address (using the server hostname |
|
| 284 | + * and the given user part, and returns it |
|
| 285 | + * Example: when given lostpassword-noreply as $user_part param, |
|
| 286 | + * and is currently accessed via http(s)://example.com/, |
|
| 287 | + * it would return '[email protected]' |
|
| 288 | + * |
|
| 289 | + * If the configuration value 'mail_from_address' is set in |
|
| 290 | + * config.php, this value will override the $user_part that |
|
| 291 | + * is passed to this function |
|
| 292 | + * @since 5.0.0 |
|
| 293 | + */ |
|
| 294 | + public static function getDefaultEmailAddress($user_part) { |
|
| 295 | + $config = \OC::$server->getConfig(); |
|
| 296 | + $user_part = $config->getSystemValue('mail_from_address', $user_part); |
|
| 297 | + $host_name = self::getServerHostName(); |
|
| 298 | + $host_name = $config->getSystemValue('mail_domain', $host_name); |
|
| 299 | + $defaultEmailAddress = $user_part.'@'.$host_name; |
|
| 300 | + |
|
| 301 | + $mailer = \OC::$server->getMailer(); |
|
| 302 | + if ($mailer->validateMailAddress($defaultEmailAddress)) { |
|
| 303 | + return $defaultEmailAddress; |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain' |
|
| 307 | + return $user_part.'@localhost.localdomain'; |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + /** |
|
| 311 | + * Creates path to an image |
|
| 312 | + * @param string $app app |
|
| 313 | + * @param string $image image name |
|
| 314 | + * @return string the url |
|
| 315 | + * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->imagePath($app, $image) |
|
| 316 | + * @since 4.0.0 |
|
| 317 | + */ |
|
| 318 | + public static function imagePath( $app, $image ) { |
|
| 319 | + return \OC::$server->getURLGenerator()->imagePath($app, $image); |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * Make a human file size (2048 to 2 kB) |
|
| 324 | + * @param int $bytes file size in bytes |
|
| 325 | + * @return string a human readable file size |
|
| 326 | + * @since 4.0.0 |
|
| 327 | + */ |
|
| 328 | + public static function humanFileSize($bytes) { |
|
| 329 | + return \OC_Helper::humanFileSize($bytes); |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * Make a computer file size (2 kB to 2048) |
|
| 334 | + * @param string $str file size in a fancy format |
|
| 335 | + * @return float a file size in bytes |
|
| 336 | + * |
|
| 337 | + * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418 |
|
| 338 | + * @since 4.0.0 |
|
| 339 | + */ |
|
| 340 | + public static function computerFileSize($str) { |
|
| 341 | + return \OC_Helper::computerFileSize($str); |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * connects a function to a hook |
|
| 346 | + * |
|
| 347 | + * @param string $signalClass class name of emitter |
|
| 348 | + * @param string $signalName name of signal |
|
| 349 | + * @param string|object $slotClass class name of slot |
|
| 350 | + * @param string $slotName name of slot |
|
| 351 | + * @return bool |
|
| 352 | + * |
|
| 353 | + * This function makes it very easy to connect to use hooks. |
|
| 354 | + * |
|
| 355 | + * TODO: write example |
|
| 356 | + * @since 4.0.0 |
|
| 357 | + */ |
|
| 358 | + static public function connectHook($signalClass, $signalName, $slotClass, $slotName) { |
|
| 359 | + return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName); |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * Emits a signal. To get data from the slot use references! |
|
| 364 | + * @param string $signalclass class name of emitter |
|
| 365 | + * @param string $signalname name of signal |
|
| 366 | + * @param array $params default: array() array with additional data |
|
| 367 | + * @return bool true if slots exists or false if not |
|
| 368 | + * |
|
| 369 | + * TODO: write example |
|
| 370 | + * @since 4.0.0 |
|
| 371 | + */ |
|
| 372 | + static public function emitHook($signalclass, $signalname, $params = array()) { |
|
| 373 | + return \OC_Hook::emit($signalclass, $signalname, $params); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare |
|
| 378 | + * multiple OC_Template elements which invoke `callRegister`. If the value |
|
| 379 | + * would not be cached these unit-tests would fail. |
|
| 380 | + * @var string |
|
| 381 | + */ |
|
| 382 | + private static $token = ''; |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * Register an get/post call. This is important to prevent CSRF attacks |
|
| 386 | + * @since 4.5.0 |
|
| 387 | + */ |
|
| 388 | + public static function callRegister() { |
|
| 389 | + if(self::$token === '') { |
|
| 390 | + self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue(); |
|
| 391 | + } |
|
| 392 | + return self::$token; |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * Check an ajax get/post call if the request token is valid. exit if not. |
|
| 397 | + * @since 4.5.0 |
|
| 398 | + * @deprecated 9.0.0 Use annotations based on the app framework. |
|
| 399 | + */ |
|
| 400 | + public static function callCheck() { |
|
| 401 | + if(!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
| 402 | + header('Location: '.\OC::$WEBROOT); |
|
| 403 | + exit(); |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + if (!\OC::$server->getRequest()->passesCSRFCheck()) { |
|
| 407 | + exit(); |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * Used to sanitize HTML |
|
| 413 | + * |
|
| 414 | + * This function is used to sanitize HTML and should be applied on any |
|
| 415 | + * string or array of strings before displaying it on a web page. |
|
| 416 | + * |
|
| 417 | + * @param string|array $value |
|
| 418 | + * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter. |
|
| 419 | + * @since 4.5.0 |
|
| 420 | + */ |
|
| 421 | + public static function sanitizeHTML($value) { |
|
| 422 | + return \OC_Util::sanitizeHTML($value); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * Public function to encode url parameters |
|
| 427 | + * |
|
| 428 | + * This function is used to encode path to file before output. |
|
| 429 | + * Encoding is done according to RFC 3986 with one exception: |
|
| 430 | + * Character '/' is preserved as is. |
|
| 431 | + * |
|
| 432 | + * @param string $component part of URI to encode |
|
| 433 | + * @return string |
|
| 434 | + * @since 6.0.0 |
|
| 435 | + */ |
|
| 436 | + public static function encodePath($component) { |
|
| 437 | + return \OC_Util::encodePath($component); |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + /** |
|
| 441 | + * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is. |
|
| 442 | + * |
|
| 443 | + * @param array $input The array to work on |
|
| 444 | + * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default) |
|
| 445 | + * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 |
|
| 446 | + * @return array |
|
| 447 | + * @since 4.5.0 |
|
| 448 | + */ |
|
| 449 | + public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') { |
|
| 450 | + return \OC_Helper::mb_array_change_key_case($input, $case, $encoding); |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + /** |
|
| 454 | + * replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement. |
|
| 455 | + * |
|
| 456 | + * @param string $string The input string. Opposite to the PHP build-in function does not accept an array. |
|
| 457 | + * @param string $replacement The replacement string. |
|
| 458 | + * @param int $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string. |
|
| 459 | + * @param int $length Length of the part to be replaced |
|
| 460 | + * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 |
|
| 461 | + * @return string |
|
| 462 | + * @since 4.5.0 |
|
| 463 | + * @deprecated 8.2.0 Use substr_replace() instead. |
|
| 464 | + */ |
|
| 465 | + public static function mb_substr_replace($string, $replacement, $start, $length = null, $encoding = 'UTF-8') { |
|
| 466 | + return substr_replace($string, $replacement, $start, $length); |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + /** |
|
| 470 | + * Replace all occurrences of the search string with the replacement string |
|
| 471 | + * |
|
| 472 | + * @param string $search The value being searched for, otherwise known as the needle. String. |
|
| 473 | + * @param string $replace The replacement string. |
|
| 474 | + * @param string $subject The string or array being searched and replaced on, otherwise known as the haystack. |
|
| 475 | + * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 |
|
| 476 | + * @param int $count If passed, this will be set to the number of replacements performed. |
|
| 477 | + * @return string |
|
| 478 | + * @since 4.5.0 |
|
| 479 | + * @deprecated 8.2.0 Use str_replace() instead. |
|
| 480 | + */ |
|
| 481 | + public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) { |
|
| 482 | + return str_replace($search, $replace, $subject, $count); |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + /** |
|
| 486 | + * performs a search in a nested array |
|
| 487 | + * |
|
| 488 | + * @param array $haystack the array to be searched |
|
| 489 | + * @param string $needle the search string |
|
| 490 | + * @param mixed $index optional, only search this key name |
|
| 491 | + * @return mixed the key of the matching field, otherwise false |
|
| 492 | + * @since 4.5.0 |
|
| 493 | + */ |
|
| 494 | + public static function recursiveArraySearch($haystack, $needle, $index = null) { |
|
| 495 | + return \OC_Helper::recursiveArraySearch($haystack, $needle, $index); |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + /** |
|
| 499 | + * calculates the maximum upload size respecting system settings, free space and user quota |
|
| 500 | + * |
|
| 501 | + * @param string $dir the current folder where the user currently operates |
|
| 502 | + * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly |
|
| 503 | + * @return int number of bytes representing |
|
| 504 | + * @since 5.0.0 |
|
| 505 | + */ |
|
| 506 | + public static function maxUploadFilesize($dir, $free = null) { |
|
| 507 | + return \OC_Helper::maxUploadFilesize($dir, $free); |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + /** |
|
| 511 | + * Calculate free space left within user quota |
|
| 512 | + * @param string $dir the current folder where the user currently operates |
|
| 513 | + * @return int number of bytes representing |
|
| 514 | + * @since 7.0.0 |
|
| 515 | + */ |
|
| 516 | + public static function freeSpace($dir) { |
|
| 517 | + return \OC_Helper::freeSpace($dir); |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + /** |
|
| 521 | + * Calculate PHP upload limit |
|
| 522 | + * |
|
| 523 | + * @return int number of bytes representing |
|
| 524 | + * @since 7.0.0 |
|
| 525 | + */ |
|
| 526 | + public static function uploadLimit() { |
|
| 527 | + return \OC_Helper::uploadLimit(); |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + /** |
|
| 531 | + * Returns whether the given file name is valid |
|
| 532 | + * @param string $file file name to check |
|
| 533 | + * @return bool true if the file name is valid, false otherwise |
|
| 534 | + * @deprecated 8.1.0 use \OC\Files\View::verifyPath() |
|
| 535 | + * @since 7.0.0 |
|
| 536 | + * @suppress PhanDeprecatedFunction |
|
| 537 | + */ |
|
| 538 | + public static function isValidFileName($file) { |
|
| 539 | + return \OC_Util::isValidFileName($file); |
|
| 540 | + } |
|
| 541 | + |
|
| 542 | + /** |
|
| 543 | + * Compare two strings to provide a natural sort |
|
| 544 | + * @param string $a first string to compare |
|
| 545 | + * @param string $b second string to compare |
|
| 546 | + * @return int -1 if $b comes before $a, 1 if $a comes before $b |
|
| 547 | + * or 0 if the strings are identical |
|
| 548 | + * @since 7.0.0 |
|
| 549 | + */ |
|
| 550 | + public static function naturalSortCompare($a, $b) { |
|
| 551 | + return \OC\NaturalSort::getInstance()->compare($a, $b); |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + /** |
|
| 555 | + * check if a password is required for each public link |
|
| 556 | + * @return boolean |
|
| 557 | + * @since 7.0.0 |
|
| 558 | + */ |
|
| 559 | + public static function isPublicLinkPasswordRequired() { |
|
| 560 | + return \OC_Util::isPublicLinkPasswordRequired(); |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + /** |
|
| 564 | + * check if share API enforces a default expire date |
|
| 565 | + * @return boolean |
|
| 566 | + * @since 8.0.0 |
|
| 567 | + */ |
|
| 568 | + public static function isDefaultExpireDateEnforced() { |
|
| 569 | + return \OC_Util::isDefaultExpireDateEnforced(); |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + protected static $needUpgradeCache = null; |
|
| 573 | + |
|
| 574 | + /** |
|
| 575 | + * Checks whether the current version needs upgrade. |
|
| 576 | + * |
|
| 577 | + * @return bool true if upgrade is needed, false otherwise |
|
| 578 | + * @since 7.0.0 |
|
| 579 | + */ |
|
| 580 | + public static function needUpgrade() { |
|
| 581 | + if (!isset(self::$needUpgradeCache)) { |
|
| 582 | + self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getSystemConfig()); |
|
| 583 | + } |
|
| 584 | + return self::$needUpgradeCache; |
|
| 585 | + } |
|
| 586 | 586 | } |
@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | class Util { |
| 60 | 60 | // consts for Logging |
| 61 | - const DEBUG=0; |
|
| 62 | - const INFO=1; |
|
| 63 | - const WARN=2; |
|
| 64 | - const ERROR=3; |
|
| 65 | - const FATAL=4; |
|
| 61 | + const DEBUG = 0; |
|
| 62 | + const INFO = 1; |
|
| 63 | + const WARN = 2; |
|
| 64 | + const ERROR = 3; |
|
| 65 | + const FATAL = 4; |
|
| 66 | 66 | |
| 67 | 67 | /** \OCP\Share\IManager */ |
| 68 | 68 | private static $shareManager; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @since 4.0.0 |
| 103 | 103 | * @deprecated 13.0.0 use log of \OCP\ILogger |
| 104 | 104 | */ |
| 105 | - public static function writeLog( $app, $message, $level ) { |
|
| 105 | + public static function writeLog($app, $message, $level) { |
|
| 106 | 106 | $context = ['app' => $app]; |
| 107 | 107 | \OC::$server->getLogger()->log($level, $message, $context); |
| 108 | 108 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @since ....0.0 - parameter $level was added in 7.0.0 |
| 116 | 116 | * @deprecated 8.2.0 use logException of \OCP\ILogger |
| 117 | 117 | */ |
| 118 | - public static function logException( $app, \Exception $ex, $level = \OCP\Util::FATAL ) { |
|
| 118 | + public static function logException($app, \Exception $ex, $level = \OCP\Util::FATAL) { |
|
| 119 | 119 | \OC::$server->getLogger()->logException($ex, ['app' => $app]); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | * @param string $file |
| 157 | 157 | * @since 4.0.0 |
| 158 | 158 | */ |
| 159 | - public static function addStyle( $application, $file = null ) { |
|
| 160 | - \OC_Util::addStyle( $application, $file ); |
|
| 159 | + public static function addStyle($application, $file = null) { |
|
| 160 | + \OC_Util::addStyle($application, $file); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | * @param string $file |
| 167 | 167 | * @since 4.0.0 |
| 168 | 168 | */ |
| 169 | - public static function addScript( $application, $file = null ) { |
|
| 170 | - \OC_Util::addScript( $application, $file ); |
|
| 169 | + public static function addScript($application, $file = null) { |
|
| 170 | + \OC_Util::addScript($application, $file); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param string $text the text content for the element |
| 190 | 190 | * @since 4.0.0 |
| 191 | 191 | */ |
| 192 | - public static function addHeader($tag, $attributes, $text=null) { |
|
| 192 | + public static function addHeader($tag, $attributes, $text = null) { |
|
| 193 | 193 | \OC_Util::addHeader($tag, $attributes, $text); |
| 194 | 194 | } |
| 195 | 195 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return string the url |
| 203 | 203 | * @since 4.0.0 - parameter $args was added in 4.5.0 |
| 204 | 204 | */ |
| 205 | - public static function linkToAbsolute( $app, $file, $args = array() ) { |
|
| 205 | + public static function linkToAbsolute($app, $file, $args = array()) { |
|
| 206 | 206 | $urlGenerator = \OC::$server->getURLGenerator(); |
| 207 | 207 | return $urlGenerator->getAbsoluteURL( |
| 208 | 208 | $urlGenerator->linkTo($app, $file, $args) |
@@ -215,11 +215,11 @@ discard block |
||
| 215 | 215 | * @return string the url |
| 216 | 216 | * @since 4.0.0 |
| 217 | 217 | */ |
| 218 | - public static function linkToRemote( $service ) { |
|
| 218 | + public static function linkToRemote($service) { |
|
| 219 | 219 | $urlGenerator = \OC::$server->getURLGenerator(); |
| 220 | - $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; |
|
| 220 | + $remoteBase = $urlGenerator->linkTo('', 'remote.php').'/'.$service; |
|
| 221 | 221 | return $urlGenerator->getAbsoluteURL( |
| 222 | - $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') |
|
| 222 | + $remoteBase.(($service[strlen($service) - 1] != '/') ? '/' : '') |
|
| 223 | 223 | ); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->linkToRoute($route, $parameters) |
| 243 | 243 | * @since 5.0.0 |
| 244 | 244 | */ |
| 245 | - public static function linkToRoute( $route, $parameters = array() ) { |
|
| 245 | + public static function linkToRoute($route, $parameters = array()) { |
|
| 246 | 246 | return \OC::$server->getURLGenerator()->linkToRoute($route, $parameters); |
| 247 | 247 | } |
| 248 | 248 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->linkTo($app, $file, $args) |
| 257 | 257 | * @since 4.0.0 - parameter $args was added in 4.5.0 |
| 258 | 258 | */ |
| 259 | - public static function linkTo( $app, $file, $args = array() ) { |
|
| 259 | + public static function linkTo($app, $file, $args = array()) { |
|
| 260 | 260 | return \OC::$server->getURLGenerator()->linkTo($app, $file, $args); |
| 261 | 261 | } |
| 262 | 262 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->imagePath($app, $image) |
| 316 | 316 | * @since 4.0.0 |
| 317 | 317 | */ |
| 318 | - public static function imagePath( $app, $image ) { |
|
| 318 | + public static function imagePath($app, $image) { |
|
| 319 | 319 | return \OC::$server->getURLGenerator()->imagePath($app, $image); |
| 320 | 320 | } |
| 321 | 321 | |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | * @since 4.5.0 |
| 387 | 387 | */ |
| 388 | 388 | public static function callRegister() { |
| 389 | - if(self::$token === '') { |
|
| 389 | + if (self::$token === '') { |
|
| 390 | 390 | self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue(); |
| 391 | 391 | } |
| 392 | 392 | return self::$token; |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | * @deprecated 9.0.0 Use annotations based on the app framework. |
| 399 | 399 | */ |
| 400 | 400 | public static function callCheck() { |
| 401 | - if(!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
| 401 | + if (!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
| 402 | 402 | header('Location: '.\OC::$WEBROOT); |
| 403 | 403 | exit(); |
| 404 | 404 | } |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | */ |
| 580 | 580 | public static function needUpgrade() { |
| 581 | 581 | if (!isset(self::$needUpgradeCache)) { |
| 582 | - self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getSystemConfig()); |
|
| 582 | + self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig()); |
|
| 583 | 583 | } |
| 584 | 584 | return self::$needUpgradeCache; |
| 585 | 585 | } |
@@ -24,156 +24,156 @@ |
||
| 24 | 24 | namespace OC\App\CodeChecker; |
| 25 | 25 | |
| 26 | 26 | class DeprecationCheck extends AbstractCheck { |
| 27 | - /** |
|
| 28 | - * @return string |
|
| 29 | - */ |
|
| 30 | - protected function getLocalDescription() { |
|
| 31 | - return 'deprecated'; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @return array E.g.: `'ClassName' => 'oc version',` |
|
| 36 | - */ |
|
| 37 | - protected function getLocalClasses() { |
|
| 38 | - return [ |
|
| 39 | - 'OC_JSON' => '8.2.0', |
|
| 40 | - |
|
| 41 | - 'OCP\Contacts' => '8.1.0', |
|
| 42 | - 'OCP\DB' => '8.1.0', |
|
| 43 | - 'OCP\JSON' => '8.1.0', |
|
| 44 | - 'OCP\Response' => '8.1.0', |
|
| 45 | - 'OCP\AppFramework\IApi' => '8.0.0', |
|
| 46 | - 'OCP\User' => '13.0.0', |
|
| 47 | - 'OCP\BackgroundJob' => '14.0.0', |
|
| 48 | - 'OCP\App' => '14.0.0', |
|
| 49 | - ]; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` |
|
| 54 | - */ |
|
| 55 | - protected function getLocalConstants() { |
|
| 56 | - return [ |
|
| 57 | - 'OC_API::GUEST_AUTH' => '8.2.0', |
|
| 58 | - 'OC_API::USER_AUTH' => '8.2.0', |
|
| 59 | - 'OC_API::SUBADMIN_AUTH' => '8.2.0', |
|
| 60 | - 'OC_API::ADMIN_AUTH' => '8.2.0', |
|
| 61 | - 'OC_API::RESPOND_UNAUTHORISED' => '8.2.0', |
|
| 62 | - 'OC_API::RESPOND_SERVER_ERROR' => '8.2.0', |
|
| 63 | - 'OC_API::RESPOND_NOT_FOUND' => '8.2.0', |
|
| 64 | - 'OC_API::RESPOND_UNKNOWN_ERROR' => '8.2.0', |
|
| 65 | - |
|
| 66 | - 'OCP::PERMISSION_CREATE' => '8.0.0', |
|
| 67 | - 'OCP::PERMISSION_READ' => '8.0.0', |
|
| 68 | - 'OCP::PERMISSION_UPDATE' => '8.0.0', |
|
| 69 | - 'OCP::PERMISSION_DELETE' => '8.0.0', |
|
| 70 | - 'OCP::PERMISSION_SHARE' => '8.0.0', |
|
| 71 | - 'OCP::PERMISSION_ALL' => '8.0.0', |
|
| 72 | - 'OCP::FILENAME_INVALID_CHARS' => '8.0.0', |
|
| 73 | - ]; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @return array E.g.: `'functionName' => 'oc version',` |
|
| 78 | - */ |
|
| 79 | - protected function getLocalFunctions() { |
|
| 80 | - return [ |
|
| 81 | - 'OCP::image_path' => '8.0.0', |
|
| 82 | - 'OCP::mimetype_icon' => '8.0.0', |
|
| 83 | - 'OCP::preview_icon' => '8.0.0', |
|
| 84 | - 'OCP::publicPreview_icon' => '8.0.0', |
|
| 85 | - 'OCP::human_file_size' => '8.0.0', |
|
| 86 | - 'OCP::relative_modified_date' => '8.0.0', |
|
| 87 | - 'OCP::simple_file_size' => '8.0.0', |
|
| 88 | - 'OCP::html_select_options' => '8.0.0', |
|
| 89 | - ]; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @return array E.g.: `'ClassName::methodName' => 'oc version',` |
|
| 94 | - */ |
|
| 95 | - protected function getLocalMethods() { |
|
| 96 | - return [ |
|
| 97 | - 'OC_L10N::get' => '8.2.0', |
|
| 98 | - |
|
| 99 | - 'OCP\Activity\IManager::publishActivity' => '8.2.0', |
|
| 100 | - |
|
| 101 | - 'OCP\App::register' => '8.1.0', |
|
| 102 | - 'OCP\App::addNavigationEntry' => '8.1.0', |
|
| 103 | - 'OCP\App::getActiveNavigationEntry' => '8.2.0', |
|
| 104 | - 'OCP\App::setActiveNavigationEntry' => '8.1.0', |
|
| 105 | - 'OCP\App::registerPersonal' => '14.0.0', |
|
| 106 | - 'OCP\App::registerAdmin' => '14.0.0', |
|
| 107 | - 'OC_App::getAppInfo' => '14.0.0', |
|
| 108 | - 'OCP\App::getAppInfo' => '14.0.0', |
|
| 109 | - 'OC_App::getAppVersion' => '14.0.0', |
|
| 110 | - 'OCP\App::getAppVersion' => '14.0.0', |
|
| 111 | - 'OCP\App::registerPersonal' => '14.0.0', |
|
| 112 | - |
|
| 113 | - 'OCP\AppFramework\Controller::params' => '7.0.0', |
|
| 114 | - 'OCP\AppFramework\Controller::getParams' => '7.0.0', |
|
| 115 | - 'OCP\AppFramework\Controller::method' => '7.0.0', |
|
| 116 | - 'OCP\AppFramework\Controller::getUploadedFile' => '7.0.0', |
|
| 117 | - 'OCP\AppFramework\Controller::env' => '7.0.0', |
|
| 118 | - 'OCP\AppFramework\Controller::cookie' => '7.0.0', |
|
| 119 | - 'OCP\AppFramework\Controller::render' => '7.0.0', |
|
| 120 | - |
|
| 121 | - 'OCP\AppFramework\IAppContainer::getCoreApi' => '8.0.0', |
|
| 122 | - 'OCP\AppFramework\IAppContainer::isLoggedIn' => '8.0.0', |
|
| 123 | - 'OCP\AppFramework\IAppContainer::isAdminUser' => '8.0.0', |
|
| 124 | - 'OCP\AppFramework\IAppContainer::log' => '8.0.0', |
|
| 125 | - |
|
| 126 | - 'OCP\BackgroundJob::registerJob' => '8.1.0', |
|
| 127 | - 'OCP\BackgroundJob::getExecutionType' => '14.0.0', |
|
| 128 | - 'OCP\BackgroundJob::setExecutionType' => '14.0.0', |
|
| 129 | - |
|
| 130 | - 'OCP\Files::tmpFile' => '8.1.0', |
|
| 131 | - 'OCP\Files::tmpFolder' => '8.1.0', |
|
| 132 | - |
|
| 133 | - 'OCP\IAppConfig::getValue' => '8.0.0', |
|
| 134 | - 'OCP\IAppConfig::deleteKey' => '8.0.0', |
|
| 135 | - 'OCP\IAppConfig::getKeys' => '8.0.0', |
|
| 136 | - 'OCP\IAppConfig::setValue' => '8.0.0', |
|
| 137 | - 'OCP\IAppConfig::deleteApp' => '8.0.0', |
|
| 138 | - |
|
| 139 | - 'OCP\IDBConnection::createQueryBuilder' => '8.2.0', |
|
| 140 | - 'OCP\IDBConnection::getExpressionBuilder' => '8.2.0', |
|
| 141 | - |
|
| 142 | - 'OCP\ISearch::search' => '8.0.0', |
|
| 143 | - |
|
| 144 | - 'OCP\IServerContainer::getCache' => '8.2.0', |
|
| 145 | - 'OCP\IServerContainer::getDb' => '8.1.0', |
|
| 146 | - 'OCP\IServerContainer::getHTTPHelper' => '8.1.0', |
|
| 147 | - |
|
| 148 | - 'OCP\Response::disableCaching' => '14.0.0', |
|
| 149 | - |
|
| 150 | - 'OCP\User::getUser' => '8.0.0', |
|
| 151 | - 'OCP\User::getUsers' => '8.1.0', |
|
| 152 | - 'OCP\User::getDisplayName' => '8.1.0', |
|
| 153 | - 'OCP\User::getDisplayNames' => '8.1.0', |
|
| 154 | - 'OCP\User::userExists' => '8.1.0', |
|
| 155 | - 'OCP\User::logout' => '8.1.0', |
|
| 156 | - 'OCP\User::checkPassword' => '8.1.0', |
|
| 157 | - 'OCP\User::isLoggedIn' => '13.0.0', |
|
| 158 | - 'OCP\User::checkAdminUser' => '13.0.0', |
|
| 159 | - 'OCP\User::checkLoggedIn' => '13.0.0', |
|
| 160 | - |
|
| 161 | - 'OCP\Util::encryptedFiles' => '8.1.0', |
|
| 162 | - 'OCP\Util::formatDate' => '8.0.0', |
|
| 163 | - 'OCP\Util::generateRandomBytes' => '8.1.0', |
|
| 164 | - 'OCP\Util::getServerHost' => '8.1.0', |
|
| 165 | - 'OCP\Util::getServerProtocol' => '8.1.0', |
|
| 166 | - 'OCP\Util::getRequestUri' => '8.1.0', |
|
| 167 | - 'OCP\Util::getScriptName' => '8.1.0', |
|
| 168 | - 'OCP\Util::imagePath' => '8.1.0', |
|
| 169 | - 'OCP\Util::isValidFileName' => '8.1.0', |
|
| 170 | - 'OCP\Util::linkToRoute' => '8.1.0', |
|
| 171 | - 'OCP\Util::linkTo' => '8.1.0', |
|
| 172 | - 'OCP\Util::logException' => '8.2.0', |
|
| 173 | - 'OCP\Util::mb_str_replace' => '8.2.0', |
|
| 174 | - 'OCP\Util::mb_substr_replace' => '8.2.0', |
|
| 175 | - 'OCP\Util::sendMail' => '8.1.0', |
|
| 176 | - 'OCP\Util::writeLog' => '13.0.0', |
|
| 177 | - ]; |
|
| 178 | - } |
|
| 27 | + /** |
|
| 28 | + * @return string |
|
| 29 | + */ |
|
| 30 | + protected function getLocalDescription() { |
|
| 31 | + return 'deprecated'; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @return array E.g.: `'ClassName' => 'oc version',` |
|
| 36 | + */ |
|
| 37 | + protected function getLocalClasses() { |
|
| 38 | + return [ |
|
| 39 | + 'OC_JSON' => '8.2.0', |
|
| 40 | + |
|
| 41 | + 'OCP\Contacts' => '8.1.0', |
|
| 42 | + 'OCP\DB' => '8.1.0', |
|
| 43 | + 'OCP\JSON' => '8.1.0', |
|
| 44 | + 'OCP\Response' => '8.1.0', |
|
| 45 | + 'OCP\AppFramework\IApi' => '8.0.0', |
|
| 46 | + 'OCP\User' => '13.0.0', |
|
| 47 | + 'OCP\BackgroundJob' => '14.0.0', |
|
| 48 | + 'OCP\App' => '14.0.0', |
|
| 49 | + ]; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` |
|
| 54 | + */ |
|
| 55 | + protected function getLocalConstants() { |
|
| 56 | + return [ |
|
| 57 | + 'OC_API::GUEST_AUTH' => '8.2.0', |
|
| 58 | + 'OC_API::USER_AUTH' => '8.2.0', |
|
| 59 | + 'OC_API::SUBADMIN_AUTH' => '8.2.0', |
|
| 60 | + 'OC_API::ADMIN_AUTH' => '8.2.0', |
|
| 61 | + 'OC_API::RESPOND_UNAUTHORISED' => '8.2.0', |
|
| 62 | + 'OC_API::RESPOND_SERVER_ERROR' => '8.2.0', |
|
| 63 | + 'OC_API::RESPOND_NOT_FOUND' => '8.2.0', |
|
| 64 | + 'OC_API::RESPOND_UNKNOWN_ERROR' => '8.2.0', |
|
| 65 | + |
|
| 66 | + 'OCP::PERMISSION_CREATE' => '8.0.0', |
|
| 67 | + 'OCP::PERMISSION_READ' => '8.0.0', |
|
| 68 | + 'OCP::PERMISSION_UPDATE' => '8.0.0', |
|
| 69 | + 'OCP::PERMISSION_DELETE' => '8.0.0', |
|
| 70 | + 'OCP::PERMISSION_SHARE' => '8.0.0', |
|
| 71 | + 'OCP::PERMISSION_ALL' => '8.0.0', |
|
| 72 | + 'OCP::FILENAME_INVALID_CHARS' => '8.0.0', |
|
| 73 | + ]; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @return array E.g.: `'functionName' => 'oc version',` |
|
| 78 | + */ |
|
| 79 | + protected function getLocalFunctions() { |
|
| 80 | + return [ |
|
| 81 | + 'OCP::image_path' => '8.0.0', |
|
| 82 | + 'OCP::mimetype_icon' => '8.0.0', |
|
| 83 | + 'OCP::preview_icon' => '8.0.0', |
|
| 84 | + 'OCP::publicPreview_icon' => '8.0.0', |
|
| 85 | + 'OCP::human_file_size' => '8.0.0', |
|
| 86 | + 'OCP::relative_modified_date' => '8.0.0', |
|
| 87 | + 'OCP::simple_file_size' => '8.0.0', |
|
| 88 | + 'OCP::html_select_options' => '8.0.0', |
|
| 89 | + ]; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @return array E.g.: `'ClassName::methodName' => 'oc version',` |
|
| 94 | + */ |
|
| 95 | + protected function getLocalMethods() { |
|
| 96 | + return [ |
|
| 97 | + 'OC_L10N::get' => '8.2.0', |
|
| 98 | + |
|
| 99 | + 'OCP\Activity\IManager::publishActivity' => '8.2.0', |
|
| 100 | + |
|
| 101 | + 'OCP\App::register' => '8.1.0', |
|
| 102 | + 'OCP\App::addNavigationEntry' => '8.1.0', |
|
| 103 | + 'OCP\App::getActiveNavigationEntry' => '8.2.0', |
|
| 104 | + 'OCP\App::setActiveNavigationEntry' => '8.1.0', |
|
| 105 | + 'OCP\App::registerPersonal' => '14.0.0', |
|
| 106 | + 'OCP\App::registerAdmin' => '14.0.0', |
|
| 107 | + 'OC_App::getAppInfo' => '14.0.0', |
|
| 108 | + 'OCP\App::getAppInfo' => '14.0.0', |
|
| 109 | + 'OC_App::getAppVersion' => '14.0.0', |
|
| 110 | + 'OCP\App::getAppVersion' => '14.0.0', |
|
| 111 | + 'OCP\App::registerPersonal' => '14.0.0', |
|
| 112 | + |
|
| 113 | + 'OCP\AppFramework\Controller::params' => '7.0.0', |
|
| 114 | + 'OCP\AppFramework\Controller::getParams' => '7.0.0', |
|
| 115 | + 'OCP\AppFramework\Controller::method' => '7.0.0', |
|
| 116 | + 'OCP\AppFramework\Controller::getUploadedFile' => '7.0.0', |
|
| 117 | + 'OCP\AppFramework\Controller::env' => '7.0.0', |
|
| 118 | + 'OCP\AppFramework\Controller::cookie' => '7.0.0', |
|
| 119 | + 'OCP\AppFramework\Controller::render' => '7.0.0', |
|
| 120 | + |
|
| 121 | + 'OCP\AppFramework\IAppContainer::getCoreApi' => '8.0.0', |
|
| 122 | + 'OCP\AppFramework\IAppContainer::isLoggedIn' => '8.0.0', |
|
| 123 | + 'OCP\AppFramework\IAppContainer::isAdminUser' => '8.0.0', |
|
| 124 | + 'OCP\AppFramework\IAppContainer::log' => '8.0.0', |
|
| 125 | + |
|
| 126 | + 'OCP\BackgroundJob::registerJob' => '8.1.0', |
|
| 127 | + 'OCP\BackgroundJob::getExecutionType' => '14.0.0', |
|
| 128 | + 'OCP\BackgroundJob::setExecutionType' => '14.0.0', |
|
| 129 | + |
|
| 130 | + 'OCP\Files::tmpFile' => '8.1.0', |
|
| 131 | + 'OCP\Files::tmpFolder' => '8.1.0', |
|
| 132 | + |
|
| 133 | + 'OCP\IAppConfig::getValue' => '8.0.0', |
|
| 134 | + 'OCP\IAppConfig::deleteKey' => '8.0.0', |
|
| 135 | + 'OCP\IAppConfig::getKeys' => '8.0.0', |
|
| 136 | + 'OCP\IAppConfig::setValue' => '8.0.0', |
|
| 137 | + 'OCP\IAppConfig::deleteApp' => '8.0.0', |
|
| 138 | + |
|
| 139 | + 'OCP\IDBConnection::createQueryBuilder' => '8.2.0', |
|
| 140 | + 'OCP\IDBConnection::getExpressionBuilder' => '8.2.0', |
|
| 141 | + |
|
| 142 | + 'OCP\ISearch::search' => '8.0.0', |
|
| 143 | + |
|
| 144 | + 'OCP\IServerContainer::getCache' => '8.2.0', |
|
| 145 | + 'OCP\IServerContainer::getDb' => '8.1.0', |
|
| 146 | + 'OCP\IServerContainer::getHTTPHelper' => '8.1.0', |
|
| 147 | + |
|
| 148 | + 'OCP\Response::disableCaching' => '14.0.0', |
|
| 149 | + |
|
| 150 | + 'OCP\User::getUser' => '8.0.0', |
|
| 151 | + 'OCP\User::getUsers' => '8.1.0', |
|
| 152 | + 'OCP\User::getDisplayName' => '8.1.0', |
|
| 153 | + 'OCP\User::getDisplayNames' => '8.1.0', |
|
| 154 | + 'OCP\User::userExists' => '8.1.0', |
|
| 155 | + 'OCP\User::logout' => '8.1.0', |
|
| 156 | + 'OCP\User::checkPassword' => '8.1.0', |
|
| 157 | + 'OCP\User::isLoggedIn' => '13.0.0', |
|
| 158 | + 'OCP\User::checkAdminUser' => '13.0.0', |
|
| 159 | + 'OCP\User::checkLoggedIn' => '13.0.0', |
|
| 160 | + |
|
| 161 | + 'OCP\Util::encryptedFiles' => '8.1.0', |
|
| 162 | + 'OCP\Util::formatDate' => '8.0.0', |
|
| 163 | + 'OCP\Util::generateRandomBytes' => '8.1.0', |
|
| 164 | + 'OCP\Util::getServerHost' => '8.1.0', |
|
| 165 | + 'OCP\Util::getServerProtocol' => '8.1.0', |
|
| 166 | + 'OCP\Util::getRequestUri' => '8.1.0', |
|
| 167 | + 'OCP\Util::getScriptName' => '8.1.0', |
|
| 168 | + 'OCP\Util::imagePath' => '8.1.0', |
|
| 169 | + 'OCP\Util::isValidFileName' => '8.1.0', |
|
| 170 | + 'OCP\Util::linkToRoute' => '8.1.0', |
|
| 171 | + 'OCP\Util::linkTo' => '8.1.0', |
|
| 172 | + 'OCP\Util::logException' => '8.2.0', |
|
| 173 | + 'OCP\Util::mb_str_replace' => '8.2.0', |
|
| 174 | + 'OCP\Util::mb_substr_replace' => '8.2.0', |
|
| 175 | + 'OCP\Util::sendMail' => '8.1.0', |
|
| 176 | + 'OCP\Util::writeLog' => '13.0.0', |
|
| 177 | + ]; |
|
| 178 | + } |
|
| 179 | 179 | } |
@@ -150,1833 +150,1833 @@ |
||
| 150 | 150 | * TODO: hookup all manager classes |
| 151 | 151 | */ |
| 152 | 152 | class Server extends ServerContainer implements IServerContainer { |
| 153 | - /** @var string */ |
|
| 154 | - private $webRoot; |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * @param string $webRoot |
|
| 158 | - * @param \OC\Config $config |
|
| 159 | - */ |
|
| 160 | - public function __construct($webRoot, \OC\Config $config) { |
|
| 161 | - parent::__construct(); |
|
| 162 | - $this->webRoot = $webRoot; |
|
| 163 | - |
|
| 164 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
| 165 | - return $c; |
|
| 166 | - }); |
|
| 167 | - |
|
| 168 | - $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
| 169 | - $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
| 170 | - |
|
| 171 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
| 172 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
| 173 | - |
|
| 174 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
| 178 | - return new PreviewManager( |
|
| 179 | - $c->getConfig(), |
|
| 180 | - $c->getRootFolder(), |
|
| 181 | - $c->getAppDataDir('preview'), |
|
| 182 | - $c->getEventDispatcher(), |
|
| 183 | - $c->getSession()->get('user_id') |
|
| 184 | - ); |
|
| 185 | - }); |
|
| 186 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
| 187 | - |
|
| 188 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 189 | - return new \OC\Preview\Watcher( |
|
| 190 | - $c->getAppDataDir('preview') |
|
| 191 | - ); |
|
| 192 | - }); |
|
| 193 | - |
|
| 194 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
| 195 | - $view = new View(); |
|
| 196 | - $util = new Encryption\Util( |
|
| 197 | - $view, |
|
| 198 | - $c->getUserManager(), |
|
| 199 | - $c->getGroupManager(), |
|
| 200 | - $c->getConfig() |
|
| 201 | - ); |
|
| 202 | - return new Encryption\Manager( |
|
| 203 | - $c->getConfig(), |
|
| 204 | - $c->getLogger(), |
|
| 205 | - $c->getL10N('core'), |
|
| 206 | - new View(), |
|
| 207 | - $util, |
|
| 208 | - new ArrayCache() |
|
| 209 | - ); |
|
| 210 | - }); |
|
| 211 | - |
|
| 212 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 213 | - $util = new Encryption\Util( |
|
| 214 | - new View(), |
|
| 215 | - $c->getUserManager(), |
|
| 216 | - $c->getGroupManager(), |
|
| 217 | - $c->getConfig() |
|
| 218 | - ); |
|
| 219 | - return new Encryption\File( |
|
| 220 | - $util, |
|
| 221 | - $c->getRootFolder(), |
|
| 222 | - $c->getShareManager() |
|
| 223 | - ); |
|
| 224 | - }); |
|
| 225 | - |
|
| 226 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 227 | - $view = new View(); |
|
| 228 | - $util = new Encryption\Util( |
|
| 229 | - $view, |
|
| 230 | - $c->getUserManager(), |
|
| 231 | - $c->getGroupManager(), |
|
| 232 | - $c->getConfig() |
|
| 233 | - ); |
|
| 234 | - |
|
| 235 | - return new Encryption\Keys\Storage($view, $util); |
|
| 236 | - }); |
|
| 237 | - $this->registerService('TagMapper', function (Server $c) { |
|
| 238 | - return new TagMapper($c->getDatabaseConnection()); |
|
| 239 | - }); |
|
| 240 | - |
|
| 241 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 242 | - $tagMapper = $c->query('TagMapper'); |
|
| 243 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
| 244 | - }); |
|
| 245 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
| 246 | - |
|
| 247 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 248 | - $config = $c->getConfig(); |
|
| 249 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
| 250 | - return new $factoryClass($this); |
|
| 251 | - }); |
|
| 252 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
| 253 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
| 254 | - }); |
|
| 255 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
| 256 | - |
|
| 257 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
| 258 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
| 259 | - }); |
|
| 260 | - $this->registerService('RootFolder', function (Server $c) { |
|
| 261 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
| 262 | - $view = new View(); |
|
| 263 | - $root = new Root( |
|
| 264 | - $manager, |
|
| 265 | - $view, |
|
| 266 | - null, |
|
| 267 | - $c->getUserMountCache(), |
|
| 268 | - $this->getLogger(), |
|
| 269 | - $this->getUserManager() |
|
| 270 | - ); |
|
| 271 | - $connector = new HookConnector($root, $view); |
|
| 272 | - $connector->viewToNode(); |
|
| 273 | - |
|
| 274 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
| 275 | - $previewConnector->connectWatcher(); |
|
| 276 | - |
|
| 277 | - return $root; |
|
| 278 | - }); |
|
| 279 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
| 280 | - |
|
| 281 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
| 282 | - return new LazyRoot(function () use ($c) { |
|
| 283 | - return $c->query('RootFolder'); |
|
| 284 | - }); |
|
| 285 | - }); |
|
| 286 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
| 287 | - |
|
| 288 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
| 289 | - $config = $c->getConfig(); |
|
| 290 | - return new \OC\User\Manager($config); |
|
| 291 | - }); |
|
| 292 | - $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
| 293 | - $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
| 294 | - |
|
| 295 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 296 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
| 297 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 298 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
| 299 | - }); |
|
| 300 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
| 301 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
| 302 | - }); |
|
| 303 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 304 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
| 305 | - }); |
|
| 306 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 307 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
| 308 | - }); |
|
| 309 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 310 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 311 | - }); |
|
| 312 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 313 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 314 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
| 315 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 316 | - }); |
|
| 317 | - return $groupManager; |
|
| 318 | - }); |
|
| 319 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
| 320 | - |
|
| 321 | - $this->registerService(Store::class, function (Server $c) { |
|
| 322 | - $session = $c->getSession(); |
|
| 323 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 324 | - $tokenProvider = $c->query(IProvider::class); |
|
| 325 | - } else { |
|
| 326 | - $tokenProvider = null; |
|
| 327 | - } |
|
| 328 | - $logger = $c->getLogger(); |
|
| 329 | - return new Store($session, $logger, $tokenProvider); |
|
| 330 | - }); |
|
| 331 | - $this->registerAlias(IStore::class, Store::class); |
|
| 332 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
| 333 | - $dbConnection = $c->getDatabaseConnection(); |
|
| 334 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
| 335 | - }); |
|
| 336 | - $this->registerService(Authentication\Token\DefaultTokenProvider::class, function (Server $c) { |
|
| 337 | - $mapper = $c->query(Authentication\Token\DefaultTokenMapper::class); |
|
| 338 | - $crypto = $c->getCrypto(); |
|
| 339 | - $config = $c->getConfig(); |
|
| 340 | - $logger = $c->getLogger(); |
|
| 341 | - $timeFactory = new TimeFactory(); |
|
| 342 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
| 343 | - }); |
|
| 344 | - $this->registerAlias(IProvider::class, Authentication\Token\DefaultTokenProvider::class); |
|
| 345 | - |
|
| 346 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
| 347 | - $manager = $c->getUserManager(); |
|
| 348 | - $session = new \OC\Session\Memory(''); |
|
| 349 | - $timeFactory = new TimeFactory(); |
|
| 350 | - // Token providers might require a working database. This code |
|
| 351 | - // might however be called when ownCloud is not yet setup. |
|
| 352 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 353 | - $defaultTokenProvider = $c->query(IProvider::class); |
|
| 354 | - } else { |
|
| 355 | - $defaultTokenProvider = null; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - $dispatcher = $c->getEventDispatcher(); |
|
| 359 | - |
|
| 360 | - $userSession = new \OC\User\Session( |
|
| 361 | - $manager, |
|
| 362 | - $session, |
|
| 363 | - $timeFactory, |
|
| 364 | - $defaultTokenProvider, |
|
| 365 | - $c->getConfig(), |
|
| 366 | - $c->getSecureRandom(), |
|
| 367 | - $c->getLockdownManager(), |
|
| 368 | - $c->getLogger() |
|
| 369 | - ); |
|
| 370 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 371 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 372 | - }); |
|
| 373 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 374 | - /** @var $user \OC\User\User */ |
|
| 375 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
| 376 | - }); |
|
| 377 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
| 378 | - /** @var $user \OC\User\User */ |
|
| 379 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
| 380 | - $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
| 381 | - }); |
|
| 382 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 383 | - /** @var $user \OC\User\User */ |
|
| 384 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
| 385 | - }); |
|
| 386 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 387 | - /** @var $user \OC\User\User */ |
|
| 388 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 389 | - }); |
|
| 390 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 391 | - /** @var $user \OC\User\User */ |
|
| 392 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 393 | - }); |
|
| 394 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 395 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 396 | - }); |
|
| 397 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
| 398 | - /** @var $user \OC\User\User */ |
|
| 399 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
| 400 | - }); |
|
| 401 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 402 | - /** @var $user \OC\User\User */ |
|
| 403 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
| 404 | - }); |
|
| 405 | - $userSession->listen('\OC\User', 'logout', function () { |
|
| 406 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
| 407 | - }); |
|
| 408 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
| 409 | - /** @var $user \OC\User\User */ |
|
| 410 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
| 411 | - $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
| 412 | - }); |
|
| 413 | - return $userSession; |
|
| 414 | - }); |
|
| 415 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
| 416 | - |
|
| 417 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
| 418 | - return new \OC\Authentication\TwoFactorAuth\Manager( |
|
| 419 | - $c->getAppManager(), |
|
| 420 | - $c->getSession(), |
|
| 421 | - $c->getConfig(), |
|
| 422 | - $c->getActivityManager(), |
|
| 423 | - $c->getLogger(), |
|
| 424 | - $c->query(IProvider::class), |
|
| 425 | - $c->query(ITimeFactory::class), |
|
| 426 | - $c->query(EventDispatcherInterface::class) |
|
| 427 | - ); |
|
| 428 | - }); |
|
| 429 | - |
|
| 430 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
| 431 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
| 432 | - |
|
| 433 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 434 | - return new \OC\AllConfig( |
|
| 435 | - $c->getSystemConfig() |
|
| 436 | - ); |
|
| 437 | - }); |
|
| 438 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
| 439 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
| 440 | - |
|
| 441 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
| 442 | - return new \OC\SystemConfig($config); |
|
| 443 | - }); |
|
| 444 | - |
|
| 445 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 446 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
| 447 | - }); |
|
| 448 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
| 449 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
| 450 | - |
|
| 451 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
| 452 | - return new \OC\L10N\Factory( |
|
| 453 | - $c->getConfig(), |
|
| 454 | - $c->getRequest(), |
|
| 455 | - $c->getUserSession(), |
|
| 456 | - \OC::$SERVERROOT |
|
| 457 | - ); |
|
| 458 | - }); |
|
| 459 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
| 460 | - |
|
| 461 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
| 462 | - $config = $c->getConfig(); |
|
| 463 | - $cacheFactory = $c->getMemCacheFactory(); |
|
| 464 | - $request = $c->getRequest(); |
|
| 465 | - return new \OC\URLGenerator( |
|
| 466 | - $config, |
|
| 467 | - $cacheFactory, |
|
| 468 | - $request |
|
| 469 | - ); |
|
| 470 | - }); |
|
| 471 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
| 472 | - |
|
| 473 | - $this->registerAlias('AppFetcher', AppFetcher::class); |
|
| 474 | - $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
| 475 | - |
|
| 476 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
| 477 | - return new Cache\File(); |
|
| 478 | - }); |
|
| 479 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
| 480 | - |
|
| 481 | - $this->registerService(Factory::class, function (Server $c) { |
|
| 482 | - |
|
| 483 | - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
| 484 | - ArrayCache::class, |
|
| 485 | - ArrayCache::class, |
|
| 486 | - ArrayCache::class |
|
| 487 | - ); |
|
| 488 | - $config = $c->getConfig(); |
|
| 489 | - $request = $c->getRequest(); |
|
| 490 | - $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
| 491 | - |
|
| 492 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 493 | - $v = \OC_App::getAppVersions(); |
|
| 494 | - $v['core'] = implode(',', \OC_Util::getVersion()); |
|
| 495 | - $version = implode(',', $v); |
|
| 496 | - $instanceId = \OC_Util::getInstanceId(); |
|
| 497 | - $path = \OC::$SERVERROOT; |
|
| 498 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 499 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
| 500 | - $config->getSystemValue('memcache.local', null), |
|
| 501 | - $config->getSystemValue('memcache.distributed', null), |
|
| 502 | - $config->getSystemValue('memcache.locking', null) |
|
| 503 | - ); |
|
| 504 | - } |
|
| 505 | - return $arrayCacheFactory; |
|
| 506 | - |
|
| 507 | - }); |
|
| 508 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
| 509 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
| 510 | - |
|
| 511 | - $this->registerService('RedisFactory', function (Server $c) { |
|
| 512 | - $systemConfig = $c->getSystemConfig(); |
|
| 513 | - return new RedisFactory($systemConfig); |
|
| 514 | - }); |
|
| 515 | - |
|
| 516 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 517 | - return new \OC\Activity\Manager( |
|
| 518 | - $c->getRequest(), |
|
| 519 | - $c->getUserSession(), |
|
| 520 | - $c->getConfig(), |
|
| 521 | - $c->query(IValidator::class) |
|
| 522 | - ); |
|
| 523 | - }); |
|
| 524 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
| 525 | - |
|
| 526 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 527 | - return new \OC\Activity\EventMerger( |
|
| 528 | - $c->getL10N('lib') |
|
| 529 | - ); |
|
| 530 | - }); |
|
| 531 | - $this->registerAlias(IValidator::class, Validator::class); |
|
| 532 | - |
|
| 533 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
| 534 | - return new AvatarManager( |
|
| 535 | - $c->query(\OC\User\Manager::class), |
|
| 536 | - $c->getAppDataDir('avatar'), |
|
| 537 | - $c->getL10N('lib'), |
|
| 538 | - $c->getLogger(), |
|
| 539 | - $c->getConfig() |
|
| 540 | - ); |
|
| 541 | - }); |
|
| 542 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
| 543 | - |
|
| 544 | - $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
| 545 | - |
|
| 546 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
| 547 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
| 548 | - $logger = Log::getLogClass($logType); |
|
| 549 | - call_user_func(array($logger, 'init')); |
|
| 550 | - $config = $this->getSystemConfig(); |
|
| 551 | - $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
| 552 | - |
|
| 553 | - return new Log($logger, $config, null, $registry); |
|
| 554 | - }); |
|
| 555 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
| 556 | - |
|
| 557 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
| 558 | - $config = $c->getConfig(); |
|
| 559 | - return new \OC\BackgroundJob\JobList( |
|
| 560 | - $c->getDatabaseConnection(), |
|
| 561 | - $config, |
|
| 562 | - new TimeFactory() |
|
| 563 | - ); |
|
| 564 | - }); |
|
| 565 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
| 566 | - |
|
| 567 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
| 568 | - $cacheFactory = $c->getMemCacheFactory(); |
|
| 569 | - $logger = $c->getLogger(); |
|
| 570 | - if ($cacheFactory->isAvailableLowLatency()) { |
|
| 571 | - $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
| 572 | - } else { |
|
| 573 | - $router = new \OC\Route\Router($logger); |
|
| 574 | - } |
|
| 575 | - return $router; |
|
| 576 | - }); |
|
| 577 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
| 578 | - |
|
| 579 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
| 580 | - return new Search(); |
|
| 581 | - }); |
|
| 582 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
| 583 | - |
|
| 584 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) { |
|
| 585 | - return new \OC\Security\RateLimiting\Limiter( |
|
| 586 | - $this->getUserSession(), |
|
| 587 | - $this->getRequest(), |
|
| 588 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
| 589 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
| 590 | - ); |
|
| 591 | - }); |
|
| 592 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 593 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
| 594 | - $this->getMemCacheFactory(), |
|
| 595 | - new \OC\AppFramework\Utility\TimeFactory() |
|
| 596 | - ); |
|
| 597 | - }); |
|
| 598 | - |
|
| 599 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 600 | - return new SecureRandom(); |
|
| 601 | - }); |
|
| 602 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
| 603 | - |
|
| 604 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
| 605 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
| 606 | - }); |
|
| 607 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
| 608 | - |
|
| 609 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
| 610 | - return new Hasher($c->getConfig()); |
|
| 611 | - }); |
|
| 612 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
| 613 | - |
|
| 614 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
| 615 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
| 616 | - }); |
|
| 617 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
| 618 | - |
|
| 619 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 620 | - $systemConfig = $c->getSystemConfig(); |
|
| 621 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
| 622 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
| 623 | - if (!$factory->isValidType($type)) { |
|
| 624 | - throw new \OC\DatabaseException('Invalid database type'); |
|
| 625 | - } |
|
| 626 | - $connectionParams = $factory->createConnectionParams(); |
|
| 627 | - $connection = $factory->getConnection($type, $connectionParams); |
|
| 628 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
| 629 | - return $connection; |
|
| 630 | - }); |
|
| 631 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
| 632 | - |
|
| 633 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
| 634 | - $config = $c->getConfig(); |
|
| 635 | - return new HTTPHelper( |
|
| 636 | - $config, |
|
| 637 | - $c->getHTTPClientService() |
|
| 638 | - ); |
|
| 639 | - }); |
|
| 640 | - |
|
| 641 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
| 642 | - $user = \OC_User::getUser(); |
|
| 643 | - $uid = $user ? $user : null; |
|
| 644 | - return new ClientService( |
|
| 645 | - $c->getConfig(), |
|
| 646 | - new \OC\Security\CertificateManager( |
|
| 647 | - $uid, |
|
| 648 | - new View(), |
|
| 649 | - $c->getConfig(), |
|
| 650 | - $c->getLogger(), |
|
| 651 | - $c->getSecureRandom() |
|
| 652 | - ) |
|
| 653 | - ); |
|
| 654 | - }); |
|
| 655 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
| 656 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
| 657 | - $eventLogger = new EventLogger(); |
|
| 658 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 659 | - // In debug mode, module is being activated by default |
|
| 660 | - $eventLogger->activate(); |
|
| 661 | - } |
|
| 662 | - return $eventLogger; |
|
| 663 | - }); |
|
| 664 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
| 665 | - |
|
| 666 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
| 667 | - $queryLogger = new QueryLogger(); |
|
| 668 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 669 | - // In debug mode, module is being activated by default |
|
| 670 | - $queryLogger->activate(); |
|
| 671 | - } |
|
| 672 | - return $queryLogger; |
|
| 673 | - }); |
|
| 674 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
| 675 | - |
|
| 676 | - $this->registerService(TempManager::class, function (Server $c) { |
|
| 677 | - return new TempManager( |
|
| 678 | - $c->getLogger(), |
|
| 679 | - $c->getConfig() |
|
| 680 | - ); |
|
| 681 | - }); |
|
| 682 | - $this->registerAlias('TempManager', TempManager::class); |
|
| 683 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
| 684 | - |
|
| 685 | - $this->registerService(AppManager::class, function (Server $c) { |
|
| 686 | - return new \OC\App\AppManager( |
|
| 687 | - $c->getUserSession(), |
|
| 688 | - $c->query(\OC\AppConfig::class), |
|
| 689 | - $c->getGroupManager(), |
|
| 690 | - $c->getMemCacheFactory(), |
|
| 691 | - $c->getEventDispatcher() |
|
| 692 | - ); |
|
| 693 | - }); |
|
| 694 | - $this->registerAlias('AppManager', AppManager::class); |
|
| 695 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
| 696 | - |
|
| 697 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
| 698 | - return new DateTimeZone( |
|
| 699 | - $c->getConfig(), |
|
| 700 | - $c->getSession() |
|
| 701 | - ); |
|
| 702 | - }); |
|
| 703 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
| 704 | - |
|
| 705 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
| 706 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
| 707 | - |
|
| 708 | - return new DateTimeFormatter( |
|
| 709 | - $c->getDateTimeZone()->getTimeZone(), |
|
| 710 | - $c->getL10N('lib', $language) |
|
| 711 | - ); |
|
| 712 | - }); |
|
| 713 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
| 714 | - |
|
| 715 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
| 716 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
| 717 | - $listener = new UserMountCacheListener($mountCache); |
|
| 718 | - $listener->listen($c->getUserManager()); |
|
| 719 | - return $mountCache; |
|
| 720 | - }); |
|
| 721 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
| 722 | - |
|
| 723 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
| 724 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
| 725 | - $mountCache = $c->query('UserMountCache'); |
|
| 726 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 727 | - |
|
| 728 | - // builtin providers |
|
| 729 | - |
|
| 730 | - $config = $c->getConfig(); |
|
| 731 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
| 732 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
| 733 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
| 734 | - |
|
| 735 | - return $manager; |
|
| 736 | - }); |
|
| 737 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
| 738 | - |
|
| 739 | - $this->registerService('IniWrapper', function ($c) { |
|
| 740 | - return new IniGetWrapper(); |
|
| 741 | - }); |
|
| 742 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 743 | - $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
| 744 | - if ($busClass) { |
|
| 745 | - list($app, $class) = explode('::', $busClass, 2); |
|
| 746 | - if ($c->getAppManager()->isInstalled($app)) { |
|
| 747 | - \OC_App::loadApp($app); |
|
| 748 | - return $c->query($class); |
|
| 749 | - } else { |
|
| 750 | - throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
| 751 | - } |
|
| 752 | - } else { |
|
| 753 | - $jobList = $c->getJobList(); |
|
| 754 | - return new CronBus($jobList); |
|
| 755 | - } |
|
| 756 | - }); |
|
| 757 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 758 | - return new TrustedDomainHelper($this->getConfig()); |
|
| 759 | - }); |
|
| 760 | - $this->registerService('Throttler', function (Server $c) { |
|
| 761 | - return new Throttler( |
|
| 762 | - $c->getDatabaseConnection(), |
|
| 763 | - new TimeFactory(), |
|
| 764 | - $c->getLogger(), |
|
| 765 | - $c->getConfig() |
|
| 766 | - ); |
|
| 767 | - }); |
|
| 768 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 769 | - // IConfig and IAppManager requires a working database. This code |
|
| 770 | - // might however be called when ownCloud is not yet setup. |
|
| 771 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 772 | - $config = $c->getConfig(); |
|
| 773 | - $appManager = $c->getAppManager(); |
|
| 774 | - } else { |
|
| 775 | - $config = null; |
|
| 776 | - $appManager = null; |
|
| 777 | - } |
|
| 778 | - |
|
| 779 | - return new Checker( |
|
| 780 | - new EnvironmentHelper(), |
|
| 781 | - new FileAccessHelper(), |
|
| 782 | - new AppLocator(), |
|
| 783 | - $config, |
|
| 784 | - $c->getMemCacheFactory(), |
|
| 785 | - $appManager, |
|
| 786 | - $c->getTempManager() |
|
| 787 | - ); |
|
| 788 | - }); |
|
| 789 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 790 | - if (isset($this['urlParams'])) { |
|
| 791 | - $urlParams = $this['urlParams']; |
|
| 792 | - } else { |
|
| 793 | - $urlParams = []; |
|
| 794 | - } |
|
| 795 | - |
|
| 796 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
| 797 | - && in_array('fakeinput', stream_get_wrappers()) |
|
| 798 | - ) { |
|
| 799 | - $stream = 'fakeinput://data'; |
|
| 800 | - } else { |
|
| 801 | - $stream = 'php://input'; |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - return new Request( |
|
| 805 | - [ |
|
| 806 | - 'get' => $_GET, |
|
| 807 | - 'post' => $_POST, |
|
| 808 | - 'files' => $_FILES, |
|
| 809 | - 'server' => $_SERVER, |
|
| 810 | - 'env' => $_ENV, |
|
| 811 | - 'cookies' => $_COOKIE, |
|
| 812 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 813 | - ? $_SERVER['REQUEST_METHOD'] |
|
| 814 | - : '', |
|
| 815 | - 'urlParams' => $urlParams, |
|
| 816 | - ], |
|
| 817 | - $this->getSecureRandom(), |
|
| 818 | - $this->getConfig(), |
|
| 819 | - $this->getCsrfTokenManager(), |
|
| 820 | - $stream |
|
| 821 | - ); |
|
| 822 | - }); |
|
| 823 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
| 824 | - |
|
| 825 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
| 826 | - return new Mailer( |
|
| 827 | - $c->getConfig(), |
|
| 828 | - $c->getLogger(), |
|
| 829 | - $c->query(Defaults::class), |
|
| 830 | - $c->getURLGenerator(), |
|
| 831 | - $c->getL10N('lib') |
|
| 832 | - ); |
|
| 833 | - }); |
|
| 834 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
| 835 | - |
|
| 836 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
| 837 | - $config = $c->getConfig(); |
|
| 838 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
| 839 | - if (is_null($factoryClass)) { |
|
| 840 | - throw new \Exception('ldapProviderFactory not set'); |
|
| 841 | - } |
|
| 842 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
| 843 | - $factory = new $factoryClass($this); |
|
| 844 | - return $factory->getLDAPProvider(); |
|
| 845 | - }); |
|
| 846 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 847 | - $ini = $c->getIniWrapper(); |
|
| 848 | - $config = $c->getConfig(); |
|
| 849 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
| 850 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 851 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
| 852 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
| 853 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
| 854 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
| 855 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
| 856 | - } |
|
| 857 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
| 858 | - } |
|
| 859 | - return new NoopLockingProvider(); |
|
| 860 | - }); |
|
| 861 | - $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
| 862 | - |
|
| 863 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
| 864 | - return new \OC\Files\Mount\Manager(); |
|
| 865 | - }); |
|
| 866 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
| 867 | - |
|
| 868 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
| 869 | - return new \OC\Files\Type\Detection( |
|
| 870 | - $c->getURLGenerator(), |
|
| 871 | - \OC::$configDir, |
|
| 872 | - \OC::$SERVERROOT . '/resources/config/' |
|
| 873 | - ); |
|
| 874 | - }); |
|
| 875 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
| 876 | - |
|
| 877 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
| 878 | - return new \OC\Files\Type\Loader( |
|
| 879 | - $c->getDatabaseConnection() |
|
| 880 | - ); |
|
| 881 | - }); |
|
| 882 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
| 883 | - $this->registerService(BundleFetcher::class, function () { |
|
| 884 | - return new BundleFetcher($this->getL10N('lib')); |
|
| 885 | - }); |
|
| 886 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 887 | - return new Manager( |
|
| 888 | - $c->query(IValidator::class) |
|
| 889 | - ); |
|
| 890 | - }); |
|
| 891 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
| 892 | - |
|
| 893 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
| 894 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
| 895 | - $manager->registerCapability(function () use ($c) { |
|
| 896 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
| 897 | - }); |
|
| 898 | - $manager->registerCapability(function () use ($c) { |
|
| 899 | - return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
| 900 | - }); |
|
| 901 | - return $manager; |
|
| 902 | - }); |
|
| 903 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
| 904 | - |
|
| 905 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
| 906 | - $config = $c->getConfig(); |
|
| 907 | - $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
| 908 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
| 909 | - $factory = new $factoryClass($this); |
|
| 910 | - $manager = $factory->getManager(); |
|
| 911 | - |
|
| 912 | - $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
| 913 | - $manager = $c->getUserManager(); |
|
| 914 | - $user = $manager->get($id); |
|
| 915 | - if(is_null($user)) { |
|
| 916 | - $l = $c->getL10N('core'); |
|
| 917 | - $displayName = $l->t('Unknown user'); |
|
| 918 | - } else { |
|
| 919 | - $displayName = $user->getDisplayName(); |
|
| 920 | - } |
|
| 921 | - return $displayName; |
|
| 922 | - }); |
|
| 923 | - |
|
| 924 | - return $manager; |
|
| 925 | - }); |
|
| 926 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
| 927 | - |
|
| 928 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 929 | - /* |
|
| 153 | + /** @var string */ |
|
| 154 | + private $webRoot; |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * @param string $webRoot |
|
| 158 | + * @param \OC\Config $config |
|
| 159 | + */ |
|
| 160 | + public function __construct($webRoot, \OC\Config $config) { |
|
| 161 | + parent::__construct(); |
|
| 162 | + $this->webRoot = $webRoot; |
|
| 163 | + |
|
| 164 | + $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
| 165 | + return $c; |
|
| 166 | + }); |
|
| 167 | + |
|
| 168 | + $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); |
|
| 169 | + $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class); |
|
| 170 | + |
|
| 171 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
| 172 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
| 173 | + |
|
| 174 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
| 178 | + return new PreviewManager( |
|
| 179 | + $c->getConfig(), |
|
| 180 | + $c->getRootFolder(), |
|
| 181 | + $c->getAppDataDir('preview'), |
|
| 182 | + $c->getEventDispatcher(), |
|
| 183 | + $c->getSession()->get('user_id') |
|
| 184 | + ); |
|
| 185 | + }); |
|
| 186 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
| 187 | + |
|
| 188 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 189 | + return new \OC\Preview\Watcher( |
|
| 190 | + $c->getAppDataDir('preview') |
|
| 191 | + ); |
|
| 192 | + }); |
|
| 193 | + |
|
| 194 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
| 195 | + $view = new View(); |
|
| 196 | + $util = new Encryption\Util( |
|
| 197 | + $view, |
|
| 198 | + $c->getUserManager(), |
|
| 199 | + $c->getGroupManager(), |
|
| 200 | + $c->getConfig() |
|
| 201 | + ); |
|
| 202 | + return new Encryption\Manager( |
|
| 203 | + $c->getConfig(), |
|
| 204 | + $c->getLogger(), |
|
| 205 | + $c->getL10N('core'), |
|
| 206 | + new View(), |
|
| 207 | + $util, |
|
| 208 | + new ArrayCache() |
|
| 209 | + ); |
|
| 210 | + }); |
|
| 211 | + |
|
| 212 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 213 | + $util = new Encryption\Util( |
|
| 214 | + new View(), |
|
| 215 | + $c->getUserManager(), |
|
| 216 | + $c->getGroupManager(), |
|
| 217 | + $c->getConfig() |
|
| 218 | + ); |
|
| 219 | + return new Encryption\File( |
|
| 220 | + $util, |
|
| 221 | + $c->getRootFolder(), |
|
| 222 | + $c->getShareManager() |
|
| 223 | + ); |
|
| 224 | + }); |
|
| 225 | + |
|
| 226 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 227 | + $view = new View(); |
|
| 228 | + $util = new Encryption\Util( |
|
| 229 | + $view, |
|
| 230 | + $c->getUserManager(), |
|
| 231 | + $c->getGroupManager(), |
|
| 232 | + $c->getConfig() |
|
| 233 | + ); |
|
| 234 | + |
|
| 235 | + return new Encryption\Keys\Storage($view, $util); |
|
| 236 | + }); |
|
| 237 | + $this->registerService('TagMapper', function (Server $c) { |
|
| 238 | + return new TagMapper($c->getDatabaseConnection()); |
|
| 239 | + }); |
|
| 240 | + |
|
| 241 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 242 | + $tagMapper = $c->query('TagMapper'); |
|
| 243 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
| 244 | + }); |
|
| 245 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
| 246 | + |
|
| 247 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 248 | + $config = $c->getConfig(); |
|
| 249 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
|
| 250 | + return new $factoryClass($this); |
|
| 251 | + }); |
|
| 252 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
| 253 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
| 254 | + }); |
|
| 255 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
| 256 | + |
|
| 257 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
| 258 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
| 259 | + }); |
|
| 260 | + $this->registerService('RootFolder', function (Server $c) { |
|
| 261 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
| 262 | + $view = new View(); |
|
| 263 | + $root = new Root( |
|
| 264 | + $manager, |
|
| 265 | + $view, |
|
| 266 | + null, |
|
| 267 | + $c->getUserMountCache(), |
|
| 268 | + $this->getLogger(), |
|
| 269 | + $this->getUserManager() |
|
| 270 | + ); |
|
| 271 | + $connector = new HookConnector($root, $view); |
|
| 272 | + $connector->viewToNode(); |
|
| 273 | + |
|
| 274 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
| 275 | + $previewConnector->connectWatcher(); |
|
| 276 | + |
|
| 277 | + return $root; |
|
| 278 | + }); |
|
| 279 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
| 280 | + |
|
| 281 | + $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
| 282 | + return new LazyRoot(function () use ($c) { |
|
| 283 | + return $c->query('RootFolder'); |
|
| 284 | + }); |
|
| 285 | + }); |
|
| 286 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
| 287 | + |
|
| 288 | + $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
| 289 | + $config = $c->getConfig(); |
|
| 290 | + return new \OC\User\Manager($config); |
|
| 291 | + }); |
|
| 292 | + $this->registerAlias('UserManager', \OC\User\Manager::class); |
|
| 293 | + $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
|
| 294 | + |
|
| 295 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 296 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
| 297 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 298 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
| 299 | + }); |
|
| 300 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
| 301 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
| 302 | + }); |
|
| 303 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 304 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
| 305 | + }); |
|
| 306 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 307 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
| 308 | + }); |
|
| 309 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 310 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 311 | + }); |
|
| 312 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 313 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 314 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
| 315 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 316 | + }); |
|
| 317 | + return $groupManager; |
|
| 318 | + }); |
|
| 319 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
| 320 | + |
|
| 321 | + $this->registerService(Store::class, function (Server $c) { |
|
| 322 | + $session = $c->getSession(); |
|
| 323 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 324 | + $tokenProvider = $c->query(IProvider::class); |
|
| 325 | + } else { |
|
| 326 | + $tokenProvider = null; |
|
| 327 | + } |
|
| 328 | + $logger = $c->getLogger(); |
|
| 329 | + return new Store($session, $logger, $tokenProvider); |
|
| 330 | + }); |
|
| 331 | + $this->registerAlias(IStore::class, Store::class); |
|
| 332 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
| 333 | + $dbConnection = $c->getDatabaseConnection(); |
|
| 334 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
| 335 | + }); |
|
| 336 | + $this->registerService(Authentication\Token\DefaultTokenProvider::class, function (Server $c) { |
|
| 337 | + $mapper = $c->query(Authentication\Token\DefaultTokenMapper::class); |
|
| 338 | + $crypto = $c->getCrypto(); |
|
| 339 | + $config = $c->getConfig(); |
|
| 340 | + $logger = $c->getLogger(); |
|
| 341 | + $timeFactory = new TimeFactory(); |
|
| 342 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
| 343 | + }); |
|
| 344 | + $this->registerAlias(IProvider::class, Authentication\Token\DefaultTokenProvider::class); |
|
| 345 | + |
|
| 346 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
| 347 | + $manager = $c->getUserManager(); |
|
| 348 | + $session = new \OC\Session\Memory(''); |
|
| 349 | + $timeFactory = new TimeFactory(); |
|
| 350 | + // Token providers might require a working database. This code |
|
| 351 | + // might however be called when ownCloud is not yet setup. |
|
| 352 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 353 | + $defaultTokenProvider = $c->query(IProvider::class); |
|
| 354 | + } else { |
|
| 355 | + $defaultTokenProvider = null; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + $dispatcher = $c->getEventDispatcher(); |
|
| 359 | + |
|
| 360 | + $userSession = new \OC\User\Session( |
|
| 361 | + $manager, |
|
| 362 | + $session, |
|
| 363 | + $timeFactory, |
|
| 364 | + $defaultTokenProvider, |
|
| 365 | + $c->getConfig(), |
|
| 366 | + $c->getSecureRandom(), |
|
| 367 | + $c->getLockdownManager(), |
|
| 368 | + $c->getLogger() |
|
| 369 | + ); |
|
| 370 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 371 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 372 | + }); |
|
| 373 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 374 | + /** @var $user \OC\User\User */ |
|
| 375 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
| 376 | + }); |
|
| 377 | + $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
| 378 | + /** @var $user \OC\User\User */ |
|
| 379 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
| 380 | + $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
|
| 381 | + }); |
|
| 382 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 383 | + /** @var $user \OC\User\User */ |
|
| 384 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
| 385 | + }); |
|
| 386 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 387 | + /** @var $user \OC\User\User */ |
|
| 388 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 389 | + }); |
|
| 390 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 391 | + /** @var $user \OC\User\User */ |
|
| 392 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 393 | + }); |
|
| 394 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 395 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 396 | + }); |
|
| 397 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
| 398 | + /** @var $user \OC\User\User */ |
|
| 399 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
| 400 | + }); |
|
| 401 | + $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 402 | + /** @var $user \OC\User\User */ |
|
| 403 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
| 404 | + }); |
|
| 405 | + $userSession->listen('\OC\User', 'logout', function () { |
|
| 406 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
| 407 | + }); |
|
| 408 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
| 409 | + /** @var $user \OC\User\User */ |
|
| 410 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
| 411 | + $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
|
| 412 | + }); |
|
| 413 | + return $userSession; |
|
| 414 | + }); |
|
| 415 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
| 416 | + |
|
| 417 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
| 418 | + return new \OC\Authentication\TwoFactorAuth\Manager( |
|
| 419 | + $c->getAppManager(), |
|
| 420 | + $c->getSession(), |
|
| 421 | + $c->getConfig(), |
|
| 422 | + $c->getActivityManager(), |
|
| 423 | + $c->getLogger(), |
|
| 424 | + $c->query(IProvider::class), |
|
| 425 | + $c->query(ITimeFactory::class), |
|
| 426 | + $c->query(EventDispatcherInterface::class) |
|
| 427 | + ); |
|
| 428 | + }); |
|
| 429 | + |
|
| 430 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
| 431 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
| 432 | + |
|
| 433 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 434 | + return new \OC\AllConfig( |
|
| 435 | + $c->getSystemConfig() |
|
| 436 | + ); |
|
| 437 | + }); |
|
| 438 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
| 439 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
| 440 | + |
|
| 441 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
| 442 | + return new \OC\SystemConfig($config); |
|
| 443 | + }); |
|
| 444 | + |
|
| 445 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 446 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
| 447 | + }); |
|
| 448 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
| 449 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
| 450 | + |
|
| 451 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
| 452 | + return new \OC\L10N\Factory( |
|
| 453 | + $c->getConfig(), |
|
| 454 | + $c->getRequest(), |
|
| 455 | + $c->getUserSession(), |
|
| 456 | + \OC::$SERVERROOT |
|
| 457 | + ); |
|
| 458 | + }); |
|
| 459 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
| 460 | + |
|
| 461 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
| 462 | + $config = $c->getConfig(); |
|
| 463 | + $cacheFactory = $c->getMemCacheFactory(); |
|
| 464 | + $request = $c->getRequest(); |
|
| 465 | + return new \OC\URLGenerator( |
|
| 466 | + $config, |
|
| 467 | + $cacheFactory, |
|
| 468 | + $request |
|
| 469 | + ); |
|
| 470 | + }); |
|
| 471 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
| 472 | + |
|
| 473 | + $this->registerAlias('AppFetcher', AppFetcher::class); |
|
| 474 | + $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
|
| 475 | + |
|
| 476 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
| 477 | + return new Cache\File(); |
|
| 478 | + }); |
|
| 479 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
| 480 | + |
|
| 481 | + $this->registerService(Factory::class, function (Server $c) { |
|
| 482 | + |
|
| 483 | + $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
|
| 484 | + ArrayCache::class, |
|
| 485 | + ArrayCache::class, |
|
| 486 | + ArrayCache::class |
|
| 487 | + ); |
|
| 488 | + $config = $c->getConfig(); |
|
| 489 | + $request = $c->getRequest(); |
|
| 490 | + $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request); |
|
| 491 | + |
|
| 492 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 493 | + $v = \OC_App::getAppVersions(); |
|
| 494 | + $v['core'] = implode(',', \OC_Util::getVersion()); |
|
| 495 | + $version = implode(',', $v); |
|
| 496 | + $instanceId = \OC_Util::getInstanceId(); |
|
| 497 | + $path = \OC::$SERVERROOT; |
|
| 498 | + $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 499 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
| 500 | + $config->getSystemValue('memcache.local', null), |
|
| 501 | + $config->getSystemValue('memcache.distributed', null), |
|
| 502 | + $config->getSystemValue('memcache.locking', null) |
|
| 503 | + ); |
|
| 504 | + } |
|
| 505 | + return $arrayCacheFactory; |
|
| 506 | + |
|
| 507 | + }); |
|
| 508 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
| 509 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
| 510 | + |
|
| 511 | + $this->registerService('RedisFactory', function (Server $c) { |
|
| 512 | + $systemConfig = $c->getSystemConfig(); |
|
| 513 | + return new RedisFactory($systemConfig); |
|
| 514 | + }); |
|
| 515 | + |
|
| 516 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 517 | + return new \OC\Activity\Manager( |
|
| 518 | + $c->getRequest(), |
|
| 519 | + $c->getUserSession(), |
|
| 520 | + $c->getConfig(), |
|
| 521 | + $c->query(IValidator::class) |
|
| 522 | + ); |
|
| 523 | + }); |
|
| 524 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
| 525 | + |
|
| 526 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 527 | + return new \OC\Activity\EventMerger( |
|
| 528 | + $c->getL10N('lib') |
|
| 529 | + ); |
|
| 530 | + }); |
|
| 531 | + $this->registerAlias(IValidator::class, Validator::class); |
|
| 532 | + |
|
| 533 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
| 534 | + return new AvatarManager( |
|
| 535 | + $c->query(\OC\User\Manager::class), |
|
| 536 | + $c->getAppDataDir('avatar'), |
|
| 537 | + $c->getL10N('lib'), |
|
| 538 | + $c->getLogger(), |
|
| 539 | + $c->getConfig() |
|
| 540 | + ); |
|
| 541 | + }); |
|
| 542 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
| 543 | + |
|
| 544 | + $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
|
| 545 | + |
|
| 546 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
| 547 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
| 548 | + $logger = Log::getLogClass($logType); |
|
| 549 | + call_user_func(array($logger, 'init')); |
|
| 550 | + $config = $this->getSystemConfig(); |
|
| 551 | + $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class); |
|
| 552 | + |
|
| 553 | + return new Log($logger, $config, null, $registry); |
|
| 554 | + }); |
|
| 555 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
| 556 | + |
|
| 557 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
| 558 | + $config = $c->getConfig(); |
|
| 559 | + return new \OC\BackgroundJob\JobList( |
|
| 560 | + $c->getDatabaseConnection(), |
|
| 561 | + $config, |
|
| 562 | + new TimeFactory() |
|
| 563 | + ); |
|
| 564 | + }); |
|
| 565 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
| 566 | + |
|
| 567 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
| 568 | + $cacheFactory = $c->getMemCacheFactory(); |
|
| 569 | + $logger = $c->getLogger(); |
|
| 570 | + if ($cacheFactory->isAvailableLowLatency()) { |
|
| 571 | + $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger); |
|
| 572 | + } else { |
|
| 573 | + $router = new \OC\Route\Router($logger); |
|
| 574 | + } |
|
| 575 | + return $router; |
|
| 576 | + }); |
|
| 577 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
| 578 | + |
|
| 579 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
| 580 | + return new Search(); |
|
| 581 | + }); |
|
| 582 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
| 583 | + |
|
| 584 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) { |
|
| 585 | + return new \OC\Security\RateLimiting\Limiter( |
|
| 586 | + $this->getUserSession(), |
|
| 587 | + $this->getRequest(), |
|
| 588 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
| 589 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
| 590 | + ); |
|
| 591 | + }); |
|
| 592 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 593 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
| 594 | + $this->getMemCacheFactory(), |
|
| 595 | + new \OC\AppFramework\Utility\TimeFactory() |
|
| 596 | + ); |
|
| 597 | + }); |
|
| 598 | + |
|
| 599 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 600 | + return new SecureRandom(); |
|
| 601 | + }); |
|
| 602 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
| 603 | + |
|
| 604 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
| 605 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
| 606 | + }); |
|
| 607 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
| 608 | + |
|
| 609 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
| 610 | + return new Hasher($c->getConfig()); |
|
| 611 | + }); |
|
| 612 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
| 613 | + |
|
| 614 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
| 615 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
| 616 | + }); |
|
| 617 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
| 618 | + |
|
| 619 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 620 | + $systemConfig = $c->getSystemConfig(); |
|
| 621 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
| 622 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
| 623 | + if (!$factory->isValidType($type)) { |
|
| 624 | + throw new \OC\DatabaseException('Invalid database type'); |
|
| 625 | + } |
|
| 626 | + $connectionParams = $factory->createConnectionParams(); |
|
| 627 | + $connection = $factory->getConnection($type, $connectionParams); |
|
| 628 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
| 629 | + return $connection; |
|
| 630 | + }); |
|
| 631 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
| 632 | + |
|
| 633 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
| 634 | + $config = $c->getConfig(); |
|
| 635 | + return new HTTPHelper( |
|
| 636 | + $config, |
|
| 637 | + $c->getHTTPClientService() |
|
| 638 | + ); |
|
| 639 | + }); |
|
| 640 | + |
|
| 641 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
| 642 | + $user = \OC_User::getUser(); |
|
| 643 | + $uid = $user ? $user : null; |
|
| 644 | + return new ClientService( |
|
| 645 | + $c->getConfig(), |
|
| 646 | + new \OC\Security\CertificateManager( |
|
| 647 | + $uid, |
|
| 648 | + new View(), |
|
| 649 | + $c->getConfig(), |
|
| 650 | + $c->getLogger(), |
|
| 651 | + $c->getSecureRandom() |
|
| 652 | + ) |
|
| 653 | + ); |
|
| 654 | + }); |
|
| 655 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
| 656 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
| 657 | + $eventLogger = new EventLogger(); |
|
| 658 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 659 | + // In debug mode, module is being activated by default |
|
| 660 | + $eventLogger->activate(); |
|
| 661 | + } |
|
| 662 | + return $eventLogger; |
|
| 663 | + }); |
|
| 664 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
| 665 | + |
|
| 666 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
| 667 | + $queryLogger = new QueryLogger(); |
|
| 668 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 669 | + // In debug mode, module is being activated by default |
|
| 670 | + $queryLogger->activate(); |
|
| 671 | + } |
|
| 672 | + return $queryLogger; |
|
| 673 | + }); |
|
| 674 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
| 675 | + |
|
| 676 | + $this->registerService(TempManager::class, function (Server $c) { |
|
| 677 | + return new TempManager( |
|
| 678 | + $c->getLogger(), |
|
| 679 | + $c->getConfig() |
|
| 680 | + ); |
|
| 681 | + }); |
|
| 682 | + $this->registerAlias('TempManager', TempManager::class); |
|
| 683 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
| 684 | + |
|
| 685 | + $this->registerService(AppManager::class, function (Server $c) { |
|
| 686 | + return new \OC\App\AppManager( |
|
| 687 | + $c->getUserSession(), |
|
| 688 | + $c->query(\OC\AppConfig::class), |
|
| 689 | + $c->getGroupManager(), |
|
| 690 | + $c->getMemCacheFactory(), |
|
| 691 | + $c->getEventDispatcher() |
|
| 692 | + ); |
|
| 693 | + }); |
|
| 694 | + $this->registerAlias('AppManager', AppManager::class); |
|
| 695 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
| 696 | + |
|
| 697 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
| 698 | + return new DateTimeZone( |
|
| 699 | + $c->getConfig(), |
|
| 700 | + $c->getSession() |
|
| 701 | + ); |
|
| 702 | + }); |
|
| 703 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
| 704 | + |
|
| 705 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
| 706 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
| 707 | + |
|
| 708 | + return new DateTimeFormatter( |
|
| 709 | + $c->getDateTimeZone()->getTimeZone(), |
|
| 710 | + $c->getL10N('lib', $language) |
|
| 711 | + ); |
|
| 712 | + }); |
|
| 713 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
| 714 | + |
|
| 715 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
| 716 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
| 717 | + $listener = new UserMountCacheListener($mountCache); |
|
| 718 | + $listener->listen($c->getUserManager()); |
|
| 719 | + return $mountCache; |
|
| 720 | + }); |
|
| 721 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
| 722 | + |
|
| 723 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
| 724 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
| 725 | + $mountCache = $c->query('UserMountCache'); |
|
| 726 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 727 | + |
|
| 728 | + // builtin providers |
|
| 729 | + |
|
| 730 | + $config = $c->getConfig(); |
|
| 731 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
| 732 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
| 733 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
| 734 | + |
|
| 735 | + return $manager; |
|
| 736 | + }); |
|
| 737 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
| 738 | + |
|
| 739 | + $this->registerService('IniWrapper', function ($c) { |
|
| 740 | + return new IniGetWrapper(); |
|
| 741 | + }); |
|
| 742 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 743 | + $busClass = $c->getConfig()->getSystemValue('commandbus'); |
|
| 744 | + if ($busClass) { |
|
| 745 | + list($app, $class) = explode('::', $busClass, 2); |
|
| 746 | + if ($c->getAppManager()->isInstalled($app)) { |
|
| 747 | + \OC_App::loadApp($app); |
|
| 748 | + return $c->query($class); |
|
| 749 | + } else { |
|
| 750 | + throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled"); |
|
| 751 | + } |
|
| 752 | + } else { |
|
| 753 | + $jobList = $c->getJobList(); |
|
| 754 | + return new CronBus($jobList); |
|
| 755 | + } |
|
| 756 | + }); |
|
| 757 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 758 | + return new TrustedDomainHelper($this->getConfig()); |
|
| 759 | + }); |
|
| 760 | + $this->registerService('Throttler', function (Server $c) { |
|
| 761 | + return new Throttler( |
|
| 762 | + $c->getDatabaseConnection(), |
|
| 763 | + new TimeFactory(), |
|
| 764 | + $c->getLogger(), |
|
| 765 | + $c->getConfig() |
|
| 766 | + ); |
|
| 767 | + }); |
|
| 768 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 769 | + // IConfig and IAppManager requires a working database. This code |
|
| 770 | + // might however be called when ownCloud is not yet setup. |
|
| 771 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 772 | + $config = $c->getConfig(); |
|
| 773 | + $appManager = $c->getAppManager(); |
|
| 774 | + } else { |
|
| 775 | + $config = null; |
|
| 776 | + $appManager = null; |
|
| 777 | + } |
|
| 778 | + |
|
| 779 | + return new Checker( |
|
| 780 | + new EnvironmentHelper(), |
|
| 781 | + new FileAccessHelper(), |
|
| 782 | + new AppLocator(), |
|
| 783 | + $config, |
|
| 784 | + $c->getMemCacheFactory(), |
|
| 785 | + $appManager, |
|
| 786 | + $c->getTempManager() |
|
| 787 | + ); |
|
| 788 | + }); |
|
| 789 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 790 | + if (isset($this['urlParams'])) { |
|
| 791 | + $urlParams = $this['urlParams']; |
|
| 792 | + } else { |
|
| 793 | + $urlParams = []; |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
| 797 | + && in_array('fakeinput', stream_get_wrappers()) |
|
| 798 | + ) { |
|
| 799 | + $stream = 'fakeinput://data'; |
|
| 800 | + } else { |
|
| 801 | + $stream = 'php://input'; |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + return new Request( |
|
| 805 | + [ |
|
| 806 | + 'get' => $_GET, |
|
| 807 | + 'post' => $_POST, |
|
| 808 | + 'files' => $_FILES, |
|
| 809 | + 'server' => $_SERVER, |
|
| 810 | + 'env' => $_ENV, |
|
| 811 | + 'cookies' => $_COOKIE, |
|
| 812 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 813 | + ? $_SERVER['REQUEST_METHOD'] |
|
| 814 | + : '', |
|
| 815 | + 'urlParams' => $urlParams, |
|
| 816 | + ], |
|
| 817 | + $this->getSecureRandom(), |
|
| 818 | + $this->getConfig(), |
|
| 819 | + $this->getCsrfTokenManager(), |
|
| 820 | + $stream |
|
| 821 | + ); |
|
| 822 | + }); |
|
| 823 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
| 824 | + |
|
| 825 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
| 826 | + return new Mailer( |
|
| 827 | + $c->getConfig(), |
|
| 828 | + $c->getLogger(), |
|
| 829 | + $c->query(Defaults::class), |
|
| 830 | + $c->getURLGenerator(), |
|
| 831 | + $c->getL10N('lib') |
|
| 832 | + ); |
|
| 833 | + }); |
|
| 834 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
| 835 | + |
|
| 836 | + $this->registerService('LDAPProvider', function (Server $c) { |
|
| 837 | + $config = $c->getConfig(); |
|
| 838 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
| 839 | + if (is_null($factoryClass)) { |
|
| 840 | + throw new \Exception('ldapProviderFactory not set'); |
|
| 841 | + } |
|
| 842 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
| 843 | + $factory = new $factoryClass($this); |
|
| 844 | + return $factory->getLDAPProvider(); |
|
| 845 | + }); |
|
| 846 | + $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 847 | + $ini = $c->getIniWrapper(); |
|
| 848 | + $config = $c->getConfig(); |
|
| 849 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
| 850 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 851 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
| 852 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
| 853 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
| 854 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
| 855 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
| 856 | + } |
|
| 857 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
| 858 | + } |
|
| 859 | + return new NoopLockingProvider(); |
|
| 860 | + }); |
|
| 861 | + $this->registerAlias('LockingProvider', ILockingProvider::class); |
|
| 862 | + |
|
| 863 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
| 864 | + return new \OC\Files\Mount\Manager(); |
|
| 865 | + }); |
|
| 866 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
| 867 | + |
|
| 868 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
| 869 | + return new \OC\Files\Type\Detection( |
|
| 870 | + $c->getURLGenerator(), |
|
| 871 | + \OC::$configDir, |
|
| 872 | + \OC::$SERVERROOT . '/resources/config/' |
|
| 873 | + ); |
|
| 874 | + }); |
|
| 875 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
| 876 | + |
|
| 877 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
| 878 | + return new \OC\Files\Type\Loader( |
|
| 879 | + $c->getDatabaseConnection() |
|
| 880 | + ); |
|
| 881 | + }); |
|
| 882 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
| 883 | + $this->registerService(BundleFetcher::class, function () { |
|
| 884 | + return new BundleFetcher($this->getL10N('lib')); |
|
| 885 | + }); |
|
| 886 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 887 | + return new Manager( |
|
| 888 | + $c->query(IValidator::class) |
|
| 889 | + ); |
|
| 890 | + }); |
|
| 891 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
| 892 | + |
|
| 893 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
| 894 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
| 895 | + $manager->registerCapability(function () use ($c) { |
|
| 896 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
| 897 | + }); |
|
| 898 | + $manager->registerCapability(function () use ($c) { |
|
| 899 | + return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
|
| 900 | + }); |
|
| 901 | + return $manager; |
|
| 902 | + }); |
|
| 903 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
| 904 | + |
|
| 905 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
| 906 | + $config = $c->getConfig(); |
|
| 907 | + $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
|
| 908 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
| 909 | + $factory = new $factoryClass($this); |
|
| 910 | + $manager = $factory->getManager(); |
|
| 911 | + |
|
| 912 | + $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
|
| 913 | + $manager = $c->getUserManager(); |
|
| 914 | + $user = $manager->get($id); |
|
| 915 | + if(is_null($user)) { |
|
| 916 | + $l = $c->getL10N('core'); |
|
| 917 | + $displayName = $l->t('Unknown user'); |
|
| 918 | + } else { |
|
| 919 | + $displayName = $user->getDisplayName(); |
|
| 920 | + } |
|
| 921 | + return $displayName; |
|
| 922 | + }); |
|
| 923 | + |
|
| 924 | + return $manager; |
|
| 925 | + }); |
|
| 926 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
| 927 | + |
|
| 928 | + $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 929 | + /* |
|
| 930 | 930 | * Dark magic for autoloader. |
| 931 | 931 | * If we do a class_exists it will try to load the class which will |
| 932 | 932 | * make composer cache the result. Resulting in errors when enabling |
| 933 | 933 | * the theming app. |
| 934 | 934 | */ |
| 935 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
| 936 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
| 937 | - $classExists = true; |
|
| 938 | - } else { |
|
| 939 | - $classExists = false; |
|
| 940 | - } |
|
| 941 | - |
|
| 942 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
| 943 | - return new ThemingDefaults( |
|
| 944 | - $c->getConfig(), |
|
| 945 | - $c->getL10N('theming'), |
|
| 946 | - $c->getURLGenerator(), |
|
| 947 | - $c->getAppDataDir('theming'), |
|
| 948 | - $c->getMemCacheFactory(), |
|
| 949 | - new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming')), |
|
| 950 | - $this->getAppManager() |
|
| 951 | - ); |
|
| 952 | - } |
|
| 953 | - return new \OC_Defaults(); |
|
| 954 | - }); |
|
| 955 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
| 956 | - /** @var Factory $cacheFactory */ |
|
| 957 | - $cacheFactory = $c->query(Factory::class); |
|
| 958 | - return new SCSSCacher( |
|
| 959 | - $c->getLogger(), |
|
| 960 | - $c->query(\OC\Files\AppData\Factory::class), |
|
| 961 | - $c->getURLGenerator(), |
|
| 962 | - $c->getConfig(), |
|
| 963 | - $c->getThemingDefaults(), |
|
| 964 | - \OC::$SERVERROOT, |
|
| 965 | - $this->getMemCacheFactory() |
|
| 966 | - ); |
|
| 967 | - }); |
|
| 968 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 969 | - /** @var Factory $cacheFactory */ |
|
| 970 | - $cacheFactory = $c->query(Factory::class); |
|
| 971 | - return new JSCombiner( |
|
| 972 | - $c->getAppDataDir('js'), |
|
| 973 | - $c->getURLGenerator(), |
|
| 974 | - $this->getMemCacheFactory(), |
|
| 975 | - $c->getSystemConfig(), |
|
| 976 | - $c->getLogger() |
|
| 977 | - ); |
|
| 978 | - }); |
|
| 979 | - $this->registerService(EventDispatcher::class, function () { |
|
| 980 | - return new EventDispatcher(); |
|
| 981 | - }); |
|
| 982 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
| 983 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
| 984 | - |
|
| 985 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 986 | - // FIXME: Instantiiated here due to cyclic dependency |
|
| 987 | - $request = new Request( |
|
| 988 | - [ |
|
| 989 | - 'get' => $_GET, |
|
| 990 | - 'post' => $_POST, |
|
| 991 | - 'files' => $_FILES, |
|
| 992 | - 'server' => $_SERVER, |
|
| 993 | - 'env' => $_ENV, |
|
| 994 | - 'cookies' => $_COOKIE, |
|
| 995 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 996 | - ? $_SERVER['REQUEST_METHOD'] |
|
| 997 | - : null, |
|
| 998 | - ], |
|
| 999 | - $c->getSecureRandom(), |
|
| 1000 | - $c->getConfig() |
|
| 1001 | - ); |
|
| 1002 | - |
|
| 1003 | - return new CryptoWrapper( |
|
| 1004 | - $c->getConfig(), |
|
| 1005 | - $c->getCrypto(), |
|
| 1006 | - $c->getSecureRandom(), |
|
| 1007 | - $request |
|
| 1008 | - ); |
|
| 1009 | - }); |
|
| 1010 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
| 1011 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
| 1012 | - |
|
| 1013 | - return new CsrfTokenManager( |
|
| 1014 | - $tokenGenerator, |
|
| 1015 | - $c->query(SessionStorage::class) |
|
| 1016 | - ); |
|
| 1017 | - }); |
|
| 1018 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1019 | - return new SessionStorage($c->getSession()); |
|
| 1020 | - }); |
|
| 1021 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
| 1022 | - return new ContentSecurityPolicyManager(); |
|
| 1023 | - }); |
|
| 1024 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
| 1025 | - |
|
| 1026 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
| 1027 | - return new ContentSecurityPolicyNonceManager( |
|
| 1028 | - $c->getCsrfTokenManager(), |
|
| 1029 | - $c->getRequest() |
|
| 1030 | - ); |
|
| 1031 | - }); |
|
| 1032 | - |
|
| 1033 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1034 | - $config = $c->getConfig(); |
|
| 1035 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
| 1036 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
| 1037 | - $factory = new $factoryClass($this); |
|
| 1038 | - |
|
| 1039 | - $manager = new \OC\Share20\Manager( |
|
| 1040 | - $c->getLogger(), |
|
| 1041 | - $c->getConfig(), |
|
| 1042 | - $c->getSecureRandom(), |
|
| 1043 | - $c->getHasher(), |
|
| 1044 | - $c->getMountManager(), |
|
| 1045 | - $c->getGroupManager(), |
|
| 1046 | - $c->getL10N('lib'), |
|
| 1047 | - $c->getL10NFactory(), |
|
| 1048 | - $factory, |
|
| 1049 | - $c->getUserManager(), |
|
| 1050 | - $c->getLazyRootFolder(), |
|
| 1051 | - $c->getEventDispatcher(), |
|
| 1052 | - $c->getMailer(), |
|
| 1053 | - $c->getURLGenerator(), |
|
| 1054 | - $c->getThemingDefaults() |
|
| 1055 | - ); |
|
| 1056 | - |
|
| 1057 | - return $manager; |
|
| 1058 | - }); |
|
| 1059 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
| 1060 | - |
|
| 1061 | - $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
| 1062 | - $instance = new Collaboration\Collaborators\Search($c); |
|
| 1063 | - |
|
| 1064 | - // register default plugins |
|
| 1065 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
| 1066 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
| 1067 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
| 1068 | - $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
| 1069 | - |
|
| 1070 | - return $instance; |
|
| 1071 | - }); |
|
| 1072 | - $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
| 1073 | - |
|
| 1074 | - $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
| 1075 | - |
|
| 1076 | - $this->registerService('SettingsManager', function (Server $c) { |
|
| 1077 | - $manager = new \OC\Settings\Manager( |
|
| 1078 | - $c->getLogger(), |
|
| 1079 | - $c->getDatabaseConnection(), |
|
| 1080 | - $c->getL10N('lib'), |
|
| 1081 | - $c->getConfig(), |
|
| 1082 | - $c->getEncryptionManager(), |
|
| 1083 | - $c->getUserManager(), |
|
| 1084 | - $c->getLockingProvider(), |
|
| 1085 | - $c->getRequest(), |
|
| 1086 | - $c->getURLGenerator(), |
|
| 1087 | - $c->query(AccountManager::class), |
|
| 1088 | - $c->getGroupManager(), |
|
| 1089 | - $c->getL10NFactory(), |
|
| 1090 | - $c->getAppManager() |
|
| 1091 | - ); |
|
| 1092 | - return $manager; |
|
| 1093 | - }); |
|
| 1094 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1095 | - return new \OC\Files\AppData\Factory( |
|
| 1096 | - $c->getRootFolder(), |
|
| 1097 | - $c->getSystemConfig() |
|
| 1098 | - ); |
|
| 1099 | - }); |
|
| 1100 | - |
|
| 1101 | - $this->registerService('LockdownManager', function (Server $c) { |
|
| 1102 | - return new LockdownManager(function () use ($c) { |
|
| 1103 | - return $c->getSession(); |
|
| 1104 | - }); |
|
| 1105 | - }); |
|
| 1106 | - |
|
| 1107 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1108 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
| 1109 | - }); |
|
| 1110 | - |
|
| 1111 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1112 | - return new CloudIdManager(); |
|
| 1113 | - }); |
|
| 1114 | - |
|
| 1115 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 1116 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 1117 | - |
|
| 1118 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 1119 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 1120 | - |
|
| 1121 | - $this->registerService(Defaults::class, function (Server $c) { |
|
| 1122 | - return new Defaults( |
|
| 1123 | - $c->getThemingDefaults() |
|
| 1124 | - ); |
|
| 1125 | - }); |
|
| 1126 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
| 1127 | - |
|
| 1128 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1129 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
| 1130 | - }); |
|
| 1131 | - |
|
| 1132 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1133 | - return new ShareHelper( |
|
| 1134 | - $c->query(\OCP\Share\IManager::class) |
|
| 1135 | - ); |
|
| 1136 | - }); |
|
| 1137 | - |
|
| 1138 | - $this->registerService(Installer::class, function(Server $c) { |
|
| 1139 | - return new Installer( |
|
| 1140 | - $c->getAppFetcher(), |
|
| 1141 | - $c->getHTTPClientService(), |
|
| 1142 | - $c->getTempManager(), |
|
| 1143 | - $c->getLogger(), |
|
| 1144 | - $c->getConfig() |
|
| 1145 | - ); |
|
| 1146 | - }); |
|
| 1147 | - |
|
| 1148 | - $this->registerService(IApiFactory::class, function(Server $c) { |
|
| 1149 | - return new ApiFactory($c->getHTTPClientService()); |
|
| 1150 | - }); |
|
| 1151 | - |
|
| 1152 | - $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
| 1153 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1154 | - return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
| 1155 | - }); |
|
| 1156 | - |
|
| 1157 | - $this->registerService(IContactsStore::class, function(Server $c) { |
|
| 1158 | - return new ContactsStore( |
|
| 1159 | - $c->getContactsManager(), |
|
| 1160 | - $c->getConfig(), |
|
| 1161 | - $c->getUserManager(), |
|
| 1162 | - $c->getGroupManager() |
|
| 1163 | - ); |
|
| 1164 | - }); |
|
| 1165 | - $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
| 1166 | - |
|
| 1167 | - $this->connectDispatcher(); |
|
| 1168 | - } |
|
| 1169 | - |
|
| 1170 | - /** |
|
| 1171 | - * @return \OCP\Calendar\IManager |
|
| 1172 | - */ |
|
| 1173 | - public function getCalendarManager() { |
|
| 1174 | - return $this->query('CalendarManager'); |
|
| 1175 | - } |
|
| 1176 | - |
|
| 1177 | - private function connectDispatcher() { |
|
| 1178 | - $dispatcher = $this->getEventDispatcher(); |
|
| 1179 | - |
|
| 1180 | - // Delete avatar on user deletion |
|
| 1181 | - $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
| 1182 | - $logger = $this->getLogger(); |
|
| 1183 | - $manager = $this->getAvatarManager(); |
|
| 1184 | - /** @var IUser $user */ |
|
| 1185 | - $user = $e->getSubject(); |
|
| 1186 | - |
|
| 1187 | - try { |
|
| 1188 | - $avatar = $manager->getAvatar($user->getUID()); |
|
| 1189 | - $avatar->remove(); |
|
| 1190 | - } catch (NotFoundException $e) { |
|
| 1191 | - // no avatar to remove |
|
| 1192 | - } catch (\Exception $e) { |
|
| 1193 | - // Ignore exceptions |
|
| 1194 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1195 | - } |
|
| 1196 | - }); |
|
| 1197 | - |
|
| 1198 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1199 | - $manager = $this->getAvatarManager(); |
|
| 1200 | - /** @var IUser $user */ |
|
| 1201 | - $user = $e->getSubject(); |
|
| 1202 | - $feature = $e->getArgument('feature'); |
|
| 1203 | - $oldValue = $e->getArgument('oldValue'); |
|
| 1204 | - $value = $e->getArgument('value'); |
|
| 1205 | - |
|
| 1206 | - try { |
|
| 1207 | - $avatar = $manager->getAvatar($user->getUID()); |
|
| 1208 | - $avatar->userChanged($feature, $oldValue, $value); |
|
| 1209 | - } catch (NotFoundException $e) { |
|
| 1210 | - // no avatar to remove |
|
| 1211 | - } |
|
| 1212 | - }); |
|
| 1213 | - } |
|
| 1214 | - |
|
| 1215 | - /** |
|
| 1216 | - * @return \OCP\Contacts\IManager |
|
| 1217 | - */ |
|
| 1218 | - public function getContactsManager() { |
|
| 1219 | - return $this->query('ContactsManager'); |
|
| 1220 | - } |
|
| 1221 | - |
|
| 1222 | - /** |
|
| 1223 | - * @return \OC\Encryption\Manager |
|
| 1224 | - */ |
|
| 1225 | - public function getEncryptionManager() { |
|
| 1226 | - return $this->query('EncryptionManager'); |
|
| 1227 | - } |
|
| 1228 | - |
|
| 1229 | - /** |
|
| 1230 | - * @return \OC\Encryption\File |
|
| 1231 | - */ |
|
| 1232 | - public function getEncryptionFilesHelper() { |
|
| 1233 | - return $this->query('EncryptionFileHelper'); |
|
| 1234 | - } |
|
| 1235 | - |
|
| 1236 | - /** |
|
| 1237 | - * @return \OCP\Encryption\Keys\IStorage |
|
| 1238 | - */ |
|
| 1239 | - public function getEncryptionKeyStorage() { |
|
| 1240 | - return $this->query('EncryptionKeyStorage'); |
|
| 1241 | - } |
|
| 1242 | - |
|
| 1243 | - /** |
|
| 1244 | - * The current request object holding all information about the request |
|
| 1245 | - * currently being processed is returned from this method. |
|
| 1246 | - * In case the current execution was not initiated by a web request null is returned |
|
| 1247 | - * |
|
| 1248 | - * @return \OCP\IRequest |
|
| 1249 | - */ |
|
| 1250 | - public function getRequest() { |
|
| 1251 | - return $this->query('Request'); |
|
| 1252 | - } |
|
| 1253 | - |
|
| 1254 | - /** |
|
| 1255 | - * Returns the preview manager which can create preview images for a given file |
|
| 1256 | - * |
|
| 1257 | - * @return \OCP\IPreview |
|
| 1258 | - */ |
|
| 1259 | - public function getPreviewManager() { |
|
| 1260 | - return $this->query('PreviewManager'); |
|
| 1261 | - } |
|
| 1262 | - |
|
| 1263 | - /** |
|
| 1264 | - * Returns the tag manager which can get and set tags for different object types |
|
| 1265 | - * |
|
| 1266 | - * @see \OCP\ITagManager::load() |
|
| 1267 | - * @return \OCP\ITagManager |
|
| 1268 | - */ |
|
| 1269 | - public function getTagManager() { |
|
| 1270 | - return $this->query('TagManager'); |
|
| 1271 | - } |
|
| 1272 | - |
|
| 1273 | - /** |
|
| 1274 | - * Returns the system-tag manager |
|
| 1275 | - * |
|
| 1276 | - * @return \OCP\SystemTag\ISystemTagManager |
|
| 1277 | - * |
|
| 1278 | - * @since 9.0.0 |
|
| 1279 | - */ |
|
| 1280 | - public function getSystemTagManager() { |
|
| 1281 | - return $this->query('SystemTagManager'); |
|
| 1282 | - } |
|
| 1283 | - |
|
| 1284 | - /** |
|
| 1285 | - * Returns the system-tag object mapper |
|
| 1286 | - * |
|
| 1287 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
| 1288 | - * |
|
| 1289 | - * @since 9.0.0 |
|
| 1290 | - */ |
|
| 1291 | - public function getSystemTagObjectMapper() { |
|
| 1292 | - return $this->query('SystemTagObjectMapper'); |
|
| 1293 | - } |
|
| 1294 | - |
|
| 1295 | - /** |
|
| 1296 | - * Returns the avatar manager, used for avatar functionality |
|
| 1297 | - * |
|
| 1298 | - * @return \OCP\IAvatarManager |
|
| 1299 | - */ |
|
| 1300 | - public function getAvatarManager() { |
|
| 1301 | - return $this->query('AvatarManager'); |
|
| 1302 | - } |
|
| 1303 | - |
|
| 1304 | - /** |
|
| 1305 | - * Returns the root folder of ownCloud's data directory |
|
| 1306 | - * |
|
| 1307 | - * @return \OCP\Files\IRootFolder |
|
| 1308 | - */ |
|
| 1309 | - public function getRootFolder() { |
|
| 1310 | - return $this->query('LazyRootFolder'); |
|
| 1311 | - } |
|
| 1312 | - |
|
| 1313 | - /** |
|
| 1314 | - * Returns the root folder of ownCloud's data directory |
|
| 1315 | - * This is the lazy variant so this gets only initialized once it |
|
| 1316 | - * is actually used. |
|
| 1317 | - * |
|
| 1318 | - * @return \OCP\Files\IRootFolder |
|
| 1319 | - */ |
|
| 1320 | - public function getLazyRootFolder() { |
|
| 1321 | - return $this->query('LazyRootFolder'); |
|
| 1322 | - } |
|
| 1323 | - |
|
| 1324 | - /** |
|
| 1325 | - * Returns a view to ownCloud's files folder |
|
| 1326 | - * |
|
| 1327 | - * @param string $userId user ID |
|
| 1328 | - * @return \OCP\Files\Folder|null |
|
| 1329 | - */ |
|
| 1330 | - public function getUserFolder($userId = null) { |
|
| 1331 | - if ($userId === null) { |
|
| 1332 | - $user = $this->getUserSession()->getUser(); |
|
| 1333 | - if (!$user) { |
|
| 1334 | - return null; |
|
| 1335 | - } |
|
| 1336 | - $userId = $user->getUID(); |
|
| 1337 | - } |
|
| 1338 | - $root = $this->getRootFolder(); |
|
| 1339 | - return $root->getUserFolder($userId); |
|
| 1340 | - } |
|
| 1341 | - |
|
| 1342 | - /** |
|
| 1343 | - * Returns an app-specific view in ownClouds data directory |
|
| 1344 | - * |
|
| 1345 | - * @return \OCP\Files\Folder |
|
| 1346 | - * @deprecated since 9.2.0 use IAppData |
|
| 1347 | - */ |
|
| 1348 | - public function getAppFolder() { |
|
| 1349 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1350 | - $root = $this->getRootFolder(); |
|
| 1351 | - if (!$root->nodeExists($dir)) { |
|
| 1352 | - $folder = $root->newFolder($dir); |
|
| 1353 | - } else { |
|
| 1354 | - $folder = $root->get($dir); |
|
| 1355 | - } |
|
| 1356 | - return $folder; |
|
| 1357 | - } |
|
| 1358 | - |
|
| 1359 | - /** |
|
| 1360 | - * @return \OC\User\Manager |
|
| 1361 | - */ |
|
| 1362 | - public function getUserManager() { |
|
| 1363 | - return $this->query('UserManager'); |
|
| 1364 | - } |
|
| 1365 | - |
|
| 1366 | - /** |
|
| 1367 | - * @return \OC\Group\Manager |
|
| 1368 | - */ |
|
| 1369 | - public function getGroupManager() { |
|
| 1370 | - return $this->query('GroupManager'); |
|
| 1371 | - } |
|
| 1372 | - |
|
| 1373 | - /** |
|
| 1374 | - * @return \OC\User\Session |
|
| 1375 | - */ |
|
| 1376 | - public function getUserSession() { |
|
| 1377 | - return $this->query('UserSession'); |
|
| 1378 | - } |
|
| 1379 | - |
|
| 1380 | - /** |
|
| 1381 | - * @return \OCP\ISession |
|
| 1382 | - */ |
|
| 1383 | - public function getSession() { |
|
| 1384 | - return $this->query('UserSession')->getSession(); |
|
| 1385 | - } |
|
| 1386 | - |
|
| 1387 | - /** |
|
| 1388 | - * @param \OCP\ISession $session |
|
| 1389 | - */ |
|
| 1390 | - public function setSession(\OCP\ISession $session) { |
|
| 1391 | - $this->query(SessionStorage::class)->setSession($session); |
|
| 1392 | - $this->query('UserSession')->setSession($session); |
|
| 1393 | - $this->query(Store::class)->setSession($session); |
|
| 1394 | - } |
|
| 1395 | - |
|
| 1396 | - /** |
|
| 1397 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
| 1398 | - */ |
|
| 1399 | - public function getTwoFactorAuthManager() { |
|
| 1400 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
| 1401 | - } |
|
| 1402 | - |
|
| 1403 | - /** |
|
| 1404 | - * @return \OC\NavigationManager |
|
| 1405 | - */ |
|
| 1406 | - public function getNavigationManager() { |
|
| 1407 | - return $this->query('NavigationManager'); |
|
| 1408 | - } |
|
| 1409 | - |
|
| 1410 | - /** |
|
| 1411 | - * @return \OCP\IConfig |
|
| 1412 | - */ |
|
| 1413 | - public function getConfig() { |
|
| 1414 | - return $this->query('AllConfig'); |
|
| 1415 | - } |
|
| 1416 | - |
|
| 1417 | - /** |
|
| 1418 | - * @return \OC\SystemConfig |
|
| 1419 | - */ |
|
| 1420 | - public function getSystemConfig() { |
|
| 1421 | - return $this->query('SystemConfig'); |
|
| 1422 | - } |
|
| 1423 | - |
|
| 1424 | - /** |
|
| 1425 | - * Returns the app config manager |
|
| 1426 | - * |
|
| 1427 | - * @return \OCP\IAppConfig |
|
| 1428 | - */ |
|
| 1429 | - public function getAppConfig() { |
|
| 1430 | - return $this->query('AppConfig'); |
|
| 1431 | - } |
|
| 1432 | - |
|
| 1433 | - /** |
|
| 1434 | - * @return \OCP\L10N\IFactory |
|
| 1435 | - */ |
|
| 1436 | - public function getL10NFactory() { |
|
| 1437 | - return $this->query('L10NFactory'); |
|
| 1438 | - } |
|
| 1439 | - |
|
| 1440 | - /** |
|
| 1441 | - * get an L10N instance |
|
| 1442 | - * |
|
| 1443 | - * @param string $app appid |
|
| 1444 | - * @param string $lang |
|
| 1445 | - * @return IL10N |
|
| 1446 | - */ |
|
| 1447 | - public function getL10N($app, $lang = null) { |
|
| 1448 | - return $this->getL10NFactory()->get($app, $lang); |
|
| 1449 | - } |
|
| 1450 | - |
|
| 1451 | - /** |
|
| 1452 | - * @return \OCP\IURLGenerator |
|
| 1453 | - */ |
|
| 1454 | - public function getURLGenerator() { |
|
| 1455 | - return $this->query('URLGenerator'); |
|
| 1456 | - } |
|
| 1457 | - |
|
| 1458 | - /** |
|
| 1459 | - * @return AppFetcher |
|
| 1460 | - */ |
|
| 1461 | - public function getAppFetcher() { |
|
| 1462 | - return $this->query(AppFetcher::class); |
|
| 1463 | - } |
|
| 1464 | - |
|
| 1465 | - /** |
|
| 1466 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
| 1467 | - * getMemCacheFactory() instead. |
|
| 1468 | - * |
|
| 1469 | - * @return \OCP\ICache |
|
| 1470 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
| 1471 | - */ |
|
| 1472 | - public function getCache() { |
|
| 1473 | - return $this->query('UserCache'); |
|
| 1474 | - } |
|
| 1475 | - |
|
| 1476 | - /** |
|
| 1477 | - * Returns an \OCP\CacheFactory instance |
|
| 1478 | - * |
|
| 1479 | - * @return \OCP\ICacheFactory |
|
| 1480 | - */ |
|
| 1481 | - public function getMemCacheFactory() { |
|
| 1482 | - return $this->query('MemCacheFactory'); |
|
| 1483 | - } |
|
| 1484 | - |
|
| 1485 | - /** |
|
| 1486 | - * Returns an \OC\RedisFactory instance |
|
| 1487 | - * |
|
| 1488 | - * @return \OC\RedisFactory |
|
| 1489 | - */ |
|
| 1490 | - public function getGetRedisFactory() { |
|
| 1491 | - return $this->query('RedisFactory'); |
|
| 1492 | - } |
|
| 1493 | - |
|
| 1494 | - |
|
| 1495 | - /** |
|
| 1496 | - * Returns the current session |
|
| 1497 | - * |
|
| 1498 | - * @return \OCP\IDBConnection |
|
| 1499 | - */ |
|
| 1500 | - public function getDatabaseConnection() { |
|
| 1501 | - return $this->query('DatabaseConnection'); |
|
| 1502 | - } |
|
| 1503 | - |
|
| 1504 | - /** |
|
| 1505 | - * Returns the activity manager |
|
| 1506 | - * |
|
| 1507 | - * @return \OCP\Activity\IManager |
|
| 1508 | - */ |
|
| 1509 | - public function getActivityManager() { |
|
| 1510 | - return $this->query('ActivityManager'); |
|
| 1511 | - } |
|
| 1512 | - |
|
| 1513 | - /** |
|
| 1514 | - * Returns an job list for controlling background jobs |
|
| 1515 | - * |
|
| 1516 | - * @return \OCP\BackgroundJob\IJobList |
|
| 1517 | - */ |
|
| 1518 | - public function getJobList() { |
|
| 1519 | - return $this->query('JobList'); |
|
| 1520 | - } |
|
| 1521 | - |
|
| 1522 | - /** |
|
| 1523 | - * Returns a logger instance |
|
| 1524 | - * |
|
| 1525 | - * @return \OCP\ILogger |
|
| 1526 | - */ |
|
| 1527 | - public function getLogger() { |
|
| 1528 | - return $this->query('Logger'); |
|
| 1529 | - } |
|
| 1530 | - |
|
| 1531 | - /** |
|
| 1532 | - * Returns a router for generating and matching urls |
|
| 1533 | - * |
|
| 1534 | - * @return \OCP\Route\IRouter |
|
| 1535 | - */ |
|
| 1536 | - public function getRouter() { |
|
| 1537 | - return $this->query('Router'); |
|
| 1538 | - } |
|
| 1539 | - |
|
| 1540 | - /** |
|
| 1541 | - * Returns a search instance |
|
| 1542 | - * |
|
| 1543 | - * @return \OCP\ISearch |
|
| 1544 | - */ |
|
| 1545 | - public function getSearch() { |
|
| 1546 | - return $this->query('Search'); |
|
| 1547 | - } |
|
| 1548 | - |
|
| 1549 | - /** |
|
| 1550 | - * Returns a SecureRandom instance |
|
| 1551 | - * |
|
| 1552 | - * @return \OCP\Security\ISecureRandom |
|
| 1553 | - */ |
|
| 1554 | - public function getSecureRandom() { |
|
| 1555 | - return $this->query('SecureRandom'); |
|
| 1556 | - } |
|
| 1557 | - |
|
| 1558 | - /** |
|
| 1559 | - * Returns a Crypto instance |
|
| 1560 | - * |
|
| 1561 | - * @return \OCP\Security\ICrypto |
|
| 1562 | - */ |
|
| 1563 | - public function getCrypto() { |
|
| 1564 | - return $this->query('Crypto'); |
|
| 1565 | - } |
|
| 1566 | - |
|
| 1567 | - /** |
|
| 1568 | - * Returns a Hasher instance |
|
| 1569 | - * |
|
| 1570 | - * @return \OCP\Security\IHasher |
|
| 1571 | - */ |
|
| 1572 | - public function getHasher() { |
|
| 1573 | - return $this->query('Hasher'); |
|
| 1574 | - } |
|
| 1575 | - |
|
| 1576 | - /** |
|
| 1577 | - * Returns a CredentialsManager instance |
|
| 1578 | - * |
|
| 1579 | - * @return \OCP\Security\ICredentialsManager |
|
| 1580 | - */ |
|
| 1581 | - public function getCredentialsManager() { |
|
| 1582 | - return $this->query('CredentialsManager'); |
|
| 1583 | - } |
|
| 1584 | - |
|
| 1585 | - /** |
|
| 1586 | - * Returns an instance of the HTTP helper class |
|
| 1587 | - * |
|
| 1588 | - * @deprecated Use getHTTPClientService() |
|
| 1589 | - * @return \OC\HTTPHelper |
|
| 1590 | - */ |
|
| 1591 | - public function getHTTPHelper() { |
|
| 1592 | - return $this->query('HTTPHelper'); |
|
| 1593 | - } |
|
| 1594 | - |
|
| 1595 | - /** |
|
| 1596 | - * Get the certificate manager for the user |
|
| 1597 | - * |
|
| 1598 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 1599 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
| 1600 | - */ |
|
| 1601 | - public function getCertificateManager($userId = '') { |
|
| 1602 | - if ($userId === '') { |
|
| 1603 | - $userSession = $this->getUserSession(); |
|
| 1604 | - $user = $userSession->getUser(); |
|
| 1605 | - if (is_null($user)) { |
|
| 1606 | - return null; |
|
| 1607 | - } |
|
| 1608 | - $userId = $user->getUID(); |
|
| 1609 | - } |
|
| 1610 | - return new CertificateManager( |
|
| 1611 | - $userId, |
|
| 1612 | - new View(), |
|
| 1613 | - $this->getConfig(), |
|
| 1614 | - $this->getLogger(), |
|
| 1615 | - $this->getSecureRandom() |
|
| 1616 | - ); |
|
| 1617 | - } |
|
| 1618 | - |
|
| 1619 | - /** |
|
| 1620 | - * Returns an instance of the HTTP client service |
|
| 1621 | - * |
|
| 1622 | - * @return \OCP\Http\Client\IClientService |
|
| 1623 | - */ |
|
| 1624 | - public function getHTTPClientService() { |
|
| 1625 | - return $this->query('HttpClientService'); |
|
| 1626 | - } |
|
| 1627 | - |
|
| 1628 | - /** |
|
| 1629 | - * Create a new event source |
|
| 1630 | - * |
|
| 1631 | - * @return \OCP\IEventSource |
|
| 1632 | - */ |
|
| 1633 | - public function createEventSource() { |
|
| 1634 | - return new \OC_EventSource(); |
|
| 1635 | - } |
|
| 1636 | - |
|
| 1637 | - /** |
|
| 1638 | - * Get the active event logger |
|
| 1639 | - * |
|
| 1640 | - * The returned logger only logs data when debug mode is enabled |
|
| 1641 | - * |
|
| 1642 | - * @return \OCP\Diagnostics\IEventLogger |
|
| 1643 | - */ |
|
| 1644 | - public function getEventLogger() { |
|
| 1645 | - return $this->query('EventLogger'); |
|
| 1646 | - } |
|
| 1647 | - |
|
| 1648 | - /** |
|
| 1649 | - * Get the active query logger |
|
| 1650 | - * |
|
| 1651 | - * The returned logger only logs data when debug mode is enabled |
|
| 1652 | - * |
|
| 1653 | - * @return \OCP\Diagnostics\IQueryLogger |
|
| 1654 | - */ |
|
| 1655 | - public function getQueryLogger() { |
|
| 1656 | - return $this->query('QueryLogger'); |
|
| 1657 | - } |
|
| 1658 | - |
|
| 1659 | - /** |
|
| 1660 | - * Get the manager for temporary files and folders |
|
| 1661 | - * |
|
| 1662 | - * @return \OCP\ITempManager |
|
| 1663 | - */ |
|
| 1664 | - public function getTempManager() { |
|
| 1665 | - return $this->query('TempManager'); |
|
| 1666 | - } |
|
| 1667 | - |
|
| 1668 | - /** |
|
| 1669 | - * Get the app manager |
|
| 1670 | - * |
|
| 1671 | - * @return \OCP\App\IAppManager |
|
| 1672 | - */ |
|
| 1673 | - public function getAppManager() { |
|
| 1674 | - return $this->query('AppManager'); |
|
| 1675 | - } |
|
| 1676 | - |
|
| 1677 | - /** |
|
| 1678 | - * Creates a new mailer |
|
| 1679 | - * |
|
| 1680 | - * @return \OCP\Mail\IMailer |
|
| 1681 | - */ |
|
| 1682 | - public function getMailer() { |
|
| 1683 | - return $this->query('Mailer'); |
|
| 1684 | - } |
|
| 1685 | - |
|
| 1686 | - /** |
|
| 1687 | - * Get the webroot |
|
| 1688 | - * |
|
| 1689 | - * @return string |
|
| 1690 | - */ |
|
| 1691 | - public function getWebRoot() { |
|
| 1692 | - return $this->webRoot; |
|
| 1693 | - } |
|
| 1694 | - |
|
| 1695 | - /** |
|
| 1696 | - * @return \OC\OCSClient |
|
| 1697 | - */ |
|
| 1698 | - public function getOcsClient() { |
|
| 1699 | - return $this->query('OcsClient'); |
|
| 1700 | - } |
|
| 1701 | - |
|
| 1702 | - /** |
|
| 1703 | - * @return \OCP\IDateTimeZone |
|
| 1704 | - */ |
|
| 1705 | - public function getDateTimeZone() { |
|
| 1706 | - return $this->query('DateTimeZone'); |
|
| 1707 | - } |
|
| 1708 | - |
|
| 1709 | - /** |
|
| 1710 | - * @return \OCP\IDateTimeFormatter |
|
| 1711 | - */ |
|
| 1712 | - public function getDateTimeFormatter() { |
|
| 1713 | - return $this->query('DateTimeFormatter'); |
|
| 1714 | - } |
|
| 1715 | - |
|
| 1716 | - /** |
|
| 1717 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
| 1718 | - */ |
|
| 1719 | - public function getMountProviderCollection() { |
|
| 1720 | - return $this->query('MountConfigManager'); |
|
| 1721 | - } |
|
| 1722 | - |
|
| 1723 | - /** |
|
| 1724 | - * Get the IniWrapper |
|
| 1725 | - * |
|
| 1726 | - * @return IniGetWrapper |
|
| 1727 | - */ |
|
| 1728 | - public function getIniWrapper() { |
|
| 1729 | - return $this->query('IniWrapper'); |
|
| 1730 | - } |
|
| 1731 | - |
|
| 1732 | - /** |
|
| 1733 | - * @return \OCP\Command\IBus |
|
| 1734 | - */ |
|
| 1735 | - public function getCommandBus() { |
|
| 1736 | - return $this->query('AsyncCommandBus'); |
|
| 1737 | - } |
|
| 1738 | - |
|
| 1739 | - /** |
|
| 1740 | - * Get the trusted domain helper |
|
| 1741 | - * |
|
| 1742 | - * @return TrustedDomainHelper |
|
| 1743 | - */ |
|
| 1744 | - public function getTrustedDomainHelper() { |
|
| 1745 | - return $this->query('TrustedDomainHelper'); |
|
| 1746 | - } |
|
| 1747 | - |
|
| 1748 | - /** |
|
| 1749 | - * Get the locking provider |
|
| 1750 | - * |
|
| 1751 | - * @return \OCP\Lock\ILockingProvider |
|
| 1752 | - * @since 8.1.0 |
|
| 1753 | - */ |
|
| 1754 | - public function getLockingProvider() { |
|
| 1755 | - return $this->query('LockingProvider'); |
|
| 1756 | - } |
|
| 1757 | - |
|
| 1758 | - /** |
|
| 1759 | - * @return \OCP\Files\Mount\IMountManager |
|
| 1760 | - **/ |
|
| 1761 | - function getMountManager() { |
|
| 1762 | - return $this->query('MountManager'); |
|
| 1763 | - } |
|
| 1764 | - |
|
| 1765 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
| 1766 | - function getUserMountCache() { |
|
| 1767 | - return $this->query('UserMountCache'); |
|
| 1768 | - } |
|
| 1769 | - |
|
| 1770 | - /** |
|
| 1771 | - * Get the MimeTypeDetector |
|
| 1772 | - * |
|
| 1773 | - * @return \OCP\Files\IMimeTypeDetector |
|
| 1774 | - */ |
|
| 1775 | - public function getMimeTypeDetector() { |
|
| 1776 | - return $this->query('MimeTypeDetector'); |
|
| 1777 | - } |
|
| 1778 | - |
|
| 1779 | - /** |
|
| 1780 | - * Get the MimeTypeLoader |
|
| 1781 | - * |
|
| 1782 | - * @return \OCP\Files\IMimeTypeLoader |
|
| 1783 | - */ |
|
| 1784 | - public function getMimeTypeLoader() { |
|
| 1785 | - return $this->query('MimeTypeLoader'); |
|
| 1786 | - } |
|
| 1787 | - |
|
| 1788 | - /** |
|
| 1789 | - * Get the manager of all the capabilities |
|
| 1790 | - * |
|
| 1791 | - * @return \OC\CapabilitiesManager |
|
| 1792 | - */ |
|
| 1793 | - public function getCapabilitiesManager() { |
|
| 1794 | - return $this->query('CapabilitiesManager'); |
|
| 1795 | - } |
|
| 1796 | - |
|
| 1797 | - /** |
|
| 1798 | - * Get the EventDispatcher |
|
| 1799 | - * |
|
| 1800 | - * @return EventDispatcherInterface |
|
| 1801 | - * @since 8.2.0 |
|
| 1802 | - */ |
|
| 1803 | - public function getEventDispatcher() { |
|
| 1804 | - return $this->query('EventDispatcher'); |
|
| 1805 | - } |
|
| 1806 | - |
|
| 1807 | - /** |
|
| 1808 | - * Get the Notification Manager |
|
| 1809 | - * |
|
| 1810 | - * @return \OCP\Notification\IManager |
|
| 1811 | - * @since 8.2.0 |
|
| 1812 | - */ |
|
| 1813 | - public function getNotificationManager() { |
|
| 1814 | - return $this->query('NotificationManager'); |
|
| 1815 | - } |
|
| 1816 | - |
|
| 1817 | - /** |
|
| 1818 | - * @return \OCP\Comments\ICommentsManager |
|
| 1819 | - */ |
|
| 1820 | - public function getCommentsManager() { |
|
| 1821 | - return $this->query('CommentsManager'); |
|
| 1822 | - } |
|
| 1823 | - |
|
| 1824 | - /** |
|
| 1825 | - * @return \OCA\Theming\ThemingDefaults |
|
| 1826 | - */ |
|
| 1827 | - public function getThemingDefaults() { |
|
| 1828 | - return $this->query('ThemingDefaults'); |
|
| 1829 | - } |
|
| 1830 | - |
|
| 1831 | - /** |
|
| 1832 | - * @return \OC\IntegrityCheck\Checker |
|
| 1833 | - */ |
|
| 1834 | - public function getIntegrityCodeChecker() { |
|
| 1835 | - return $this->query('IntegrityCodeChecker'); |
|
| 1836 | - } |
|
| 1837 | - |
|
| 1838 | - /** |
|
| 1839 | - * @return \OC\Session\CryptoWrapper |
|
| 1840 | - */ |
|
| 1841 | - public function getSessionCryptoWrapper() { |
|
| 1842 | - return $this->query('CryptoWrapper'); |
|
| 1843 | - } |
|
| 1844 | - |
|
| 1845 | - /** |
|
| 1846 | - * @return CsrfTokenManager |
|
| 1847 | - */ |
|
| 1848 | - public function getCsrfTokenManager() { |
|
| 1849 | - return $this->query('CsrfTokenManager'); |
|
| 1850 | - } |
|
| 1851 | - |
|
| 1852 | - /** |
|
| 1853 | - * @return Throttler |
|
| 1854 | - */ |
|
| 1855 | - public function getBruteForceThrottler() { |
|
| 1856 | - return $this->query('Throttler'); |
|
| 1857 | - } |
|
| 1858 | - |
|
| 1859 | - /** |
|
| 1860 | - * @return IContentSecurityPolicyManager |
|
| 1861 | - */ |
|
| 1862 | - public function getContentSecurityPolicyManager() { |
|
| 1863 | - return $this->query('ContentSecurityPolicyManager'); |
|
| 1864 | - } |
|
| 1865 | - |
|
| 1866 | - /** |
|
| 1867 | - * @return ContentSecurityPolicyNonceManager |
|
| 1868 | - */ |
|
| 1869 | - public function getContentSecurityPolicyNonceManager() { |
|
| 1870 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
| 1871 | - } |
|
| 1872 | - |
|
| 1873 | - /** |
|
| 1874 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1875 | - * |
|
| 1876 | - * @return \OCA\Files_External\Service\BackendService |
|
| 1877 | - */ |
|
| 1878 | - public function getStoragesBackendService() { |
|
| 1879 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
| 1880 | - } |
|
| 1881 | - |
|
| 1882 | - /** |
|
| 1883 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1884 | - * |
|
| 1885 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
| 1886 | - */ |
|
| 1887 | - public function getGlobalStoragesService() { |
|
| 1888 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
| 1889 | - } |
|
| 1890 | - |
|
| 1891 | - /** |
|
| 1892 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1893 | - * |
|
| 1894 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
| 1895 | - */ |
|
| 1896 | - public function getUserGlobalStoragesService() { |
|
| 1897 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
| 1898 | - } |
|
| 1899 | - |
|
| 1900 | - /** |
|
| 1901 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1902 | - * |
|
| 1903 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
| 1904 | - */ |
|
| 1905 | - public function getUserStoragesService() { |
|
| 1906 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
| 1907 | - } |
|
| 1908 | - |
|
| 1909 | - /** |
|
| 1910 | - * @return \OCP\Share\IManager |
|
| 1911 | - */ |
|
| 1912 | - public function getShareManager() { |
|
| 1913 | - return $this->query('ShareManager'); |
|
| 1914 | - } |
|
| 1915 | - |
|
| 1916 | - /** |
|
| 1917 | - * @return \OCP\Collaboration\Collaborators\ISearch |
|
| 1918 | - */ |
|
| 1919 | - public function getCollaboratorSearch() { |
|
| 1920 | - return $this->query('CollaboratorSearch'); |
|
| 1921 | - } |
|
| 1922 | - |
|
| 1923 | - /** |
|
| 1924 | - * @return \OCP\Collaboration\AutoComplete\IManager |
|
| 1925 | - */ |
|
| 1926 | - public function getAutoCompleteManager(){ |
|
| 1927 | - return $this->query(IManager::class); |
|
| 1928 | - } |
|
| 1929 | - |
|
| 1930 | - /** |
|
| 1931 | - * Returns the LDAP Provider |
|
| 1932 | - * |
|
| 1933 | - * @return \OCP\LDAP\ILDAPProvider |
|
| 1934 | - */ |
|
| 1935 | - public function getLDAPProvider() { |
|
| 1936 | - return $this->query('LDAPProvider'); |
|
| 1937 | - } |
|
| 1938 | - |
|
| 1939 | - /** |
|
| 1940 | - * @return \OCP\Settings\IManager |
|
| 1941 | - */ |
|
| 1942 | - public function getSettingsManager() { |
|
| 1943 | - return $this->query('SettingsManager'); |
|
| 1944 | - } |
|
| 1945 | - |
|
| 1946 | - /** |
|
| 1947 | - * @return \OCP\Files\IAppData |
|
| 1948 | - */ |
|
| 1949 | - public function getAppDataDir($app) { |
|
| 1950 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
| 1951 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
| 1952 | - return $factory->get($app); |
|
| 1953 | - } |
|
| 1954 | - |
|
| 1955 | - /** |
|
| 1956 | - * @return \OCP\Lockdown\ILockdownManager |
|
| 1957 | - */ |
|
| 1958 | - public function getLockdownManager() { |
|
| 1959 | - return $this->query('LockdownManager'); |
|
| 1960 | - } |
|
| 1961 | - |
|
| 1962 | - /** |
|
| 1963 | - * @return \OCP\Federation\ICloudIdManager |
|
| 1964 | - */ |
|
| 1965 | - public function getCloudIdManager() { |
|
| 1966 | - return $this->query(ICloudIdManager::class); |
|
| 1967 | - } |
|
| 1968 | - |
|
| 1969 | - /** |
|
| 1970 | - * @return \OCP\Remote\Api\IApiFactory |
|
| 1971 | - */ |
|
| 1972 | - public function getRemoteApiFactory() { |
|
| 1973 | - return $this->query(IApiFactory::class); |
|
| 1974 | - } |
|
| 1975 | - |
|
| 1976 | - /** |
|
| 1977 | - * @return \OCP\Remote\IInstanceFactory |
|
| 1978 | - */ |
|
| 1979 | - public function getRemoteInstanceFactory() { |
|
| 1980 | - return $this->query(IInstanceFactory::class); |
|
| 1981 | - } |
|
| 935 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
| 936 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
| 937 | + $classExists = true; |
|
| 938 | + } else { |
|
| 939 | + $classExists = false; |
|
| 940 | + } |
|
| 941 | + |
|
| 942 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { |
|
| 943 | + return new ThemingDefaults( |
|
| 944 | + $c->getConfig(), |
|
| 945 | + $c->getL10N('theming'), |
|
| 946 | + $c->getURLGenerator(), |
|
| 947 | + $c->getAppDataDir('theming'), |
|
| 948 | + $c->getMemCacheFactory(), |
|
| 949 | + new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming')), |
|
| 950 | + $this->getAppManager() |
|
| 951 | + ); |
|
| 952 | + } |
|
| 953 | + return new \OC_Defaults(); |
|
| 954 | + }); |
|
| 955 | + $this->registerService(SCSSCacher::class, function (Server $c) { |
|
| 956 | + /** @var Factory $cacheFactory */ |
|
| 957 | + $cacheFactory = $c->query(Factory::class); |
|
| 958 | + return new SCSSCacher( |
|
| 959 | + $c->getLogger(), |
|
| 960 | + $c->query(\OC\Files\AppData\Factory::class), |
|
| 961 | + $c->getURLGenerator(), |
|
| 962 | + $c->getConfig(), |
|
| 963 | + $c->getThemingDefaults(), |
|
| 964 | + \OC::$SERVERROOT, |
|
| 965 | + $this->getMemCacheFactory() |
|
| 966 | + ); |
|
| 967 | + }); |
|
| 968 | + $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 969 | + /** @var Factory $cacheFactory */ |
|
| 970 | + $cacheFactory = $c->query(Factory::class); |
|
| 971 | + return new JSCombiner( |
|
| 972 | + $c->getAppDataDir('js'), |
|
| 973 | + $c->getURLGenerator(), |
|
| 974 | + $this->getMemCacheFactory(), |
|
| 975 | + $c->getSystemConfig(), |
|
| 976 | + $c->getLogger() |
|
| 977 | + ); |
|
| 978 | + }); |
|
| 979 | + $this->registerService(EventDispatcher::class, function () { |
|
| 980 | + return new EventDispatcher(); |
|
| 981 | + }); |
|
| 982 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
| 983 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
| 984 | + |
|
| 985 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 986 | + // FIXME: Instantiiated here due to cyclic dependency |
|
| 987 | + $request = new Request( |
|
| 988 | + [ |
|
| 989 | + 'get' => $_GET, |
|
| 990 | + 'post' => $_POST, |
|
| 991 | + 'files' => $_FILES, |
|
| 992 | + 'server' => $_SERVER, |
|
| 993 | + 'env' => $_ENV, |
|
| 994 | + 'cookies' => $_COOKIE, |
|
| 995 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 996 | + ? $_SERVER['REQUEST_METHOD'] |
|
| 997 | + : null, |
|
| 998 | + ], |
|
| 999 | + $c->getSecureRandom(), |
|
| 1000 | + $c->getConfig() |
|
| 1001 | + ); |
|
| 1002 | + |
|
| 1003 | + return new CryptoWrapper( |
|
| 1004 | + $c->getConfig(), |
|
| 1005 | + $c->getCrypto(), |
|
| 1006 | + $c->getSecureRandom(), |
|
| 1007 | + $request |
|
| 1008 | + ); |
|
| 1009 | + }); |
|
| 1010 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
| 1011 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
| 1012 | + |
|
| 1013 | + return new CsrfTokenManager( |
|
| 1014 | + $tokenGenerator, |
|
| 1015 | + $c->query(SessionStorage::class) |
|
| 1016 | + ); |
|
| 1017 | + }); |
|
| 1018 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1019 | + return new SessionStorage($c->getSession()); |
|
| 1020 | + }); |
|
| 1021 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
| 1022 | + return new ContentSecurityPolicyManager(); |
|
| 1023 | + }); |
|
| 1024 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
| 1025 | + |
|
| 1026 | + $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
| 1027 | + return new ContentSecurityPolicyNonceManager( |
|
| 1028 | + $c->getCsrfTokenManager(), |
|
| 1029 | + $c->getRequest() |
|
| 1030 | + ); |
|
| 1031 | + }); |
|
| 1032 | + |
|
| 1033 | + $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1034 | + $config = $c->getConfig(); |
|
| 1035 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
|
| 1036 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
| 1037 | + $factory = new $factoryClass($this); |
|
| 1038 | + |
|
| 1039 | + $manager = new \OC\Share20\Manager( |
|
| 1040 | + $c->getLogger(), |
|
| 1041 | + $c->getConfig(), |
|
| 1042 | + $c->getSecureRandom(), |
|
| 1043 | + $c->getHasher(), |
|
| 1044 | + $c->getMountManager(), |
|
| 1045 | + $c->getGroupManager(), |
|
| 1046 | + $c->getL10N('lib'), |
|
| 1047 | + $c->getL10NFactory(), |
|
| 1048 | + $factory, |
|
| 1049 | + $c->getUserManager(), |
|
| 1050 | + $c->getLazyRootFolder(), |
|
| 1051 | + $c->getEventDispatcher(), |
|
| 1052 | + $c->getMailer(), |
|
| 1053 | + $c->getURLGenerator(), |
|
| 1054 | + $c->getThemingDefaults() |
|
| 1055 | + ); |
|
| 1056 | + |
|
| 1057 | + return $manager; |
|
| 1058 | + }); |
|
| 1059 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
| 1060 | + |
|
| 1061 | + $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) { |
|
| 1062 | + $instance = new Collaboration\Collaborators\Search($c); |
|
| 1063 | + |
|
| 1064 | + // register default plugins |
|
| 1065 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]); |
|
| 1066 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]); |
|
| 1067 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]); |
|
| 1068 | + $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]); |
|
| 1069 | + |
|
| 1070 | + return $instance; |
|
| 1071 | + }); |
|
| 1072 | + $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class); |
|
| 1073 | + |
|
| 1074 | + $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
|
| 1075 | + |
|
| 1076 | + $this->registerService('SettingsManager', function (Server $c) { |
|
| 1077 | + $manager = new \OC\Settings\Manager( |
|
| 1078 | + $c->getLogger(), |
|
| 1079 | + $c->getDatabaseConnection(), |
|
| 1080 | + $c->getL10N('lib'), |
|
| 1081 | + $c->getConfig(), |
|
| 1082 | + $c->getEncryptionManager(), |
|
| 1083 | + $c->getUserManager(), |
|
| 1084 | + $c->getLockingProvider(), |
|
| 1085 | + $c->getRequest(), |
|
| 1086 | + $c->getURLGenerator(), |
|
| 1087 | + $c->query(AccountManager::class), |
|
| 1088 | + $c->getGroupManager(), |
|
| 1089 | + $c->getL10NFactory(), |
|
| 1090 | + $c->getAppManager() |
|
| 1091 | + ); |
|
| 1092 | + return $manager; |
|
| 1093 | + }); |
|
| 1094 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1095 | + return new \OC\Files\AppData\Factory( |
|
| 1096 | + $c->getRootFolder(), |
|
| 1097 | + $c->getSystemConfig() |
|
| 1098 | + ); |
|
| 1099 | + }); |
|
| 1100 | + |
|
| 1101 | + $this->registerService('LockdownManager', function (Server $c) { |
|
| 1102 | + return new LockdownManager(function () use ($c) { |
|
| 1103 | + return $c->getSession(); |
|
| 1104 | + }); |
|
| 1105 | + }); |
|
| 1106 | + |
|
| 1107 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1108 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
| 1109 | + }); |
|
| 1110 | + |
|
| 1111 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1112 | + return new CloudIdManager(); |
|
| 1113 | + }); |
|
| 1114 | + |
|
| 1115 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 1116 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 1117 | + |
|
| 1118 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 1119 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 1120 | + |
|
| 1121 | + $this->registerService(Defaults::class, function (Server $c) { |
|
| 1122 | + return new Defaults( |
|
| 1123 | + $c->getThemingDefaults() |
|
| 1124 | + ); |
|
| 1125 | + }); |
|
| 1126 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
| 1127 | + |
|
| 1128 | + $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1129 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
| 1130 | + }); |
|
| 1131 | + |
|
| 1132 | + $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1133 | + return new ShareHelper( |
|
| 1134 | + $c->query(\OCP\Share\IManager::class) |
|
| 1135 | + ); |
|
| 1136 | + }); |
|
| 1137 | + |
|
| 1138 | + $this->registerService(Installer::class, function(Server $c) { |
|
| 1139 | + return new Installer( |
|
| 1140 | + $c->getAppFetcher(), |
|
| 1141 | + $c->getHTTPClientService(), |
|
| 1142 | + $c->getTempManager(), |
|
| 1143 | + $c->getLogger(), |
|
| 1144 | + $c->getConfig() |
|
| 1145 | + ); |
|
| 1146 | + }); |
|
| 1147 | + |
|
| 1148 | + $this->registerService(IApiFactory::class, function(Server $c) { |
|
| 1149 | + return new ApiFactory($c->getHTTPClientService()); |
|
| 1150 | + }); |
|
| 1151 | + |
|
| 1152 | + $this->registerService(IInstanceFactory::class, function(Server $c) { |
|
| 1153 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
| 1154 | + return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService()); |
|
| 1155 | + }); |
|
| 1156 | + |
|
| 1157 | + $this->registerService(IContactsStore::class, function(Server $c) { |
|
| 1158 | + return new ContactsStore( |
|
| 1159 | + $c->getContactsManager(), |
|
| 1160 | + $c->getConfig(), |
|
| 1161 | + $c->getUserManager(), |
|
| 1162 | + $c->getGroupManager() |
|
| 1163 | + ); |
|
| 1164 | + }); |
|
| 1165 | + $this->registerAlias(IContactsStore::class, ContactsStore::class); |
|
| 1166 | + |
|
| 1167 | + $this->connectDispatcher(); |
|
| 1168 | + } |
|
| 1169 | + |
|
| 1170 | + /** |
|
| 1171 | + * @return \OCP\Calendar\IManager |
|
| 1172 | + */ |
|
| 1173 | + public function getCalendarManager() { |
|
| 1174 | + return $this->query('CalendarManager'); |
|
| 1175 | + } |
|
| 1176 | + |
|
| 1177 | + private function connectDispatcher() { |
|
| 1178 | + $dispatcher = $this->getEventDispatcher(); |
|
| 1179 | + |
|
| 1180 | + // Delete avatar on user deletion |
|
| 1181 | + $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
|
| 1182 | + $logger = $this->getLogger(); |
|
| 1183 | + $manager = $this->getAvatarManager(); |
|
| 1184 | + /** @var IUser $user */ |
|
| 1185 | + $user = $e->getSubject(); |
|
| 1186 | + |
|
| 1187 | + try { |
|
| 1188 | + $avatar = $manager->getAvatar($user->getUID()); |
|
| 1189 | + $avatar->remove(); |
|
| 1190 | + } catch (NotFoundException $e) { |
|
| 1191 | + // no avatar to remove |
|
| 1192 | + } catch (\Exception $e) { |
|
| 1193 | + // Ignore exceptions |
|
| 1194 | + $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1195 | + } |
|
| 1196 | + }); |
|
| 1197 | + |
|
| 1198 | + $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1199 | + $manager = $this->getAvatarManager(); |
|
| 1200 | + /** @var IUser $user */ |
|
| 1201 | + $user = $e->getSubject(); |
|
| 1202 | + $feature = $e->getArgument('feature'); |
|
| 1203 | + $oldValue = $e->getArgument('oldValue'); |
|
| 1204 | + $value = $e->getArgument('value'); |
|
| 1205 | + |
|
| 1206 | + try { |
|
| 1207 | + $avatar = $manager->getAvatar($user->getUID()); |
|
| 1208 | + $avatar->userChanged($feature, $oldValue, $value); |
|
| 1209 | + } catch (NotFoundException $e) { |
|
| 1210 | + // no avatar to remove |
|
| 1211 | + } |
|
| 1212 | + }); |
|
| 1213 | + } |
|
| 1214 | + |
|
| 1215 | + /** |
|
| 1216 | + * @return \OCP\Contacts\IManager |
|
| 1217 | + */ |
|
| 1218 | + public function getContactsManager() { |
|
| 1219 | + return $this->query('ContactsManager'); |
|
| 1220 | + } |
|
| 1221 | + |
|
| 1222 | + /** |
|
| 1223 | + * @return \OC\Encryption\Manager |
|
| 1224 | + */ |
|
| 1225 | + public function getEncryptionManager() { |
|
| 1226 | + return $this->query('EncryptionManager'); |
|
| 1227 | + } |
|
| 1228 | + |
|
| 1229 | + /** |
|
| 1230 | + * @return \OC\Encryption\File |
|
| 1231 | + */ |
|
| 1232 | + public function getEncryptionFilesHelper() { |
|
| 1233 | + return $this->query('EncryptionFileHelper'); |
|
| 1234 | + } |
|
| 1235 | + |
|
| 1236 | + /** |
|
| 1237 | + * @return \OCP\Encryption\Keys\IStorage |
|
| 1238 | + */ |
|
| 1239 | + public function getEncryptionKeyStorage() { |
|
| 1240 | + return $this->query('EncryptionKeyStorage'); |
|
| 1241 | + } |
|
| 1242 | + |
|
| 1243 | + /** |
|
| 1244 | + * The current request object holding all information about the request |
|
| 1245 | + * currently being processed is returned from this method. |
|
| 1246 | + * In case the current execution was not initiated by a web request null is returned |
|
| 1247 | + * |
|
| 1248 | + * @return \OCP\IRequest |
|
| 1249 | + */ |
|
| 1250 | + public function getRequest() { |
|
| 1251 | + return $this->query('Request'); |
|
| 1252 | + } |
|
| 1253 | + |
|
| 1254 | + /** |
|
| 1255 | + * Returns the preview manager which can create preview images for a given file |
|
| 1256 | + * |
|
| 1257 | + * @return \OCP\IPreview |
|
| 1258 | + */ |
|
| 1259 | + public function getPreviewManager() { |
|
| 1260 | + return $this->query('PreviewManager'); |
|
| 1261 | + } |
|
| 1262 | + |
|
| 1263 | + /** |
|
| 1264 | + * Returns the tag manager which can get and set tags for different object types |
|
| 1265 | + * |
|
| 1266 | + * @see \OCP\ITagManager::load() |
|
| 1267 | + * @return \OCP\ITagManager |
|
| 1268 | + */ |
|
| 1269 | + public function getTagManager() { |
|
| 1270 | + return $this->query('TagManager'); |
|
| 1271 | + } |
|
| 1272 | + |
|
| 1273 | + /** |
|
| 1274 | + * Returns the system-tag manager |
|
| 1275 | + * |
|
| 1276 | + * @return \OCP\SystemTag\ISystemTagManager |
|
| 1277 | + * |
|
| 1278 | + * @since 9.0.0 |
|
| 1279 | + */ |
|
| 1280 | + public function getSystemTagManager() { |
|
| 1281 | + return $this->query('SystemTagManager'); |
|
| 1282 | + } |
|
| 1283 | + |
|
| 1284 | + /** |
|
| 1285 | + * Returns the system-tag object mapper |
|
| 1286 | + * |
|
| 1287 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
| 1288 | + * |
|
| 1289 | + * @since 9.0.0 |
|
| 1290 | + */ |
|
| 1291 | + public function getSystemTagObjectMapper() { |
|
| 1292 | + return $this->query('SystemTagObjectMapper'); |
|
| 1293 | + } |
|
| 1294 | + |
|
| 1295 | + /** |
|
| 1296 | + * Returns the avatar manager, used for avatar functionality |
|
| 1297 | + * |
|
| 1298 | + * @return \OCP\IAvatarManager |
|
| 1299 | + */ |
|
| 1300 | + public function getAvatarManager() { |
|
| 1301 | + return $this->query('AvatarManager'); |
|
| 1302 | + } |
|
| 1303 | + |
|
| 1304 | + /** |
|
| 1305 | + * Returns the root folder of ownCloud's data directory |
|
| 1306 | + * |
|
| 1307 | + * @return \OCP\Files\IRootFolder |
|
| 1308 | + */ |
|
| 1309 | + public function getRootFolder() { |
|
| 1310 | + return $this->query('LazyRootFolder'); |
|
| 1311 | + } |
|
| 1312 | + |
|
| 1313 | + /** |
|
| 1314 | + * Returns the root folder of ownCloud's data directory |
|
| 1315 | + * This is the lazy variant so this gets only initialized once it |
|
| 1316 | + * is actually used. |
|
| 1317 | + * |
|
| 1318 | + * @return \OCP\Files\IRootFolder |
|
| 1319 | + */ |
|
| 1320 | + public function getLazyRootFolder() { |
|
| 1321 | + return $this->query('LazyRootFolder'); |
|
| 1322 | + } |
|
| 1323 | + |
|
| 1324 | + /** |
|
| 1325 | + * Returns a view to ownCloud's files folder |
|
| 1326 | + * |
|
| 1327 | + * @param string $userId user ID |
|
| 1328 | + * @return \OCP\Files\Folder|null |
|
| 1329 | + */ |
|
| 1330 | + public function getUserFolder($userId = null) { |
|
| 1331 | + if ($userId === null) { |
|
| 1332 | + $user = $this->getUserSession()->getUser(); |
|
| 1333 | + if (!$user) { |
|
| 1334 | + return null; |
|
| 1335 | + } |
|
| 1336 | + $userId = $user->getUID(); |
|
| 1337 | + } |
|
| 1338 | + $root = $this->getRootFolder(); |
|
| 1339 | + return $root->getUserFolder($userId); |
|
| 1340 | + } |
|
| 1341 | + |
|
| 1342 | + /** |
|
| 1343 | + * Returns an app-specific view in ownClouds data directory |
|
| 1344 | + * |
|
| 1345 | + * @return \OCP\Files\Folder |
|
| 1346 | + * @deprecated since 9.2.0 use IAppData |
|
| 1347 | + */ |
|
| 1348 | + public function getAppFolder() { |
|
| 1349 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1350 | + $root = $this->getRootFolder(); |
|
| 1351 | + if (!$root->nodeExists($dir)) { |
|
| 1352 | + $folder = $root->newFolder($dir); |
|
| 1353 | + } else { |
|
| 1354 | + $folder = $root->get($dir); |
|
| 1355 | + } |
|
| 1356 | + return $folder; |
|
| 1357 | + } |
|
| 1358 | + |
|
| 1359 | + /** |
|
| 1360 | + * @return \OC\User\Manager |
|
| 1361 | + */ |
|
| 1362 | + public function getUserManager() { |
|
| 1363 | + return $this->query('UserManager'); |
|
| 1364 | + } |
|
| 1365 | + |
|
| 1366 | + /** |
|
| 1367 | + * @return \OC\Group\Manager |
|
| 1368 | + */ |
|
| 1369 | + public function getGroupManager() { |
|
| 1370 | + return $this->query('GroupManager'); |
|
| 1371 | + } |
|
| 1372 | + |
|
| 1373 | + /** |
|
| 1374 | + * @return \OC\User\Session |
|
| 1375 | + */ |
|
| 1376 | + public function getUserSession() { |
|
| 1377 | + return $this->query('UserSession'); |
|
| 1378 | + } |
|
| 1379 | + |
|
| 1380 | + /** |
|
| 1381 | + * @return \OCP\ISession |
|
| 1382 | + */ |
|
| 1383 | + public function getSession() { |
|
| 1384 | + return $this->query('UserSession')->getSession(); |
|
| 1385 | + } |
|
| 1386 | + |
|
| 1387 | + /** |
|
| 1388 | + * @param \OCP\ISession $session |
|
| 1389 | + */ |
|
| 1390 | + public function setSession(\OCP\ISession $session) { |
|
| 1391 | + $this->query(SessionStorage::class)->setSession($session); |
|
| 1392 | + $this->query('UserSession')->setSession($session); |
|
| 1393 | + $this->query(Store::class)->setSession($session); |
|
| 1394 | + } |
|
| 1395 | + |
|
| 1396 | + /** |
|
| 1397 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
| 1398 | + */ |
|
| 1399 | + public function getTwoFactorAuthManager() { |
|
| 1400 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
| 1401 | + } |
|
| 1402 | + |
|
| 1403 | + /** |
|
| 1404 | + * @return \OC\NavigationManager |
|
| 1405 | + */ |
|
| 1406 | + public function getNavigationManager() { |
|
| 1407 | + return $this->query('NavigationManager'); |
|
| 1408 | + } |
|
| 1409 | + |
|
| 1410 | + /** |
|
| 1411 | + * @return \OCP\IConfig |
|
| 1412 | + */ |
|
| 1413 | + public function getConfig() { |
|
| 1414 | + return $this->query('AllConfig'); |
|
| 1415 | + } |
|
| 1416 | + |
|
| 1417 | + /** |
|
| 1418 | + * @return \OC\SystemConfig |
|
| 1419 | + */ |
|
| 1420 | + public function getSystemConfig() { |
|
| 1421 | + return $this->query('SystemConfig'); |
|
| 1422 | + } |
|
| 1423 | + |
|
| 1424 | + /** |
|
| 1425 | + * Returns the app config manager |
|
| 1426 | + * |
|
| 1427 | + * @return \OCP\IAppConfig |
|
| 1428 | + */ |
|
| 1429 | + public function getAppConfig() { |
|
| 1430 | + return $this->query('AppConfig'); |
|
| 1431 | + } |
|
| 1432 | + |
|
| 1433 | + /** |
|
| 1434 | + * @return \OCP\L10N\IFactory |
|
| 1435 | + */ |
|
| 1436 | + public function getL10NFactory() { |
|
| 1437 | + return $this->query('L10NFactory'); |
|
| 1438 | + } |
|
| 1439 | + |
|
| 1440 | + /** |
|
| 1441 | + * get an L10N instance |
|
| 1442 | + * |
|
| 1443 | + * @param string $app appid |
|
| 1444 | + * @param string $lang |
|
| 1445 | + * @return IL10N |
|
| 1446 | + */ |
|
| 1447 | + public function getL10N($app, $lang = null) { |
|
| 1448 | + return $this->getL10NFactory()->get($app, $lang); |
|
| 1449 | + } |
|
| 1450 | + |
|
| 1451 | + /** |
|
| 1452 | + * @return \OCP\IURLGenerator |
|
| 1453 | + */ |
|
| 1454 | + public function getURLGenerator() { |
|
| 1455 | + return $this->query('URLGenerator'); |
|
| 1456 | + } |
|
| 1457 | + |
|
| 1458 | + /** |
|
| 1459 | + * @return AppFetcher |
|
| 1460 | + */ |
|
| 1461 | + public function getAppFetcher() { |
|
| 1462 | + return $this->query(AppFetcher::class); |
|
| 1463 | + } |
|
| 1464 | + |
|
| 1465 | + /** |
|
| 1466 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
| 1467 | + * getMemCacheFactory() instead. |
|
| 1468 | + * |
|
| 1469 | + * @return \OCP\ICache |
|
| 1470 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
| 1471 | + */ |
|
| 1472 | + public function getCache() { |
|
| 1473 | + return $this->query('UserCache'); |
|
| 1474 | + } |
|
| 1475 | + |
|
| 1476 | + /** |
|
| 1477 | + * Returns an \OCP\CacheFactory instance |
|
| 1478 | + * |
|
| 1479 | + * @return \OCP\ICacheFactory |
|
| 1480 | + */ |
|
| 1481 | + public function getMemCacheFactory() { |
|
| 1482 | + return $this->query('MemCacheFactory'); |
|
| 1483 | + } |
|
| 1484 | + |
|
| 1485 | + /** |
|
| 1486 | + * Returns an \OC\RedisFactory instance |
|
| 1487 | + * |
|
| 1488 | + * @return \OC\RedisFactory |
|
| 1489 | + */ |
|
| 1490 | + public function getGetRedisFactory() { |
|
| 1491 | + return $this->query('RedisFactory'); |
|
| 1492 | + } |
|
| 1493 | + |
|
| 1494 | + |
|
| 1495 | + /** |
|
| 1496 | + * Returns the current session |
|
| 1497 | + * |
|
| 1498 | + * @return \OCP\IDBConnection |
|
| 1499 | + */ |
|
| 1500 | + public function getDatabaseConnection() { |
|
| 1501 | + return $this->query('DatabaseConnection'); |
|
| 1502 | + } |
|
| 1503 | + |
|
| 1504 | + /** |
|
| 1505 | + * Returns the activity manager |
|
| 1506 | + * |
|
| 1507 | + * @return \OCP\Activity\IManager |
|
| 1508 | + */ |
|
| 1509 | + public function getActivityManager() { |
|
| 1510 | + return $this->query('ActivityManager'); |
|
| 1511 | + } |
|
| 1512 | + |
|
| 1513 | + /** |
|
| 1514 | + * Returns an job list for controlling background jobs |
|
| 1515 | + * |
|
| 1516 | + * @return \OCP\BackgroundJob\IJobList |
|
| 1517 | + */ |
|
| 1518 | + public function getJobList() { |
|
| 1519 | + return $this->query('JobList'); |
|
| 1520 | + } |
|
| 1521 | + |
|
| 1522 | + /** |
|
| 1523 | + * Returns a logger instance |
|
| 1524 | + * |
|
| 1525 | + * @return \OCP\ILogger |
|
| 1526 | + */ |
|
| 1527 | + public function getLogger() { |
|
| 1528 | + return $this->query('Logger'); |
|
| 1529 | + } |
|
| 1530 | + |
|
| 1531 | + /** |
|
| 1532 | + * Returns a router for generating and matching urls |
|
| 1533 | + * |
|
| 1534 | + * @return \OCP\Route\IRouter |
|
| 1535 | + */ |
|
| 1536 | + public function getRouter() { |
|
| 1537 | + return $this->query('Router'); |
|
| 1538 | + } |
|
| 1539 | + |
|
| 1540 | + /** |
|
| 1541 | + * Returns a search instance |
|
| 1542 | + * |
|
| 1543 | + * @return \OCP\ISearch |
|
| 1544 | + */ |
|
| 1545 | + public function getSearch() { |
|
| 1546 | + return $this->query('Search'); |
|
| 1547 | + } |
|
| 1548 | + |
|
| 1549 | + /** |
|
| 1550 | + * Returns a SecureRandom instance |
|
| 1551 | + * |
|
| 1552 | + * @return \OCP\Security\ISecureRandom |
|
| 1553 | + */ |
|
| 1554 | + public function getSecureRandom() { |
|
| 1555 | + return $this->query('SecureRandom'); |
|
| 1556 | + } |
|
| 1557 | + |
|
| 1558 | + /** |
|
| 1559 | + * Returns a Crypto instance |
|
| 1560 | + * |
|
| 1561 | + * @return \OCP\Security\ICrypto |
|
| 1562 | + */ |
|
| 1563 | + public function getCrypto() { |
|
| 1564 | + return $this->query('Crypto'); |
|
| 1565 | + } |
|
| 1566 | + |
|
| 1567 | + /** |
|
| 1568 | + * Returns a Hasher instance |
|
| 1569 | + * |
|
| 1570 | + * @return \OCP\Security\IHasher |
|
| 1571 | + */ |
|
| 1572 | + public function getHasher() { |
|
| 1573 | + return $this->query('Hasher'); |
|
| 1574 | + } |
|
| 1575 | + |
|
| 1576 | + /** |
|
| 1577 | + * Returns a CredentialsManager instance |
|
| 1578 | + * |
|
| 1579 | + * @return \OCP\Security\ICredentialsManager |
|
| 1580 | + */ |
|
| 1581 | + public function getCredentialsManager() { |
|
| 1582 | + return $this->query('CredentialsManager'); |
|
| 1583 | + } |
|
| 1584 | + |
|
| 1585 | + /** |
|
| 1586 | + * Returns an instance of the HTTP helper class |
|
| 1587 | + * |
|
| 1588 | + * @deprecated Use getHTTPClientService() |
|
| 1589 | + * @return \OC\HTTPHelper |
|
| 1590 | + */ |
|
| 1591 | + public function getHTTPHelper() { |
|
| 1592 | + return $this->query('HTTPHelper'); |
|
| 1593 | + } |
|
| 1594 | + |
|
| 1595 | + /** |
|
| 1596 | + * Get the certificate manager for the user |
|
| 1597 | + * |
|
| 1598 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 1599 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
| 1600 | + */ |
|
| 1601 | + public function getCertificateManager($userId = '') { |
|
| 1602 | + if ($userId === '') { |
|
| 1603 | + $userSession = $this->getUserSession(); |
|
| 1604 | + $user = $userSession->getUser(); |
|
| 1605 | + if (is_null($user)) { |
|
| 1606 | + return null; |
|
| 1607 | + } |
|
| 1608 | + $userId = $user->getUID(); |
|
| 1609 | + } |
|
| 1610 | + return new CertificateManager( |
|
| 1611 | + $userId, |
|
| 1612 | + new View(), |
|
| 1613 | + $this->getConfig(), |
|
| 1614 | + $this->getLogger(), |
|
| 1615 | + $this->getSecureRandom() |
|
| 1616 | + ); |
|
| 1617 | + } |
|
| 1618 | + |
|
| 1619 | + /** |
|
| 1620 | + * Returns an instance of the HTTP client service |
|
| 1621 | + * |
|
| 1622 | + * @return \OCP\Http\Client\IClientService |
|
| 1623 | + */ |
|
| 1624 | + public function getHTTPClientService() { |
|
| 1625 | + return $this->query('HttpClientService'); |
|
| 1626 | + } |
|
| 1627 | + |
|
| 1628 | + /** |
|
| 1629 | + * Create a new event source |
|
| 1630 | + * |
|
| 1631 | + * @return \OCP\IEventSource |
|
| 1632 | + */ |
|
| 1633 | + public function createEventSource() { |
|
| 1634 | + return new \OC_EventSource(); |
|
| 1635 | + } |
|
| 1636 | + |
|
| 1637 | + /** |
|
| 1638 | + * Get the active event logger |
|
| 1639 | + * |
|
| 1640 | + * The returned logger only logs data when debug mode is enabled |
|
| 1641 | + * |
|
| 1642 | + * @return \OCP\Diagnostics\IEventLogger |
|
| 1643 | + */ |
|
| 1644 | + public function getEventLogger() { |
|
| 1645 | + return $this->query('EventLogger'); |
|
| 1646 | + } |
|
| 1647 | + |
|
| 1648 | + /** |
|
| 1649 | + * Get the active query logger |
|
| 1650 | + * |
|
| 1651 | + * The returned logger only logs data when debug mode is enabled |
|
| 1652 | + * |
|
| 1653 | + * @return \OCP\Diagnostics\IQueryLogger |
|
| 1654 | + */ |
|
| 1655 | + public function getQueryLogger() { |
|
| 1656 | + return $this->query('QueryLogger'); |
|
| 1657 | + } |
|
| 1658 | + |
|
| 1659 | + /** |
|
| 1660 | + * Get the manager for temporary files and folders |
|
| 1661 | + * |
|
| 1662 | + * @return \OCP\ITempManager |
|
| 1663 | + */ |
|
| 1664 | + public function getTempManager() { |
|
| 1665 | + return $this->query('TempManager'); |
|
| 1666 | + } |
|
| 1667 | + |
|
| 1668 | + /** |
|
| 1669 | + * Get the app manager |
|
| 1670 | + * |
|
| 1671 | + * @return \OCP\App\IAppManager |
|
| 1672 | + */ |
|
| 1673 | + public function getAppManager() { |
|
| 1674 | + return $this->query('AppManager'); |
|
| 1675 | + } |
|
| 1676 | + |
|
| 1677 | + /** |
|
| 1678 | + * Creates a new mailer |
|
| 1679 | + * |
|
| 1680 | + * @return \OCP\Mail\IMailer |
|
| 1681 | + */ |
|
| 1682 | + public function getMailer() { |
|
| 1683 | + return $this->query('Mailer'); |
|
| 1684 | + } |
|
| 1685 | + |
|
| 1686 | + /** |
|
| 1687 | + * Get the webroot |
|
| 1688 | + * |
|
| 1689 | + * @return string |
|
| 1690 | + */ |
|
| 1691 | + public function getWebRoot() { |
|
| 1692 | + return $this->webRoot; |
|
| 1693 | + } |
|
| 1694 | + |
|
| 1695 | + /** |
|
| 1696 | + * @return \OC\OCSClient |
|
| 1697 | + */ |
|
| 1698 | + public function getOcsClient() { |
|
| 1699 | + return $this->query('OcsClient'); |
|
| 1700 | + } |
|
| 1701 | + |
|
| 1702 | + /** |
|
| 1703 | + * @return \OCP\IDateTimeZone |
|
| 1704 | + */ |
|
| 1705 | + public function getDateTimeZone() { |
|
| 1706 | + return $this->query('DateTimeZone'); |
|
| 1707 | + } |
|
| 1708 | + |
|
| 1709 | + /** |
|
| 1710 | + * @return \OCP\IDateTimeFormatter |
|
| 1711 | + */ |
|
| 1712 | + public function getDateTimeFormatter() { |
|
| 1713 | + return $this->query('DateTimeFormatter'); |
|
| 1714 | + } |
|
| 1715 | + |
|
| 1716 | + /** |
|
| 1717 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
| 1718 | + */ |
|
| 1719 | + public function getMountProviderCollection() { |
|
| 1720 | + return $this->query('MountConfigManager'); |
|
| 1721 | + } |
|
| 1722 | + |
|
| 1723 | + /** |
|
| 1724 | + * Get the IniWrapper |
|
| 1725 | + * |
|
| 1726 | + * @return IniGetWrapper |
|
| 1727 | + */ |
|
| 1728 | + public function getIniWrapper() { |
|
| 1729 | + return $this->query('IniWrapper'); |
|
| 1730 | + } |
|
| 1731 | + |
|
| 1732 | + /** |
|
| 1733 | + * @return \OCP\Command\IBus |
|
| 1734 | + */ |
|
| 1735 | + public function getCommandBus() { |
|
| 1736 | + return $this->query('AsyncCommandBus'); |
|
| 1737 | + } |
|
| 1738 | + |
|
| 1739 | + /** |
|
| 1740 | + * Get the trusted domain helper |
|
| 1741 | + * |
|
| 1742 | + * @return TrustedDomainHelper |
|
| 1743 | + */ |
|
| 1744 | + public function getTrustedDomainHelper() { |
|
| 1745 | + return $this->query('TrustedDomainHelper'); |
|
| 1746 | + } |
|
| 1747 | + |
|
| 1748 | + /** |
|
| 1749 | + * Get the locking provider |
|
| 1750 | + * |
|
| 1751 | + * @return \OCP\Lock\ILockingProvider |
|
| 1752 | + * @since 8.1.0 |
|
| 1753 | + */ |
|
| 1754 | + public function getLockingProvider() { |
|
| 1755 | + return $this->query('LockingProvider'); |
|
| 1756 | + } |
|
| 1757 | + |
|
| 1758 | + /** |
|
| 1759 | + * @return \OCP\Files\Mount\IMountManager |
|
| 1760 | + **/ |
|
| 1761 | + function getMountManager() { |
|
| 1762 | + return $this->query('MountManager'); |
|
| 1763 | + } |
|
| 1764 | + |
|
| 1765 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
| 1766 | + function getUserMountCache() { |
|
| 1767 | + return $this->query('UserMountCache'); |
|
| 1768 | + } |
|
| 1769 | + |
|
| 1770 | + /** |
|
| 1771 | + * Get the MimeTypeDetector |
|
| 1772 | + * |
|
| 1773 | + * @return \OCP\Files\IMimeTypeDetector |
|
| 1774 | + */ |
|
| 1775 | + public function getMimeTypeDetector() { |
|
| 1776 | + return $this->query('MimeTypeDetector'); |
|
| 1777 | + } |
|
| 1778 | + |
|
| 1779 | + /** |
|
| 1780 | + * Get the MimeTypeLoader |
|
| 1781 | + * |
|
| 1782 | + * @return \OCP\Files\IMimeTypeLoader |
|
| 1783 | + */ |
|
| 1784 | + public function getMimeTypeLoader() { |
|
| 1785 | + return $this->query('MimeTypeLoader'); |
|
| 1786 | + } |
|
| 1787 | + |
|
| 1788 | + /** |
|
| 1789 | + * Get the manager of all the capabilities |
|
| 1790 | + * |
|
| 1791 | + * @return \OC\CapabilitiesManager |
|
| 1792 | + */ |
|
| 1793 | + public function getCapabilitiesManager() { |
|
| 1794 | + return $this->query('CapabilitiesManager'); |
|
| 1795 | + } |
|
| 1796 | + |
|
| 1797 | + /** |
|
| 1798 | + * Get the EventDispatcher |
|
| 1799 | + * |
|
| 1800 | + * @return EventDispatcherInterface |
|
| 1801 | + * @since 8.2.0 |
|
| 1802 | + */ |
|
| 1803 | + public function getEventDispatcher() { |
|
| 1804 | + return $this->query('EventDispatcher'); |
|
| 1805 | + } |
|
| 1806 | + |
|
| 1807 | + /** |
|
| 1808 | + * Get the Notification Manager |
|
| 1809 | + * |
|
| 1810 | + * @return \OCP\Notification\IManager |
|
| 1811 | + * @since 8.2.0 |
|
| 1812 | + */ |
|
| 1813 | + public function getNotificationManager() { |
|
| 1814 | + return $this->query('NotificationManager'); |
|
| 1815 | + } |
|
| 1816 | + |
|
| 1817 | + /** |
|
| 1818 | + * @return \OCP\Comments\ICommentsManager |
|
| 1819 | + */ |
|
| 1820 | + public function getCommentsManager() { |
|
| 1821 | + return $this->query('CommentsManager'); |
|
| 1822 | + } |
|
| 1823 | + |
|
| 1824 | + /** |
|
| 1825 | + * @return \OCA\Theming\ThemingDefaults |
|
| 1826 | + */ |
|
| 1827 | + public function getThemingDefaults() { |
|
| 1828 | + return $this->query('ThemingDefaults'); |
|
| 1829 | + } |
|
| 1830 | + |
|
| 1831 | + /** |
|
| 1832 | + * @return \OC\IntegrityCheck\Checker |
|
| 1833 | + */ |
|
| 1834 | + public function getIntegrityCodeChecker() { |
|
| 1835 | + return $this->query('IntegrityCodeChecker'); |
|
| 1836 | + } |
|
| 1837 | + |
|
| 1838 | + /** |
|
| 1839 | + * @return \OC\Session\CryptoWrapper |
|
| 1840 | + */ |
|
| 1841 | + public function getSessionCryptoWrapper() { |
|
| 1842 | + return $this->query('CryptoWrapper'); |
|
| 1843 | + } |
|
| 1844 | + |
|
| 1845 | + /** |
|
| 1846 | + * @return CsrfTokenManager |
|
| 1847 | + */ |
|
| 1848 | + public function getCsrfTokenManager() { |
|
| 1849 | + return $this->query('CsrfTokenManager'); |
|
| 1850 | + } |
|
| 1851 | + |
|
| 1852 | + /** |
|
| 1853 | + * @return Throttler |
|
| 1854 | + */ |
|
| 1855 | + public function getBruteForceThrottler() { |
|
| 1856 | + return $this->query('Throttler'); |
|
| 1857 | + } |
|
| 1858 | + |
|
| 1859 | + /** |
|
| 1860 | + * @return IContentSecurityPolicyManager |
|
| 1861 | + */ |
|
| 1862 | + public function getContentSecurityPolicyManager() { |
|
| 1863 | + return $this->query('ContentSecurityPolicyManager'); |
|
| 1864 | + } |
|
| 1865 | + |
|
| 1866 | + /** |
|
| 1867 | + * @return ContentSecurityPolicyNonceManager |
|
| 1868 | + */ |
|
| 1869 | + public function getContentSecurityPolicyNonceManager() { |
|
| 1870 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
| 1871 | + } |
|
| 1872 | + |
|
| 1873 | + /** |
|
| 1874 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1875 | + * |
|
| 1876 | + * @return \OCA\Files_External\Service\BackendService |
|
| 1877 | + */ |
|
| 1878 | + public function getStoragesBackendService() { |
|
| 1879 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
| 1880 | + } |
|
| 1881 | + |
|
| 1882 | + /** |
|
| 1883 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1884 | + * |
|
| 1885 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
| 1886 | + */ |
|
| 1887 | + public function getGlobalStoragesService() { |
|
| 1888 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
| 1889 | + } |
|
| 1890 | + |
|
| 1891 | + /** |
|
| 1892 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1893 | + * |
|
| 1894 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
| 1895 | + */ |
|
| 1896 | + public function getUserGlobalStoragesService() { |
|
| 1897 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
| 1898 | + } |
|
| 1899 | + |
|
| 1900 | + /** |
|
| 1901 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1902 | + * |
|
| 1903 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
| 1904 | + */ |
|
| 1905 | + public function getUserStoragesService() { |
|
| 1906 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
| 1907 | + } |
|
| 1908 | + |
|
| 1909 | + /** |
|
| 1910 | + * @return \OCP\Share\IManager |
|
| 1911 | + */ |
|
| 1912 | + public function getShareManager() { |
|
| 1913 | + return $this->query('ShareManager'); |
|
| 1914 | + } |
|
| 1915 | + |
|
| 1916 | + /** |
|
| 1917 | + * @return \OCP\Collaboration\Collaborators\ISearch |
|
| 1918 | + */ |
|
| 1919 | + public function getCollaboratorSearch() { |
|
| 1920 | + return $this->query('CollaboratorSearch'); |
|
| 1921 | + } |
|
| 1922 | + |
|
| 1923 | + /** |
|
| 1924 | + * @return \OCP\Collaboration\AutoComplete\IManager |
|
| 1925 | + */ |
|
| 1926 | + public function getAutoCompleteManager(){ |
|
| 1927 | + return $this->query(IManager::class); |
|
| 1928 | + } |
|
| 1929 | + |
|
| 1930 | + /** |
|
| 1931 | + * Returns the LDAP Provider |
|
| 1932 | + * |
|
| 1933 | + * @return \OCP\LDAP\ILDAPProvider |
|
| 1934 | + */ |
|
| 1935 | + public function getLDAPProvider() { |
|
| 1936 | + return $this->query('LDAPProvider'); |
|
| 1937 | + } |
|
| 1938 | + |
|
| 1939 | + /** |
|
| 1940 | + * @return \OCP\Settings\IManager |
|
| 1941 | + */ |
|
| 1942 | + public function getSettingsManager() { |
|
| 1943 | + return $this->query('SettingsManager'); |
|
| 1944 | + } |
|
| 1945 | + |
|
| 1946 | + /** |
|
| 1947 | + * @return \OCP\Files\IAppData |
|
| 1948 | + */ |
|
| 1949 | + public function getAppDataDir($app) { |
|
| 1950 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
| 1951 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
| 1952 | + return $factory->get($app); |
|
| 1953 | + } |
|
| 1954 | + |
|
| 1955 | + /** |
|
| 1956 | + * @return \OCP\Lockdown\ILockdownManager |
|
| 1957 | + */ |
|
| 1958 | + public function getLockdownManager() { |
|
| 1959 | + return $this->query('LockdownManager'); |
|
| 1960 | + } |
|
| 1961 | + |
|
| 1962 | + /** |
|
| 1963 | + * @return \OCP\Federation\ICloudIdManager |
|
| 1964 | + */ |
|
| 1965 | + public function getCloudIdManager() { |
|
| 1966 | + return $this->query(ICloudIdManager::class); |
|
| 1967 | + } |
|
| 1968 | + |
|
| 1969 | + /** |
|
| 1970 | + * @return \OCP\Remote\Api\IApiFactory |
|
| 1971 | + */ |
|
| 1972 | + public function getRemoteApiFactory() { |
|
| 1973 | + return $this->query(IApiFactory::class); |
|
| 1974 | + } |
|
| 1975 | + |
|
| 1976 | + /** |
|
| 1977 | + * @return \OCP\Remote\IInstanceFactory |
|
| 1978 | + */ |
|
| 1979 | + public function getRemoteInstanceFactory() { |
|
| 1980 | + return $this->query(IInstanceFactory::class); |
|
| 1981 | + } |
|
| 1982 | 1982 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | parent::__construct(); |
| 162 | 162 | $this->webRoot = $webRoot; |
| 163 | 163 | |
| 164 | - $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) { |
|
| 164 | + $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
| 165 | 165 | return $c; |
| 166 | 166 | }); |
| 167 | 167 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | $this->registerAlias(IActionFactory::class, ActionFactory::class); |
| 175 | 175 | |
| 176 | 176 | |
| 177 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
| 177 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
| 178 | 178 | return new PreviewManager( |
| 179 | 179 | $c->getConfig(), |
| 180 | 180 | $c->getRootFolder(), |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | }); |
| 186 | 186 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
| 187 | 187 | |
| 188 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 188 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
| 189 | 189 | return new \OC\Preview\Watcher( |
| 190 | 190 | $c->getAppDataDir('preview') |
| 191 | 191 | ); |
| 192 | 192 | }); |
| 193 | 193 | |
| 194 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
| 194 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
| 195 | 195 | $view = new View(); |
| 196 | 196 | $util = new Encryption\Util( |
| 197 | 197 | $view, |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | ); |
| 210 | 210 | }); |
| 211 | 211 | |
| 212 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 212 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
| 213 | 213 | $util = new Encryption\Util( |
| 214 | 214 | new View(), |
| 215 | 215 | $c->getUserManager(), |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | ); |
| 224 | 224 | }); |
| 225 | 225 | |
| 226 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 226 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
| 227 | 227 | $view = new View(); |
| 228 | 228 | $util = new Encryption\Util( |
| 229 | 229 | $view, |
@@ -234,30 +234,30 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | return new Encryption\Keys\Storage($view, $util); |
| 236 | 236 | }); |
| 237 | - $this->registerService('TagMapper', function (Server $c) { |
|
| 237 | + $this->registerService('TagMapper', function(Server $c) { |
|
| 238 | 238 | return new TagMapper($c->getDatabaseConnection()); |
| 239 | 239 | }); |
| 240 | 240 | |
| 241 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 241 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
| 242 | 242 | $tagMapper = $c->query('TagMapper'); |
| 243 | 243 | return new TagManager($tagMapper, $c->getUserSession()); |
| 244 | 244 | }); |
| 245 | 245 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
| 246 | 246 | |
| 247 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 247 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
| 248 | 248 | $config = $c->getConfig(); |
| 249 | 249 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class); |
| 250 | 250 | return new $factoryClass($this); |
| 251 | 251 | }); |
| 252 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
| 252 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
| 253 | 253 | return $c->query('SystemTagManagerFactory')->getManager(); |
| 254 | 254 | }); |
| 255 | 255 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
| 256 | 256 | |
| 257 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
| 257 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
| 258 | 258 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
| 259 | 259 | }); |
| 260 | - $this->registerService('RootFolder', function (Server $c) { |
|
| 260 | + $this->registerService('RootFolder', function(Server $c) { |
|
| 261 | 261 | $manager = \OC\Files\Filesystem::getMountManager(null); |
| 262 | 262 | $view = new View(); |
| 263 | 263 | $root = new Root( |
@@ -278,38 +278,38 @@ discard block |
||
| 278 | 278 | }); |
| 279 | 279 | $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
| 280 | 280 | |
| 281 | - $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) { |
|
| 282 | - return new LazyRoot(function () use ($c) { |
|
| 281 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
| 282 | + return new LazyRoot(function() use ($c) { |
|
| 283 | 283 | return $c->query('RootFolder'); |
| 284 | 284 | }); |
| 285 | 285 | }); |
| 286 | 286 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
| 287 | 287 | |
| 288 | - $this->registerService(\OC\User\Manager::class, function (Server $c) { |
|
| 288 | + $this->registerService(\OC\User\Manager::class, function(Server $c) { |
|
| 289 | 289 | $config = $c->getConfig(); |
| 290 | 290 | return new \OC\User\Manager($config); |
| 291 | 291 | }); |
| 292 | 292 | $this->registerAlias('UserManager', \OC\User\Manager::class); |
| 293 | 293 | $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class); |
| 294 | 294 | |
| 295 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 295 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
| 296 | 296 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
| 297 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 297 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
| 298 | 298 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
| 299 | 299 | }); |
| 300 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
| 300 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
| 301 | 301 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
| 302 | 302 | }); |
| 303 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 303 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
| 304 | 304 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
| 305 | 305 | }); |
| 306 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 306 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
| 307 | 307 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
| 308 | 308 | }); |
| 309 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 309 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 310 | 310 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
| 311 | 311 | }); |
| 312 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 312 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 313 | 313 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
| 314 | 314 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
| 315 | 315 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | }); |
| 319 | 319 | $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
| 320 | 320 | |
| 321 | - $this->registerService(Store::class, function (Server $c) { |
|
| 321 | + $this->registerService(Store::class, function(Server $c) { |
|
| 322 | 322 | $session = $c->getSession(); |
| 323 | 323 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
| 324 | 324 | $tokenProvider = $c->query(IProvider::class); |
@@ -329,11 +329,11 @@ discard block |
||
| 329 | 329 | return new Store($session, $logger, $tokenProvider); |
| 330 | 330 | }); |
| 331 | 331 | $this->registerAlias(IStore::class, Store::class); |
| 332 | - $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) { |
|
| 332 | + $this->registerService(Authentication\Token\DefaultTokenMapper::class, function(Server $c) { |
|
| 333 | 333 | $dbConnection = $c->getDatabaseConnection(); |
| 334 | 334 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
| 335 | 335 | }); |
| 336 | - $this->registerService(Authentication\Token\DefaultTokenProvider::class, function (Server $c) { |
|
| 336 | + $this->registerService(Authentication\Token\DefaultTokenProvider::class, function(Server $c) { |
|
| 337 | 337 | $mapper = $c->query(Authentication\Token\DefaultTokenMapper::class); |
| 338 | 338 | $crypto = $c->getCrypto(); |
| 339 | 339 | $config = $c->getConfig(); |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | }); |
| 344 | 344 | $this->registerAlias(IProvider::class, Authentication\Token\DefaultTokenProvider::class); |
| 345 | 345 | |
| 346 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
| 346 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
| 347 | 347 | $manager = $c->getUserManager(); |
| 348 | 348 | $session = new \OC\Session\Memory(''); |
| 349 | 349 | $timeFactory = new TimeFactory(); |
@@ -367,45 +367,45 @@ discard block |
||
| 367 | 367 | $c->getLockdownManager(), |
| 368 | 368 | $c->getLogger() |
| 369 | 369 | ); |
| 370 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 370 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
| 371 | 371 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
| 372 | 372 | }); |
| 373 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 373 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
| 374 | 374 | /** @var $user \OC\User\User */ |
| 375 | 375 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
| 376 | 376 | }); |
| 377 | - $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) { |
|
| 377 | + $userSession->listen('\OC\User', 'preDelete', function($user) use ($dispatcher) { |
|
| 378 | 378 | /** @var $user \OC\User\User */ |
| 379 | 379 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
| 380 | 380 | $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user)); |
| 381 | 381 | }); |
| 382 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 382 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
| 383 | 383 | /** @var $user \OC\User\User */ |
| 384 | 384 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
| 385 | 385 | }); |
| 386 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 386 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
| 387 | 387 | /** @var $user \OC\User\User */ |
| 388 | 388 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
| 389 | 389 | }); |
| 390 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 390 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
| 391 | 391 | /** @var $user \OC\User\User */ |
| 392 | 392 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
| 393 | 393 | }); |
| 394 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 394 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
| 395 | 395 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
| 396 | 396 | }); |
| 397 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
| 397 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
| 398 | 398 | /** @var $user \OC\User\User */ |
| 399 | 399 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
| 400 | 400 | }); |
| 401 | - $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) { |
|
| 401 | + $userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) { |
|
| 402 | 402 | /** @var $user \OC\User\User */ |
| 403 | 403 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
| 404 | 404 | }); |
| 405 | - $userSession->listen('\OC\User', 'logout', function () { |
|
| 405 | + $userSession->listen('\OC\User', 'logout', function() { |
|
| 406 | 406 | \OC_Hook::emit('OC_User', 'logout', array()); |
| 407 | 407 | }); |
| 408 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
| 408 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) use ($dispatcher) { |
|
| 409 | 409 | /** @var $user \OC\User\User */ |
| 410 | 410 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
| 411 | 411 | $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | }); |
| 415 | 415 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
| 416 | 416 | |
| 417 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
| 417 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
| 418 | 418 | return new \OC\Authentication\TwoFactorAuth\Manager( |
| 419 | 419 | $c->getAppManager(), |
| 420 | 420 | $c->getSession(), |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
| 431 | 431 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
| 432 | 432 | |
| 433 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 433 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
| 434 | 434 | return new \OC\AllConfig( |
| 435 | 435 | $c->getSystemConfig() |
| 436 | 436 | ); |
@@ -438,17 +438,17 @@ discard block |
||
| 438 | 438 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
| 439 | 439 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
| 440 | 440 | |
| 441 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
| 441 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
| 442 | 442 | return new \OC\SystemConfig($config); |
| 443 | 443 | }); |
| 444 | 444 | |
| 445 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 445 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
| 446 | 446 | return new \OC\AppConfig($c->getDatabaseConnection()); |
| 447 | 447 | }); |
| 448 | 448 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
| 449 | 449 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
| 450 | 450 | |
| 451 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
| 451 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
| 452 | 452 | return new \OC\L10N\Factory( |
| 453 | 453 | $c->getConfig(), |
| 454 | 454 | $c->getRequest(), |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | }); |
| 459 | 459 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
| 460 | 460 | |
| 461 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
| 461 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
| 462 | 462 | $config = $c->getConfig(); |
| 463 | 463 | $cacheFactory = $c->getMemCacheFactory(); |
| 464 | 464 | $request = $c->getRequest(); |
@@ -473,12 +473,12 @@ discard block |
||
| 473 | 473 | $this->registerAlias('AppFetcher', AppFetcher::class); |
| 474 | 474 | $this->registerAlias('CategoryFetcher', CategoryFetcher::class); |
| 475 | 475 | |
| 476 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
| 476 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
| 477 | 477 | return new Cache\File(); |
| 478 | 478 | }); |
| 479 | 479 | $this->registerAlias('UserCache', \OCP\ICache::class); |
| 480 | 480 | |
| 481 | - $this->registerService(Factory::class, function (Server $c) { |
|
| 481 | + $this->registerService(Factory::class, function(Server $c) { |
|
| 482 | 482 | |
| 483 | 483 | $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(), |
| 484 | 484 | ArrayCache::class, |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | $version = implode(',', $v); |
| 496 | 496 | $instanceId = \OC_Util::getInstanceId(); |
| 497 | 497 | $path = \OC::$SERVERROOT; |
| 498 | - $prefix = md5($instanceId . '-' . $version . '-' . $path); |
|
| 498 | + $prefix = md5($instanceId.'-'.$version.'-'.$path); |
|
| 499 | 499 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
| 500 | 500 | $config->getSystemValue('memcache.local', null), |
| 501 | 501 | $config->getSystemValue('memcache.distributed', null), |
@@ -508,12 +508,12 @@ discard block |
||
| 508 | 508 | $this->registerAlias('MemCacheFactory', Factory::class); |
| 509 | 509 | $this->registerAlias(ICacheFactory::class, Factory::class); |
| 510 | 510 | |
| 511 | - $this->registerService('RedisFactory', function (Server $c) { |
|
| 511 | + $this->registerService('RedisFactory', function(Server $c) { |
|
| 512 | 512 | $systemConfig = $c->getSystemConfig(); |
| 513 | 513 | return new RedisFactory($systemConfig); |
| 514 | 514 | }); |
| 515 | 515 | |
| 516 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 516 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
| 517 | 517 | return new \OC\Activity\Manager( |
| 518 | 518 | $c->getRequest(), |
| 519 | 519 | $c->getUserSession(), |
@@ -523,14 +523,14 @@ discard block |
||
| 523 | 523 | }); |
| 524 | 524 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
| 525 | 525 | |
| 526 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 526 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
| 527 | 527 | return new \OC\Activity\EventMerger( |
| 528 | 528 | $c->getL10N('lib') |
| 529 | 529 | ); |
| 530 | 530 | }); |
| 531 | 531 | $this->registerAlias(IValidator::class, Validator::class); |
| 532 | 532 | |
| 533 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
| 533 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
| 534 | 534 | return new AvatarManager( |
| 535 | 535 | $c->query(\OC\User\Manager::class), |
| 536 | 536 | $c->getAppDataDir('avatar'), |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class); |
| 545 | 545 | |
| 546 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
| 546 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
| 547 | 547 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
| 548 | 548 | $logger = Log::getLogClass($logType); |
| 549 | 549 | call_user_func(array($logger, 'init')); |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | }); |
| 555 | 555 | $this->registerAlias('Logger', \OCP\ILogger::class); |
| 556 | 556 | |
| 557 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
| 557 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
| 558 | 558 | $config = $c->getConfig(); |
| 559 | 559 | return new \OC\BackgroundJob\JobList( |
| 560 | 560 | $c->getDatabaseConnection(), |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | }); |
| 565 | 565 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
| 566 | 566 | |
| 567 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
| 567 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
| 568 | 568 | $cacheFactory = $c->getMemCacheFactory(); |
| 569 | 569 | $logger = $c->getLogger(); |
| 570 | 570 | if ($cacheFactory->isAvailableLowLatency()) { |
@@ -576,12 +576,12 @@ discard block |
||
| 576 | 576 | }); |
| 577 | 577 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
| 578 | 578 | |
| 579 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
| 579 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
| 580 | 580 | return new Search(); |
| 581 | 581 | }); |
| 582 | 582 | $this->registerAlias('Search', \OCP\ISearch::class); |
| 583 | 583 | |
| 584 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) { |
|
| 584 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) { |
|
| 585 | 585 | return new \OC\Security\RateLimiting\Limiter( |
| 586 | 586 | $this->getUserSession(), |
| 587 | 587 | $this->getRequest(), |
@@ -589,34 +589,34 @@ discard block |
||
| 589 | 589 | $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
| 590 | 590 | ); |
| 591 | 591 | }); |
| 592 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) { |
|
| 592 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
| 593 | 593 | return new \OC\Security\RateLimiting\Backend\MemoryCache( |
| 594 | 594 | $this->getMemCacheFactory(), |
| 595 | 595 | new \OC\AppFramework\Utility\TimeFactory() |
| 596 | 596 | ); |
| 597 | 597 | }); |
| 598 | 598 | |
| 599 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 599 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
| 600 | 600 | return new SecureRandom(); |
| 601 | 601 | }); |
| 602 | 602 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
| 603 | 603 | |
| 604 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
| 604 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
| 605 | 605 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
| 606 | 606 | }); |
| 607 | 607 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
| 608 | 608 | |
| 609 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
| 609 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
| 610 | 610 | return new Hasher($c->getConfig()); |
| 611 | 611 | }); |
| 612 | 612 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
| 613 | 613 | |
| 614 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
| 614 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
| 615 | 615 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
| 616 | 616 | }); |
| 617 | 617 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
| 618 | 618 | |
| 619 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 619 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
| 620 | 620 | $systemConfig = $c->getSystemConfig(); |
| 621 | 621 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
| 622 | 622 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | }); |
| 631 | 631 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
| 632 | 632 | |
| 633 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
| 633 | + $this->registerService('HTTPHelper', function(Server $c) { |
|
| 634 | 634 | $config = $c->getConfig(); |
| 635 | 635 | return new HTTPHelper( |
| 636 | 636 | $config, |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | ); |
| 639 | 639 | }); |
| 640 | 640 | |
| 641 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
| 641 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
| 642 | 642 | $user = \OC_User::getUser(); |
| 643 | 643 | $uid = $user ? $user : null; |
| 644 | 644 | return new ClientService( |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | ); |
| 654 | 654 | }); |
| 655 | 655 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
| 656 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
| 656 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
| 657 | 657 | $eventLogger = new EventLogger(); |
| 658 | 658 | if ($c->getSystemConfig()->getValue('debug', false)) { |
| 659 | 659 | // In debug mode, module is being activated by default |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | }); |
| 664 | 664 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
| 665 | 665 | |
| 666 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
| 666 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
| 667 | 667 | $queryLogger = new QueryLogger(); |
| 668 | 668 | if ($c->getSystemConfig()->getValue('debug', false)) { |
| 669 | 669 | // In debug mode, module is being activated by default |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | }); |
| 674 | 674 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
| 675 | 675 | |
| 676 | - $this->registerService(TempManager::class, function (Server $c) { |
|
| 676 | + $this->registerService(TempManager::class, function(Server $c) { |
|
| 677 | 677 | return new TempManager( |
| 678 | 678 | $c->getLogger(), |
| 679 | 679 | $c->getConfig() |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | $this->registerAlias('TempManager', TempManager::class); |
| 683 | 683 | $this->registerAlias(ITempManager::class, TempManager::class); |
| 684 | 684 | |
| 685 | - $this->registerService(AppManager::class, function (Server $c) { |
|
| 685 | + $this->registerService(AppManager::class, function(Server $c) { |
|
| 686 | 686 | return new \OC\App\AppManager( |
| 687 | 687 | $c->getUserSession(), |
| 688 | 688 | $c->query(\OC\AppConfig::class), |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | $this->registerAlias('AppManager', AppManager::class); |
| 695 | 695 | $this->registerAlias(IAppManager::class, AppManager::class); |
| 696 | 696 | |
| 697 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
| 697 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
| 698 | 698 | return new DateTimeZone( |
| 699 | 699 | $c->getConfig(), |
| 700 | 700 | $c->getSession() |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | }); |
| 703 | 703 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
| 704 | 704 | |
| 705 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
| 705 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
| 706 | 706 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
| 707 | 707 | |
| 708 | 708 | return new DateTimeFormatter( |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | }); |
| 713 | 713 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
| 714 | 714 | |
| 715 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
| 715 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
| 716 | 716 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
| 717 | 717 | $listener = new UserMountCacheListener($mountCache); |
| 718 | 718 | $listener->listen($c->getUserManager()); |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | }); |
| 721 | 721 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
| 722 | 722 | |
| 723 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
| 723 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
| 724 | 724 | $loader = \OC\Files\Filesystem::getLoader(); |
| 725 | 725 | $mountCache = $c->query('UserMountCache'); |
| 726 | 726 | $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
@@ -736,10 +736,10 @@ discard block |
||
| 736 | 736 | }); |
| 737 | 737 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
| 738 | 738 | |
| 739 | - $this->registerService('IniWrapper', function ($c) { |
|
| 739 | + $this->registerService('IniWrapper', function($c) { |
|
| 740 | 740 | return new IniGetWrapper(); |
| 741 | 741 | }); |
| 742 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 742 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
| 743 | 743 | $busClass = $c->getConfig()->getSystemValue('commandbus'); |
| 744 | 744 | if ($busClass) { |
| 745 | 745 | list($app, $class) = explode('::', $busClass, 2); |
@@ -754,10 +754,10 @@ discard block |
||
| 754 | 754 | return new CronBus($jobList); |
| 755 | 755 | } |
| 756 | 756 | }); |
| 757 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 757 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
| 758 | 758 | return new TrustedDomainHelper($this->getConfig()); |
| 759 | 759 | }); |
| 760 | - $this->registerService('Throttler', function (Server $c) { |
|
| 760 | + $this->registerService('Throttler', function(Server $c) { |
|
| 761 | 761 | return new Throttler( |
| 762 | 762 | $c->getDatabaseConnection(), |
| 763 | 763 | new TimeFactory(), |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | $c->getConfig() |
| 766 | 766 | ); |
| 767 | 767 | }); |
| 768 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 768 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
| 769 | 769 | // IConfig and IAppManager requires a working database. This code |
| 770 | 770 | // might however be called when ownCloud is not yet setup. |
| 771 | 771 | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | $c->getTempManager() |
| 787 | 787 | ); |
| 788 | 788 | }); |
| 789 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 789 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
| 790 | 790 | if (isset($this['urlParams'])) { |
| 791 | 791 | $urlParams = $this['urlParams']; |
| 792 | 792 | } else { |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | }); |
| 823 | 823 | $this->registerAlias('Request', \OCP\IRequest::class); |
| 824 | 824 | |
| 825 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
| 825 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
| 826 | 826 | return new Mailer( |
| 827 | 827 | $c->getConfig(), |
| 828 | 828 | $c->getLogger(), |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | }); |
| 834 | 834 | $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
| 835 | 835 | |
| 836 | - $this->registerService('LDAPProvider', function (Server $c) { |
|
| 836 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
| 837 | 837 | $config = $c->getConfig(); |
| 838 | 838 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
| 839 | 839 | if (is_null($factoryClass)) { |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | $factory = new $factoryClass($this); |
| 844 | 844 | return $factory->getLDAPProvider(); |
| 845 | 845 | }); |
| 846 | - $this->registerService(ILockingProvider::class, function (Server $c) { |
|
| 846 | + $this->registerService(ILockingProvider::class, function(Server $c) { |
|
| 847 | 847 | $ini = $c->getIniWrapper(); |
| 848 | 848 | $config = $c->getConfig(); |
| 849 | 849 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -860,49 +860,49 @@ discard block |
||
| 860 | 860 | }); |
| 861 | 861 | $this->registerAlias('LockingProvider', ILockingProvider::class); |
| 862 | 862 | |
| 863 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
| 863 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
| 864 | 864 | return new \OC\Files\Mount\Manager(); |
| 865 | 865 | }); |
| 866 | 866 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
| 867 | 867 | |
| 868 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
| 868 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
| 869 | 869 | return new \OC\Files\Type\Detection( |
| 870 | 870 | $c->getURLGenerator(), |
| 871 | 871 | \OC::$configDir, |
| 872 | - \OC::$SERVERROOT . '/resources/config/' |
|
| 872 | + \OC::$SERVERROOT.'/resources/config/' |
|
| 873 | 873 | ); |
| 874 | 874 | }); |
| 875 | 875 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
| 876 | 876 | |
| 877 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
| 877 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
| 878 | 878 | return new \OC\Files\Type\Loader( |
| 879 | 879 | $c->getDatabaseConnection() |
| 880 | 880 | ); |
| 881 | 881 | }); |
| 882 | 882 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
| 883 | - $this->registerService(BundleFetcher::class, function () { |
|
| 883 | + $this->registerService(BundleFetcher::class, function() { |
|
| 884 | 884 | return new BundleFetcher($this->getL10N('lib')); |
| 885 | 885 | }); |
| 886 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 886 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
| 887 | 887 | return new Manager( |
| 888 | 888 | $c->query(IValidator::class) |
| 889 | 889 | ); |
| 890 | 890 | }); |
| 891 | 891 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
| 892 | 892 | |
| 893 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
| 893 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
| 894 | 894 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
| 895 | - $manager->registerCapability(function () use ($c) { |
|
| 895 | + $manager->registerCapability(function() use ($c) { |
|
| 896 | 896 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
| 897 | 897 | }); |
| 898 | - $manager->registerCapability(function () use ($c) { |
|
| 898 | + $manager->registerCapability(function() use ($c) { |
|
| 899 | 899 | return $c->query(\OC\Security\Bruteforce\Capabilities::class); |
| 900 | 900 | }); |
| 901 | 901 | return $manager; |
| 902 | 902 | }); |
| 903 | 903 | $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
| 904 | 904 | |
| 905 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) { |
|
| 905 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
| 906 | 906 | $config = $c->getConfig(); |
| 907 | 907 | $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class); |
| 908 | 908 | /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | $manager->registerDisplayNameResolver('user', function($id) use ($c) { |
| 913 | 913 | $manager = $c->getUserManager(); |
| 914 | 914 | $user = $manager->get($id); |
| 915 | - if(is_null($user)) { |
|
| 915 | + if (is_null($user)) { |
|
| 916 | 916 | $l = $c->getL10N('core'); |
| 917 | 917 | $displayName = $l->t('Unknown user'); |
| 918 | 918 | } else { |
@@ -925,7 +925,7 @@ discard block |
||
| 925 | 925 | }); |
| 926 | 926 | $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
| 927 | 927 | |
| 928 | - $this->registerService('ThemingDefaults', function (Server $c) { |
|
| 928 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
| 929 | 929 | /* |
| 930 | 930 | * Dark magic for autoloader. |
| 931 | 931 | * If we do a class_exists it will try to load the class which will |
@@ -952,7 +952,7 @@ discard block |
||
| 952 | 952 | } |
| 953 | 953 | return new \OC_Defaults(); |
| 954 | 954 | }); |
| 955 | - $this->registerService(SCSSCacher::class, function (Server $c) { |
|
| 955 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
| 956 | 956 | /** @var Factory $cacheFactory */ |
| 957 | 957 | $cacheFactory = $c->query(Factory::class); |
| 958 | 958 | return new SCSSCacher( |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | $this->getMemCacheFactory() |
| 966 | 966 | ); |
| 967 | 967 | }); |
| 968 | - $this->registerService(JSCombiner::class, function (Server $c) { |
|
| 968 | + $this->registerService(JSCombiner::class, function(Server $c) { |
|
| 969 | 969 | /** @var Factory $cacheFactory */ |
| 970 | 970 | $cacheFactory = $c->query(Factory::class); |
| 971 | 971 | return new JSCombiner( |
@@ -976,13 +976,13 @@ discard block |
||
| 976 | 976 | $c->getLogger() |
| 977 | 977 | ); |
| 978 | 978 | }); |
| 979 | - $this->registerService(EventDispatcher::class, function () { |
|
| 979 | + $this->registerService(EventDispatcher::class, function() { |
|
| 980 | 980 | return new EventDispatcher(); |
| 981 | 981 | }); |
| 982 | 982 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
| 983 | 983 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
| 984 | 984 | |
| 985 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 985 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
| 986 | 986 | // FIXME: Instantiiated here due to cyclic dependency |
| 987 | 987 | $request = new Request( |
| 988 | 988 | [ |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | $request |
| 1008 | 1008 | ); |
| 1009 | 1009 | }); |
| 1010 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
| 1010 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
| 1011 | 1011 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
| 1012 | 1012 | |
| 1013 | 1013 | return new CsrfTokenManager( |
@@ -1015,22 +1015,22 @@ discard block |
||
| 1015 | 1015 | $c->query(SessionStorage::class) |
| 1016 | 1016 | ); |
| 1017 | 1017 | }); |
| 1018 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 1018 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
| 1019 | 1019 | return new SessionStorage($c->getSession()); |
| 1020 | 1020 | }); |
| 1021 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
| 1021 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
| 1022 | 1022 | return new ContentSecurityPolicyManager(); |
| 1023 | 1023 | }); |
| 1024 | 1024 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
| 1025 | 1025 | |
| 1026 | - $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) { |
|
| 1026 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
| 1027 | 1027 | return new ContentSecurityPolicyNonceManager( |
| 1028 | 1028 | $c->getCsrfTokenManager(), |
| 1029 | 1029 | $c->getRequest() |
| 1030 | 1030 | ); |
| 1031 | 1031 | }); |
| 1032 | 1032 | |
| 1033 | - $this->registerService(\OCP\Share\IManager::class, function (Server $c) { |
|
| 1033 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
| 1034 | 1034 | $config = $c->getConfig(); |
| 1035 | 1035 | $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class); |
| 1036 | 1036 | /** @var \OCP\Share\IProviderFactory $factory */ |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | |
| 1074 | 1074 | $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class); |
| 1075 | 1075 | |
| 1076 | - $this->registerService('SettingsManager', function (Server $c) { |
|
| 1076 | + $this->registerService('SettingsManager', function(Server $c) { |
|
| 1077 | 1077 | $manager = new \OC\Settings\Manager( |
| 1078 | 1078 | $c->getLogger(), |
| 1079 | 1079 | $c->getDatabaseConnection(), |
@@ -1091,24 +1091,24 @@ discard block |
||
| 1091 | 1091 | ); |
| 1092 | 1092 | return $manager; |
| 1093 | 1093 | }); |
| 1094 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 1094 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
| 1095 | 1095 | return new \OC\Files\AppData\Factory( |
| 1096 | 1096 | $c->getRootFolder(), |
| 1097 | 1097 | $c->getSystemConfig() |
| 1098 | 1098 | ); |
| 1099 | 1099 | }); |
| 1100 | 1100 | |
| 1101 | - $this->registerService('LockdownManager', function (Server $c) { |
|
| 1102 | - return new LockdownManager(function () use ($c) { |
|
| 1101 | + $this->registerService('LockdownManager', function(Server $c) { |
|
| 1102 | + return new LockdownManager(function() use ($c) { |
|
| 1103 | 1103 | return $c->getSession(); |
| 1104 | 1104 | }); |
| 1105 | 1105 | }); |
| 1106 | 1106 | |
| 1107 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 1107 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) { |
|
| 1108 | 1108 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
| 1109 | 1109 | }); |
| 1110 | 1110 | |
| 1111 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 1111 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
| 1112 | 1112 | return new CloudIdManager(); |
| 1113 | 1113 | }); |
| 1114 | 1114 | |
@@ -1118,18 +1118,18 @@ discard block |
||
| 1118 | 1118 | $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
| 1119 | 1119 | $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
| 1120 | 1120 | |
| 1121 | - $this->registerService(Defaults::class, function (Server $c) { |
|
| 1121 | + $this->registerService(Defaults::class, function(Server $c) { |
|
| 1122 | 1122 | return new Defaults( |
| 1123 | 1123 | $c->getThemingDefaults() |
| 1124 | 1124 | ); |
| 1125 | 1125 | }); |
| 1126 | 1126 | $this->registerAlias('Defaults', \OCP\Defaults::class); |
| 1127 | 1127 | |
| 1128 | - $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) { |
|
| 1128 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
| 1129 | 1129 | return $c->query(\OCP\IUserSession::class)->getSession(); |
| 1130 | 1130 | }); |
| 1131 | 1131 | |
| 1132 | - $this->registerService(IShareHelper::class, function (Server $c) { |
|
| 1132 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
| 1133 | 1133 | return new ShareHelper( |
| 1134 | 1134 | $c->query(\OCP\Share\IManager::class) |
| 1135 | 1135 | ); |
@@ -1191,11 +1191,11 @@ discard block |
||
| 1191 | 1191 | // no avatar to remove |
| 1192 | 1192 | } catch (\Exception $e) { |
| 1193 | 1193 | // Ignore exceptions |
| 1194 | - $logger->info('Could not cleanup avatar of ' . $user->getUID()); |
|
| 1194 | + $logger->info('Could not cleanup avatar of '.$user->getUID()); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | }); |
| 1197 | 1197 | |
| 1198 | - $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) { |
|
| 1198 | + $dispatcher->addListener('OCP\IUser::changeUser', function(GenericEvent $e) { |
|
| 1199 | 1199 | $manager = $this->getAvatarManager(); |
| 1200 | 1200 | /** @var IUser $user */ |
| 1201 | 1201 | $user = $e->getSubject(); |
@@ -1346,7 +1346,7 @@ discard block |
||
| 1346 | 1346 | * @deprecated since 9.2.0 use IAppData |
| 1347 | 1347 | */ |
| 1348 | 1348 | public function getAppFolder() { |
| 1349 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1349 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
| 1350 | 1350 | $root = $this->getRootFolder(); |
| 1351 | 1351 | if (!$root->nodeExists($dir)) { |
| 1352 | 1352 | $folder = $root->newFolder($dir); |
@@ -1923,7 +1923,7 @@ discard block |
||
| 1923 | 1923 | /** |
| 1924 | 1924 | * @return \OCP\Collaboration\AutoComplete\IManager |
| 1925 | 1925 | */ |
| 1926 | - public function getAutoCompleteManager(){ |
|
| 1926 | + public function getAutoCompleteManager() { |
|
| 1927 | 1927 | return $this->query(IManager::class); |
| 1928 | 1928 | } |
| 1929 | 1929 | |
@@ -57,492 +57,492 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | interface IServerContainer extends IContainer { |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * The calendar manager will act as a broker between consumers for calendar information and |
|
| 62 | - * providers which actual deliver the calendar information. |
|
| 63 | - * |
|
| 64 | - * @return \OCP\Calendar\IManager |
|
| 65 | - * @since 13.0.0 |
|
| 66 | - */ |
|
| 67 | - public function getCalendarManager(); |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * The contacts manager will act as a broker between consumers for contacts information and |
|
| 71 | - * providers which actual deliver the contact information. |
|
| 72 | - * |
|
| 73 | - * @return \OCP\Contacts\IManager |
|
| 74 | - * @since 6.0.0 |
|
| 75 | - */ |
|
| 76 | - public function getContactsManager(); |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * The current request object holding all information about the request currently being processed |
|
| 80 | - * is returned from this method. |
|
| 81 | - * In case the current execution was not initiated by a web request null is returned |
|
| 82 | - * |
|
| 83 | - * @return \OCP\IRequest |
|
| 84 | - * @since 6.0.0 |
|
| 85 | - */ |
|
| 86 | - public function getRequest(); |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Returns the preview manager which can create preview images for a given file |
|
| 90 | - * |
|
| 91 | - * @return \OCP\IPreview |
|
| 92 | - * @since 6.0.0 |
|
| 93 | - */ |
|
| 94 | - public function getPreviewManager(); |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Returns the tag manager which can get and set tags for different object types |
|
| 98 | - * |
|
| 99 | - * @see \OCP\ITagManager::load() |
|
| 100 | - * @return \OCP\ITagManager |
|
| 101 | - * @since 6.0.0 |
|
| 102 | - */ |
|
| 103 | - public function getTagManager(); |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Returns the root folder of ownCloud's data directory |
|
| 107 | - * |
|
| 108 | - * @return \OCP\Files\IRootFolder |
|
| 109 | - * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
| 110 | - */ |
|
| 111 | - public function getRootFolder(); |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Returns a view to ownCloud's files folder |
|
| 115 | - * |
|
| 116 | - * @param string $userId user ID |
|
| 117 | - * @return \OCP\Files\Folder |
|
| 118 | - * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
| 119 | - * @see getUserFolder in \OCP\Files\IRootFolder |
|
| 120 | - */ |
|
| 121 | - public function getUserFolder($userId = null); |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Returns an app-specific view in ownClouds data directory |
|
| 125 | - * |
|
| 126 | - * @return \OCP\Files\Folder |
|
| 127 | - * @since 6.0.0 |
|
| 128 | - * @deprecated 9.2.0 use IAppData |
|
| 129 | - */ |
|
| 130 | - public function getAppFolder(); |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Returns a user manager |
|
| 134 | - * |
|
| 135 | - * @return \OCP\IUserManager |
|
| 136 | - * @since 8.0.0 |
|
| 137 | - */ |
|
| 138 | - public function getUserManager(); |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Returns a group manager |
|
| 142 | - * |
|
| 143 | - * @return \OCP\IGroupManager |
|
| 144 | - * @since 8.0.0 |
|
| 145 | - */ |
|
| 146 | - public function getGroupManager(); |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Returns the user session |
|
| 150 | - * |
|
| 151 | - * @return \OCP\IUserSession |
|
| 152 | - * @since 6.0.0 |
|
| 153 | - */ |
|
| 154 | - public function getUserSession(); |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Returns the navigation manager |
|
| 158 | - * |
|
| 159 | - * @return \OCP\INavigationManager |
|
| 160 | - * @since 6.0.0 |
|
| 161 | - */ |
|
| 162 | - public function getNavigationManager(); |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Returns the config manager |
|
| 166 | - * |
|
| 167 | - * @return \OCP\IConfig |
|
| 168 | - * @since 6.0.0 |
|
| 169 | - */ |
|
| 170 | - public function getConfig(); |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * Returns a Crypto instance |
|
| 174 | - * |
|
| 175 | - * @return \OCP\Security\ICrypto |
|
| 176 | - * @since 8.0.0 |
|
| 177 | - */ |
|
| 178 | - public function getCrypto(); |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * Returns a Hasher instance |
|
| 182 | - * |
|
| 183 | - * @return \OCP\Security\IHasher |
|
| 184 | - * @since 8.0.0 |
|
| 185 | - */ |
|
| 186 | - public function getHasher(); |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Returns a SecureRandom instance |
|
| 190 | - * |
|
| 191 | - * @return \OCP\Security\ISecureRandom |
|
| 192 | - * @since 8.1.0 |
|
| 193 | - */ |
|
| 194 | - public function getSecureRandom(); |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Returns a CredentialsManager instance |
|
| 198 | - * |
|
| 199 | - * @return \OCP\Security\ICredentialsManager |
|
| 200 | - * @since 9.0.0 |
|
| 201 | - */ |
|
| 202 | - public function getCredentialsManager(); |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Returns the app config manager |
|
| 206 | - * |
|
| 207 | - * @return \OCP\IAppConfig |
|
| 208 | - * @since 7.0.0 |
|
| 209 | - */ |
|
| 210 | - public function getAppConfig(); |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * @return \OCP\L10N\IFactory |
|
| 214 | - * @since 8.2.0 |
|
| 215 | - */ |
|
| 216 | - public function getL10NFactory(); |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * get an L10N instance |
|
| 220 | - * @param string $app appid |
|
| 221 | - * @param string $lang |
|
| 222 | - * @return \OCP\IL10N |
|
| 223 | - * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
| 224 | - */ |
|
| 225 | - public function getL10N($app, $lang = null); |
|
| 226 | - |
|
| 227 | - /** |
|
| 228 | - * @return \OC\Encryption\Manager |
|
| 229 | - * @since 8.1.0 |
|
| 230 | - */ |
|
| 231 | - public function getEncryptionManager(); |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * @return \OC\Encryption\File |
|
| 235 | - * @since 8.1.0 |
|
| 236 | - */ |
|
| 237 | - public function getEncryptionFilesHelper(); |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * @return \OCP\Encryption\Keys\IStorage |
|
| 241 | - * @since 8.1.0 |
|
| 242 | - */ |
|
| 243 | - public function getEncryptionKeyStorage(); |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * Returns the URL generator |
|
| 247 | - * |
|
| 248 | - * @return \OCP\IURLGenerator |
|
| 249 | - * @since 6.0.0 |
|
| 250 | - */ |
|
| 251 | - public function getURLGenerator(); |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * Returns an ICache instance |
|
| 255 | - * |
|
| 256 | - * @return \OCP\ICache |
|
| 257 | - * @since 6.0.0 |
|
| 258 | - */ |
|
| 259 | - public function getCache(); |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * Returns an \OCP\CacheFactory instance |
|
| 263 | - * |
|
| 264 | - * @return \OCP\ICacheFactory |
|
| 265 | - * @since 7.0.0 |
|
| 266 | - */ |
|
| 267 | - public function getMemCacheFactory(); |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * Returns the current session |
|
| 271 | - * |
|
| 272 | - * @return \OCP\ISession |
|
| 273 | - * @since 6.0.0 |
|
| 274 | - */ |
|
| 275 | - public function getSession(); |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * Returns the activity manager |
|
| 279 | - * |
|
| 280 | - * @return \OCP\Activity\IManager |
|
| 281 | - * @since 6.0.0 |
|
| 282 | - */ |
|
| 283 | - public function getActivityManager(); |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * Returns the current session |
|
| 287 | - * |
|
| 288 | - * @return \OCP\IDBConnection |
|
| 289 | - * @since 6.0.0 |
|
| 290 | - */ |
|
| 291 | - public function getDatabaseConnection(); |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * Returns an avatar manager, used for avatar functionality |
|
| 295 | - * |
|
| 296 | - * @return \OCP\IAvatarManager |
|
| 297 | - * @since 6.0.0 |
|
| 298 | - */ |
|
| 299 | - public function getAvatarManager(); |
|
| 300 | - |
|
| 301 | - /** |
|
| 302 | - * Returns an job list for controlling background jobs |
|
| 303 | - * |
|
| 304 | - * @return \OCP\BackgroundJob\IJobList |
|
| 305 | - * @since 7.0.0 |
|
| 306 | - */ |
|
| 307 | - public function getJobList(); |
|
| 308 | - |
|
| 309 | - /** |
|
| 310 | - * Returns a logger instance |
|
| 311 | - * |
|
| 312 | - * @return \OCP\ILogger |
|
| 313 | - * @since 8.0.0 |
|
| 314 | - */ |
|
| 315 | - public function getLogger(); |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * Returns a router for generating and matching urls |
|
| 319 | - * |
|
| 320 | - * @return \OCP\Route\IRouter |
|
| 321 | - * @since 7.0.0 |
|
| 322 | - */ |
|
| 323 | - public function getRouter(); |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * Returns a search instance |
|
| 327 | - * |
|
| 328 | - * @return \OCP\ISearch |
|
| 329 | - * @since 7.0.0 |
|
| 330 | - */ |
|
| 331 | - public function getSearch(); |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * Get the certificate manager for the user |
|
| 335 | - * |
|
| 336 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 337 | - * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
| 338 | - * @since 8.0.0 |
|
| 339 | - */ |
|
| 340 | - public function getCertificateManager($userId = null); |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * Create a new event source |
|
| 344 | - * |
|
| 345 | - * @return \OCP\IEventSource |
|
| 346 | - * @since 8.0.0 |
|
| 347 | - */ |
|
| 348 | - public function createEventSource(); |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * Returns an instance of the HTTP helper class |
|
| 352 | - * @return \OC\HTTPHelper |
|
| 353 | - * @deprecated 8.1.0 Use \OCP\Http\Client\IClientService |
|
| 354 | - * @since 8.0.0 |
|
| 355 | - */ |
|
| 356 | - public function getHTTPHelper(); |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * Returns an instance of the HTTP client service |
|
| 360 | - * |
|
| 361 | - * @return \OCP\Http\Client\IClientService |
|
| 362 | - * @since 8.1.0 |
|
| 363 | - */ |
|
| 364 | - public function getHTTPClientService(); |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * Get the active event logger |
|
| 368 | - * |
|
| 369 | - * @return \OCP\Diagnostics\IEventLogger |
|
| 370 | - * @since 8.0.0 |
|
| 371 | - */ |
|
| 372 | - public function getEventLogger(); |
|
| 373 | - |
|
| 374 | - /** |
|
| 375 | - * Get the active query logger |
|
| 376 | - * |
|
| 377 | - * The returned logger only logs data when debug mode is enabled |
|
| 378 | - * |
|
| 379 | - * @return \OCP\Diagnostics\IQueryLogger |
|
| 380 | - * @since 8.0.0 |
|
| 381 | - */ |
|
| 382 | - public function getQueryLogger(); |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * Get the manager for temporary files and folders |
|
| 386 | - * |
|
| 387 | - * @return \OCP\ITempManager |
|
| 388 | - * @since 8.0.0 |
|
| 389 | - */ |
|
| 390 | - public function getTempManager(); |
|
| 391 | - |
|
| 392 | - /** |
|
| 393 | - * Get the app manager |
|
| 394 | - * |
|
| 395 | - * @return \OCP\App\IAppManager |
|
| 396 | - * @since 8.0.0 |
|
| 397 | - */ |
|
| 398 | - public function getAppManager(); |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * Get the webroot |
|
| 402 | - * |
|
| 403 | - * @return string |
|
| 404 | - * @since 8.0.0 |
|
| 405 | - */ |
|
| 406 | - public function getWebRoot(); |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
| 410 | - * @since 8.0.0 |
|
| 411 | - */ |
|
| 412 | - public function getMountProviderCollection(); |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * Get the IniWrapper |
|
| 416 | - * |
|
| 417 | - * @return \bantu\IniGetWrapper\IniGetWrapper |
|
| 418 | - * @since 8.0.0 |
|
| 419 | - */ |
|
| 420 | - public function getIniWrapper(); |
|
| 421 | - /** |
|
| 422 | - * @return \OCP\Command\IBus |
|
| 423 | - * @since 8.1.0 |
|
| 424 | - */ |
|
| 425 | - public function getCommandBus(); |
|
| 426 | - |
|
| 427 | - /** |
|
| 428 | - * Creates a new mailer |
|
| 429 | - * |
|
| 430 | - * @return \OCP\Mail\IMailer |
|
| 431 | - * @since 8.1.0 |
|
| 432 | - */ |
|
| 433 | - public function getMailer(); |
|
| 434 | - |
|
| 435 | - /** |
|
| 436 | - * Get the locking provider |
|
| 437 | - * |
|
| 438 | - * @return \OCP\Lock\ILockingProvider |
|
| 439 | - * @since 8.1.0 |
|
| 440 | - */ |
|
| 441 | - public function getLockingProvider(); |
|
| 442 | - |
|
| 443 | - /** |
|
| 444 | - * @return \OCP\Files\Mount\IMountManager |
|
| 445 | - * @since 8.2.0 |
|
| 446 | - */ |
|
| 447 | - public function getMountManager(); |
|
| 448 | - |
|
| 449 | - /** |
|
| 450 | - * Get the MimeTypeDetector |
|
| 451 | - * |
|
| 452 | - * @return \OCP\Files\IMimeTypeDetector |
|
| 453 | - * @since 8.2.0 |
|
| 454 | - */ |
|
| 455 | - public function getMimeTypeDetector(); |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * Get the MimeTypeLoader |
|
| 459 | - * |
|
| 460 | - * @return \OCP\Files\IMimeTypeLoader |
|
| 461 | - * @since 8.2.0 |
|
| 462 | - */ |
|
| 463 | - public function getMimeTypeLoader(); |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * Get the EventDispatcher |
|
| 467 | - * |
|
| 468 | - * @return EventDispatcherInterface |
|
| 469 | - * @since 8.2.0 |
|
| 470 | - */ |
|
| 471 | - public function getEventDispatcher(); |
|
| 472 | - |
|
| 473 | - /** |
|
| 474 | - * Get the Notification Manager |
|
| 475 | - * |
|
| 476 | - * @return \OCP\Notification\IManager |
|
| 477 | - * @since 9.0.0 |
|
| 478 | - */ |
|
| 479 | - public function getNotificationManager(); |
|
| 480 | - |
|
| 481 | - /** |
|
| 482 | - * @return \OCP\Comments\ICommentsManager |
|
| 483 | - * @since 9.0.0 |
|
| 484 | - */ |
|
| 485 | - public function getCommentsManager(); |
|
| 486 | - |
|
| 487 | - /** |
|
| 488 | - * Returns the system-tag manager |
|
| 489 | - * |
|
| 490 | - * @return \OCP\SystemTag\ISystemTagManager |
|
| 491 | - * |
|
| 492 | - * @since 9.0.0 |
|
| 493 | - */ |
|
| 494 | - public function getSystemTagManager(); |
|
| 495 | - |
|
| 496 | - /** |
|
| 497 | - * Returns the system-tag object mapper |
|
| 498 | - * |
|
| 499 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
| 500 | - * |
|
| 501 | - * @since 9.0.0 |
|
| 502 | - */ |
|
| 503 | - public function getSystemTagObjectMapper(); |
|
| 504 | - |
|
| 505 | - /** |
|
| 506 | - * Returns the share manager |
|
| 507 | - * |
|
| 508 | - * @return \OCP\Share\IManager |
|
| 509 | - * @since 9.0.0 |
|
| 510 | - */ |
|
| 511 | - public function getShareManager(); |
|
| 512 | - |
|
| 513 | - /** |
|
| 514 | - * @return IContentSecurityPolicyManager |
|
| 515 | - * @since 9.0.0 |
|
| 516 | - */ |
|
| 517 | - public function getContentSecurityPolicyManager(); |
|
| 518 | - |
|
| 519 | - /** |
|
| 520 | - * @return \OCP\IDateTimeZone |
|
| 521 | - * @since 8.0.0 |
|
| 522 | - */ |
|
| 523 | - public function getDateTimeZone(); |
|
| 524 | - |
|
| 525 | - /** |
|
| 526 | - * @return \OCP\IDateTimeFormatter |
|
| 527 | - * @since 8.0.0 |
|
| 528 | - */ |
|
| 529 | - public function getDateTimeFormatter(); |
|
| 530 | - |
|
| 531 | - /** |
|
| 532 | - * @return \OCP\Federation\ICloudIdManager |
|
| 533 | - * @since 12.0.0 |
|
| 534 | - */ |
|
| 535 | - public function getCloudIdManager(); |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * @return \OCP\Remote\Api\IApiFactory |
|
| 539 | - * @since 13.0.0 |
|
| 540 | - */ |
|
| 541 | - public function getRemoteApiFactory(); |
|
| 542 | - |
|
| 543 | - /** |
|
| 544 | - * @return \OCP\Remote\IInstanceFactory |
|
| 545 | - * @since 13.0.0 |
|
| 546 | - */ |
|
| 547 | - public function getRemoteInstanceFactory(); |
|
| 60 | + /** |
|
| 61 | + * The calendar manager will act as a broker between consumers for calendar information and |
|
| 62 | + * providers which actual deliver the calendar information. |
|
| 63 | + * |
|
| 64 | + * @return \OCP\Calendar\IManager |
|
| 65 | + * @since 13.0.0 |
|
| 66 | + */ |
|
| 67 | + public function getCalendarManager(); |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The contacts manager will act as a broker between consumers for contacts information and |
|
| 71 | + * providers which actual deliver the contact information. |
|
| 72 | + * |
|
| 73 | + * @return \OCP\Contacts\IManager |
|
| 74 | + * @since 6.0.0 |
|
| 75 | + */ |
|
| 76 | + public function getContactsManager(); |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * The current request object holding all information about the request currently being processed |
|
| 80 | + * is returned from this method. |
|
| 81 | + * In case the current execution was not initiated by a web request null is returned |
|
| 82 | + * |
|
| 83 | + * @return \OCP\IRequest |
|
| 84 | + * @since 6.0.0 |
|
| 85 | + */ |
|
| 86 | + public function getRequest(); |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Returns the preview manager which can create preview images for a given file |
|
| 90 | + * |
|
| 91 | + * @return \OCP\IPreview |
|
| 92 | + * @since 6.0.0 |
|
| 93 | + */ |
|
| 94 | + public function getPreviewManager(); |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Returns the tag manager which can get and set tags for different object types |
|
| 98 | + * |
|
| 99 | + * @see \OCP\ITagManager::load() |
|
| 100 | + * @return \OCP\ITagManager |
|
| 101 | + * @since 6.0.0 |
|
| 102 | + */ |
|
| 103 | + public function getTagManager(); |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Returns the root folder of ownCloud's data directory |
|
| 107 | + * |
|
| 108 | + * @return \OCP\Files\IRootFolder |
|
| 109 | + * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder |
|
| 110 | + */ |
|
| 111 | + public function getRootFolder(); |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Returns a view to ownCloud's files folder |
|
| 115 | + * |
|
| 116 | + * @param string $userId user ID |
|
| 117 | + * @return \OCP\Files\Folder |
|
| 118 | + * @since 6.0.0 - parameter $userId was added in 8.0.0 |
|
| 119 | + * @see getUserFolder in \OCP\Files\IRootFolder |
|
| 120 | + */ |
|
| 121 | + public function getUserFolder($userId = null); |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Returns an app-specific view in ownClouds data directory |
|
| 125 | + * |
|
| 126 | + * @return \OCP\Files\Folder |
|
| 127 | + * @since 6.0.0 |
|
| 128 | + * @deprecated 9.2.0 use IAppData |
|
| 129 | + */ |
|
| 130 | + public function getAppFolder(); |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Returns a user manager |
|
| 134 | + * |
|
| 135 | + * @return \OCP\IUserManager |
|
| 136 | + * @since 8.0.0 |
|
| 137 | + */ |
|
| 138 | + public function getUserManager(); |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Returns a group manager |
|
| 142 | + * |
|
| 143 | + * @return \OCP\IGroupManager |
|
| 144 | + * @since 8.0.0 |
|
| 145 | + */ |
|
| 146 | + public function getGroupManager(); |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Returns the user session |
|
| 150 | + * |
|
| 151 | + * @return \OCP\IUserSession |
|
| 152 | + * @since 6.0.0 |
|
| 153 | + */ |
|
| 154 | + public function getUserSession(); |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Returns the navigation manager |
|
| 158 | + * |
|
| 159 | + * @return \OCP\INavigationManager |
|
| 160 | + * @since 6.0.0 |
|
| 161 | + */ |
|
| 162 | + public function getNavigationManager(); |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Returns the config manager |
|
| 166 | + * |
|
| 167 | + * @return \OCP\IConfig |
|
| 168 | + * @since 6.0.0 |
|
| 169 | + */ |
|
| 170 | + public function getConfig(); |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * Returns a Crypto instance |
|
| 174 | + * |
|
| 175 | + * @return \OCP\Security\ICrypto |
|
| 176 | + * @since 8.0.0 |
|
| 177 | + */ |
|
| 178 | + public function getCrypto(); |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * Returns a Hasher instance |
|
| 182 | + * |
|
| 183 | + * @return \OCP\Security\IHasher |
|
| 184 | + * @since 8.0.0 |
|
| 185 | + */ |
|
| 186 | + public function getHasher(); |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Returns a SecureRandom instance |
|
| 190 | + * |
|
| 191 | + * @return \OCP\Security\ISecureRandom |
|
| 192 | + * @since 8.1.0 |
|
| 193 | + */ |
|
| 194 | + public function getSecureRandom(); |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Returns a CredentialsManager instance |
|
| 198 | + * |
|
| 199 | + * @return \OCP\Security\ICredentialsManager |
|
| 200 | + * @since 9.0.0 |
|
| 201 | + */ |
|
| 202 | + public function getCredentialsManager(); |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Returns the app config manager |
|
| 206 | + * |
|
| 207 | + * @return \OCP\IAppConfig |
|
| 208 | + * @since 7.0.0 |
|
| 209 | + */ |
|
| 210 | + public function getAppConfig(); |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * @return \OCP\L10N\IFactory |
|
| 214 | + * @since 8.2.0 |
|
| 215 | + */ |
|
| 216 | + public function getL10NFactory(); |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * get an L10N instance |
|
| 220 | + * @param string $app appid |
|
| 221 | + * @param string $lang |
|
| 222 | + * @return \OCP\IL10N |
|
| 223 | + * @since 6.0.0 - parameter $lang was added in 8.0.0 |
|
| 224 | + */ |
|
| 225 | + public function getL10N($app, $lang = null); |
|
| 226 | + |
|
| 227 | + /** |
|
| 228 | + * @return \OC\Encryption\Manager |
|
| 229 | + * @since 8.1.0 |
|
| 230 | + */ |
|
| 231 | + public function getEncryptionManager(); |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * @return \OC\Encryption\File |
|
| 235 | + * @since 8.1.0 |
|
| 236 | + */ |
|
| 237 | + public function getEncryptionFilesHelper(); |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * @return \OCP\Encryption\Keys\IStorage |
|
| 241 | + * @since 8.1.0 |
|
| 242 | + */ |
|
| 243 | + public function getEncryptionKeyStorage(); |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * Returns the URL generator |
|
| 247 | + * |
|
| 248 | + * @return \OCP\IURLGenerator |
|
| 249 | + * @since 6.0.0 |
|
| 250 | + */ |
|
| 251 | + public function getURLGenerator(); |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * Returns an ICache instance |
|
| 255 | + * |
|
| 256 | + * @return \OCP\ICache |
|
| 257 | + * @since 6.0.0 |
|
| 258 | + */ |
|
| 259 | + public function getCache(); |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * Returns an \OCP\CacheFactory instance |
|
| 263 | + * |
|
| 264 | + * @return \OCP\ICacheFactory |
|
| 265 | + * @since 7.0.0 |
|
| 266 | + */ |
|
| 267 | + public function getMemCacheFactory(); |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * Returns the current session |
|
| 271 | + * |
|
| 272 | + * @return \OCP\ISession |
|
| 273 | + * @since 6.0.0 |
|
| 274 | + */ |
|
| 275 | + public function getSession(); |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * Returns the activity manager |
|
| 279 | + * |
|
| 280 | + * @return \OCP\Activity\IManager |
|
| 281 | + * @since 6.0.0 |
|
| 282 | + */ |
|
| 283 | + public function getActivityManager(); |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * Returns the current session |
|
| 287 | + * |
|
| 288 | + * @return \OCP\IDBConnection |
|
| 289 | + * @since 6.0.0 |
|
| 290 | + */ |
|
| 291 | + public function getDatabaseConnection(); |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * Returns an avatar manager, used for avatar functionality |
|
| 295 | + * |
|
| 296 | + * @return \OCP\IAvatarManager |
|
| 297 | + * @since 6.0.0 |
|
| 298 | + */ |
|
| 299 | + public function getAvatarManager(); |
|
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * Returns an job list for controlling background jobs |
|
| 303 | + * |
|
| 304 | + * @return \OCP\BackgroundJob\IJobList |
|
| 305 | + * @since 7.0.0 |
|
| 306 | + */ |
|
| 307 | + public function getJobList(); |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * Returns a logger instance |
|
| 311 | + * |
|
| 312 | + * @return \OCP\ILogger |
|
| 313 | + * @since 8.0.0 |
|
| 314 | + */ |
|
| 315 | + public function getLogger(); |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * Returns a router for generating and matching urls |
|
| 319 | + * |
|
| 320 | + * @return \OCP\Route\IRouter |
|
| 321 | + * @since 7.0.0 |
|
| 322 | + */ |
|
| 323 | + public function getRouter(); |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * Returns a search instance |
|
| 327 | + * |
|
| 328 | + * @return \OCP\ISearch |
|
| 329 | + * @since 7.0.0 |
|
| 330 | + */ |
|
| 331 | + public function getSearch(); |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * Get the certificate manager for the user |
|
| 335 | + * |
|
| 336 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 337 | + * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in |
|
| 338 | + * @since 8.0.0 |
|
| 339 | + */ |
|
| 340 | + public function getCertificateManager($userId = null); |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * Create a new event source |
|
| 344 | + * |
|
| 345 | + * @return \OCP\IEventSource |
|
| 346 | + * @since 8.0.0 |
|
| 347 | + */ |
|
| 348 | + public function createEventSource(); |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * Returns an instance of the HTTP helper class |
|
| 352 | + * @return \OC\HTTPHelper |
|
| 353 | + * @deprecated 8.1.0 Use \OCP\Http\Client\IClientService |
|
| 354 | + * @since 8.0.0 |
|
| 355 | + */ |
|
| 356 | + public function getHTTPHelper(); |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * Returns an instance of the HTTP client service |
|
| 360 | + * |
|
| 361 | + * @return \OCP\Http\Client\IClientService |
|
| 362 | + * @since 8.1.0 |
|
| 363 | + */ |
|
| 364 | + public function getHTTPClientService(); |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * Get the active event logger |
|
| 368 | + * |
|
| 369 | + * @return \OCP\Diagnostics\IEventLogger |
|
| 370 | + * @since 8.0.0 |
|
| 371 | + */ |
|
| 372 | + public function getEventLogger(); |
|
| 373 | + |
|
| 374 | + /** |
|
| 375 | + * Get the active query logger |
|
| 376 | + * |
|
| 377 | + * The returned logger only logs data when debug mode is enabled |
|
| 378 | + * |
|
| 379 | + * @return \OCP\Diagnostics\IQueryLogger |
|
| 380 | + * @since 8.0.0 |
|
| 381 | + */ |
|
| 382 | + public function getQueryLogger(); |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * Get the manager for temporary files and folders |
|
| 386 | + * |
|
| 387 | + * @return \OCP\ITempManager |
|
| 388 | + * @since 8.0.0 |
|
| 389 | + */ |
|
| 390 | + public function getTempManager(); |
|
| 391 | + |
|
| 392 | + /** |
|
| 393 | + * Get the app manager |
|
| 394 | + * |
|
| 395 | + * @return \OCP\App\IAppManager |
|
| 396 | + * @since 8.0.0 |
|
| 397 | + */ |
|
| 398 | + public function getAppManager(); |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * Get the webroot |
|
| 402 | + * |
|
| 403 | + * @return string |
|
| 404 | + * @since 8.0.0 |
|
| 405 | + */ |
|
| 406 | + public function getWebRoot(); |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
| 410 | + * @since 8.0.0 |
|
| 411 | + */ |
|
| 412 | + public function getMountProviderCollection(); |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * Get the IniWrapper |
|
| 416 | + * |
|
| 417 | + * @return \bantu\IniGetWrapper\IniGetWrapper |
|
| 418 | + * @since 8.0.0 |
|
| 419 | + */ |
|
| 420 | + public function getIniWrapper(); |
|
| 421 | + /** |
|
| 422 | + * @return \OCP\Command\IBus |
|
| 423 | + * @since 8.1.0 |
|
| 424 | + */ |
|
| 425 | + public function getCommandBus(); |
|
| 426 | + |
|
| 427 | + /** |
|
| 428 | + * Creates a new mailer |
|
| 429 | + * |
|
| 430 | + * @return \OCP\Mail\IMailer |
|
| 431 | + * @since 8.1.0 |
|
| 432 | + */ |
|
| 433 | + public function getMailer(); |
|
| 434 | + |
|
| 435 | + /** |
|
| 436 | + * Get the locking provider |
|
| 437 | + * |
|
| 438 | + * @return \OCP\Lock\ILockingProvider |
|
| 439 | + * @since 8.1.0 |
|
| 440 | + */ |
|
| 441 | + public function getLockingProvider(); |
|
| 442 | + |
|
| 443 | + /** |
|
| 444 | + * @return \OCP\Files\Mount\IMountManager |
|
| 445 | + * @since 8.2.0 |
|
| 446 | + */ |
|
| 447 | + public function getMountManager(); |
|
| 448 | + |
|
| 449 | + /** |
|
| 450 | + * Get the MimeTypeDetector |
|
| 451 | + * |
|
| 452 | + * @return \OCP\Files\IMimeTypeDetector |
|
| 453 | + * @since 8.2.0 |
|
| 454 | + */ |
|
| 455 | + public function getMimeTypeDetector(); |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * Get the MimeTypeLoader |
|
| 459 | + * |
|
| 460 | + * @return \OCP\Files\IMimeTypeLoader |
|
| 461 | + * @since 8.2.0 |
|
| 462 | + */ |
|
| 463 | + public function getMimeTypeLoader(); |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * Get the EventDispatcher |
|
| 467 | + * |
|
| 468 | + * @return EventDispatcherInterface |
|
| 469 | + * @since 8.2.0 |
|
| 470 | + */ |
|
| 471 | + public function getEventDispatcher(); |
|
| 472 | + |
|
| 473 | + /** |
|
| 474 | + * Get the Notification Manager |
|
| 475 | + * |
|
| 476 | + * @return \OCP\Notification\IManager |
|
| 477 | + * @since 9.0.0 |
|
| 478 | + */ |
|
| 479 | + public function getNotificationManager(); |
|
| 480 | + |
|
| 481 | + /** |
|
| 482 | + * @return \OCP\Comments\ICommentsManager |
|
| 483 | + * @since 9.0.0 |
|
| 484 | + */ |
|
| 485 | + public function getCommentsManager(); |
|
| 486 | + |
|
| 487 | + /** |
|
| 488 | + * Returns the system-tag manager |
|
| 489 | + * |
|
| 490 | + * @return \OCP\SystemTag\ISystemTagManager |
|
| 491 | + * |
|
| 492 | + * @since 9.0.0 |
|
| 493 | + */ |
|
| 494 | + public function getSystemTagManager(); |
|
| 495 | + |
|
| 496 | + /** |
|
| 497 | + * Returns the system-tag object mapper |
|
| 498 | + * |
|
| 499 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
| 500 | + * |
|
| 501 | + * @since 9.0.0 |
|
| 502 | + */ |
|
| 503 | + public function getSystemTagObjectMapper(); |
|
| 504 | + |
|
| 505 | + /** |
|
| 506 | + * Returns the share manager |
|
| 507 | + * |
|
| 508 | + * @return \OCP\Share\IManager |
|
| 509 | + * @since 9.0.0 |
|
| 510 | + */ |
|
| 511 | + public function getShareManager(); |
|
| 512 | + |
|
| 513 | + /** |
|
| 514 | + * @return IContentSecurityPolicyManager |
|
| 515 | + * @since 9.0.0 |
|
| 516 | + */ |
|
| 517 | + public function getContentSecurityPolicyManager(); |
|
| 518 | + |
|
| 519 | + /** |
|
| 520 | + * @return \OCP\IDateTimeZone |
|
| 521 | + * @since 8.0.0 |
|
| 522 | + */ |
|
| 523 | + public function getDateTimeZone(); |
|
| 524 | + |
|
| 525 | + /** |
|
| 526 | + * @return \OCP\IDateTimeFormatter |
|
| 527 | + * @since 8.0.0 |
|
| 528 | + */ |
|
| 529 | + public function getDateTimeFormatter(); |
|
| 530 | + |
|
| 531 | + /** |
|
| 532 | + * @return \OCP\Federation\ICloudIdManager |
|
| 533 | + * @since 12.0.0 |
|
| 534 | + */ |
|
| 535 | + public function getCloudIdManager(); |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * @return \OCP\Remote\Api\IApiFactory |
|
| 539 | + * @since 13.0.0 |
|
| 540 | + */ |
|
| 541 | + public function getRemoteApiFactory(); |
|
| 542 | + |
|
| 543 | + /** |
|
| 544 | + * @return \OCP\Remote\IInstanceFactory |
|
| 545 | + * @since 13.0.0 |
|
| 546 | + */ |
|
| 547 | + public function getRemoteInstanceFactory(); |
|
| 548 | 548 | } |