views:

106

answers:

2

I've got this:

UserProfile prof = getUserProfile(properties.CurrentUserId);
UserProfile toCheck = getUserProfile(anotherUsersId);

"prof" user must be on a higher or on the same level as "toCheck" user. If "toCheck" is on a lower level he/she must be on the same branch of the hierarchy tree. If they are on the same level, their manager must be the same.

Is there an easy way to check this?

+2  A: 

There are a few methods that should help you here:

There is no "easy way" that I've found but you can write your own helper classes that use these methods, traverse the user profiles, and find the information you need.

As an aside: "Colleagues" is not related to this. They are a list of people that, with a complete My Site implementation, users can manage themselves.

Alex Angas
GetManager was the solution. But it wasn't an easy way. :) (Nontrivial (for me)) recursion were needed.
Vili
A: 

Some pseudo code:

function compare(manager, toCheck, prof) 
{
    toManager=toCheck.manager;
    if (toManager!=null)
    {
        if (manager==tomanager || prof==tomanager)
        {
            return true;
        }
        else
        {
            return compare("", tomanager, prof);
        }
    }
    else // he/she is the boss
    {
        return false;
    }

}

...

if (prof.manager!=null)
{
    compare(prof.manager, toCheck, prof);
}
else  // he/she is the boss
{
    return true;
}
Vili