How can I keep archived content from showing up in search views? In the filters list I see Indexed Node: Status, but that only offers 'published' or 'unpublished' as options. Since archived content is still technically published, it shows up in the search results, but then a user clicks on it and gets an access denied message. I would like to be able to keep it out of search results altogether.

Comments

paean99’s picture

I think that archived content are in fact flagged content with the 'trash flag'.
In fact the OA archive module is supported by the Trash Flag module, or so i think.

I do not know about the search api on its own and his relation to Flags, but it should be possible to use the Views integration with Search API and exclude the trashed/flagged content (if not already done natively).

nrackleff’s picture

Hmmm. I do not see the Trash Flag listed in the available fields or list of filters when I am creating a Database Node Index view through the views UI. I have Open Atrium Archive turned on in features. Do I need to do something else to make it available to the views UI?

paean99’s picture

It seems that search api has a special relationship with drupal permissions.
https://www.drupal.org/node/1254452#search_api_node_access

There is here some permissions problem, possibly related to Views does not respect hook_node_access or some misconfiguration on the view.

I think that a quick fix for your case could be achieved by enabling 'Exclude unpublished nodes' on the Node Index search filters.
You might have to reindex it.

mpotter’s picture

Sounds like (and based on another issue you posted) that the oa_archive module is not enabled on your site. This module modifies queries to prevent archived content from appearing.

To add it to a custom view you need to add a Relationship with Flags. See the Recent Content view in Open Atrium as an example view that doesn't show archived content.

The search views that come with OA2 in oa_search already have this ability, so maybe you haven't reverted your search to use these views.

jkingsnorth’s picture

Status: Active » Postponed (maintainer needs more info)

Did mpotter's suggestion help?

nrackleff’s picture

Yes, that does seem to have helped. People who do not have permission to see archived content are now not seeing it in the search results. I'm still a little confused about archiving in general. What is the purpose of archiving? How is it different than 'unpublish'? Why would someone choose one over the other for a piece of content?

nrackleff’s picture

No wait, I take that back. It is still showing up in search results for people who are not allowed to see archived content. But, that may have something to do with the other issue where I have turned off all archive related permissions for everyone but admin and users are still seeing the archive this button on content when they should not see the button. Not sure which is the real problem. https://www.drupal.org/node/2449005 If a user sees a piece of authenticated content in a search result and clicks on it, they do get an access denied message and cannot view the content. This is the default search results view, not a view that I created.

jkingsnorth’s picture

nrackleff: After you've changed teh permissions make sure you rebuild permissions in Reports > Status. And you will probably have to re-build your search index as well. (Not sure exactly where that is off the top of my head. In Configuration > somewhere.) Because all the old items might still be indexed. This sounds like an issue I've seen here before, but I couldn't find it, sorry. In that case completely rebuilding the search index fixed this issue.

nrackleff’s picture

It seems to have worked.

  • I edited permissions
  • Rebuilt permissions
  • Checked the index to make sure "Exclude Unpublished content" was checked. It was not checked by default - at least not in my instance.
  • I checked it and saved, then rebuilt the index.

I do still have the problem of users who do not have permission to archive things still getting the "archive this" option, but that is under https://www.drupal.org/node/2449005 so I think we can consider this one closed. Thank you all for your help with this.

jkingsnorth’s picture

Status: Postponed (maintainer needs more info) » Fixed

Great, lets close this and focus efforts over there then.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.