from Products.CMFCore.permissions import View, ListPortalMembers, ManagePortal, SetOwnPassword, ChangePermissions
from permissions import RemoveMember, SetLocalRoles, CheckMemberPermission
from utils import _checkMemberPermission
-from Products.CMFCore.utils import getToolByName, _checkPermission, _getAuthenticatedUser
+from Products.CMFCore.utils import _checkPermission, _getAuthenticatedUser
+from Products.CMFCore.utils import getUtilityByInterfaceName
from utils import formatFullName, translate
from Products.CMFDefault.utils import decode
from Products.CMFDefault.Document import addDocument
security.declareProtected(ListPortalMembers, 'getMembersMetadata')
def getMembersMetadata(self, users) :
- """ return metadatas from portal_catalog """
+ """ return metadata from portal_catalog """
userDict = {}
for u in users : userDict[u] = True
- ctool = getToolByName(self, 'portal_catalog')
+ ctool = getUtilityByInterfaceName('Products.CMFCore.interfaces.ICatalogTool')
memberBrains = ctool(portal_type='Member Data', sort_on='getMemberSortableFormat')
memberList = []
complementList = []
if users :
for mb in memberBrains :
- metadatas = {'id' : mb.getId, 'fullname' : mb.getMemberFullName}
+ metadata = {'id' : mb.getId, 'fullname' : mb.getMemberFullName}
if userDict.has_key(mb.getId) :
- memberList.append(metadatas)
+ memberList.append(metadata)
else :
- complementList.append(metadatas)
+ complementList.append(metadata)
else :
complementList = [{'id' : mb.getId, 'fullname' : mb.getMemberFullName} for mb in memberBrains]
""" remove member
"""
# TODO : remove member document ?
- mdtool = getToolByName(self, 'portal_memberdata')
+ mdtool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IMemberDataTool')
for m in self.getMembers(memberIds) :
m.manage_beforeDelete()
mdtool.deleteMemberData(m.getId())
security.declareProtected(ManagePortal, 'setMemberAreaPortalType')
def setMemberAreaPortalType(self, member_folder_portal_type):
""" Set member area portal type to construct."""
- ttool = getToolByName(self, 'portal_types')
+ ttool = getUtilityByInterfaceName('Products.CMFCore.interfaces.ITypesTool')
if member_folder_portal_type not in ttool.objectIds() :
raise ValueError, "Unknown portal type : %s" % str(member_folder_portal_type)
if hasattr( aq_base(members), member_id ):
return None
- ttool = getToolByName(self, 'portal_types')
+ ttool = getUtilityByInterfaceName('Products.CMFCore.interfaces.ITypesTool')
info = getattr(ttool, self.memberareaPortalType)
memberFullName = self.getMemberFullNameById(member_id, nameBefore = 0)
f.manage_setLocalRoles(member_id, ['Owner'])
f.reindexObjectSecurity()
-
- # Create Member's initial content.
- if hasattr(self, 'createMemberContent') :
- self.createMemberContent(member=user,
- member_id=member_id,
- member_folder=f)
- else :
- def _(message, context, expand=()) :
- trmessage = decode(translate(message, context), context)
- expand = tuple([decode(e, context) for e in expand])
- return (trmessage % expand).encode('utf-8')
-
- # Create Member's home page.
- addDocument( f
- , 'index_html'
- , title = _("%s's Home", self, (memberFullName,))
- , description = _("%s's front page", self, (memberFullName,))
- , text_format = "html"
- , text = self.default_member_content(memberFullName=memberFullName).encode('utf-8')
- )
-
- # Grant Ownership and Owner role to Member
- f.index_html.changeOwnership(user)
- f.index_html.__ac_local_roles__ = None
- f.index_html.manage_setLocalRoles(member_id, ['Owner'])
-
- f.index_html._setPortalTypeName( 'Document' )
-
- # Overcome an apparent catalog bug.
- f.index_html.reindexObject()
- wftool = getToolByName( f, 'portal_workflow' )
- wftool.notifyCreated( f.index_html )
-
return f
words = searchString.strip().split()
words = [word.lower() for word in words]
- mdtool = getToolByName(self, 'portal_memberdata')
+ mdtool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IMemberDataTool')
mdProperties = mdtool.propertyIds()
searchableProperties = [ p['id'] for p in mdtool.propertyMap() if p['type'] == 'string' ] + ['id']
try : searchableProperties.remove('portal_skin')