I'm having a problem with the Weight not working. I have a user that has 2 roles ("normal" and "premium").

Role Limit Content Type Per Weight
premium 2 audio forever -50
normal 1 audio forever -49

According to the documentation, the user with both the premium/normal roles should be limited to 2 audio posts forever, but they are being limited to 1. I tried reversing the weights, and they were still limited to 1. Any ideas?

Comments

tj2653’s picture

Here's the table with more-readable formatting:

Role       Limit      Content Type             Per         Weight
premium     2             audio              forever        -50
normal      1             audio              forever        -49
lazyboy’s picture

Hi tj2653

Does the user have both roles premium and normal assigned to him ? If so, then it is correct behavior, as the most restrictive quota will be applied in that case (role "normal").

Regards
lazyboy

lazyboy’s picture

I'm just thinking here... Maybe it should not work like that. Perhaps I should modify it so that the first role match is used (sorted by weight), and if there are more than 1 role (of the same name) per weight, then only the most restrictive case is used. If we assume the above, then what you described above should be a "bug". Let me think about it, and I might probably patch it this weekend.

Regards
lazyboy

tj2653’s picture

Hi lazyboy,

To answer your question, yes, the user has both roles assigned to him (normal and premium). I guess I misunderstood your description on the module page. I read it to be like you describe in #3. The reason why it might be a good idea to go with #3 is because some people have roles added to grant additional/more access (and not limit them to what their original role was).

Thanks,
tj2653

lazyboy’s picture

Assigned: Unassigned » lazyboy

tj2653

I've changed the way that the module evaluates quotas based on the weight. The first match between the content type for a quota that matches a role given to the user will now be used. This has some implications.

Consider your example:

Role Limit Content Type Per Weight
premium 2 audio forever -50
normal 1 audio forever -49

If the user has both roles (premium and normal), that user will *always* be able to create to posts of type audio. If the user has only role premium, the same applies. If the user has only role normal, then on 1 content type audio can be created. All well and good.

But you need to keep the following in mind:
If you now add another quota of the following:

Role Limit Content Type Per Weight
RoleX 0 audio forever -48

(note the weight)
If the user has both premium (and or normal) and RoleX, then the quota for RoleX will never be applied because the quota for premium/normal has already satisfied the evaluation algorithm. However, if you change it to:

Role Limit Content Type Per Weight
RoleX 0 all content forever -48

(again, notice the weight and content type)
Now if you assign the same user roles premium/normal, and also RoleX, then the audio quota will first be evaluated for content type audio, but for any other content type the user cannot create any content. This means you can have a special case for audio, and then a "catchall" quota for any other possible content types.

If you have the following:

Role Limit Content Type Per Weight
RoleX 0 all content forever -50
premium 2 audio forever -49
normal 1 audio forever -48
(notice the weights)
If the user has premium/normal and RoleX, then that user will not be able to create any content at all (including audio), as the first quota overrides anything below it (because it is weighted lowest).

I hope this all makes sense to you. Play around a bit and let me know how it works for you. I won't close this ticket for now, as I would like to get some feedback on the new algorithm.

Regards
lazyboy

tj2653’s picture

Hi lazyboy,

Good point...I had not thought about that. Fortunately, it doesn't apply to me, as I control any "0" permissions through not giving them that permission in "Access control". Assuming that other people do the same, I don't think it will be a problem.

I will test out the new build today, and will let you know if there are any problems or I can think of any other fringe cases where there might be a problem. Thank you very much!

tj2653

lazyboy’s picture

Status: Active » Closed (fixed)

No new comment regarding the new weight system for 10 days. I would assume it is all working as expected now. If a problem is discovered in the interim while I am away overseas, please create a new issue ticket.

Regards
lazyboy

tj2653’s picture

Hi lazyboy,

I will test the new build tonight. I didn't really get a chance to test the weighting yet, but I'll let you know the results soon.

Thanks

tj2653’s picture

So far, it seems to be working as expected after some light testing. Thanks.