From 9a4963c85b8c7ca45c4f07f7ae21d1ae4f92f877 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 25 Mar 2017 20:25:20 +0100 Subject: [PATCH] new type API --- lam/lib/modules/sambaGroupMapping.inc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lam/lib/modules/sambaGroupMapping.inc b/lam/lib/modules/sambaGroupMapping.inc index ccb33545..bbfd1ca9 100644 --- a/lam/lib/modules/sambaGroupMapping.inc +++ b/lam/lib/modules/sambaGroupMapping.inc @@ -1,10 +1,11 @@ getConfiguredType($_POST['type']); $this->loadSIDCache(); $userFilter = ''; $userFilterRegex = ''; @@ -447,8 +450,8 @@ class sambaGroupMapping extends baseModule { $userFilterRegex = '/' . str_replace(array('*', '(', ')'), array('.*', '\(', '\)'), $_POST['newFilter']) . '/ui'; } $options = array(); - $filter = get_ldap_filter($_POST['type']); - $entries = searchLDAPByFilter($filter, array('dn', 'cn', 'uid', 'sambaSID'), array($_POST['type'])); + $filter = get_ldap_filter($type->getId()); + $entries = searchLDAP($type->getSuffix(), $filter, array('dn', 'cn', 'uid', 'sambaSID')); $entryCount = sizeof($entries); for ($i = 0; $i < $entryCount; $i++) { // require SID @@ -482,7 +485,7 @@ class sambaGroupMapping extends baseModule { $filterGroup->addElement(new htmlInputField('newFilter', $userFilter)); $filterGroup->addElement(new htmlButton('setFilter', _('Filter'))); $filterGroup->addElement(new htmlHelpLink('filter')); - $filterGroup->addElement(new htmlHiddenInput('type', $_POST['type'])); + $filterGroup->addElement(new htmlHiddenInput('type', $type->getId())); $return->addElement($filterGroup, true); $return->addElement(new htmlSpacer(null, '10px'), true); $buttonTable = new htmlTable(); @@ -491,13 +494,13 @@ class sambaGroupMapping extends baseModule { $return->addElement($buttonTable); return $return; } - $types = array('user', 'group', 'host'); + $types = $typeManager->getConfiguredTypesForScopes(array('user', 'group', 'host')); $options = array(); $optionsSelected = array(); - for ($i = 0; $i < sizeof($types); $i++) { - $options[LAM\TYPES\getTypeAlias($types[$i])] = $types[$i]; - if ($types[$i] == 'group') { - $optionsSelected[] = $types[$i]; + foreach ($types as $type) { + $options[$type->getAlias()] = $type->getId(); + if (empty($optionsSelected) && ($type->getScope() == 'group')) { + $optionsSelected[] = $type->getId(); } } $typeTable = new htmlTable();