From 4fc654dece6815d0ee081c067126f18a2a45aeb4 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Fri, 25 Jan 2008 23:16:14 +0000 Subject: * added support to getAttrInfo() for selecting only the attributes matching a given scope (where 'core' means no scope) git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1495 95ad53e4-c205-0410-b2fa-d234c58c8868 --- config-db/OpenSLX/AttributeRoster.pm | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'config-db') diff --git a/config-db/OpenSLX/AttributeRoster.pm b/config-db/OpenSLX/AttributeRoster.pm index 33644207..0308540e 100644 --- a/config-db/OpenSLX/AttributeRoster.pm +++ b/config-db/OpenSLX/AttributeRoster.pm @@ -398,15 +398,30 @@ An hash-ref with info about all known attributes. sub getAttrInfo { - my $class = shift; - my $name = shift; + my $class = shift; + my $params = shift; $class->_init() if !%AttributeInfo; - if (defined $name) { - my $attrInfo = $AttributeInfo{$name}; + if (defined $params->{name}) { + my $attrInfo = $AttributeInfo{$params->{name}}; return if !defined $attrInfo; - return { $name => $AttributeInfo{$name} }; + return { $params->{name} => $AttributeInfo{$params->{name}} }; + } + elsif (defined $params->{scope}) { + my %MatchingAttributeInfo; + my $lcScope = lc($params->{scope}); + foreach my $attr (keys %AttributeInfo) { + my $attrScope = ''; + if ($attr =~ m{^(.+?)::}) { + $attrScope = $1; + } + if ((!$attrScope && $lcScope eq 'core') + || lc($attrScope) eq $lcScope) { + $MatchingAttributeInfo{$attr} = $AttributeInfo{$attr}; + } + } + return \%MatchingAttributeInfo; } return \%AttributeInfo; -- cgit v1.2.3-55-g7522