DI IConfig into ldap helper
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
1ba2b7e5d4
commit
bdf4bf4669
|
@ -32,7 +32,7 @@ OCP\JSON::checkAppEnabled('user_ldap');
|
|||
OCP\JSON::callCheck();
|
||||
|
||||
$prefix = (string)$_POST['ldap_serverconfig_chooser'];
|
||||
$helper = new \OCA\User_LDAP\Helper();
|
||||
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
|
||||
if($helper->deleteServerConfiguration($prefix)) {
|
||||
OCP\JSON::success();
|
||||
} else {
|
||||
|
|
|
@ -27,7 +27,7 @@ OCP\JSON::checkAdminUser();
|
|||
OCP\JSON::checkAppEnabled('user_ldap');
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
$helper = new \OCA\User_LDAP\Helper();
|
||||
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
|
||||
$serverConnections = $helper->getServerConfigurationPrefixes();
|
||||
sort($serverConnections);
|
||||
$lk = array_pop($serverConnections);
|
||||
|
|
|
@ -60,7 +60,9 @@ $userManager = new \OCA\User_LDAP\User\Manager(
|
|||
\OC::$server->getDatabaseConnection(),
|
||||
\OC::$server->getUserManager());
|
||||
|
||||
$access = new \OCA\User_LDAP\Access($con, $ldapWrapper, $userManager, new \OCA\User_LDAP\Helper());
|
||||
$access = new \OCA\User_LDAP\Access($con, $ldapWrapper, $userManager, new \OCA\User_LDAP\Helper(
|
||||
\OC::$server->getConfig()
|
||||
));
|
||||
|
||||
$wizard = new \OCA\User_LDAP\Wizard($configuration, $ldapWrapper, $access);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
$helper = new \OCA\User_LDAP\Helper();
|
||||
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
|
||||
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
|
||||
$ldapWrapper = new OCA\User_LDAP\LDAP();
|
||||
$ocConfig = \OC::$server->getConfig();
|
||||
|
|
|
@ -26,5 +26,5 @@ if($state === 'doSet') {
|
|||
OCP\Config::setSystemValue('ldapIgnoreNamingRules', false);
|
||||
}
|
||||
|
||||
$helper = new \OCA\User_LDAP\Helper();
|
||||
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
|
||||
$helper->setLDAPProvider();
|
||||
|
|
|
@ -30,7 +30,7 @@ use OCA\User_LDAP\User\DeletedUsersIndex;
|
|||
|
||||
$dbConnection = \OC::$server->getDatabaseConnection();
|
||||
$userMapping = new UserMapping($dbConnection);
|
||||
$helper = new Helper();
|
||||
$helper = new Helper(\OC::$server->getConfig());
|
||||
$ocConfig = \OC::$server->getConfig();
|
||||
$uBackend = new User_Proxy(
|
||||
$helper->getServerConfigurationPrefixes(true),
|
||||
|
|
|
@ -20,5 +20,5 @@
|
|||
*
|
||||
*/
|
||||
|
||||
$helper = new \OCA\User_LDAP\Helper();
|
||||
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
|
||||
$helper->setLDAPProvider();
|
||||
|
|
|
@ -102,7 +102,7 @@ class Search extends Command {
|
|||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
$helper = new Helper();
|
||||
$helper = new Helper($this->ocConfig);
|
||||
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
|
||||
$ldapWrapper = new LDAP();
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class SetConfig extends Command {
|
|||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
$helper = new Helper();
|
||||
$helper = new Helper(\OC::$server->getConfig());
|
||||
$availableConfigs = $helper->getServerConfigurationPrefixes();
|
||||
$configID = $input->getArgument('configID');
|
||||
if(!in_array($configID, $availableConfigs)) {
|
||||
|
|
|
@ -47,7 +47,7 @@ class TestConfig extends Command {
|
|||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
$helper = new Helper();
|
||||
$helper = new Helper(\OC::$server->getConfig());
|
||||
$availableConfigs = $helper->getServerConfigurationPrefixes();
|
||||
$configID = $input->getArgument('configID');
|
||||
if(!in_array($configID, $availableConfigs)) {
|
||||
|
|
|
@ -87,7 +87,7 @@ class Connection extends LDAPUtility {
|
|||
if($memcache->isAvailable()) {
|
||||
$this->cache = $memcache->create();
|
||||
}
|
||||
$helper = new Helper();
|
||||
$helper = new Helper(\OC::$server->getConfig());
|
||||
$this->doNotValidate = !in_array($this->configPrefix,
|
||||
$helper->getServerConfigurationPrefixes());
|
||||
$this->hasPagedResultSupport =
|
||||
|
|
|
@ -30,8 +30,22 @@
|
|||
|
||||
namespace OCA\User_LDAP;
|
||||
|
||||
use OCP\IConfig;
|
||||
|
||||
class Helper {
|
||||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* Helper constructor.
|
||||
*
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns prefixes for each saved LDAP/AD server configuration.
|
||||
* @param bool $activeConfigurations optional, whether only active configuration shall be
|
||||
|
@ -251,7 +265,7 @@ class Helper {
|
|||
}
|
||||
|
||||
//ain't it ironic?
|
||||
$helper = new Helper();
|
||||
$helper = new Helper(\OC::$server->getConfig());
|
||||
|
||||
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
|
||||
$ldapWrapper = new LDAP();
|
||||
|
|
|
@ -83,7 +83,7 @@ class CleanUp extends TimedJob {
|
|||
if(isset($arguments['helper'])) {
|
||||
$this->ldapHelper = $arguments['helper'];
|
||||
} else {
|
||||
$this->ldapHelper = new Helper();
|
||||
$this->ldapHelper = new Helper(\OC::$server->getConfig());
|
||||
}
|
||||
|
||||
if(isset($arguments['ocConfig'])) {
|
||||
|
|
|
@ -172,7 +172,7 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob {
|
|||
if(!is_null(self::$groupBE)) {
|
||||
return self::$groupBE;
|
||||
}
|
||||
$helper = new Helper();
|
||||
$helper = new Helper(\OC::$server->getConfig());
|
||||
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
|
||||
$ldapWrapper = new LDAP();
|
||||
if(count($configPrefixes) === 1) {
|
||||
|
|
|
@ -52,7 +52,7 @@ class LDAPProviderFactory implements ILDAPProviderFactory {
|
|||
public function getLDAPProvider() {
|
||||
$dbConnection = $this->serverContainer->getDatabaseConnection();
|
||||
$userMapping = new UserMapping($dbConnection);
|
||||
return new LDAPProvider($this->serverContainer, new Helper(),
|
||||
return new LDAPProvider($this->serverContainer, new Helper($this->serverContainer->getConfig()),
|
||||
new DeletedUsersIndex($this->serverContainer->getConfig(),
|
||||
$dbConnection, $userMapping));
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ abstract class Proxy {
|
|||
$userManager =
|
||||
new Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(), $db, $coreUserManager);
|
||||
$connector = new Connection($this->ldap, $configPrefix);
|
||||
$access = new Access($connector, $this->ldap, $userManager, new Helper());
|
||||
$access = new Access($connector, $this->ldap, $userManager, new Helper(\OC::$server->getConfig()));
|
||||
$access->setUserMapper($userMap);
|
||||
$access->setGroupMapper($groupMap);
|
||||
self::$accesses[$configPrefix] = $access;
|
||||
|
|
|
@ -45,7 +45,7 @@ class Admin implements ISettings {
|
|||
* @return TemplateResponse
|
||||
*/
|
||||
public function getForm() {
|
||||
$helper = new Helper();
|
||||
$helper = new Helper(\OC::$server->getConfig());
|
||||
$prefixes = $helper->getServerConfigurationPrefixes();
|
||||
$hosts = $helper->getServerConfigurationHosts();
|
||||
|
||||
|
|
|
@ -724,7 +724,7 @@ class Wizard extends LDAPUtility {
|
|||
//this did not help :(
|
||||
//Let's see whether we can parse the Host URL and convert the domain to
|
||||
//a base DN
|
||||
$helper = new Helper();
|
||||
$helper = new Helper(\OC::$server->getConfig());
|
||||
$domain = $helper->getDomainFromURL($this->configuration->ldapHost);
|
||||
if(!$domain) {
|
||||
return false;
|
||||
|
|
|
@ -67,7 +67,7 @@ class AccessTest extends \Test\TestCase {
|
|||
$this->createMock(Image::class),
|
||||
$this->createMock(IDBConnection::class),
|
||||
$this->createMock(IUserManager::class)));
|
||||
$helper = new \OCA\User_LDAP\Helper();
|
||||
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
|
||||
|
||||
return array($lw, $connector, $um, $helper);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class Group_LDAPTest extends \Test\TestCase {
|
|||
$um = $this->getMockBuilder('\OCA\User_LDAP\User\Manager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$helper = new \OCA\User_LDAP\Helper();
|
||||
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
|
||||
$access = $this->getMock('\OCA\User_LDAP\Access',
|
||||
$accMethods,
|
||||
array($connector, $lw, $um, $helper));
|
||||
|
|
|
@ -113,7 +113,7 @@ abstract class AbstractIntegrationTest {
|
|||
* initializes the test Helper
|
||||
*/
|
||||
protected function initHelper() {
|
||||
$this->helper = new Helper();
|
||||
$this->helper = new Helper(\OC::$server->getConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -121,7 +121,7 @@ class LDAPProviderTest extends \Test\TestCase {
|
|||
|
||||
$server = $this->getServerMock($backend);
|
||||
|
||||
$helper = new \OCA\User_LDAP\Helper();
|
||||
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
|
||||
|
||||
$ldapProvider = $this->getLDAPProvider($server);
|
||||
$this->assertEquals(
|
||||
|
@ -137,7 +137,7 @@ class LDAPProviderTest extends \Test\TestCase {
|
|||
|
||||
$server = $this->getServerMock($backend);
|
||||
|
||||
$helper = new \OCA\User_LDAP\Helper();
|
||||
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
|
||||
|
||||
$ldapProvider = $this->getLDAPProvider($server);
|
||||
$this->assertEquals(
|
||||
|
|
|
@ -55,7 +55,7 @@ class AdminTest extends TestCase {
|
|||
*/
|
||||
public function testGetForm() {
|
||||
|
||||
$helper = new Helper();
|
||||
$helper = new Helper(\OC::$server->getConfig());
|
||||
$prefixes = $helper->getServerConfigurationPrefixes();
|
||||
$hosts = $helper->getServerConfigurationHosts();
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class UserTest extends \Test\TestCase {
|
|||
$umMethods, array($cfMock, $fsMock, $logMock, $avaMgr, $im, $dbc, $userMgr));
|
||||
$connector = $this->getMock('\OCA\User_LDAP\Connection',
|
||||
$conMethods, array($lw, null, null));
|
||||
$helper = new \OCA\User_LDAP\Helper();
|
||||
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
|
||||
$access = $this->getMock('\OCA\User_LDAP\Access',
|
||||
$accMethods, array($connector, $lw, $um, $helper));
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ class User_LDAPTest extends TestCase {
|
|||
->method('getDeletedUser')
|
||||
->will($this->returnValue($offlineUser));
|
||||
|
||||
$helper = new Helper();
|
||||
$helper = new Helper(\OC::$server->getConfig());
|
||||
|
||||
$access = $this->getMockBuilder(Access::class)
|
||||
->setMethodsExcept(['getConnection'])
|
||||
|
|
|
@ -70,7 +70,7 @@ class WizardTest extends \Test\TestCase {
|
|||
$um = $this->getMockBuilder('\OCA\User_LDAP\User\Manager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$helper = new \OCA\User_LDAP\Helper();
|
||||
$helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig());
|
||||
$access = $this->getMock('\OCA\User_LDAP\Access',
|
||||
$accMethods, array($connector, $lw, $um, $helper));
|
||||
|
||||
|
|
Loading…
Reference in New Issue