[Zope-PTK] Further enhancements to membership roster for intranets
Michael Bernstein
mbernstein@profitscape.com
Fri, 29 Sep 2000 15:00:00 -0500
I decided to implement an Intranet directory/membership roster. I
started with the ManageMembers dtml method in membership, but copied it
out to a '/members' folder index_html method.
I also created a new Python Method inside acl_users by copying
getMembers and naming the copy getListedMembers. The original method had
this body:
-8<--------------------------------------------------
user_ids=self.UserSource.getPersistentItemIDs()
users=[]
for i in user_ids:
users.append(self.getItem(i))
return users
-8<--------------------------------------------------
Which I modified like so:
-8<--------------------------------------------------
user_ids=self.UserSource.getPersistentItemIDs()
users=[]
for i in user_ids:
if self.UserSource.getItem(i).listed:
users.append(self.getItem(i))
return users
-8<--------------------------------------------------
The index_html method in '/members' implements a policy of showing the
entire list of members if you're logged in, but Anonymous viewrs only
see members who have have the listed option set. I also made a few other
changes:
- The PortalMember ZClass has 'Firstname' 'Lastname' instead of
'GivenName' 'Surname'
- The ZClass has an additional 'Extension' property, which is listed for
each member.
- Alternate rows have green backgrounds to increase legibility
- If a folder in the '/members' folder exists whose id matches
the User name, the user name is linked to it.
Here's the index_html code, I hope it's useful:
-8<--------------------------------------------------
<dtml-var standard_html_header>
<h2><dtml-var title_or_id></h2>
<dtml-unless bs>
<dtml-call "REQUEST.set('bs', '10')">
</dtml-unless>
<dtml-with "PARENTS[-1]">
<dtml-with acl_users>
<table border=0 cellspacing=0 cellpadding="5">
<tr><th>Name</th><th>User ID</th><th>Extension</th><th>Email
Address</th><tr>
<dtml-unless bs>
<dtml-call "REQUEST.set('bs', '10')">
</dtml-unless>
<dtml-if "AUTHENTICATED_USER.has_role(['Member','Manager'])">
<dtml-in getMembers sort=Lastname,Firstname,getUserName size=bs orphan=1
start=qs reverse>
<tr <dtml-if sequence-even>BGCOLOR="#CCFFCC"</dtml-if>>
<dtml-if "_.hasattr(PARENTS[-1].members, getUserName())">
<td><dtml-var getFullName> </td><td><a
href="/members/&dtml-getUserName;/">(&dtml-getUserName;)</a></td><td>&dtml-Extension; </td><td><a
href="mailto:&dtml-email;">&dtml-email;</a></td>
<dtml-else>
<td><dtml-var
getFullName> </td><td>(&dtml-getUserName;)</td><td>&dtml-Extension; </td><td><a
href="mailto:&dtml-email;">&dtml-email;</a></td>
</dtml-if>
</tr>
</dtml-in>
<dtml-else>
<dtml-in getListedMembers sort=Lastname,Firstname,getUserName size=bs
orphan=1 start=qs reverse>
<tr <dtml-if sequence-even>BGCOLOR="#CCFFCC"</dtml-if>>
<dtml-if "_.hasattr(PARENTS[-1].members, getUserName())">
<td><dtml-var getFullName> </td><td><a
href="/members/&dtml-getUserName;/">(&dtml-getUserName;)</a></td><td>&dtml-Extension; </td><td><a
href="mailto:&dtml-email;">&dtml-email;</a></td>
<dtml-else>
<td><dtml-var
getFullName> </td><td>(&dtml-getUserName;)</td><td>&dtml-Extension; </td><td><a
href="mailto:&dtml-email;">&dtml-email;</a></td>
</dtml-if>
</tr>
</dtml-in>
</dtml-if>
<tr>
<td colspan="3">
<form>
<label>Show me this many users at a time: <input type="text" size=4
value="&dtml-bs;" name="bs"></label>
<input type="submit" value="Change">
</form>
</td>
</tr>
<tr>
<td colspan="3">
<dtml-in getMembers sort=id size=bs orphan=1 start=qs previous>
<a href="<dtml-var URL><dtml-var sequence-query>qs=<dtml-var
previous-sequence-start-number>"
>Previous <dtml-var previous-sequence-size> Members</a>
<dtml-else>
No previous Members
</dtml-in>
|
<dtml-in getMembers sort=id size=bs orphan=1 start=qs next>
<a href="<dtml-var URL><dtml-var sequence-query>qs=<dtml-var
next-sequence-start-number>"
>Next <dtml-var next-sequence-size> Members</a>
<dtml-else>
No more Members
</dtml-in>
</td>
</tr>
</table>
</dtml-with>
</dtml-with>
<dtml-var standard_html_footer>
-8<--------------------------------------------------
HTH,
Michael Bernstein.