Commit 3347e8db authored by Jean-Paul Smets's avatar Jean-Paul Smets

Added method getViewPermissionOwner to retrieved Owner user ID whenever Owner...

Added method getViewPermissionOwner to retrieved Owner user ID whenever Owner has View permission. Please suggest better name if you can.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13059 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6658bd65
...@@ -33,6 +33,7 @@ import ExtensionClass ...@@ -33,6 +33,7 @@ import ExtensionClass
from Globals import InitializeClass, DTMLFile, PersistentMapping from Globals import InitializeClass, DTMLFile, PersistentMapping
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.Permission import pname, Permission from AccessControl.Permission import pname, Permission
from AccessControl.PermissionRole import rolesForPermissionOn
from Acquisition import aq_base, aq_inner, aq_acquire, aq_chain from Acquisition import aq_base, aq_inner, aq_acquire, aq_chain
import OFS.History import OFS.History
...@@ -357,11 +358,14 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder): ...@@ -357,11 +358,14 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, prop_holder):
method_id) method_id)
else: else:
# Wrap method into WorkflowMethod is needed # Wrap method into WorkflowMethod is needed
if getattr(klass,method_id,None) is not None: if getattr(klass, method_id, None) is not None:
method = getattr(klass, method_id) method = getattr(klass, method_id)
if callable(method): if callable(method):
if not isinstance(method, WorkflowMethod): if not isinstance(method, WorkflowMethod):
method = WorkflowMethod(method, method_id) method = WorkflowMethod(method, method_id)
# We must set the method on the klass
# because klass has priority in lookup over
# _ac_dynamic
setattr(klass, method_id, method) setattr(klass, method_id, method)
else: else:
method = getattr(prop_holder, method_id) method = getattr(prop_holder, method_id)
...@@ -1419,6 +1423,18 @@ class Base( CopyContainer, ...@@ -1419,6 +1423,18 @@ class Base( CopyContainer,
return tuple(permission_list) return tuple(permission_list)
security.declareProtected( Permissions.AccessContentsInformation, 'getViewPermissionOwner' )
def getViewPermissionOwner(self):
"""
Returns the user ID of the owner if Owner role
has View permission. Returns None else.
"""
path, user_id = self.getOwnerTuple()
if 'Owner' in rolesForPermissionOn(Permissions.View, self):
path, user_id = self.getOwnerTuple()
return user_id
return None
# Private accessors for the implementation of relations based on # Private accessors for the implementation of relations based on
# categories # categories
security.declareProtected( Permissions.ModifyPortalContent, '_setValue' ) security.declareProtected( Permissions.ModifyPortalContent, '_setValue' )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment