josegonzalez/sanction — pull request #16 by mreishus (2012-01-18 16:51:19+00:00)
Title: Fix bug when passing multiple rules under one field name

When using a rule like:

Permit::access(
array('controller' => 'foobar', 'action' => array('edit', 'delete')),
array('auth' => array('Group.name' => array('group1', 'group2'))),
array('redirect' => array('admin' => false, 'controller' => 'foobar', 'action' => 'deny'))
);

The plugin would restrict access like so:

not group1 and not group2 = Deny
group1 and not group2 = Allow
not group1 and group2 = Allow
group1 and group2 = Deny

The code in _execute() would set $count to count( array('Group.name' => array('group1', 'group2')) ), which is 1, but would later decrement $count for each group I was a member of. If I was in both groups, $count would end up as -1 and I would be denied access since it's not 0.

Change $count calculation to use set::flatten().

This provides "AND" functionality, but a way to have "OR" functionality would also be nice!