Closed (fixed)
Project:
Search API
Version:
7.x-1.x-dev
Component:
Views integration
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 Sep 2011 at 12:54 UTC
Updated:
14 Apr 2013 at 18:00 UTC
Jump to comment: Most recent file
Comments
Comment #1
drunken monkeyThe attached would add a corresponding Views option. Please review!
Comment #2
BarisW commentedHmm, this doesn't seem to work for me. For user 1 it's okay, but with a default user I get a lot of notices and zero results.
And some more..
Comment #3
BarisW commentedComment #4
BarisW commentedFor reference, I reported a bug in OG, which turned out to be caused by this bug (?) in Search API Views: #1419538: How to exclude private group content from Search API?
Comment #5
BarisW commentedThomas, if you have time, please look into this. Currently it is not possible to exclude private content from search results if those results are displayed using Views. All help is welcome!
Comment #6
simon georges commentedTrying to adapt the patch to the current -dev version.
Comment #7
simon georges commentedOk, this patch does not work at all. Let me try to do better.
Comment #8
simon georges commentedThis one works. But I'm sure it could be optimized (because it loads every entity one after another). There's also a small fix from a copy-paste of the patch in #1 regarding the
#default_valuein the Views form options.Comment #9
BarisW commentedThanks, this seems to work. I don't see the nodes any more in the results I'm not allowed to see. However, the views counter still remains the same and the Facets (facet api) still show a filter. So I can filter on the content type I'm not allowed to see, and after filtering, I get a 'no results found'.
Any thoughts on this?
Comment #10
BarisW commentedPlus, are we're doing it on a page level now? I'd expect 10 results per page, where I'm now seeing 9 (one node disappears which I'm not allowed to see).
Comment #11
simon georges commentedI have the same issues. But I only adapted the patch, I'm not an expert in Search/Facet APIs, so I was thinking somebody would just jump on it to help ;-)
Comment #12
balintbrewsThis issue is already fixed, it's implemented in the current recommended stable release (maybe even in earlier releases as well, I'm not sure about that).
Comment #13
olofbokedal commentedThis doesn't exist in the latest dev, so no, it hasn't been implemented yet.
The patch from #8 removes the results, but the pager acts on the original result count. The "removal logic" should probably be executed earlier, but I don't know where and when. I'll continue to investigate this.
Comment #14
olofbokedal commentedAfter some heavy thinking, I think the only possible way to respect the pager, facets count etc, is to alter the query before it has been executed. This requires that the access information is stored in a table, for instance in the node_access table.
This might be possible to achieve for nodes, but it'll probably be hard. However, I think it's impossible to achieve in a proper way for other entities.
Comment #15
simon georges commentedYes, I've actually completely dismissed the idea, as I didn't find any proper way to do it...
Comment #16
drunken monkeyAs balintk said (and as can be read in the issue link in the OP), this is already implemented, at least for nodes. See the "Node access" data alteration under "Workflow". However, it's sadly not possible to do it on a generic level for all entity types, as far as I can see. That and the fact that content that isn't indexed right away might still be shown to unauthorized users, leads to the need for this option, which would be kind of a last ressort.
Yes, the paging will be wrong, as will the facets, the "Current search" block, etc. But it's usually still preferable compared to showing classified content to unauthorized users.
However, as far as you can you should of course use normal filters to do that (or, as said, the "Node access" data alteration). Or implement a corresponding data alteration for the entity type you're using.
Anyways, the patch in #8 looks pretty good to me. Anyone else can confirm it works?
We should probably just change the description to warn users to only use this as a last ressort, because it'll break things. (And re-add the README.txt changes from my original patch in #1.)
Comment #17
drunken monkeyComment #18
olofbokedal commentedYes, #8 does solve this issue and works as intended.
Comment #19
drunken monkeyThanks for testing!
Committed.