Created
November 24, 2009 14:31
-
-
Save cbeer/241901 to your computer and use it in GitHub Desktop.
This file contains 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
require 'dispatcher' | |
require 'odrl/lib/odrl' | |
module Rights_DocumentPatch | |
def self.included(base) | |
base.extend(ClassMethods) | |
base.send(:include, InstanceMethods) | |
end | |
module ClassMethods | |
end | |
module InstanceMethods | |
end | |
end | |
module Rights_UserPatch | |
def self.included(base) | |
base.extend(ClassMethods) | |
base.send(:include, InstanceMethods) | |
end | |
module ClassMethods | |
end | |
module InstanceMethods | |
def uid | |
end | |
def name | |
end | |
def groups | |
tags | |
end | |
end | |
end | |
Dispatcher.to_prepare do | |
SolrDocument.send(:include, Rights_DocumentPatch) | |
User.send(:include, Rights_UserPatch) | |
User.acts_as_taggable | |
end |
This file contains 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
require 'open-uri' | |
module FedoraHelper | |
[...] | |
def fedora_check_rights(pid, permission) | |
d = ODRL::Rights::Document.new | |
d.doc = open('http://openvaultresearch.wgbh.org:8080/fedora/get/' + pid + '/Rights') | |
d.eval permission, {}, current_user, {} | |
end | |
def render_fedora_partial(pid, cmodel) | |
begin | |
fedora_check_rights pid, 'play' | |
render :partial=>"fedora/_show_partials/#{cmodel}", :locals=>{:fedora_object=>pid} | |
rescue ODRL::Rights::InsufficientPrivileges | |
render :partial => "fedora/_show_partials/odrl_rights_insufficientprivileges", :locals=>{:fedora_object=>pid} | |
end | |
end | |
[...] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment