When a section gets archived, users still see "Create X in Y" buttons for the archived section. This causes confusion, especially in our case where we only allow users to archive and not delete sections.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JeffM2001 created an issue. See original summary.

JeffM2001’s picture

Status: Active » Needs review
FileSize
3.89 KB

This patch adds a $include_archived parameter to oa_core_space_sections(). One question I have is what the default should be. For the moment I have it defaulting to TRUE (erring on the side of backward compatibility), but every other function with an $include_archived option defaults to FALSE.

The patch also adds flag hooks to clear the button cache when sections are archived or unarchived.

mpotter’s picture

Status: Needs review » Needs work

I think adding this argument to the oa_core_space_sections() is a good idea. To be consistent, I think the default should be FALSE and we should go through the entire Atrium code and look for who calls this function and update it if needed.

However, rather than just passing TRUE or FALSE, I think this needs to be permission-based. If a user has the permission to View Archived Content then it probably makes sense for the archived content to show up in the command buttons, menus, etc. But if that permission is not set then the archived sections should be hidden as you mention...not just from command buttons, but also in the toolbar menus.

JeffM2001’s picture

Hmmm, having it default to FALSE sounds good, but not sure about making it permission-based. To me, the ability to create content in an archived section doesn't really make sense, and has just caused confusion (this is actually the problem I'm trying to solve). It's even been true for our higher-level admins.

I guess it would be ok if it was only based on the "view trash content" permission and not "view trash bin" (which is the one we actually give people). Still, it seems unnecessary to me, at least in the context of command buttons. Another complication is that it would require changing how buttons are cached. Currently they are cached by gid, but this would need a user context as well.

And for other uses of the function, setting $include_archived to TRUE and $bypass_access_check to FALSE should already return a permissions-based list, right?

mpotter’s picture

You raise a good point on the command buttons. Certainly *creating* new content in an archived section should probably be harder and even with command buttons disabled admins can still add content via normal Drupal means if needed. And you are right that it makes the caching less complicated. So I can go with that.

So:

1) Set default to FALSE
2) Change other occurrences of the function to pass TRUE for $include_archived unless it doesn't make sense. For example, in the Toolbar, you probably only want to show archived sections if they have the "View archived content" permission.

JeffM2001’s picture

Ok, changed the default. Here's where I found calls to oa_core_space_sections() and what I did with each:

* oa_archive (finding sections to recursively [un]archive) — set to TRUE, also noticed that hook_flag needed to be updated for 3.x so added that too since it seems closely related
* oa_clone (cloning sections in a space — set to TRUE
* oa_toolbar (section list in admin widgets) — my inclination would be exclude archived sections here, but deferring to you, made it permissions based
* oa_core.fields.inc (options in node edit form) — set to TRUE
* oa_buttons (command buttons) — left as is, i.e. archived excluded
* oa_core.module (exposed forms) — permissions based
* oa_core_user_spaces.inc — permissions based
* oa_sitemap — left as is, archived excluded

mpotter’s picture

Status: Needs review » Needs work

Nice! I think this is really close! My one last comment is to remove the dup code for the flag and unflag hooks and call a single function for that.

Your comment about the 3.x flag changes were actually news to me and I'm looking through Atrium for other hook_flag implementations now. Looks like a couple that I need to fix. So thanks for mentioning that and fixing it for oa_archive.

mpotter’s picture

Status: Needs work » Reviewed & tested by the community

Going to RTBC this and adjust the helper function when I do the commit. Want to get this pushed and you've already done a ton of work on this, thanks!

mpotter’s picture

Status: Reviewed & tested by the community » Fixed

OK, committed to 6d7763c in oa_core, b75f8a9 in oa_archive, ca57946 in oa_clone, 526b3c3 in oa_toolbar

mpotter’s picture

You should also grab the patch from #2474195: Update to Flag 7.x-3.6 that fixes another oa_core flag/unflag issue, and the latest dev of the Trash Flag module that also fixes the same api change issue.

JeffM2001’s picture

Thanks Mike!

Status: Fixed » Closed (fixed)

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