Merge pull request #29 from LDAPAccountManager/lam58

Lam58
This commit is contained in:
gruberroland 2017-03-16 20:05:43 +01:00 committed by GitHub
commit 4179b1bbe6
3 changed files with 38 additions and 14 deletions

View File

@ -4,7 +4,7 @@ namespace LAM\TYPES;
$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) 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
@ -339,6 +339,17 @@ class ConfiguredType {
return $ret; return $ret;
} }
/**
* Returns the names of the active modules for this type.
*
* @return string[] module names
*/
public function getModules() {
$typeSettings = $this->typeManager->getConfig()->get_typeSettings();
$modules = !empty($typeSettings['modules_' . $this->getId()]) ? $typeSettings['modules_' . $this->getId()] : '';
return explode(',', $modules);
}
} }
/** /**
@ -474,6 +485,23 @@ class TypeManager {
return $scopedTypes; return $scopedTypes;
} }
/**
* Returns a list of configured types for these scopes.
*
* @param array $scopes scopes (e.g. user)
* @return \LAM\TYPES\ConfiguredType[] list of ConfiguredType
*/
public function getConfiguredTypesForScopes($scopes) {
$allTypes = $this->getConfiguredTypes();
$scopedTypes = array();
foreach ($allTypes as $type) {
if (in_array($type->getScope(), $scopes)) {
$scopedTypes[] = $type;
}
}
return $scopedTypes;
}
/** /**
* Builds a configured account type. * Builds a configured account type.
* *

View File

@ -1,9 +1,10 @@
<?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) 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
@ -251,20 +252,18 @@ class lamGroupList extends lamList {
'deleteEntry' => _("Delete selected roles")); 'deleteEntry' => _("Delete selected roles"));
} }
// build suffix list for account types // build suffix list for account types
$types = array('user', 'gon', 'group'); $typeManager = new TypeManager();
$activeTypes = $_SESSION['config']->get_ActiveTypes(); $scopes = array('user', 'gon', 'group');
$types = $typeManager->getConfiguredTypesForScopes($scopes);
foreach ($types as $type) { foreach ($types as $type) {
if (!in_array($type, $activeTypes)) { $suffix = $type->getSuffix();
continue;
}
$suffix = $_SESSION['config']->get_Suffix($type);
// stop if suffixes are not unique // stop if suffixes are not unique
if (isset($this->suffixList[$suffix])) { if (isset($this->suffixList[$suffix])) {
$this->suffixList = array(); $this->suffixList = array();
break; break;
} }
if (!empty($suffix)) { if (!empty($suffix)) {
$this->suffixList[$suffix] = $type; $this->suffixList[$suffix] = $type->getId();
} }
} }
} }

View File

@ -15,7 +15,7 @@ use \htmlDiv;
$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) 2004 - 2016 Roland Gruber Copyright (C) 2004 - 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
@ -272,12 +272,9 @@ echo "</html>\n";
* @param htmlTable $container meta HTML container * @param htmlTable $container meta HTML container
*/ */
function config_showAccountModules($type, &$container) { function config_showAccountModules($type, &$container) {
$conf = &$_SESSION['conf_config'];
$typeSettings = $conf->get_typeSettings();
// account modules // account modules
$available = getAvailableModules($type->getScope(), true); $available = getAvailableModules($type->getScope(), true);
$selected = !empty($typeSettings['modules_' . $type->getId()]) ? $typeSettings['modules_' . $type->getId()] : ''; $selected = $type->getModules();
$selected = explode(',', $selected);
$sortedAvailable = array(); $sortedAvailable = array();
for ($i = 0; $i < sizeof($available); $i++) { for ($i = 0; $i < sizeof($available); $i++) {
$sortedAvailable[$available[$i]] = getModuleAlias($available[$i], $type->getScope()); $sortedAvailable[$available[$i]] = getModuleAlias($available[$i], $type->getScope());