[CMF-checkins] CVS: CMF/CMFCore - CMFCorePermissions.py:1.16.2.1
MembershipTool.py:1.38.2.4 PortalFolder.py:1.48.2.1
Yvo Schubbe
schubbe at web.de
Sat Sep 20 07:49:52 EDT 2003
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv21859/CMFCore
Modified Files:
Tag: yuppie-deleteMembers-branch
CMFCorePermissions.py MembershipTool.py PortalFolder.py
Log Message:
- added 'Change local roles' Permission
- made Local Roles action and methods guarded by 'Change local roles'
- made use of CMFCoreExceptions in deleteMembers
=== CMF/CMFCore/CMFCorePermissions.py 1.16 => 1.16.2.1 ===
--- CMF/CMFCore/CMFCorePermissions.py:1.16 Wed Sep 3 05:21:21 2003
+++ CMF/CMFCore/CMFCorePermissions.py Sat Sep 20 07:49:52 2003
@@ -92,6 +92,9 @@
SetOwnProperties = 'Set own properties'
setDefaultRoles(SetOwnProperties, ('Manager',)) # + Member
+ChangeLocalRoles = 'Change local roles'
+setDefaultRoles(ChangeLocalRoles, ('Owner', 'Manager'))
+
MailForgottenPassword = 'Mail forgotten password'
setDefaultRoles(MailForgottenPassword, ('Anonymous', 'Manager',))
=== CMF/CMFCore/MembershipTool.py 1.38.2.3 => 1.38.2.4 ===
--- CMF/CMFCore/MembershipTool.py:1.38.2.3 Sat Sep 13 06:37:32 2003
+++ CMF/CMFCore/MembershipTool.py Sat Sep 20 07:49:52 2003
@@ -30,7 +30,10 @@
from Globals import PersistentMapping
from ActionProviderBase import ActionProviderBase
+from CMFCoreExceptions import CMFNotImplementedError
+from CMFCoreExceptions import CMFUnauthorizedError
from CMFCorePermissions import AccessContentsInformation
+from CMFCorePermissions import ChangeLocalRoles
from CMFCorePermissions import ManagePortal
from CMFCorePermissions import ManageUsers
from CMFCorePermissions import SetOwnPassword
@@ -389,7 +392,7 @@
""" What local roles can I assign? """
member = self.getAuthenticatedMember()
- if 'Manager' in member.getRoles():
+ if _checkPermission(ManageUsers, obj):
return self.getPortalRoles()
else:
member_roles = list( member.getRolesInContext( obj ) )
@@ -401,7 +404,8 @@
def setLocalRoles(self, obj, member_ids, member_role, reindex=1):
""" Add local roles on an item.
"""
- if _checkPermission(ManageUsers, obj):
+ if ( _checkPermission(ChangeLocalRoles, obj)
+ and member_role in self.getCandidateLocalRoles(obj) ):
for member_id in member_ids:
roles = list(obj.get_local_roles_for_userid( userid=member_id ))
@@ -419,7 +423,7 @@
def deleteLocalRoles(self, obj, member_ids, reindex=1, recursive=0):
""" Delete local roles of specified members.
"""
- if _checkPermission(ManageUsers, obj):
+ if _checkPermission(ChangeLocalRoles, obj):
for member_id in member_ids:
if obj.get_local_roles_for_userid(userid=member_id):
obj.manage_delLocalRoles(userids=member_ids)
@@ -470,10 +474,12 @@
member_ids.remove(member_id)
try:
acl_users.userFolderDelUsers(member_ids)
- except 'NotImplemented':
- return ()
+ except (NotImplementedError, 'NotImplemented'):
+ raise CMFNotImplementedError('The underlying User Folder '
+ 'doesn\'t support deleting members.')
else:
- return ()
+ raise CMFUnauthorizedError('You need the \'Manage users\' '
+ 'permission for the underlying User Folder.')
# Delete member data in portal_memberdata.
mdtool = getToolByName(self, 'portal_memberdata', None)
=== CMF/CMFCore/PortalFolder.py 1.48 => 1.48.2.1 ===
--- CMF/CMFCore/PortalFolder.py:1.48 Mon Sep 1 10:44:11 2003
+++ CMF/CMFCore/PortalFolder.py Sat Sep 20 07:49:52 2003
@@ -26,6 +26,7 @@
from CMFCorePermissions import AddPortalContent
from CMFCorePermissions import AddPortalFolders
+from CMFCorePermissions import ChangeLocalRoles
from CMFCorePermissions import ListFolderContents
from CMFCorePermissions import ManagePortal
from CMFCorePermissions import ManageProperties
@@ -62,7 +63,7 @@
, 'name' : 'Local Roles'
, 'action':
'string:${object_url}/folder_localrole_form'
- , 'permissions' : (ManageProperties,)
+ , 'permissions' : (ChangeLocalRoles,)
, 'category' : 'folder'
}
)
More information about the CMF-checkins
mailing list