new type API

This commit is contained in:
Roland Gruber 2017-04-02 15:34:45 +02:00
parent 7d5310f588
commit fb1ab48b38
1 changed files with 27 additions and 25 deletions

View File

@ -2,6 +2,7 @@
use \LAM\PDF\PDFTable; use \LAM\PDF\PDFTable;
use \LAM\PDF\PDFTableCell; use \LAM\PDF\PDFTableCell;
use \LAM\PDF\PDFTableRow; use \LAM\PDF\PDFTableRow;
use \LAM\TYPES\TypeManager;
/* /*
$Id$ $Id$
@ -121,18 +122,21 @@ class nisNetGroupUser extends baseModule {
return; return;
} }
$this->uidOrig = $attr['uid'][0]; $this->uidOrig = $attr['uid'][0];
$types = array('netgroup'); $typeManager = new TypeManager();
$typeSettings = $_SESSION['config']->get_typeSettings(); $types = $typeManager->getConfiguredTypesForScope('netgroup');
$groupList = array(); $groupList = array();
$filter = '(&(objectClass=nisNetgroup)(nisnetgrouptriple=*))'; foreach ($types as $type) {
if (!empty($typeSettings['filter_' . $types[0]])) { $filter = '(&(objectClass=nisNetgroup)(nisnetgrouptriple=*))';
$typeFilter = $typeSettings['filter_' . $types[0]]; $typeFilter = $type->getAdditionalLdapFilter();
if (strpos($typeFilter, '(') !== 0) { if (!empty($typeFilter)) {
$typeFilter = '(' . $typeFilter . ')'; if (strpos($typeFilter, '(') !== 0) {
$typeFilter = '(' . $typeFilter . ')';
}
$filter = '(&' . $filter . $typeFilter . ')';
} }
$filter = '(&' . $filter . $typeFilter . ')'; $groupsFound = searchLDAP($type->getSuffix(), $filter, array('dn', 'cn', 'nisnetgrouptriple'));
$groupList = array_merge($groupList, $groupsFound);
} }
$groupList = searchLDAPByFilter($filter, array('dn', 'cn', 'nisnetgrouptriple'), $types);
$this->groupsOrig = array(); $this->groupsOrig = array();
$tripleRegex = '/^\\(([^,]*),([^,]*),([^,]*)\\)$/'; $tripleRegex = '/^\\(([^,]*),([^,]*),([^,]*)\\)$/';
foreach ($groupList as $group) { foreach ($groupList as $group) {
@ -639,23 +643,21 @@ class nisNetGroupUser extends baseModule {
return $this->groupCache; return $this->groupCache;
} }
$return = array(); $return = array();
$types = array('netgroup'); $typeManager = new TypeManager();
$typeSettings = $_SESSION['config']->get_typeSettings(); $types = $typeManager->getConfiguredTypesForScope('netgroup');
if (sizeof($types) > 0) { foreach ($types as $type) {
foreach ($types as $type) { $filter = '(objectClass=nisNetgroup)';
$filter = '(objectClass=nisNetgroup)'; $typeFilter = $type->getAdditionalLdapFilter();
if (!empty($typeSettings['filter_' . $type])) { if (!empty($typeFilter)) {
$typeFilter = $typeSettings['filter_' . $type]; if (strpos($typeFilter, '(') !== 0) {
if (strpos($typeFilter, '(') !== 0) { $typeFilter = '(' . $typeFilter . ')';
$typeFilter = '(' . $typeFilter . ')';
}
$filter = '(&' . $filter . $typeFilter . ')';
} }
$results = searchLDAPByFilter($filter, array('cn', 'dn', 'nisnetgrouptriple'), array($type)); $filter = '(&' . $filter . $typeFilter . ')';
for ($i = 0; $i < sizeof($results); $i++) { }
if (isset($results[$i]['cn'][0]) && isset($results[$i]['dn'])) { $results = searchLDAP($type->getSuffix(), $filter, array('cn', 'dn', 'nisnetgrouptriple'));
$return[] = $results[$i]; for ($i = 0; $i < sizeof($results); $i++) {
} if (isset($results[$i]['cn'][0]) && isset($results[$i]['dn'])) {
$return[] = $results[$i];
} }
} }
} }