[Zope-CMF] showing an item only to selected groups

Roel Van den Bergh roel@planetinterior.com
Wed, 4 Dec 2002 16:54:18 +0100


-----Original Message-----
From: Dieter Maurer [mailto:dieter@handshake.de]
Sent: Tuesday, December 03, 2002 9:12 PM
To: roel@planetinterior.com
Cc: zope-cmf@zope.org
Subject: Re: [Zope-CMF] showing an item only to slected groups


Roel Van den Bergh writes:
 > I've build a graphical homepage in front of a CMF site.
 >
 > Within the site a certain folder is only accessible and viewable to a
group
 > using NuxUserGroups and the 'skip_unauthorized' function in CMF 1.3. That
 > works fine, only the allowed groups can view/visit the folder.
 >
 > Now I do not want the button and text for that folder to show up on the
 > homepage.
 >
 > I'm used to hide static content for 'Guests' with
 >
 > <dtml-let member="portal_membership.getAuthenticatedMember()"
 >           listMembers="portal_membership.checkPermission('List portal
 > members', member)">
 > <dtml-if listMembers>
 > ...
 > </dtml-let>
 > </dtml-if>
 >
 > But I can't figure out how to check for a certain 'Group'
Use

	portal_membership.checkPermission(permission,object)

to check whether the current user(!) has "permission" on "object".

As NUXGroups are implemented as local roles (as far as I know),
this should work when you get the correct object.


Dieter

Tnx for the quick reply but I still can't get it right.
Went trough Zopelabs and even dug in the raw NuxUserGroups material without
any succes.

Found something in the 'Zope Book' related to 'roles'

 <dtml-var "AUTHENTICATED_USER.has_role('Member')">
 <dtml-var "AUTHENTICATED_USER.getRoles()">
 <dtml-var "AUTHENTICATED_USER.getRolesInContext('folder_name')">

Resolves in

 1
 ('Member', 'Authenticated')
 ['Member', 'Authenticated']

Aparrantly 'Groups' are not treated as 'roles' or 'local roles'

Trying to use code snippets from NuxUserGroups directly resultated in
numerus NameErrors and KeyErrors and AtributeErrors.

Probably searching in the wrong direction.

My only goal is to show a static image only to certain 'Members' who share
the same NuxUser 'group'.

Roel.