[Zope-CMF] Exposing the document owner's role

Lucas Hofman lucas.hofman@pgs.com
Fri, 10 Aug 2001 13:45:56 +0200


On Thursday 09 August 2001 04:29, norbert@attira.com wrote:
> I'm looking to display the role (anon user, member, reviewer) of the
> creator/owner of a particular piece of CMF content.
>
> Preferably, I'd look up the role from the member id in Creator() but I'm at
> a loss on how to do this.  My first guess was to look at what's available
> through portal_membership but this only seems to give me the role of
> the current user who's accessing the portal.
>
> Alternatively, I think I could add a user's role to a document's metadata
> upon creation, but this seems like a backward way of achieving my
> goal. I'm not interested much in the role a user once had when he or
> she created the document, but more in what this role is now.
>
> Any ideas / code samples welcome!
>
This is a code fragment from my modified roster method, which lists (among 
some other attributes) the role(s) a user has:


<dtml-let roster="portal_membership.getRoster()"
          userMgr="portal_membership.checkPermission( 'Manage_users', Members 
)"
>

<--- snip -->

<dtml-in roster mapping size=bs orphan=1 start=qs>
 <dtml-let homeUrl="portal_membership.getHomeUrl(id, verifyPermission=1)"
           fullName="portal_membership.getFullName(id)"
           member="portal_membership.getMemberById(id)"
           email="member.email">
 <tr>
  <td>
    <dtml-if email>
      <a href="mailto://&dtml-email;">&dtml-id; (&dtml-fullName;)</a>
     <dtml-else>
      &dtml-id;(&dtml-fullName;)
    </dtml-if>
  </td>
 <dtml-if userMgr>
  <td>
    <dtml-if homeUrl>
      <a href="&dtml-homeUrl;">home</a>
    </dtml-if>
  </td>
  <td>
   <dtml-var "_.string.join( portal_membership.getRoles(id), ',' )">
   </td>
  <td>
    <dtml-var "member.nrLogins">
   </td>
  <td>
    <dtml-try>
     <dtml-var "member.login_time" fmt="ISO"> 
    <dtml-except TypeError>
      N/A
    </dtml-try>
   </td>
 </dtml-if>
 </tr>
 </dtml-let>
</dtml-in>

The most interresting bit (for you) is:
<dtml-var "_.string.join( portal_membership.getRoles(id), ',' )">

you can get id from the creator or owner attribute.
 
Regards,
-- 
Lucas Hofman
PGS Research                                    work: +47 67514059
PO Box 354                                       fax: +47 67526640
N-1326 Lysaker, Norway                          home: +47 67581373