Sha256: b43304be155f85195693e51e67a1830f67e82cca89fb1934700a62f2f5b44787

Contents?: true

Size: 741 Bytes

Versions: 3

Compression:

Stored size: 741 Bytes

Contents

module BlacklightUserGeneratedContent
  module SolrHelper
    module Scope
      def self.included(some_class)
        some_class.solr_search_params_logic << :restrict_to_user_generated_content_scope
      end
  
      def restrict_to_user_generated_content_scope solr_parameters, user_parameters
        solr_parameters[:fq] ||= []
        if current_user
          if current_user.has_role? :admin and user_params[:all]
            solr_parameters[:fq] << "comments_ids_i:[* TO *]"
          else
            solr_parameters[:fq] << "comments_user_ids_i:#{current_user.id} OR tags_user_ids_i:#{current_user.id}"
          end
        else
          solr_parameters[:fq] << "comments_public_b:true"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight_user_generated_content-0.0.3 lib/blacklight_user_generated_content/solr_helper/scope.rb
blacklight_user_generated_content-0.0.2 lib/blacklight_user_generated_content/solr_helper/scope.rb
blacklight_user_generated_content-0.0.1 lib/blacklight_user_generated_content/solr_helper/scope.rb