Hello! I’ve been working on a plugin that uses the Guest User role to allow some non-dashboard users to see a private item’s show page if they are set to be allowed for that specific item.
I’ve been following the advice of some of the other posts on here, but I’m stuck now making the check against my permissions table because I can’t figure out how to access the Record’s id below:
class PermissionsAccessAclAssertion implements Zend_Acl_Assert_Interface {
public function assert(
Zend_Acl $acl,
Zend_Acl_Role_Interface $role = null,
Zend_Acl_Resource_Interface $resource = null,
$privilege = null)
{
if ($privilege == 'showNotPublic') {
if (($role instanceof User) && $resource->getResourceId() == 'Items') {
$db = get_db();
$accessTable = $db->getTable('UserPermissionsPermsissions');
$accessRecords = $accessTable->findBy(array('user_id' => $role->id,
'item_id' => $resource->id, )); // <----this right here is my problem, I can't figure out how to get the Item ID, this doesn't work because $resource->id returns "Items")
...
...
...
Here is where I call the code above:
public function hookDefineAcl($args) {
$acl = $args['acl'];
$acl->allow('guest',
'Items',
array('view','showNotPublic'),
new PermissionsAccessAclAssertion());
}
I have a feeling I’m just using the Resource interface wrong, can anyone point me in the right direction?