Implement ACL (Access-Control-List) for own Magento modules
The following snippets show how to implement ACL (Access-Control-List) for system configuration fields and main menu entries of your own modules. It is also shown, how to check the ACL’s in the PHP code of your Module. Implement ACL – Access control for system configuration If you had configured a system configuration (System→Configuration) like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
<?xml version="1.0" encoding="utf-8"?> <config> <sections> <asksheldon_friendsandfamily translate="label" module="asksheldon_friendsandfamily"> <label>Friends & Family</label> <tab>customer</tab> <frontend_type>text</frontend_type> <sort_order>1</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <groups> <general translate="label" module="asksheldon_friendsandfamily"> <label>General</label> <frontend_type>text</frontend_type> <sort_order>1</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <fields> <enabled translate="label"> <label>Enable</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_yesno</source_model> <sort_order>10</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </enabled> <customer_groups translate="label comment"> <label>Customer groups</label> <frontend_type>multiselect</frontend_type> <source_model>adminhtml/system_config_source_customer_group</source_model> <sort_order>11</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <comment>Groups for Friends & Family discounts.</comment> </customer_groups> </fields> </general> <welcomeemail> <label>Editmail</label> <frontend_type>text</frontend_type> <sort_order>2</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <fields> <identity translate="label"> <label>Welcomemail Sender</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_email_identity</source_model> <sort_order>2</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </identity> <template translate="label"> <label>Welcomemail-Template</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_email_template</source_model> <sort_order>3</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </template> <copy_to translate="label comment"> <label>Send Welcome Copy To</label> <frontend_type>text</frontend_type> <sort_order>5</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> <comment>Comma-separated.</comment> </copy_to> <copy_method translate="label"> <label>Send Welcome Copy Method</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_email_method</source_model> <sort_order>6</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </copy_method> </fields> </welcomeemail> </groups> </asksheldon_friendsandfamily> </sections> </config> |