[CMF-checkins] CVS: CMF/CMFCore - MembershipTool.py:1.38.2.2
Yvo Schubbe
schubbe at web.de
Tue Sep 9 10:08:35 EDT 2003
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv15636/CMFCore
Modified Files:
Tag: yuppie-deleteMembers-branch
MembershipTool.py
Log Message:
added deleteMemberArea and deleteMembers methods
=== CMF/CMFCore/MembershipTool.py 1.38.2.1 => 1.38.2.2 ===
--- CMF/CMFCore/MembershipTool.py:1.38.2.1 Tue Sep 9 08:07:23 2003
+++ CMF/CMFCore/MembershipTool.py Tue Sep 9 09:08:05 2003
@@ -15,6 +15,7 @@
$Id$
"""
+from types import StringType
from utils import UniqueObject, _getAuthenticatedUser, _checkPermission
from utils import getToolByName, _dtmldir
from OFS.Folder import Folder
@@ -278,6 +279,19 @@
security.declarePublic('createMemberarea')
createMemberarea = createMemberArea
+ security.declareProtected(ManageUsers, 'deleteMemberArea')
+ def deleteMemberArea(self, member_id):
+ """ Delete member area of member specified by member_id.
+ """
+ members = self.getMembersFolder()
+ if not members:
+ return 0
+ if hasattr( aq_base(members), member_id ):
+ members.manage_delObjects(member_id)
+ return 1
+ else:
+ return 0
+
security.declarePublic('isAnonymousUser')
def isAnonymousUser(self):
'''
@@ -434,6 +448,47 @@
if properties is not None:
member = self.getMemberById(id)
member.setMemberProperties(properties)
+
+ security.declareProtected(ManageUsers, 'deleteMembers')
+ def deleteMembers(self, member_ids, delete_memberareas=1,
+ delete_localroles=1):
+ """ Delete members specified by member_ids.
+ """
+
+ # Delete members in acl_users.
+ acl_users = self.acl_users
+ if _checkPermission(ManageUsers, acl_users):
+ if type(member_ids) is StringType:
+ member_ids = (member_ids,)
+ member_ids = list(member_ids)
+ for member_id in member_ids[:]:
+ if not acl_users.getUserById(member_id, None):
+ member_ids.remove(member_id)
+ try:
+ acl_users.userFolderDelUsers(member_ids)
+ except 'NotImplemented':
+ return ()
+ else:
+ return ()
+
+ # Delete member data in portal_memberdata.
+ mdtool = getToolByName(self, 'portal_memberdata', None)
+ if mdtool:
+ for member_id in member_ids:
+ mdtool.deleteMemberData(member_id)
+
+ # Delete members' home folders including all content items.
+ if delete_memberareas:
+ for member_id in member_ids:
+ self.deleteMemberArea(member_id)
+
+ # Delete members' local roles.
+ if delete_localroles:
+ utool = getToolByName(self, 'portal_url', None)
+ self.deleteLocalRoles( utool.getPortalObject(), member_ids,
+ reindex=1, recursive=1 )
+
+ return tuple(member_ids)
security.declarePublic('getHomeFolder')
def getHomeFolder(self, id=None, verifyPermission=0):
More information about the CMF-checkins
mailing list