You are here: Home / Documentation / How To's / How to list the site administrators, site owners, and content creators

How to list the site administrators, site owners, and content creators

by nguyen — published Nov 06, 2013 02:53 PM, last modified Aug 16, 2016 10:50 AM
for all Plone sites in a given Zope

In the ZMI root of your Zope, create a Script (Python)

Call it .listAdminsOwnersEditors

Its code should be:

# Script to place in Zope root that lists who is in the Administrators group in all the contained Plone sites.

def listManagers(site):
  out = []
  users = site.acl_users
  prm = users.portal_role_manager
  pgm = users.source_groups
  pm = site.portal_membership
  if True:
    who = prm.listAssignedPrincipals('Manager')
    who2 = pgm.listAssignedPrincipals('Administrators')
    out.append('<b>Final Admin membership</b> %s' % [x[0] for x in who2])
    out.append('.')
    for x in who2:
      uniqueDictAdmins[x[0]] = 1
    pg = site.portal_groups
    siteowners = pg.getGroupMembers('Site Owner')
    out.append('<b>Site Owner members</b> %s.' % [x for x in siteowners])
    for x in siteowners:
      #uniqueDictSiteOwners[x]=1
      uniqueDictAdmins[x]=1
  # portal_catalog/Indexes/Creator/uniqueValues
  pc = site.portal_catalog
  creators = pc.Indexes['Creator'].uniqueValues()
  out.append('<b>content creators</b> %s.' % [x for x in creators])
  for x in creators:
    uniqueDictCreators[x]=1
  # now get email addresses
  if True:
    for u in uniqueDictAdmins.keys():
      m = pm.getMemberById(u)
      if hasattr(m, 'getProperty'):
        email = m.getProperty('email', None)
        if email:
          uniqueDictAdminEmails[email] = 1
    for u in uniqueDictCreators.keys():
      m = pm.getMemberById(u)
      if hasattr(m, 'getProperty'):
        email = m.getProperty('email', None)
        if email:
          uniqueDictCreatorEmails[email] = 1

uniqueDictAdmins = {}
uniqueDictAdminEmails = {}
uniqueDictCreators = {}
uniqueDictCreatorEmails = {}

for itemTuple in context.items():
 (item, itemType) = itemTuple
 if str(itemType).startswith('<PloneSite at '):
   site = getattr(context, item)
   print "<b>Plone site <a href=\"%s\" target=\"_blank\">%s</a></b>: %s<br>" % (site.portal_url()+'/manage_main', site.id, listManagers(site))
 elif str(itemType).startswith('<Folder at '):
   folder = getattr(context, item)
   print "<a href='%s/manage_main' target='_blank_'><h1>%s</h1></a>" % (folder.absolute_url(), item)
   for folderItemTuple in folder.items():
     (folderItem, folderItemType) = folderItemTuple
     if str(folderItemType).startswith('<PloneSite at '):
       site = getattr(folder, folderItem)
       print "<b>Plone site <a href=\"%s\" target=\"_blank\">%s</a></b>: %s<br>" % (site.portal_url()+'/manage_main', site.id, listManagers(site))
    
#print "<h2>admins and site owners</h2> %s" % '<br>'.join(uniqueDictAdmins.keys())
print "<h2>admins and site owners email addresses</h2> %s" % '<br>'.join(uniqueDictAdminEmails.keys())

#print "<h2>content creators</h2> %s" % '<br>'.join(uniqueDictCreators.keys())
print "<h2>content creators email addresses</h2> %s" % '<br>'.join(uniqueDictCreatorEmails.keys())

return printed

 

 
Navigation