It doesn’t work by default. You have to “massage” the code a bit. I’ll try and cut and paste it below. But if you PM me I’ll send you my own PDF notes.
How to add Security Groups to Custom Modules
When you add a custom module, you can mass assign from list view, and it does functionally work in that users will only see what they are assigned. However, in the detail view, the subpanel is not populated. Even if you do populate it, it has no effect on the actual security group??? Problem!
Solution is to add a relationship between the module and security groups and also to modify the relationship meta.
-
Go to Admin→Studio and open your custom module
-
Click Relationships then Add Relationship
-
Configure the options so that it mimics the image below
-
Click Save
-
Find the generated relationship file in the custom/metadata directory and replace with the following code
(file name formatted YOURCUSTOMMODULE_securitygroupsMetaData.php):
<?php
$dictionary["YOURCUSTOMMODULE_securitygroups"] = array (
'true_relationship_type' => 'many-to-many',
'relationships' =>
array (
' YOURCUSTOMMODULE _securitygroups' =>
array (
'lhs_module' => 'SecurityGroups',
'lhs_table' => 'securitygroups',
'lhs_key' => 'id',
'rhs_module' => 'YOURMODULENAME',
'rhs_table' => 'YOURCUSTOMMODULE',
'rhs_key' => 'id',
'join_table' => 'securitygroups_records',
'join_key_lhs' => 'securitygroup_id',
'join_key_rhs' => 'record_id',
'relationship_type' => 'many-to-many',
'relationship_role_column' => 'module',
'relationship_role_column_value' => ' YOURMODULENAME',
),
),
);
?>
YOU MUST CLEAR THE ENTIRE FILE AND REPLACE WITH THE ABOVE OR IT WILL NOT WORK!!!
-
Replace YOURCUSTOMMODULE with the first part of the metadata file name.
-
Replace YOURMODULENAME with the name of your module. (lhs_module in the original file)
-
Run Admin→Repair→Repair Relationships
-
Make sure that the appropriate role(s) have your custom module Enabled
You should now see the Mass Assign panel on the list view as well as the Security Groups subpanel on the detail view.