• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Create Categories, Forums and set Permissions

#1
We want to create automatic a new category and create 3 new forums inside.
This should be no problem with the datawriters, but how can we set automatic the permission?

1. create the category with XenForo_DataWriter_Category
2. crate the forums with XenForo_DataWriter_Forum

but what then?
 

Shadab

Well-known member
#2
Use the permission model: XenForo_Model_Permission.

Setting node permissions for a usergroup:
PHP:
$permissionModel->updateContentPermissionsForUserCollection(
	$permissions, 'node', $nodeId, $userGroupId, 0
);
Setting node permissions for a single user:
PHP:
$permissionModel->updateContentPermissionsForUserCollection(
	$permissions, 'node', $nodeId, 0, $userId
);
The permissions array should be in this format:
Code:
[permission_group_id_1]

	[permission_id_1] => [value]
	[permission_id_2] => [value]

[permission_group_id_2]

	[permission_id_3] => [value]
	[permission_id_4] => [value]
where value is one of these strings:
  • 'unset'
  • 'content_allow'
  • 'reset'
  • 'deny'
  • '0' (integer permission: inherit)
  • '-1' (integer permission: unlimited)
  • Any other positive integer value, if it's an integer permission

Reference:
/library/XenForo/ControllerAdmin/Permission/Node.php
  • XenForo_ControllerAdmin_Permission_Node::actionUserGroupSave()
  • XenForo_ControllerAdmin_Permission_Node::actionUserSave()