new type API

This commit is contained in:
Roland Gruber 2016-12-31 11:13:36 +01:00
parent ccc2721f51
commit 7027522950
2 changed files with 53 additions and 27 deletions

View File

@ -357,9 +357,18 @@ class nisMailAliasUser extends baseModule {
$return->addElement(new htmlHiddenInput('recipient', $recipient), true);
// new mail alias
$return->addElement(new htmlSubTitle(_('Create new alias')), true);
$typeObj = new mailAlias();
$ous = $typeObj->getSuffixList();
$return->addElement(new htmlTableExtendedSelect('new_ou', $ous, array(), _('Suffix'), 'suffix'), true);
$typeManager = new \LAM\TYPES\TypeManager();
$mailAliasTypes = $typeManager->getConfiguredTypesForScope('mailAlias');
$ous = array();
foreach ($mailAliasTypes as $type) {
$ous = array_merge($ous, $type->getBaseType()->getSuffixList());
}
$ous = array_unique($ous);
usort($ous, 'compareDN');
$suffixSelect = new htmlTableExtendedSelect('new_ou', $ous, array(), _('Suffix'), 'suffix');
$suffixSelect->setRightToLeftTextDirection(true);
$suffixSelect->setSortElements(false);
$return->addElement($suffixSelect, true);
$newAliasCn = empty($_POST['new_cn']) ? '' : $_POST['new_cn'];
$return->addElement(new htmlTableExtendedInputField(_('Alias name'), 'new_cn', $newAliasCn, 'newAlias'), true);
$return->addVerticalSpace('5px');

View File

@ -389,6 +389,23 @@ class TypeManager {
return $configuredTypes;
}
/**
* Returns a list of configured types for this scope.
*
* @param string $scope scope (e.g. user)
* @return \LAM\TYPES\ConfiguredType[] list of ConfiguredType
*/
public function getConfiguredTypesForScope($scope) {
$allTypes = $this->getConfiguredTypes();
$scopedTypes = array();
foreach ($allTypes as $type) {
if ($type->getScope() == $scope) {
$scopedTypes[] = $type;
}
}
return $scopedTypes;
}
/**
* Builds a configured account type.
*