nextcloud/settings/Application.php

132 lines
4.2 KiB
PHP
Raw Normal View History

<?php
/**
2016-07-21 18:07:57 +03:00
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
2016-05-26 20:56:05 +03:00
* @author Björn Schießle <bjoern@schiessle.org>
* @author Christoph Wurst <christoph@owncloud.com>
2015-03-26 13:44:34 +03:00
* @author Georg Ehrke <georg@owncloud.com>
2016-07-21 18:07:57 +03:00
* @author Joas Schilling <coding@schilljs.com>
2016-05-26 20:56:05 +03:00
* @author Lukas Reschke <lukas@statuscode.ch>
2015-03-26 13:44:34 +03:00
* @author Morris Jobke <hey@morrisjobke.de>
2016-07-21 19:13:36 +03:00
* @author Robin Appelman <robin@icewind.nl>
2016-07-21 18:07:57 +03:00
* @author Roeland Jago Douma <roeland@famdouma.nl>
2015-06-25 12:43:55 +03:00
* @author Thomas Müller <thomas.mueller@tmit.eu>
2015-03-26 13:44:34 +03:00
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Settings;
use OC\App\AppStore\Fetcher\AppFetcher;
use OC\App\AppStore\Fetcher\CategoryFetcher;
use OC\AppFramework\Utility\TimeFactory;
use OC\Authentication\Token\IProvider;
use OC\Server;
use OC\ServerContainer;
use OC\Settings\Mailer\NewUserMailHelper;
use OC\Settings\Middleware\SubadminMiddleware;
use OCA\Theming\ThemingDefaults;
use OCP\AppFramework\App;
use OCP\IContainer;
use OCP\Settings\IManager;
use OCP\Util;
/**
* @package OC\Settings
*/
class Application extends App {
/**
* @param array $urlParams
*/
public function __construct(array $urlParams=[]){
parent::__construct('settings', $urlParams);
$container = $this->getContainer();
// Register Middleware
$container->registerAlias('SubadminMiddleware', SubadminMiddleware::class);
$container->registerMiddleWare('SubadminMiddleware');
/**
* Core class wrappers
*/
/** FIXME: Remove once OC_User is non-static and mockable */
$container->registerService('isAdmin', function() {
return \OC_User::isAdminUser(\OC_User::getUser());
});
/** FIXME: Remove once OC_SubAdmin is non-static and mockable */
$container->registerService('isSubAdmin', function(IContainer $c) {
2015-10-27 16:09:45 +03:00
$userObject = \OC::$server->getUserSession()->getUser();
$isSubAdmin = false;
if($userObject !== null) {
$isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject);
}
return $isSubAdmin;
2015-01-30 16:16:16 +03:00
});
$container->registerService('userCertificateManager', function(IContainer $c) {
return $c->query('ServerContainer')->getCertificateManager();
}, false);
$container->registerService('systemCertificateManager', function (IContainer $c) {
return $c->query('ServerContainer')->getCertificateManager(null);
}, false);
$container->registerService(IProvider::class, function (IContainer $c) {
return $c->query('ServerContainer')->query(IProvider::class);
});
$container->registerService(IManager::class, function (IContainer $c) {
return $c->query('ServerContainer')->getSettingsManager();
});
$container->registerService(NewUserMailHelper::class, function (IContainer $c) {
/** @var Server $server */
$server = $c->query('ServerContainer');
return new NewUserMailHelper(
$server->getThemingDefaults(),
$server->getURLGenerator(),
$server->getL10N('settings'),
$server->getMailer(),
$server->getSecureRandom(),
new TimeFactory(),
$server->getConfig(),
$server->getCrypto(),
Util::getDefaultEmailAddress('no-reply')
);
});
$container->registerService(AppFetcher::class, function (IContainer $c) {
/** @var Server $server */
$server = $c->query('ServerContainer');
return new AppFetcher(
$server->getAppDataDir('appstore'),
$server->getHTTPClientService(),
$server->query(TimeFactory::class),
$server->getConfig()
);
});
$container->registerService(CategoryFetcher::class, function (IContainer $c) {
/** @var Server $server */
$server = $c->query('ServerContainer');
return new CategoryFetcher(
$server->getAppDataDir('appstore'),
$server->getHTTPClientService(),
$server->query(TimeFactory::class),
$server->getConfig()
);
});
}
}