From ea51f1cc498bca0a9e47c646fb277269ce077437 Mon Sep 17 00:00:00 2001 From: Ivan Tyagov <ivan@nexedi.com> Date: Mon, 23 Feb 2009 15:01:58 +0000 Subject: [PATCH] Implement menu handling. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25664 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Wizard/Tool/IntrospectionTool.py | 33 +++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/product/ERP5Wizard/Tool/IntrospectionTool.py b/product/ERP5Wizard/Tool/IntrospectionTool.py index b3aa9365c8..6ecda1ce3b 100644 --- a/product/ERP5Wizard/Tool/IntrospectionTool.py +++ b/product/ERP5Wizard/Tool/IntrospectionTool.py @@ -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) -- 2.30.9