Created
December 2, 2015 22:58
-
-
Save patrickmj/001e1045e9178f5f61d8 to your computer and use it in GitHub Desktop.
Partial hiding of files in Omeka
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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