Sha256: 8dd08652e4906824b2a8e084c6d9a92824201835436208500878985ff192bee9

Contents?: true

Size: 1.48 KB

Versions: 36

Compression:

Stored size: 1.48 KB

Contents

module Hyrax
  ### Allows :deposit as a valid type
  class AdminSetSearchBuilder < ::SearchBuilder
    # This skips the filter added by FilterSuppressed
    self.default_processor_chain -= [:only_active_works]

    # @param [#repository,#blacklight_config,#current_ability] context
    # @param [Symbol] access one of :edit, :read, or :deposit
    def initialize(context, access)
      @access = access
      super(context)
    end

    # This overrides the models in FilterByType
    def models
      [::AdminSet]
    end

    # Overrides Hydra::AccessControlsEnforcement
    def discovery_permissions
      if @access == :edit
        @discovery_permissions ||= ["edit"]
      else
        super
      end
    end

    # If :deposit access is requested, check to see which admin sets the user has
    # deposit or manage access to.
    # @return [Array<String>] a list of filters to apply to the solr query
    def gated_discovery_filters
      return super if @access != :deposit
      ["{!terms f=id}#{admin_set_ids_for_deposit.join(',')}"]
    end

    private

      # IDs of admin_sets into which a user can deposit.
      #
      # @return [Array<String>] IDs of admin_sets into which the user can deposit
      # @note Several checks get the user's groups from the user's ability.  The same values can be retrieved directly from a passed in ability.
      def admin_set_ids_for_deposit
        Hyrax::Collections::PermissionsService.source_ids_for_deposit(ability: current_ability)
      end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.9.5 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.9.4 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.9.3 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.9.2 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.9.1 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.9.0 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.8.0 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.7.2 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.7.1 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.7.0 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.6.0 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-3.0.0.pre.rc1 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-3.0.0.pre.beta3 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.5.1 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.5.0 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-3.0.0.pre.beta2 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.4.1 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-3.0.0.pre.beta1 app/search_builders/hyrax/admin_set_search_builder.rb
hyrax-2.4.0 app/search_builders/hyrax/admin_set_search_builder.rb