From a92642795bd74703bed41de58273d931961ec7af Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 16 Mar 2017 19:44:01 +0100 Subject: [PATCH] new type API --- lam/lib/types.inc | 17 +++++++++++++++++ lam/lib/types/group.inc | 15 +++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lam/lib/types.inc b/lam/lib/types.inc index b14f176b..cf6452a4 100644 --- a/lam/lib/types.inc +++ b/lam/lib/types.inc @@ -485,6 +485,23 @@ class TypeManager { 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. * diff --git a/lam/lib/types/group.inc b/lam/lib/types/group.inc index c62cdfa3..123a4d81 100644 --- a/lam/lib/types/group.inc +++ b/lam/lib/types/group.inc @@ -1,9 +1,10 @@ _("Delete selected roles")); } // build suffix list for account types - $types = array('user', 'gon', 'group'); - $activeTypes = $_SESSION['config']->get_ActiveTypes(); + $typeManager = new TypeManager(); + $scopes = array('user', 'gon', 'group'); + $types = $typeManager->getConfiguredTypesForScopes($scopes); foreach ($types as $type) { - if (!in_array($type, $activeTypes)) { - continue; - } - $suffix = $_SESSION['config']->get_Suffix($type); + $suffix = $type->getSuffix(); // stop if suffixes are not unique if (isset($this->suffixList[$suffix])) { $this->suffixList = array(); break; } if (!empty($suffix)) { - $this->suffixList[$suffix] = $type; + $this->suffixList[$suffix] = $type->getId(); } } }