XF 2.2 Get Node Permissions

Mikey

Well-known member
I'm updating a previous plugin from XF1.x to XF2.x for @xenfans

Previously I had this to get a list of Private Nodes - but can't see how I convert this over to XF 2.x

Code:
// build our query
$_query = $this->getPrivateNodeQuery();
// get db instance
$db = XenForo_Application::getDb();
// get results
$privateNodes = $db->fetchAll($_query);

// Get forum
$forum = $this->_getForumData();

foreach ($privateNodes as $node) {
    // node id is in private node id list?
    if ($node['node_id'] === $forum['node_id']) {
        // return false
        $return = false;
    }
}

return $return;

I have the \XF\Entity\Forum and \XF\Entity\Node available to me, but I can't see how to see that a Node/Forum is private from these areas. I see PermissionCacheContent is a thing but I have no idea how to quickly check (as above) if a Node is set as private or not.
 
I'm updating a previous plugin from XF1.x to XF2.x for @xenfans

Previously I had this to get a list of Private Nodes - but can't see how I convert this over to XF 2.x

Code:
// build our query
$_query = $this->getPrivateNodeQuery();
// get db instance
$db = XenForo_Application::getDb();
// get results
$privateNodes = $db->fetchAll($_query);

// Get forum
$forum = $this->_getForumData();

foreach ($privateNodes as $node) {
    // node id is in private node id list?
    if ($node['node_id'] === $forum['node_id']) {
        // return false
        $return = false;
    }
}

return $return;

I have the \XF\Entity\Forum and \XF\Entity\Node available to me, but I can't see how to see that a Node/Forum is private from these areas. I see PermissionCacheContent is a thing but I have no idea how to quickly check (as above) if a Node is set as private or not. The action of that is:

Friendly bump. We are still looking for a bit of info to get us started.

I haven't tried myself, but I'd review the following functions/files:

XF\Admin\Controller\Node
public function actionPermissions(ParameterBag $params)


XF\ControllerPlugin\NodePermission


XF\ControllerPlugin\AbstractPermission
public function actionList(ParameterBag $params)

Those all interact and return an $isPrivate variable which is used within the node permission in the admin CP. You should be able to mirror that to accomplish what you want.
 
I don't really remember the XF1 permission system, but in XF2 here's how I did it.

How about going through XF:Node repository, and do something like this

PHP:
$nodeRepo = $this->repository('XF:Node');

$forums = $nodeRepo->getNodeOptionsData(false, 'Forum');

then try adding a filter to $forum? it has filterViewable method in Node repo class.
 
Back
Top Bottom