new type API
This commit is contained in:
parent
2f45affd69
commit
daa51d1659
|
@ -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
|
||||||
Copyright (C) 2005 - 2016 Roland Gruber
|
Copyright (C) 2005 - 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
|
||||||
|
@ -828,16 +829,9 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
// update groups if DN changed
|
// update groups if DN changed
|
||||||
if (isset($this->getAccountContainer()->dn_orig) && ($this->getAccountContainer()->dn_orig != $this->getAccountContainer()->finalDN)) {
|
if (isset($this->getAccountContainer()->dn_orig) && ($this->getAccountContainer()->dn_orig != $this->getAccountContainer()->finalDN)) {
|
||||||
// update owner/member/uniqueMember attributes
|
// update owner/member/uniqueMember attributes
|
||||||
$types = $_SESSION['config']->get_ActiveTypes();
|
$searchAttrs = array('member', 'uniquemember', 'owner');
|
||||||
if (in_array('gon', $types)) {
|
|
||||||
$gonTypes[] = 'gon';
|
|
||||||
}
|
|
||||||
if (in_array('group', $types)) {
|
|
||||||
$gonTypes[] = 'group';
|
|
||||||
}
|
|
||||||
$searchAttrs = array('member', 'uniqueMember', 'owner');
|
|
||||||
foreach ($searchAttrs as $searchAttr) {
|
foreach ($searchAttrs as $searchAttr) {
|
||||||
$ownerGroups = searchLDAPByAttribute($searchAttr, $this->getAccountContainer()->dn_orig, null, array('dn', $searchAttr), $gonTypes);
|
$ownerGroups = searchLDAPByAttribute($searchAttr, $this->getAccountContainer()->dn_orig, null, array('dn', $searchAttr), array('gon', 'group'));
|
||||||
for ($i = 0; $i < sizeof($ownerGroups); $i++) {
|
for ($i = 0; $i < sizeof($ownerGroups); $i++) {
|
||||||
$found = false;
|
$found = false;
|
||||||
$newOwners = $ownerGroups[$i][$searchAttr];
|
$newOwners = $ownerGroups[$i][$searchAttr];
|
||||||
|
@ -910,12 +904,7 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
// remove from group of names
|
// remove from group of names
|
||||||
$dn = $this->getAccountContainer()->dn_orig;
|
$dn = $this->getAccountContainer()->dn_orig;
|
||||||
$gonTypes = array('group');
|
$gons = searchLDAPByFilter('(|(member=' . $dn . ')(uniqueMember=' . $dn . '))', array('member', 'uniqueMember'), array('group', 'gon'));
|
||||||
$types = $_SESSION['config']->get_ActiveTypes();
|
|
||||||
if (in_array('gon', $types)) {
|
|
||||||
$gonTypes[] = 'gon';
|
|
||||||
}
|
|
||||||
$gons = searchLDAPByFilter('(|(member=' . $dn . ')(uniqueMember=' . $dn . '))', array('member', 'uniqueMember'), $gonTypes);
|
|
||||||
for ($i = 0; $i < sizeof($gons); $i++) {
|
for ($i = 0; $i < sizeof($gons); $i++) {
|
||||||
if (isset($gons[$i]['member'])) {
|
if (isset($gons[$i]['member'])) {
|
||||||
$return[$gons[$i]['dn']]['remove']['member'][] = $dn;
|
$return[$gons[$i]['dn']]['remove']['member'][] = $dn;
|
||||||
|
@ -1516,7 +1505,9 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
$return = new htmlTable();
|
$return = new htmlTable();
|
||||||
$return->addElement(new htmlTableExtendedInputCheckbox('deletehomedir', true, _('Delete home directory'), 'deletehomedir'), true);
|
$return->addElement(new htmlTableExtendedInputCheckbox('deletehomedir', true, _('Delete home directory'), 'deletehomedir'), true);
|
||||||
}
|
}
|
||||||
if (($this->get_scope() == 'user') && in_array('sudo', $_SESSION['config']->get_ActiveTypes())) {
|
$typeManager = new TypeManager();
|
||||||
|
$sudoTypes = $typeManager->getConfiguredTypesForScope('sudo');
|
||||||
|
if (($this->get_scope() == 'user') && !empty($sudoTypes)) {
|
||||||
if ($return == null) {
|
if ($return == null) {
|
||||||
$return = new htmlTable();
|
$return = new htmlTable();
|
||||||
}
|
}
|
||||||
|
@ -3025,32 +3016,21 @@ class posixAccount extends baseModule implements passwordService {
|
||||||
return $this->gonCache;
|
return $this->gonCache;
|
||||||
}
|
}
|
||||||
$return = array();
|
$return = array();
|
||||||
$types = array();
|
$typeManager = new TypeManager();
|
||||||
if (in_array('group', $_SESSION['config']->get_ActiveTypes())) {
|
$types = $typeManager->getConfiguredTypesForScopes(array('gon', 'group'));
|
||||||
$types[] = 'group';
|
|
||||||
}
|
|
||||||
if (in_array('gon', $_SESSION['config']->get_ActiveTypes())) {
|
|
||||||
$types[] = 'gon';
|
|
||||||
}
|
|
||||||
$typeSettings = $_SESSION['config']->get_typeSettings();
|
|
||||||
if (sizeof($types) > 0) {
|
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$filter = '(|(objectClass=groupOfNames)(objectClass=groupOfMembers)(objectClass=groupOfUniqueNames))';
|
$filter = '(|(objectClass=groupOfNames)(objectClass=groupOfMembers)(objectClass=groupOfUniqueNames))';
|
||||||
if (!empty($typeSettings['filter_' . $type])) {
|
$typeFilter = get_ldap_filter($type->getId());
|
||||||
$typeFilter = $typeSettings['filter_' . $type];
|
$results = searchLDAP($type->getSuffix(), $typeFilter, array('cn', 'dn', 'objectClass'));
|
||||||
if (strpos($typeFilter, '(') !== 0) {
|
|
||||||
$typeFilter = '(' . $typeFilter . ')';
|
|
||||||
}
|
|
||||||
$filter = '(&' . $filter . $typeFilter . ')';
|
|
||||||
}
|
|
||||||
$results = searchLDAPByFilter($filter, array('cn', 'dn', 'objectClass'), array($type));
|
|
||||||
for ($i = 0; $i < sizeof($results); $i++) {
|
for ($i = 0; $i < sizeof($results); $i++) {
|
||||||
if (isset($results[$i]['cn'][0]) && isset($results[$i]['dn'])) {
|
if ((in_array('groupOfNames', $results[$i]['objectclass'])
|
||||||
|
|| in_array('groupOfMembers', $results[$i]['objectclass'])
|
||||||
|
|| in_array('groupOfUniqueNames', $results[$i]['objectclass']))
|
||||||
|
&& isset($results[$i]['cn'][0])) {
|
||||||
$return[$results[$i]['dn']] = $results[$i];
|
$return[$results[$i]['dn']] = $results[$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$this->gonCache = $return;
|
$this->gonCache = $return;
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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$
|
||||||
|
|
||||||
|
@ -652,8 +653,10 @@ class windowsGroup extends baseModule {
|
||||||
*/
|
*/
|
||||||
function display_html_user() {
|
function display_html_user() {
|
||||||
$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) . '_user_select']) && isset($_POST['type'])) {
|
if (isset($_POST['form_subpage_' . get_class($this) . '_user_select']) && isset($_POST['type'])) {
|
||||||
|
$type = $typeManager->getConfiguredType($_POST['type']);
|
||||||
$filterGroup = new htmlGroup();
|
$filterGroup = new htmlGroup();
|
||||||
$filterGroup->addElement(new htmlOutputText(_('Filter') . ' '));
|
$filterGroup->addElement(new htmlOutputText(_('Filter') . ' '));
|
||||||
$filter = new htmlInputField('windows_filter');
|
$filter = new htmlInputField('windows_filter');
|
||||||
|
@ -663,8 +666,8 @@ class windowsGroup extends baseModule {
|
||||||
$return->addElement($filterGroup, true);
|
$return->addElement($filterGroup, true);
|
||||||
|
|
||||||
$options = array();
|
$options = array();
|
||||||
$filter = get_ldap_filter($_POST['type']);
|
$filter = get_ldap_filter($type->getId());
|
||||||
$entries = searchLDAPByFilter($filter, array('dn'), array($_POST['type']));
|
$entries = searchLDAP($type->getSuffix(), $filter, array('dn'));
|
||||||
for ($i = 0; $i < sizeof($entries); $i++) {
|
for ($i = 0; $i < sizeof($entries); $i++) {
|
||||||
$entries[$i] = $entries[$i]['dn'];
|
$entries[$i] = $entries[$i]['dn'];
|
||||||
}
|
}
|
||||||
|
@ -719,13 +722,13 @@ class windowsGroup extends baseModule {
|
||||||
$return->addElement($removeButton, true);
|
$return->addElement($removeButton, true);
|
||||||
$return->addElement(new htmlOutputText(' ', false), true);
|
$return->addElement(new htmlOutputText(' ', false), true);
|
||||||
}
|
}
|
||||||
$types = $_SESSION['config']->get_ActiveTypes();
|
$types = $typeManager->getConfiguredTypes();
|
||||||
$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] == 'user') {
|
if ($type->getScope() == 'user') {
|
||||||
$optionsSelected[] = $types[$i];
|
$optionsSelected[] = $type->getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$typeTable = new htmlTable();
|
$typeTable = new htmlTable();
|
||||||
|
|
Loading…
Reference in New Issue