Commit ea51f1cc authored by Ivan Tyagov's avatar Ivan Tyagov

Implement menu handling.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25664 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ae97fa4a
......@@ -30,17 +30,18 @@ from AccessControl import ClassSecurityInfo
from Globals import InitializeClass, DTMLFile
from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ERP5Type import Permissions
from AccessControl.SecurityManagement import setSecurityManager
from Products.ERP5Wizard import _dtmldir
from Products.ERP5Wizard.LogMixIn import LogMixIn
from AccessControl.SecurityManagement import newSecurityManager, \
getSecurityManager, setSecurityManager
import zLOG
from Products.ERP5Wizard.Tool.WizardTool import _setSuperSecurityManager
from Products.ERP5Type.Cache import CachingMethod
class IntrospectionTool(BaseTool, LogMixIn):
"""
This tool provides both local and remote introspection.
This tool provides both local and remote introspection.
"""
id = 'portal_introspections'
title = 'Introspection Tool'
meta_type = 'ERP5 Introspection Tool'
......@@ -52,4 +53,28 @@ class IntrospectionTool(BaseTool, LogMixIn):
security.declareProtected(Permissions.ManagePortal, 'manage_overview')
manage_overview = DTMLFile('explainIntrospectionTool', _dtmldir )
security.declareProtected('getERP5MenuItemList', Permissions.View)
def getERP5MenuItemList(self, kw):
"""
Returns menu items for a given user
"""
portal = self.getPortalObject()
user_name = kw.pop('user_name', None)
is_portal_manager = portal.portal_membership.checkPermission(Permissions.ManagePortal, \
portal)
downgrade_authenticated_user = user_name is not None and is_portal_manager
if downgrade_authenticated_user:
# downgrade to desired user
original_security_manager = _setSuperSecurityManager(self, user_name)
# call the method implementing it
erp5_menu_item_list = self._getTypeBasedMethod('getERP5MenuItemList',
fallback_script_id='ERP5Site_getERP5MenuItemList')()
if downgrade_authenticated_user:
# restore original Security Manager
setSecurityManager(original_security_manager)
return erp5_menu_item_list
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