The Xmf\Module\Helper\Permission class is a module aware helper for simplified access to system group permissions in a module.
System group permissions use a string $gperm_name as a permission name, and an integer $gperm_itemid to identify a item that the permission applies to. The permissions are further identified by the mid of the module the permission relates to, and the groupid the permission applies to.
This helper streamlines using permissions by automatically using module and group information that can be inferred.
Check if the user has the permission named $gperm_name for the item identified by $gperm_itemid.
Normally an admin user always has permission. If $trueifadmin, an optional boolean, is specified as false, the admin user's permissions will be checked like any normal user.
Returns true if the user has the permission, otherwise false.
getItemIds($gperm_name, $gperm_groupid)
Returns an array of items for which the group(s) specified in $gperm_groupid have the permission named in $gperm_name.
Check if the user has the permission named $gperm_name for the item identified by $gperm_itemid. If not, the session will be redirected to the module relative URL specified in $url with the message in $message.
getGroupsForItem($gperm_name, $gperm_itemid)
Get array of groups granted permissions for the permission named $gperm_name for the item identified by $gperm_itemid.
Normally an admin user always has permission. If $trueifadmin, an optional boolean, is specified as false, the admin user's permissions will be checked like any normal user.
Creates a XoopsFormSelectGroup form element to select groups with permission to a specific $gperm_name and $gperm_itemid. The form element will be preset with existing permissions.
The caption for the element is specified in $caption.
If the name $name is empty or omitted, a default name created by defaultFieldName() will be used.
Set $include_anon (default false) to true to include the anonymous group. The size in $size (default 5) sets number of vertical rows shown in the element. If $multiple (default true) is true, multiple groups can be assigned to the permission.
defaultFieldName($gperm_name, $gperm_itemid)
Generate a default name to be used for the XoopsFormSelectGroup based on $gperm_name and $gperm_itemid.
If you do not specify the name in getGroupSelectFormForItem() this allows you to determine the element name to retrieve the user input.