1. 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

Discussion in 'XenForo Development Discussions' started by ajnos, Mar 14, 2011.

  1. ajnos

    ajnos Member

    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?
     
  2. Shadab

    Shadab Well-Known Member

    Use the permission model: XenForo_Model_Permission.

    Setting node permissions for a usergroup:
    PHP:
    $permissionModel->updateContentPermissionsForUserCollection(
        
    $permissions'node'$nodeId$userGroupId0
    );
    Setting node permissions for a single user:
    PHP:
    $permissionModel->updateContentPermissionsForUserCollection(
        
    $permissions'node'$nodeId0$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()
     
    ajnos likes this.

Share This Page