Kasper,

Sorry for the late reply,

>Is there any way of getting the groups a user is member of?
>Instead of running through all of the groups and all of the permissions and
>checking for hasRole!


I use;

    public Vector allUsersGroups(RunData data) throws Exception
    {
        Vector v = new Vector(10);
        
        //check that username isnt null
        User user = data.getUser();
        if (user.hasLoggedIn())
        {
       
            Criteria criteria = new Criteria();
            criteria.addJoin(GroupPeer.GROUP_ID,UserGroupRolePeer.GROUP_ID);
 
criteria.addJoin(UserGroupRolePeer.USER_ID,TurbineUserPeer.USER_ID);
 
criteria.add(TurbineUserPeer.USERNAME,data.getUser().getUserName()); 
            criteria.addOrderByColumn(GroupPeer.NAME);
            criteria.setDistinct();
          
            v = GroupPeer.doSelect(criteria);

            //System.out.println("v.size for AllUsersGroups " + v.size() );
        
        }
         
        return v;
    }

If the user isnt logged in they get no choice of groups, I handle that in a
velocity navigation. I also store the Group that the user is in, in
user.setTemp(). 



Cameron Riley


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to