Commit ac118109 authored by Jean-Paul Smets's avatar Jean-Paul Smets

added action introspection

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25698 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d8eec5b4
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass, DTMLFile from Globals import InitializeClass, DTMLFile
from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Tool.BaseTool import BaseTool from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from AccessControl.SecurityManagement import setSecurityManager from AccessControl.SecurityManagement import setSecurityManager
...@@ -35,44 +36,44 @@ from Products.ERP5 import _dtmldir ...@@ -35,44 +36,44 @@ from Products.ERP5 import _dtmldir
from Products.ERP5Type.Utils import _setSuperSecurityManager from Products.ERP5Type.Utils import _setSuperSecurityManager
from Products.ERP5Type.Cache import CachingMethod from Products.ERP5Type.Cache import CachingMethod
_MARKER = []
class IntrospectionTool(BaseTool): class IntrospectionTool(BaseTool):
""" """
This tool provides both local and remote introspection. This tool provides both local and remote introspection.
""" """
id = 'portal_introspections' id = 'portal_introspections'
title = 'Introspection Tool' title = 'Introspection Tool'
meta_type = 'ERP5 Introspection Tool' meta_type = 'ERP5 Introspection Tool'
portal_type = 'Introspection Tool' portal_type = 'Introspection Tool'
allowed_content_types = ('Anonymized Introspection Report', 'User Introspection Report',) allowed_content_types = ('Anonymized Introspection Report', 'User Introspection Report',) # XXX User Portal Type please
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareProtected(Permissions.ManagePortal, 'manage_overview') security.declareProtected(Permissions.ManagePortal, 'manage_overview')
manage_overview = DTMLFile('explainIntrospectionTool', _dtmldir ) manage_overview = DTMLFile('explainIntrospectionTool', _dtmldir )
security.declareProtected('getERP5MenuItemList', Permissions.View) security.declareProtected('getFilteredActionDict', Permissions.AccessContentsInformation)
def getERP5MenuItemList(self, kw): def getFilteredActionDict(self, user_name=_MARKER):
""" """
Returns menu items for a given user Returns menu items for a given user
""" """
portal = self.getPortalObject() portal = self.getPortalObject()
erp5_user_name = kw.pop('erp5_user_name', None) is_portal_manager = getToolByName(portal,
is_portal_manager = portal.portal_membership.checkPermission(Permissions.ManagePortal, \ 'portal_membership').checkPermission(Permissions.ManagePortal, self)
portal) downgrade_authenticated_user = user_name is not _MARKER and is_portal_manager
downgrade_authenticated_user = erp5_user_name is not None and is_portal_manager
if downgrade_authenticated_user: if downgrade_authenticated_user:
# downgrade to desired user # downgrade to desired user
original_security_manager = _setSuperSecurityManager(self, erp5_user_name) original_security_manager = _setSuperSecurityManager(self, erp5_user_name)
# call the method implementing it # call the method implementing it
erp5_menu_item_list = self._getTypeBasedMethod('getERP5MenuItemList', erp5_menu_dict = getToolByName(portal, 'portal_actions').listFilteredActionsFor(portal)
fallback_script_id='ERP5Site_getERP5MenuItemList')(**kw)
if downgrade_authenticated_user: if downgrade_authenticated_user:
# restore original Security Manager # restore original Security Manager
setSecurityManager(original_security_manager) setSecurityManager(original_security_manager)
return erp5_menu_item_list return erp5_menu_dict
InitializeClass(IntrospectionTool) InitializeClass(IntrospectionTool)
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