refactoring

This commit is contained in:
Roland Gruber 2019-07-19 10:16:28 +02:00
parent b831414ca4
commit 2ade724c40
1 changed files with 50 additions and 40 deletions

View File

@ -6,7 +6,7 @@ use LAM\TYPES\ConfiguredType;
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz Copyright (C) 2003 - 2006 Tilo Lutz
2007 - 2018 Roland Gruber 2007 - 2019 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -561,12 +561,6 @@ class posixGroup extends baseModule implements passwordService {
// configuration options // configuration options
$configContainer = new htmlResponsiveRow(); $configContainer = new htmlResponsiveRow();
$configContainer->add(new htmlSubTitle(_("Groups")), 12); $configContainer->add(new htmlSubTitle(_("Groups")), 12);
$genOptions = array(
_('Fixed range') => 'range',
_('Samba ID pool') => 'sambaPool',
_('Windows domain info') => 'windowsDomain',
_('Magic number') => 'magicNumber'
);
foreach ($allScopes[get_class($this)] as $typeId) { foreach ($allScopes[get_class($this)] as $typeId) {
if (sizeof($allScopes[get_class($this)]) > 1) { if (sizeof($allScopes[get_class($this)]) > 1) {
$title = new htmlDiv(null, new htmlOutputText($typeManager->getConfiguredType($typeId)->getAlias())); $title = new htmlDiv(null, new htmlOutputText($typeManager->getConfiguredType($typeId)->getAlias()));
@ -574,6 +568,45 @@ class posixGroup extends baseModule implements passwordService {
$configContainer->add($title, 12, 6); $configContainer->add($title, 12, 6);
$configContainer->add(new htmlOutputText(' ', false), 0, 6); $configContainer->add(new htmlOutputText(' ', false), 0, 6);
} }
$this->addAccountSpecificConfigOptions($configContainer, $typeId);
}
$gonModules = array('groupOfNames', 'groupOfUniqueNames');
$gonFound = false;
foreach ($gonModules as $gonModule) {
if (!empty($allScopes[$gonModule])) {
foreach ($allScopes[$gonModule] as $gonTypeId) {
if (getScopeFromTypeId($gonTypeId) === 'group') {
$gonFound = true;
}
}
}
}
if ($gonFound || !isset($allScopes['posixAccount'])) {
$configContainer->add(new htmlSubTitle(_("Options")), 12);
}
if ($gonFound) {
$configContainer->add(new htmlResponsiveInputCheckbox('posixGroup_autoSyncGon', false, _('Force sync with group of names'), 'autoSyncGon'), 12);
}
// display password hash option only if posixAccount module is not used
if (!isset($allScopes['posixAccount'])) {
$configContainer->add(new htmlResponsiveSelect('posixAccount_pwdHash', getSupportedHashTypes(), array('SSHA'), _("Password hash type"), 'pwdHash'), 12);
}
return $configContainer;
}
/**
* Adds the account specific options to the config container.
*
* @param htmlResponsiveRow $configContainer container
* @param string $typeId type ID
*/
protected function addAccountSpecificConfigOptions(&$configContainer, $typeId) {
$genOptions = array(
_('Fixed range') => 'range',
_('Samba ID pool') => 'sambaPool',
_('Windows domain info') => 'windowsDomain',
_('Magic number') => 'magicNumber'
);
$gidGeneratorSelect = new htmlResponsiveSelect('posixGroup_' . $typeId . '_gidGenerator', $genOptions, array('range'), _('GID generator'), 'gidGenerator'); $gidGeneratorSelect = new htmlResponsiveSelect('posixGroup_' . $typeId . '_gidGenerator', $genOptions, array('range'), _('GID generator'), 'gidGenerator');
$gidGeneratorSelect->setHasDescriptiveElements(true); $gidGeneratorSelect->setHasDescriptiveElements(true);
$gidGeneratorSelect->setTableRowsToHide(array( $gidGeneratorSelect->setTableRowsToHide(array(
@ -608,29 +641,6 @@ class posixGroup extends baseModule implements passwordService {
$configContainer->add(new htmlResponsiveInputCheckbox('posixGroup_' . $typeId . '_hidememberUid', false, _('Disable membership management'), 'hidememberUid'), 12); $configContainer->add(new htmlResponsiveInputCheckbox('posixGroup_' . $typeId . '_hidememberUid', false, _('Disable membership management'), 'hidememberUid'), 12);
$configContainer->addVerticalSpacer('2rem'); $configContainer->addVerticalSpacer('2rem');
} }
$gonModules = array('groupOfNames', 'groupOfUniqueNames');
$gonFound = false;
foreach ($gonModules as $gonModule) {
if (!empty($allScopes[$gonModule])) {
foreach ($allScopes[$gonModule] as $gonTypeId) {
if (getScopeFromTypeId($gonTypeId) === 'group') {
$gonFound = true;
}
}
}
}
if ($gonFound || !isset($allScopes['posixAccount'])) {
$configContainer->add(new htmlSubTitle(_("Options")), 12);
}
if ($gonFound) {
$configContainer->add(new htmlResponsiveInputCheckbox('posixGroup_autoSyncGon', false, _('Force sync with group of names'), 'autoSyncGon'), 12);
}
// display password hash option only if posixAccount module is not used
if (!isset($allScopes['posixAccount'])) {
$configContainer->add(new htmlResponsiveSelect('posixAccount_pwdHash', getSupportedHashTypes(), array('SSHA'), _("Password hash type"), 'pwdHash'), 12);
}
return $configContainer;
}
/** /**
* {@inheritDoc} * {@inheritDoc}