@@ -50,122 +50,122 @@ |
||
| 50 | 50 | class Application extends App { |
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @param array $urlParams |
|
| 55 | - */ |
|
| 56 | - public function __construct(array $urlParams=[]){ |
|
| 57 | - parent::__construct('settings', $urlParams); |
|
| 58 | - |
|
| 59 | - $container = $this->getContainer(); |
|
| 60 | - |
|
| 61 | - // Register Middleware |
|
| 62 | - $container->registerAlias('SubadminMiddleware', SubadminMiddleware::class); |
|
| 63 | - $container->registerMiddleWare('SubadminMiddleware'); |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Core class wrappers |
|
| 67 | - */ |
|
| 68 | - /** FIXME: Remove once OC_User is non-static and mockable */ |
|
| 69 | - $container->registerService('isAdmin', function() { |
|
| 70 | - return \OC_User::isAdminUser(\OC_User::getUser()); |
|
| 71 | - }); |
|
| 72 | - /** FIXME: Remove once OC_SubAdmin is non-static and mockable */ |
|
| 73 | - $container->registerService('isSubAdmin', function(IContainer $c) { |
|
| 74 | - $userObject = \OC::$server->getUserSession()->getUser(); |
|
| 75 | - $isSubAdmin = false; |
|
| 76 | - if($userObject !== null) { |
|
| 77 | - $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
|
| 78 | - } |
|
| 79 | - return $isSubAdmin; |
|
| 80 | - }); |
|
| 81 | - $container->registerService('userCertificateManager', function(IContainer $c) { |
|
| 82 | - return $c->query('ServerContainer')->getCertificateManager(); |
|
| 83 | - }, false); |
|
| 84 | - $container->registerService('systemCertificateManager', function (IContainer $c) { |
|
| 85 | - return $c->query('ServerContainer')->getCertificateManager(null); |
|
| 86 | - }, false); |
|
| 87 | - $container->registerService(IProvider::class, function (IContainer $c) { |
|
| 88 | - return $c->query('ServerContainer')->query(IProvider::class); |
|
| 89 | - }); |
|
| 90 | - $container->registerService(IManager::class, function (IContainer $c) { |
|
| 91 | - return $c->query('ServerContainer')->getSettingsManager(); |
|
| 92 | - }); |
|
| 93 | - |
|
| 94 | - $container->registerService(NewUserMailHelper::class, function (IContainer $c) { |
|
| 95 | - /** @var Server $server */ |
|
| 96 | - $server = $c->query('ServerContainer'); |
|
| 97 | - /** @var Defaults $defaults */ |
|
| 98 | - $defaults = $server->query(Defaults::class); |
|
| 99 | - |
|
| 100 | - return new NewUserMailHelper( |
|
| 101 | - $defaults, |
|
| 102 | - $server->getURLGenerator(), |
|
| 103 | - $server->getL10NFactory(), |
|
| 104 | - $server->getMailer(), |
|
| 105 | - $server->getSecureRandom(), |
|
| 106 | - new TimeFactory(), |
|
| 107 | - $server->getConfig(), |
|
| 108 | - $server->getCrypto(), |
|
| 109 | - Util::getDefaultEmailAddress('no-reply') |
|
| 110 | - ); |
|
| 111 | - }); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - public function register() { |
|
| 115 | - $activityManager = $this->getContainer()->getServer()->getActivityManager(); |
|
| 116 | - $activityManager->registerSetting(Setting::class); // FIXME move to info.xml |
|
| 117 | - $activityManager->registerProvider(Provider::class); // FIXME move to info.xml |
|
| 118 | - $activityManager->registerFilter(SecurityFilter::class); // FIXME move to info.xml |
|
| 119 | - $activityManager->registerSetting(SecuritySetting::class); // FIXME move to info.xml |
|
| 120 | - $activityManager->registerProvider(SecurityProvider::class); // FIXME move to info.xml |
|
| 121 | - |
|
| 122 | - Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword'); |
|
| 123 | - Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo'); |
|
| 124 | - |
|
| 125 | - Util::connectHook('\OCP\Config', 'js', $this, 'extendJsConfig'); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @param array $parameters |
|
| 130 | - * @throws \InvalidArgumentException |
|
| 131 | - * @throws \BadMethodCallException |
|
| 132 | - * @throws \Exception |
|
| 133 | - * @throws \OCP\AppFramework\QueryException |
|
| 134 | - */ |
|
| 135 | - public function onChangePassword(array $parameters) { |
|
| 136 | - /** @var Hooks $hooks */ |
|
| 137 | - $hooks = $this->getContainer()->query(Hooks::class); |
|
| 138 | - $hooks->onChangePassword($parameters['uid']); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @param array $parameters |
|
| 143 | - * @throws \InvalidArgumentException |
|
| 144 | - * @throws \BadMethodCallException |
|
| 145 | - * @throws \Exception |
|
| 146 | - * @throws \OCP\AppFramework\QueryException |
|
| 147 | - */ |
|
| 148 | - public function onChangeInfo(array $parameters) { |
|
| 149 | - if ($parameters['feature'] !== 'eMailAddress') { |
|
| 150 | - return; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** @var Hooks $hooks */ |
|
| 154 | - $hooks = $this->getContainer()->query(Hooks::class); |
|
| 155 | - $hooks->onChangeEmail($parameters['user'], $parameters['old_value']); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @param array $settings |
|
| 160 | - */ |
|
| 161 | - public function extendJsConfig(array $settings) { |
|
| 162 | - $appConfig = json_decode($settings['array']['oc_appconfig'], true); |
|
| 163 | - |
|
| 164 | - $publicWebFinger = \OC::$server->getConfig()->getAppValue('core', 'public_webfinger', ''); |
|
| 165 | - if (!empty($publicWebFinger)) { |
|
| 166 | - $appConfig['core']['public_webfinger'] = $publicWebFinger; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - $settings['array']['oc_appconfig'] = json_encode($appConfig); |
|
| 170 | - } |
|
| 53 | + /** |
|
| 54 | + * @param array $urlParams |
|
| 55 | + */ |
|
| 56 | + public function __construct(array $urlParams=[]){ |
|
| 57 | + parent::__construct('settings', $urlParams); |
|
| 58 | + |
|
| 59 | + $container = $this->getContainer(); |
|
| 60 | + |
|
| 61 | + // Register Middleware |
|
| 62 | + $container->registerAlias('SubadminMiddleware', SubadminMiddleware::class); |
|
| 63 | + $container->registerMiddleWare('SubadminMiddleware'); |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Core class wrappers |
|
| 67 | + */ |
|
| 68 | + /** FIXME: Remove once OC_User is non-static and mockable */ |
|
| 69 | + $container->registerService('isAdmin', function() { |
|
| 70 | + return \OC_User::isAdminUser(\OC_User::getUser()); |
|
| 71 | + }); |
|
| 72 | + /** FIXME: Remove once OC_SubAdmin is non-static and mockable */ |
|
| 73 | + $container->registerService('isSubAdmin', function(IContainer $c) { |
|
| 74 | + $userObject = \OC::$server->getUserSession()->getUser(); |
|
| 75 | + $isSubAdmin = false; |
|
| 76 | + if($userObject !== null) { |
|
| 77 | + $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
|
| 78 | + } |
|
| 79 | + return $isSubAdmin; |
|
| 80 | + }); |
|
| 81 | + $container->registerService('userCertificateManager', function(IContainer $c) { |
|
| 82 | + return $c->query('ServerContainer')->getCertificateManager(); |
|
| 83 | + }, false); |
|
| 84 | + $container->registerService('systemCertificateManager', function (IContainer $c) { |
|
| 85 | + return $c->query('ServerContainer')->getCertificateManager(null); |
|
| 86 | + }, false); |
|
| 87 | + $container->registerService(IProvider::class, function (IContainer $c) { |
|
| 88 | + return $c->query('ServerContainer')->query(IProvider::class); |
|
| 89 | + }); |
|
| 90 | + $container->registerService(IManager::class, function (IContainer $c) { |
|
| 91 | + return $c->query('ServerContainer')->getSettingsManager(); |
|
| 92 | + }); |
|
| 93 | + |
|
| 94 | + $container->registerService(NewUserMailHelper::class, function (IContainer $c) { |
|
| 95 | + /** @var Server $server */ |
|
| 96 | + $server = $c->query('ServerContainer'); |
|
| 97 | + /** @var Defaults $defaults */ |
|
| 98 | + $defaults = $server->query(Defaults::class); |
|
| 99 | + |
|
| 100 | + return new NewUserMailHelper( |
|
| 101 | + $defaults, |
|
| 102 | + $server->getURLGenerator(), |
|
| 103 | + $server->getL10NFactory(), |
|
| 104 | + $server->getMailer(), |
|
| 105 | + $server->getSecureRandom(), |
|
| 106 | + new TimeFactory(), |
|
| 107 | + $server->getConfig(), |
|
| 108 | + $server->getCrypto(), |
|
| 109 | + Util::getDefaultEmailAddress('no-reply') |
|
| 110 | + ); |
|
| 111 | + }); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + public function register() { |
|
| 115 | + $activityManager = $this->getContainer()->getServer()->getActivityManager(); |
|
| 116 | + $activityManager->registerSetting(Setting::class); // FIXME move to info.xml |
|
| 117 | + $activityManager->registerProvider(Provider::class); // FIXME move to info.xml |
|
| 118 | + $activityManager->registerFilter(SecurityFilter::class); // FIXME move to info.xml |
|
| 119 | + $activityManager->registerSetting(SecuritySetting::class); // FIXME move to info.xml |
|
| 120 | + $activityManager->registerProvider(SecurityProvider::class); // FIXME move to info.xml |
|
| 121 | + |
|
| 122 | + Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword'); |
|
| 123 | + Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo'); |
|
| 124 | + |
|
| 125 | + Util::connectHook('\OCP\Config', 'js', $this, 'extendJsConfig'); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @param array $parameters |
|
| 130 | + * @throws \InvalidArgumentException |
|
| 131 | + * @throws \BadMethodCallException |
|
| 132 | + * @throws \Exception |
|
| 133 | + * @throws \OCP\AppFramework\QueryException |
|
| 134 | + */ |
|
| 135 | + public function onChangePassword(array $parameters) { |
|
| 136 | + /** @var Hooks $hooks */ |
|
| 137 | + $hooks = $this->getContainer()->query(Hooks::class); |
|
| 138 | + $hooks->onChangePassword($parameters['uid']); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * @param array $parameters |
|
| 143 | + * @throws \InvalidArgumentException |
|
| 144 | + * @throws \BadMethodCallException |
|
| 145 | + * @throws \Exception |
|
| 146 | + * @throws \OCP\AppFramework\QueryException |
|
| 147 | + */ |
|
| 148 | + public function onChangeInfo(array $parameters) { |
|
| 149 | + if ($parameters['feature'] !== 'eMailAddress') { |
|
| 150 | + return; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** @var Hooks $hooks */ |
|
| 154 | + $hooks = $this->getContainer()->query(Hooks::class); |
|
| 155 | + $hooks->onChangeEmail($parameters['user'], $parameters['old_value']); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @param array $settings |
|
| 160 | + */ |
|
| 161 | + public function extendJsConfig(array $settings) { |
|
| 162 | + $appConfig = json_decode($settings['array']['oc_appconfig'], true); |
|
| 163 | + |
|
| 164 | + $publicWebFinger = \OC::$server->getConfig()->getAppValue('core', 'public_webfinger', ''); |
|
| 165 | + if (!empty($publicWebFinger)) { |
|
| 166 | + $appConfig['core']['public_webfinger'] = $publicWebFinger; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + $settings['array']['oc_appconfig'] = json_encode($appConfig); |
|
| 170 | + } |
|
| 171 | 171 | } |
@@ -32,61 +32,61 @@ |
||
| 32 | 32 | |
| 33 | 33 | try { |
| 34 | 34 | |
| 35 | - require_once __DIR__ . '/lib/base.php'; |
|
| 36 | - if (\OCP\Util::needUpgrade()) { |
|
| 37 | - // since the behavior of apps or remotes are unpredictable during |
|
| 38 | - // an upgrade, return a 503 directly |
|
| 39 | - OC_Template::printErrorPage('Service unavailable', '', 503); |
|
| 40 | - exit; |
|
| 41 | - } |
|
| 35 | + require_once __DIR__ . '/lib/base.php'; |
|
| 36 | + if (\OCP\Util::needUpgrade()) { |
|
| 37 | + // since the behavior of apps or remotes are unpredictable during |
|
| 38 | + // an upgrade, return a 503 directly |
|
| 39 | + OC_Template::printErrorPage('Service unavailable', '', 503); |
|
| 40 | + exit; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - OC::checkMaintenanceMode(); |
|
| 44 | - $request = \OC::$server->getRequest(); |
|
| 45 | - $pathInfo = $request->getPathInfo(); |
|
| 43 | + OC::checkMaintenanceMode(); |
|
| 44 | + $request = \OC::$server->getRequest(); |
|
| 45 | + $pathInfo = $request->getPathInfo(); |
|
| 46 | 46 | |
| 47 | - if (!$pathInfo && $request->getParam('service', '') === '') { |
|
| 48 | - http_response_code(404); |
|
| 49 | - exit; |
|
| 50 | - } elseif ($request->getParam('service', '')) { |
|
| 51 | - $service = $request->getParam('service', ''); |
|
| 52 | - } else { |
|
| 53 | - $pathInfo = trim($pathInfo, '/'); |
|
| 54 | - list($service) = explode('/', $pathInfo); |
|
| 55 | - } |
|
| 56 | - $file = \OC::$server->getConfig()->getAppValue('core', 'public_' . strip_tags($service)); |
|
| 57 | - if ($file === '') { |
|
| 58 | - http_response_code(404); |
|
| 59 | - exit; |
|
| 60 | - } |
|
| 47 | + if (!$pathInfo && $request->getParam('service', '') === '') { |
|
| 48 | + http_response_code(404); |
|
| 49 | + exit; |
|
| 50 | + } elseif ($request->getParam('service', '')) { |
|
| 51 | + $service = $request->getParam('service', ''); |
|
| 52 | + } else { |
|
| 53 | + $pathInfo = trim($pathInfo, '/'); |
|
| 54 | + list($service) = explode('/', $pathInfo); |
|
| 55 | + } |
|
| 56 | + $file = \OC::$server->getConfig()->getAppValue('core', 'public_' . strip_tags($service)); |
|
| 57 | + if ($file === '') { |
|
| 58 | + http_response_code(404); |
|
| 59 | + exit; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $parts = explode('/', $file, 2); |
|
| 63 | - $app = $parts[0]; |
|
| 62 | + $parts = explode('/', $file, 2); |
|
| 63 | + $app = $parts[0]; |
|
| 64 | 64 | |
| 65 | - // Load all required applications |
|
| 66 | - \OC::$REQUESTEDAPP = $app; |
|
| 67 | - OC_App::loadApps(array('authentication')); |
|
| 68 | - OC_App::loadApps(array('filesystem', 'logging')); |
|
| 65 | + // Load all required applications |
|
| 66 | + \OC::$REQUESTEDAPP = $app; |
|
| 67 | + OC_App::loadApps(array('authentication')); |
|
| 68 | + OC_App::loadApps(array('filesystem', 'logging')); |
|
| 69 | 69 | |
| 70 | - if (!\OC::$server->getAppManager()->isInstalled($app)) { |
|
| 71 | - throw new Exception('App not installed: ' . $app); |
|
| 72 | - } |
|
| 73 | - OC_App::loadApp($app); |
|
| 74 | - OC_User::setIncognitoMode(true); |
|
| 70 | + if (!\OC::$server->getAppManager()->isInstalled($app)) { |
|
| 71 | + throw new Exception('App not installed: ' . $app); |
|
| 72 | + } |
|
| 73 | + OC_App::loadApp($app); |
|
| 74 | + OC_User::setIncognitoMode(true); |
|
| 75 | 75 | |
| 76 | - $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/'; |
|
| 76 | + $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/'; |
|
| 77 | 77 | |
| 78 | - require_once OC_App::getAppPath($app) . '/' . $parts[1]; |
|
| 78 | + require_once OC_App::getAppPath($app) . '/' . $parts[1]; |
|
| 79 | 79 | |
| 80 | 80 | } catch (Exception $ex) { |
| 81 | - $status = 500; |
|
| 82 | - if ($ex instanceof \OC\ServiceUnavailableException) { |
|
| 83 | - $status = 503; |
|
| 84 | - } |
|
| 85 | - //show the user a detailed error page |
|
| 86 | - \OC::$server->getLogger()->logException($ex, ['app' => 'public']); |
|
| 87 | - OC_Template::printExceptionErrorPage($ex, $status); |
|
| 81 | + $status = 500; |
|
| 82 | + if ($ex instanceof \OC\ServiceUnavailableException) { |
|
| 83 | + $status = 503; |
|
| 84 | + } |
|
| 85 | + //show the user a detailed error page |
|
| 86 | + \OC::$server->getLogger()->logException($ex, ['app' => 'public']); |
|
| 87 | + OC_Template::printExceptionErrorPage($ex, $status); |
|
| 88 | 88 | } catch (Error $ex) { |
| 89 | - //show the user a detailed error page |
|
| 90 | - \OC::$server->getLogger()->logException($ex, ['app' => 'public']); |
|
| 91 | - OC_Template::printExceptionErrorPage($ex, 500); |
|
| 89 | + //show the user a detailed error page |
|
| 90 | + \OC::$server->getLogger()->logException($ex, ['app' => 'public']); |
|
| 91 | + OC_Template::printExceptionErrorPage($ex, 500); |
|
| 92 | 92 | } |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | -require_once __DIR__ . '/lib/versioncheck.php'; |
|
| 31 | +require_once __DIR__.'/lib/versioncheck.php'; |
|
| 32 | 32 | |
| 33 | 33 | try { |
| 34 | 34 | |
| 35 | - require_once __DIR__ . '/lib/base.php'; |
|
| 35 | + require_once __DIR__.'/lib/base.php'; |
|
| 36 | 36 | if (\OCP\Util::needUpgrade()) { |
| 37 | 37 | // since the behavior of apps or remotes are unpredictable during |
| 38 | 38 | // an upgrade, return a 503 directly |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $pathInfo = trim($pathInfo, '/'); |
| 54 | 54 | list($service) = explode('/', $pathInfo); |
| 55 | 55 | } |
| 56 | - $file = \OC::$server->getConfig()->getAppValue('core', 'public_' . strip_tags($service)); |
|
| 56 | + $file = \OC::$server->getConfig()->getAppValue('core', 'public_'.strip_tags($service)); |
|
| 57 | 57 | if ($file === '') { |
| 58 | 58 | http_response_code(404); |
| 59 | 59 | exit; |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | OC_App::loadApps(array('filesystem', 'logging')); |
| 69 | 69 | |
| 70 | 70 | if (!\OC::$server->getAppManager()->isInstalled($app)) { |
| 71 | - throw new Exception('App not installed: ' . $app); |
|
| 71 | + throw new Exception('App not installed: '.$app); |
|
| 72 | 72 | } |
| 73 | 73 | OC_App::loadApp($app); |
| 74 | 74 | OC_User::setIncognitoMode(true); |
| 75 | 75 | |
| 76 | - $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/'; |
|
| 76 | + $baseuri = OC::$WEBROOT.'/public.php/'.$service.'/'; |
|
| 77 | 77 | |
| 78 | - require_once OC_App::getAppPath($app) . '/' . $parts[1]; |
|
| 78 | + require_once OC_App::getAppPath($app).'/'.$parts[1]; |
|
| 79 | 79 | |
| 80 | 80 | } catch (Exception $ex) { |
| 81 | 81 | $status = 500; |