Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@patrickmj
Created December 2, 2015 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickmj/001e1045e9178f5f61d8 to your computer and use it in GitHub Desktop.
Save patrickmj/001e1045e9178f5f61d8 to your computer and use it in GitHub Desktop.
Partial hiding of files in Omeka
<?php
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 (is_object($role)) {
if($role->getRoleId() == 'super') {
return false;
}
if($role->getRoleId() == 'admin') {
if(get_class($resource) == 'Item') {
return false;
}
if(get_class($resource) == 'File') {
return true;
}
}
}
return true;
}
}
<?php
class EmbargoPlugin extends Omeka_Plugin_AbstractPlugin
{
public $_hooks = array('define_acl');
public function hookDefineAcl($args)
{
$acl = $args['acl'];
require_once(__DIR__ . '/EmbargoAclAssertion.php');
$acl = $args['acl'];
$acl->addResource('viewEmbargoedItems');
$acl->deny(null,
array('Items', 'Files'),
array('show', 'showNotPublic'),
new EmbargoAclAssertion);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment