$GroupObject->GroupUserRoleMemberList bug?

Moderator: crythias

Locked
Nicsoft
Znuny newbie
Posts: 53
Joined: 12 Aug 2010, 14:58
Znuny Version: 2.4
Location: Stockholm
Contact:

$GroupObject->GroupUserRoleMemberList bug?

Post by Nicsoft »

Hi,

I am trying to get a list of roles that a user is belonging to via SOAP. According to the definition at http://dev.otrs.org/ Kernel::System::Group::GroupUserRoleMemberList() the result should be like this:
Result: HASH -> returns a hash of key => group id, value => group name
This is the function I am using:

$GroupObject->GroupUserRoleMemberList(
UserID => $ID,
Result => 'HASH',
);


The userID I am using is '3'.

The role ID in OTRS is 1, 2 and 3.

When recursively printing the result it looks like this: Array ( [s-gensym3] => 1 [s-gensym5] => 3 [s-gensym7] => 3 [s-gensym9] => 3 [s-gensym11] => 2 [s-gensym13] => 3 )

There are no names. I do understand that it is the user ID I'm getting.

How should I do in order to get the names? Or should I consider the text at http://dev.otrs.org/ to be incorrect and the result that I get is what I will get and nothing else? Or is the text correct and we have a bug?

/Niklas
Last edited by Nicsoft on 15 Aug 2011, 21:19, edited 1 time in total.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: $GroupObject->GroupUserRoleMemberList bug?

Post by crythias »

Nicsoft wrote:I am trying to get a list of roles that a user is belonging to via SOAP
What names do you want? Group names, Role Names, or User Names?
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Nicsoft
Znuny newbie
Posts: 53
Joined: 12 Aug 2010, 14:58
Znuny Version: 2.4
Location: Stockholm
Contact:

Re: $GroupObject->GroupUserRoleMemberList bug?

Post by Nicsoft »

What I want to do is more or less exactly what is specified: Post user id and get an associative array back with [roleid] => rolename.

The text is actually not correct anyway I think; the key should probably be the role-id and the value role name but in reality it's actually the user ID that is returned. Incorrect info in my post, I'll update that information.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: $GroupObject->GroupUserRoleMemberList bug?

Post by crythias »

You say you're passing

Code: Select all

$GroupObject->GroupUserRoleMemberList(
UserID => '3',
Result => 'HASH',
);
which makes a $CacheKey = 'GroupUserRoleMemberList::Hash::UserID::3'

Code: Select all

    my $SQL = "SELECT ru.role_id, ru.user_id, r.name FROM role_user ru, roles r, users u
        WHERE r.valid_id IN ($ValidIDs)
            AND r.id = ru.role_id
            AND ru.user_id = u.id
            AND u.valid_id IN ($ValidIDs)
            AND ru.user_id = $Param{UserID}; (effectively)
This returns this:

Code: Select all

    while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
        my $Key   = '';
        my $Value = '';
        if ( $Param{RoleID} || $Param{RoleIDs} ) {
            $Key   = $Row[1];
            $Value = $Row[0];
        }
        else { // UserID or UserIDs param?
            $Key   = $Row[0];
            $Value = $Row[1];
        }
I'm guessing there might be a bug here. r.name appears to be called but isn't referenced. My *guess* is that $Value should be $Row[2] for this purpose.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Nicsoft
Znuny newbie
Posts: 53
Joined: 12 Aug 2010, 14:58
Znuny Version: 2.4
Location: Stockholm
Contact:

Re: $GroupObject->GroupUserRoleMemberList bug?

Post by Nicsoft »

Locked