XF 2.2 user permissions & node permissions

Robert9

Well-known member
Is this the right way for a permission set as (forum, eatNuts)?

Code:
        if (($visitor->hasPermission('forum', 'eatNuts')
                || $visitor->hasNodePermission($forum->node_id, 'eatNuts'))

Then I can set permission to the usergroup and/or to a forum->permission->usergroup->permission?

My example does not work, and I dont know why.
 
Ok. Seems not necessary.

$visitor->hasNodePermission($forum->node_id, 'eatNuts')

is ok for both: set as usergroup permission or forum->usergroup permission
 
Last edited:
But now i have a funny problem.

To add another sort, I need

Code:
namespace ...\XF\Repository;

class Thread extends XFCP_Thread
{
    public function getDefaultThreadListSortOptions($forAdminConfig): array
    {
        $options = parent::getDefaultThreadListSortOptions($forAdminConfig);


If i have the usergroup permsssion it is easy:

$visitor = \XF::visitor();
if ($visitor->hasPermission('general', 'whatever')) {


but if i set forum>permission>usergroup->permission i dont have $forum / node_id to ask for hasNodePermission

but if i dont allow to filter by whatever, then it makes no sense to sort by whatever;

how can i bringt hasNodePermissions to getDefaultThreadListSortOptions, please?
 
Last edited:
To make it short:

How can i get the node_id for

Code:
namespace ...\XF\Repository;
class Thread extends XFCP_Thread
{
    public function getDefaultThreadListSortOptions($forAdminConfig): array
    {
        $options = parent::getDefaultThreadListSortOptions($forAdminConfig);
 
Solution maybe here?

Code:
namespace XF\ForumType;
...
abstract class AbstractHandler
{

    public function getThreadListSortOptions(Forum $forum, bool $forAdminConfig = false): array
    {
        return \XF::repository('XF:Thread')->getDefaultThreadListSortOptions($forAdminConfig);
    }
 
Top Bottom