1)); $sec = New acl2(1,'##DEFAULT##'); //echo 'phpgw:
'; print_r($GLOBALS['phpgw']); echo '
'; $sec->get_memberships(); //echo 'memberships_sql: '.$sec->memberships_sql.'
'; //echo 'memberships:
'; print_r($sec->memberships); echo '
'; function ttt($location, $rights) { GLOBAL $sec; if ($sec->check($location, $rights)) { echo $rights.' is valid
'; } else { echo $rights.' is invalid
'; } } echo 'This test is going to delete all your phpgw_acl2 records to ensure that the tests run as expected.
'; $GLOBALS['phpgw']->db->query('DELETE FROM phpgw_acl2',__LINE__,__FILE__); echo 'Action: DELETE FROM phpgw_acl2

'; echo 'Running checks on .one.two.three after changing directly granted rights as well as ones it will inherit from
'; echo '
1: check rights for .one.two which will get inherited by .one.two.three
'; ttt('.one.two', 1); ttt('.one.two', 2); ttt('.one.two', 4); ttt('.one.two', 8); echo 'You can see that no rights are set, so none will be inherited
'; echo '
2: checking .one.two.three
'; ttt('.one.two.three', 1); ttt('.one.two.three', 2); ttt('.one.two.three', 4); ttt('.one.two.three', 8); echo 'You can see that no rights are set directly as well
'; echo '
3: add rights 4 to .one.two.three
'; echo 'Action: $acl2->add(\'.one.two.three\',4,0);
'; $sec->add('.one.two.three',4,0); ttt('.one.two.three', 1); ttt('.one.two.three', 2); ttt('.one.two.three', 4); ttt('.one.two.three', 8); echo '
4: add rights 8 to .one.two.three
'; echo 'Action: $acl2->add(\'.one.two.three\',8,0);
'; $sec->add('.one.two.three',8,0); ttt('.one.two.three', 1); ttt('.one.two.three', 2); ttt('.one.two.three', 4); ttt('.one.two.three', 8); echo '
5: remove rights 4 from .one.two.three
'; echo 'Action: $acl2->remove(\'.one.two.three\',4,0);
'; $sec->remove('.one.two.three',4,0); ttt('.one.two.three', 1); ttt('.one.two.three', 2); ttt('.one.two.three', 4); ttt('.one.two.three', 8); echo '
5: set rights to 2 on .one.two.three
'; echo 'Action: $acl2->set(\'.one.two.three\', 2,0);
'; $sec->set('.one.two.three', 2,0); ttt('.one.two.three', 1); ttt('.one.two.three', 2); ttt('.one.two.three', 4); ttt('.one.two.three', 8); echo '
Now to see inheritance in action...
'; echo '6: add rights 8 to .one.two
'; echo 'Action: $acl2->add(\'.one.two\',8,0);
'; $sec->add('.one.two',8,0); ttt('.one.two.three', 1); ttt('.one.two.three', 2); ttt('.one.two.three', 4); ttt('.one.two.three', 8); echo 'You can see here that it has inherited rights 8 from .one.two
'; echo '
7: add rights 4 to .one.two
'; echo 'Action: $acl2->add(\'.one.two\',4,0);
'; $sec->add('.one.two',4,0); ttt('.one.two.three', 1); ttt('.one.two.three', 2); ttt('.one.two.three', 4); ttt('.one.two.three', 8); echo 'You can see here that it has also inherited rights 4 from .one.two
'; echo '
Now to see inherited rights masks in action...
'; echo '8: add rights mask for 8 to .one.two
'; echo 'Action: $acl2->add(\'.one.two\',8,1);
'; $sec->add('.one.two',8,1); ttt('.one.two.three', 1); ttt('.one.two.three', 2); ttt('.one.two.three', 4); ttt('.one.two.three', 8); echo 'You can see here that it no longer inherited rights 8 from .one.two
'; echo '
It will help to see the rights for .one.two at this point to clearly see the rights mask doing its work
'; echo '9: display rights for .one.two
'; ttt('.one.two', 1); ttt('.one.two', 2); ttt('.one.two', 4); ttt('.one.two', 8); echo 'You can see here that it has rights for 4 and 8, and yet above you saw that .one.two.three did not inherited rights 4 from it
'; //echo 'rights_cache:
'; print_r($sec->rights_cache); echo '
'; ?>