i'm testing right now and cant find any difference between $modx->hasPermission and $modx->user->hasPermission. it's about $modx instance again. The very point i'm using permissions is i have few policy templates and bound to groups policies.
when i create a new group, that will require some permissions from those policies - it's easy to add new policy, bind to group and tick some checkboxes, rather than looking through pages of code and adding groups to isMember(). for now i created a snippet that returns true\false based on group and when new group added - i modify snippet, not the code. still i feel like im using a hammer in a lab.... all solutions i'm using for now are quite simple, but this one looks not that accurate (like those goto)
i'm not very good at explanaitions, so, for example:
policy template
product.create.city.own
product.create.city.any
product.create.shop.own
product.create.shop.any
product.edit.city.own
product.edit.city.any
...
then policies
for one group i create policy like
product.create.city.own = 1
product.create.city.any
product.create.shop.own = 1
product.create.shop.any
product.edit.city.own
product.edit.city.any
for another
product.create.city.own
product.create.city.any = 1
product.create.shop.own
product.create.shop.any = 1
product.edit.city.own
product.edit.city.any
and some like
product.create.city.own 1
product.create.city.any
product.create.shop.own
product.create.shop.any = 1
product.edit.city.own
product.edit.city.any
that fits my need - very easy to check one access when creating product if can change city or shop. so if i need another group - i create policy, bind and dont need to replace any isMemeber - i can just check if this user has permission. and while having about 20 groups for now - it's not really easy to remember the scheme, cause there are lots of permissions to check, view,edit,create,modify for 9 basic fields that can combine in different way.
And again - it works perfectly, but while allowing user to be in multiple group and combine permissions - i'm curious why there is no easy way to check permissions for a user (not current), i have to do extra actions as grabbing groups, then grabbing policies, then grabbing values from them.
May be im missing some basic logic of hasPermission? Im sorry if beeing too disturbing. i adore modx, thats why a bit confused here.