基于Magento中的用户角色禁用后端模块
是否可以根据活动用户的角色禁用Magento中的自定义后端模块?如果我创建一个登录监听器,并在该监听器中获取用户角色,是否有任何事件可以分派以禁用特定模块 是的。您的自定义模块需要有acl资源定义,这样您就可以根据用户角色启用和禁用该模块或其某些操作。这实际上相对简单,可以通过在modules etc文件夹中创建一个名为adminhtml.xml的文件来实现。此文件将包含管理员中模块菜单系统的定义,还将包含访问控制列表的定义 创建包含模块操作定义的文件后,请清除缓存,然后在编辑用户角色时应看到配置选项基于Magento中的用户角色禁用后端模块,magento,magento-1.7,Magento,Magento 1.7,是否可以根据活动用户的角色禁用Magento中的自定义后端模块?如果我创建一个登录监听器,并在该监听器中获取用户角色,是否有任何事件可以分派以禁用特定模块 是的。您的自定义模块需要有acl资源定义,这样您就可以根据用户角色启用和禁用该模块或其某些操作。这实际上相对简单,可以通过在modules etc文件夹中创建一个名为adminhtml.xml的文件来实现。此文件将包含管理员中模块菜单系统的定义,还将包含访问控制列表的定义 创建包含模块操作定义的文件后,请清除缓存,然后在编辑用户角色时应看到配
<config>
<menu>
<your_module_name module="your_module_name">
<title>Your Module Name</title>
<sort_order>100</sort_order>
<children>
<new module="your_module_name" translate="title">
<title>Add New Article</title>
<sort_order>0</sort_order>
<action>your_module_name_admin/manage/new</action>
</new>
<list module="your_module_name" translate="title">
<title>Articles</title>
<sort_order>10</sort_order>
<action>your_module_name_admin/manage/index</action>
</list>
<settings translate="title" module="your_module_name">
<title>Settings</title>
<action>adminhtml/system_config/edit/section/your_module_name</action>
<sort_order>40</sort_order>
</settings>
</children>
</your_module_name>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<your_module_name>
<title>Your Module Name</title>
<sort_order>70</sort_order>
<children>
<new>
<title>Create New Article</title>
<sort_order>0</sort_order>
</new>
<list>
<title>View & Edit Articles</title>
<sort_order>1</sort_order>
</list>
</children>
</your_module_name>
<system>
<children>
<config>
<children>
<your_module_name>
<title>Config Section Under System --> Configuration If Your Module Has One</title>
</your_module_name>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
您的模块名
100
添加新文章
0
您的\模块\名称\管理员/管理/新建
文章
10
您的\u模块\u名称\u管理员/管理/索引
设置
adminhtml/system\u config/edit/section/your\u module\u name
40
允许一切
您的模块名
70
创建新文章
0
检视及;编辑文章
1.
系统-->配置下的配置部分(如果模块有)
您根本不需要编辑代码。只需根据需要创建模块,就可以通过创建用户角色来控制管理员的模块输出。只需转到Admin->System->Permission->Roles->Create New Role->Role Resources->Select Resource Access to Custom
(在这里您可以看到系统中所有页面都启用了所有模块),然后取消选中该用户角色的模块。保存它。完成了。仅此而已。模块只能全局禁用。它不能是基于条件的。这基本上是根据用户的角色启用/禁用菜单。我想实现的功能是,如果登录用户是管理员,则禁用覆盖某些核心块的某些模块,如果登录用户是自定义角色用户,则启用这些模块。您的问题应该是这样的!您是否尝试过资源ACL,因为您必须以某种方式管理角色。在我看来,如果它不能完全满足您的要求,您可以使用ACL进行管理,然后在块覆盖方法中添加自定义检查。如果该类型的管理员用户类型不允许这样做,那么您只需返回原始的核心方法,否则您就可以进行重写。e、 g.在您的块中,检查(Mage::getSingleton('admin/session')->isAllowed('admin/system/config/my_acl')){YourCode}或者{return parent::method()}您需要来自模块etc文件夹中的adminhtml.xml文件的acl资源定义,以便在设置自定义角色资源时显示您的模块及其操作。他无论如何都不想那样做,但是