Prevent an item to be displayed


How can I prevent an item to be displayed (expect from makeing it not public) and redirect the page ?

I'm making an Embargo plugin. I can hide items in the /items/ via hookItemsBrowseSql() hook, but if you browse directly to the url (like /items/show/5), I would like to make a redirection to the home page or a 403 error.

Thank you.

Could you tell a little more about why the public/private distinction doesn't work for your needs? That seems like the most straightforward option so far.

It's for an embargo plugin. Items have an embargo date before which they can't be seen either they are public or private.

Before this embargo date, items can't be seen (private or public). After this date, two cases :
- if they are public, then they can be seen,
- if they are private, remain private and can not been seen.

The goal of this plugin is that you don't have to change visibility of item manually.

Thanks !

I'm definitely interested in this plugin and for those who work with theses & dissertations or other scholarly material, I could see it being very valuable.

Hi georgiawebgurl,

It is exactly the case !

@ahemery - I worked with T&Ds for years. We developed an inhouse solution (we were not using Omeka, but none of the other software at the time really could do the embargo and release process, either). Do take a look at the bookreader if you are working with those kinds of materials. I think it is a neat way to get a "book experience." I am using it for a scrapbook/digital archives project. Still some quirks to work out before I'm ready to share. Robin

Since you've got the browse sql hook working, the following approach might give you what you need. Basically, it creates a more complex ACL assertion that would check against your embargoed items somehow. First, the AclAssertion would look something like this:


class EmbargoAclAssertion 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 ($role->getRoleId() == 'super') {
            return false;

//your code to decide about access. This check is against denial, to return true to deny, false to allow
        //congratulations! you can see the item!
        return false;

$role is the User object. Here, it maintains access to super users so at least someone can get to the item.

Then, in the plugin class, use hookDefineAcl

public $_hooks = array('define_acl');

    public function hookDefineAcl($args)
        $acl = $args['acl'];
        require_once(__DIR__ . '/EmbargoAclAssertion.php'); // assumes above file is at root of plugin
        $acl = $args['acl'];
                array('show', 'showNotPublic'),
                new EmbargoAclAssertion);

I _think_ that will put all the pieces that you need together.

Update. forgot to mention that $resource is the Item object itself, so that should give you what you need to do your checks.

I'll have a look, thank you !

EDIT: Oops, answer found (not looking at the right place)...


in EmbargoAclAssertion::asset(), $resource is as follow :
protected '_resourceId' => string 'Items' (length=5)

How can I get the item ID ?