It would be useful for BEANs to have a state property so they can be inactive/disabled/unpublished/hidden (I don't care about the name). When a bean is inactive state bean_block_view() would return NULL and the bean wouldn't render. In a later phase permissions could be added "View inactive beans" which would be similar to the core node "view unpublished content" permission.

I'm happy to hack on this if people think it is worthwhile.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

indytechcook’s picture

This does sound worthwhile for me. I've been thinking about this for the 2.x version. We need to make sure to make all of the current beans active in an update hook.

skwashd’s picture

Assigned: Unassigned » skwashd

I'll look at implementing this.

saltednut’s picture

@skwashed are you still working on this?

Samvel’s picture

Hi Guys, created module with property status https://drupal.org/project/bean_status

skwashd’s picture

Assigned: skwashd » Unassigned
Issue summary: View changes

@brantwynn not right now. I have been working on other priorities.

Feng-Shui’s picture

Status: Active » Needs review
FileSize
12.16 KB

The attached patch is an initial pass at adding a status (published/unpublished) property to Beans. It contains:

  1. New status field with a default of 1 - published
  2. Views integration as a field and a filter
  3. Update of the access callback for the bean on its entity path, this needs to go through hook_bean_access() in order to take advantage of a new "view unpublished beans" permission
  4. Test coverage for the "view unpublished beans" and "view bean page" permissions
  5. An update to the schema to support the new field
  6. An update hook to add the new field to existing installs

Happy to look at any changes to this patch in order to progress this issue, I need this feature on a site so will be running this patch.

Status: Needs review » Needs work

The last submitted patch, 6: 1874544-9-bean-status-property.patch, failed testing.

Feng-Shui’s picture

Status: Needs work » Needs review
FileSize
11.96 KB

Fix issue with the paths in the patch...

Status: Needs review » Needs work

The last submitted patch, 8: 1874544-7-bean-status-property.patch, failed testing.

Feng-Shui’s picture

Status: Needs work » Needs review
FileSize
11.73 KB

ffs...

Feng-Shui’s picture

Status: Needs review » Needs work

The last submitted patch, 10: 1874544-10-bean-status-property.patch, failed testing.

Feng-Shui’s picture

Status: Needs review » Needs work

The last submitted patch, 13: 1874544-13-bean-status-property.patch, failed testing.

Feng-Shui’s picture

Well that's interesting. uuid.test (line 13) is using a PHP trait so this patch needs to be tested against PHP 5.4. Re-queueing for PHP 5.4.

See https://www.drupal.org/node/2763727

Feng-Shui’s picture

Status: Needs work » Needs review
skwashd’s picture

I've updated the project config to test with PHP 5.4 and 5.6.

Feng-Shui’s picture

Thanks Dave. I've got to do a bit more testing on this patch (and the other three patches that it'll be running with), but what are the next steps for this issue? Are you keen on seeing this go into the module, and if so, do you have any concerns or additional testing that you want written?

DamienMcKenna’s picture

Given there's already the Bean Status module, why bother adding this to the Bean module itself? Would it not be better to promote Bean Status as the recommended solution for this?

Feng-Shui’s picture

A couple of reasons:

  1. skwashd suggested the the Bean Status module should have been contributed as a patch to the Bean module, the Bean Status module maintainer agreed: https://www.drupal.org/node/2147127
  2. the Bean Status module rolls its own db table and adds extra queries for each Bean CRUD operation
  3. given that Beans are content, having a published/unpublished flag that's inherently part of the bean made sense to us
  4. the Bean Status module didn't have Views support, which we needed, so given the need to patch one of the modules, the preference was to patch Bean rather than adding a new module, and then patching it too
Feng-Shui’s picture

Status: Needs review » Needs work

FYI, there is some complexity around the installation of this patch. As the code in the patch relies on a db update hook, there can be situations where a WSOD appears if the update hook is not run before beans are loaded. We're currently looking at a two phase release, first release to push the database update, and the second release to push the code.

Given the above, the comments by @DamienMcKenna, and the fact that it doesn't look like this is going to get much traction, we're going to look at patching the Bean Status module with Views support and a few other things that we need or running this as a local patch with the anticipation that this will not get into a Bean release.

I'm not going to close this issue, as it's not mine, but I'm going to set the status to needs work.