new type API

This commit is contained in:
Roland Gruber 2017-03-25 20:25:20 +01:00
parent 207c77b5f0
commit 9a4963c85b
1 changed files with 12 additions and 9 deletions

View File

@ -1,10 +1,11 @@
<?php <?php
use \LAM\TYPES\TypeManager;
/* /*
$Id$ $Id$
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 - 2016 Roland Gruber 2007 - 2017 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
@ -437,8 +438,10 @@ class sambaGroupMapping extends baseModule {
*/ */
function display_html_members() { function display_html_members() {
$return = new htmlTable(); $return = new htmlTable();
$typeManager = new TypeManager();
// show list of possible new members // show list of possible new members
if ((isset($_POST['form_subpage_' . get_class($this) . '_members_select']) || isset($_POST['setFilter'])) && isset($_POST['type'])) { if ((isset($_POST['form_subpage_' . get_class($this) . '_members_select']) || isset($_POST['setFilter'])) && isset($_POST['type'])) {
$type = $typeManager->getConfiguredType($_POST['type']);
$this->loadSIDCache(); $this->loadSIDCache();
$userFilter = ''; $userFilter = '';
$userFilterRegex = ''; $userFilterRegex = '';
@ -447,8 +450,8 @@ class sambaGroupMapping extends baseModule {
$userFilterRegex = '/' . str_replace(array('*', '(', ')'), array('.*', '\(', '\)'), $_POST['newFilter']) . '/ui'; $userFilterRegex = '/' . str_replace(array('*', '(', ')'), array('.*', '\(', '\)'), $_POST['newFilter']) . '/ui';
} }
$options = array(); $options = array();
$filter = get_ldap_filter($_POST['type']); $filter = get_ldap_filter($type->getId());
$entries = searchLDAPByFilter($filter, array('dn', 'cn', 'uid', 'sambaSID'), array($_POST['type'])); $entries = searchLDAP($type->getSuffix(), $filter, array('dn', 'cn', 'uid', 'sambaSID'));
$entryCount = sizeof($entries); $entryCount = sizeof($entries);
for ($i = 0; $i < $entryCount; $i++) { for ($i = 0; $i < $entryCount; $i++) {
// require SID // require SID
@ -482,7 +485,7 @@ class sambaGroupMapping extends baseModule {
$filterGroup->addElement(new htmlInputField('newFilter', $userFilter)); $filterGroup->addElement(new htmlInputField('newFilter', $userFilter));
$filterGroup->addElement(new htmlButton('setFilter', _('Filter'))); $filterGroup->addElement(new htmlButton('setFilter', _('Filter')));
$filterGroup->addElement(new htmlHelpLink('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($filterGroup, true);
$return->addElement(new htmlSpacer(null, '10px'), true); $return->addElement(new htmlSpacer(null, '10px'), true);
$buttonTable = new htmlTable(); $buttonTable = new htmlTable();
@ -491,13 +494,13 @@ class sambaGroupMapping extends baseModule {
$return->addElement($buttonTable); $return->addElement($buttonTable);
return $return; return $return;
} }
$types = array('user', 'group', 'host'); $types = $typeManager->getConfiguredTypesForScopes(array('user', 'group', 'host'));
$options = array(); $options = array();
$optionsSelected = array(); $optionsSelected = array();
for ($i = 0; $i < sizeof($types); $i++) { foreach ($types as $type) {
$options[LAM\TYPES\getTypeAlias($types[$i])] = $types[$i]; $options[$type->getAlias()] = $type->getId();
if ($types[$i] == 'group') { if (empty($optionsSelected) && ($type->getScope() == 'group')) {
$optionsSelected[] = $types[$i]; $optionsSelected[] = $type->getId();
} }
} }
$typeTable = new htmlTable(); $typeTable = new htmlTable();