Class: Hydra::AdminPolicy
- Inherits:
-
ActiveFedora::Base
- Object
- ActiveFedora::Base
- Hydra::AdminPolicy
- Includes:
- Hydra::AccessControls::Permissions
- Defined in:
- lib/hydra/admin_policy.rb
Class Method Summary collapse
- .editable_by_user(user) ⇒ Object
- .readable_by_user(user) ⇒ Object
- .where_user_has_permissions(user, permissions = [:edit]) ⇒ Object
Instance Method Summary collapse
-
#default_permissions ⇒ Object
Returns a list with all the permissions on the object.
-
#default_permissions=(params) ⇒ Object
Updates those permissions that are provided to it.
Methods included from Hydra::AccessControls::Permissions
#discover_groups, #discover_groups=, #discover_groups_string, #discover_groups_string=, #discover_users, #discover_users=, #discover_users_string, #discover_users_string=, #edit_groups, #edit_groups=, #edit_groups_string, #edit_groups_string=, #edit_users, #edit_users=, #permissions, #permissions=, #permissions_attributes=, #read_groups, #read_groups=, #read_groups_string, #read_groups_string=, #read_users, #read_users=, #read_users_string, #read_users_string=, #set_discover_groups, #set_discover_users, #set_edit_groups, #set_edit_users, #set_read_groups, #set_read_users
Methods included from Hydra::AccessControls::Visibility
#visibility, #visibility=, #visibility_changed?
Class Method Details
.editable_by_user(user) ⇒ Object
29 30 31 |
# File 'lib/hydra/admin_policy.rb', line 29 def self.editable_by_user(user) (user, [:edit]) end |
.readable_by_user(user) ⇒ Object
25 26 27 |
# File 'lib/hydra/admin_policy.rb', line 25 def self.readable_by_user(user) (user, [:read, :edit]) end |
.where_user_has_permissions(user, permissions = [:edit]) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/hydra/admin_policy.rb', line 33 def self.(user, =[:edit]) or_query = [] RoleMapper.roles(user).each do |group| .each do || or_query << ActiveFedora::SolrService.solr_name("#{}_access_group", indexer)+":#{group}" end end .each do || or_query << ActiveFedora::SolrService.solr_name("#{}_access_person", indexer)+":#{user.user_key}" end find_with_conditions(or_query.join(" OR ")) end |
Instance Method Details
#default_permissions ⇒ Object
Returns a list with all the permissions on the object.
73 74 75 76 77 |
# File 'lib/hydra/admin_policy.rb', line 73 def (defaultRights.groups.map {|x| {:type=>'group', :access=>x[1], :name=>x[0] }} + defaultRights.users.map {|x| {:type=>'user', :access=>x[1], :name=>x[0]}}) end |
#default_permissions=(params) ⇒ Object
Updates those permissions that are provided to it. Does not replace any permissions unless they are provided
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/hydra/admin_policy.rb', line 50 def (params) perm_hash = {'person' => defaultRights.users, 'group'=> defaultRights.groups} params.each do |row| if row[:type] == 'user' || row[:type] == 'person' perm_hash['person'][row[:name]] = row[:access] elsif row[:type] == 'group' perm_hash['group'][row[:name]] = row[:access] else raise ArgumentError, "Permission type must be 'user', 'person' (alias for 'user'), or 'group'" end end defaultRights.(perm_hash) end |