XF 2.0 hasNodePermission & hasPermission

Fethi.dz

Well-known member
Hi,

This is my 1st add-on that I try to code on XF2, I face some difficulties to set the proper way to get the permission for groups.

I extended the class Thread as follow:

PHP:
<?php
namespace FL\ForumPermissions\XF\Entity;

class Thread extends XFCP_Thread
{

    public function canReply(&$error = null)
    {

    $visitor = \XF::visitor();
    $nodeId = $this->node_id;

        if (!$visitor->hasNodePermission($nodeId, 'postRepliesOthers'))
        {
            return false;
        }

    return true;
    }

}

I have add the Class extensions in Admin CP, Base class name: XF\Entity\Thread, Extension class name: FL\ForumPermissions\XF\Entity\Thread


Now the problem that I face is, when I go to that nodes permission and set the new option to No for example Admin group I expect the correct output of the extended Thread class but if I set the option No in the group permissions noting change even if the node permission for that group is Inherit. The strange thing is when I set the option to Never in the group permissions the node permission for that group when is set to Inherit it get the option from the group permission as Never.


My questions is: how to make the Inherit option of the node permissions follow the option set in the group permissions & vice versa if I change the node permission for that group it will overide the group permission
 
Last edited:
I think you're confused?

If the general usergroup permission is set to No, and the node permission to Inherit then the expected output permission will be No.

Never permissions can't be overridden anywhere - hence the term Never.

From your description, it sounds like it's working correctly?

Liam
 
Hi Liam,

Thanks for your reply :)

If the general usergroup permission is set to No, and the node permission to Inherit then the expected output permission will be No.

Yes the expected output should be No when it’s inherent in node permission but its not. Nothing change when it’s set to no in group permission.

I don’t know where is the mistake!!!
 
I don't know what happened yesterday night to the add-on. I rebuild it today and it works as it should. Maybe because it was totally late o_O

Thanks again @Liam W for taking time to reply on my confusion :)
 
Top Bottom