I use taxonomy to divide a website in sections, e.g. youth, children etc.
It would be very very nice to have [node:workbench_access:name] available as a token to determine the patterns for URL aliasing.

Els the contributor has to fill in a separate field, with is redundant. Besides I do not want them to be able to do this since they should be able to only add content to their own section.
I understand workbench_access provides in this, except that I need somehow the URL-pattern.

Comments

agentrickard’s picture

Seems reasonable. Shouldn't be very hard.

Patch?

Fonkel’s picture

I'm not a coder, so I'm not able to write a patch (if that's what you mean :-)

agentrickard’s picture

That was my hope. This shouldn't take very long though, and should be ready for the 1.0 release.

Fonkel’s picture

Thanks a lot! Sorry that I can't do this for you guys! I think you did a great job with this module!

agentrickard’s picture

Assigned: Unassigned » dave reid
Status: Active » Needs review
StatusFileSize
new3.53 KB

Here's a patch. Well, not really a patch. Just rename the attached file workbench_access.tokens.inc and drop it in the workbench_access directory.

Seems to work. Could (maybe) use a test?

dave reid’s picture

Will give this a test plus write some tests for this tomorrow!

Fonkel’s picture

Thanks for posting this file.
What I've found out is that in the case of taxonomy used for URL aliasing, I can use the token for taxonomy-term-name in the URL.
I have not found this yet in the tokens that workbench exposes?

agentrickard’s picture

It's there. If you're using taxonomy as the scheme, it should be [node:workbench_access].

Fonkel’s picture

Great, it does work very well!
While testing this, I came to another request:
Let's say I have several events for the different sections of the website.
I used to filter these results in the view using contextual filter (argument) of section.
This was possible with the taxonomy-field.
Is it possible to expose the Workbench Access field as an argument? Or at least as a filter, so the content can be filtered down to a certain section?

agentrickard’s picture

You mean this #1191484: Workbench Access Views Contextual Filters, I assume. Otherwise, please open a new issue.

dave reid’s picture

StatusFileSize
new3.57 KB

Here's the proper patch. To review the changes:

1. Only two tokens are needed: workbench-access-sections (section names keyed by access ID), and workbench-access-type. Using the array token type we now get [node:workbench-access-sections:keys] rather than having to implement [node:workbench_access_id].
2. Created a re-usable workbench_access_get_node_sections() functions to return a node's access section names keyed by access ID.
3. Fixed variable_get('workbench_access')'s default is actually 'taxonomy'.
4. Fixed [node:workbench-accesss-type] returns the machine name and not the actual name.

Just need to write some tests for this.

dave reid’s picture

Title: Expose the field workbench_access through tokens for URL aliassing » Add tokens for workbench access sections
Version: 7.x-1.0-beta9 » 7.x-1.x-dev
agentrickard’s picture

Don't we need the 'access_id' for people not using Token module?

dave reid’s picture

I would think that most people (including the reporter) are most interested in the section names and not the IDs. I think for the purposes here it's perfectly reasonable to say "You can install the Token module to access the IDs as token to access [node:workbench-access-sections:keys]."

As a token system maintainer I'd prefer to avoid duplicating tokens wherever possible. If we did provide a [node:workbench-access-ids] token then it would not only be duplicating [node:workbench-access-sections:keys] but also adding more tokens and data to the token tree because of the additional token.

dave reid’s picture

StatusFileSize
new14.13 KB

- Revised patch that moves/renames [node:workbench-access-type] to [site:workbench-access-scheme] as the access scheme is site-wide and not node-based.
- Also creates a access scheme token type so you can do [site:workbench-access-scheme:machine-name].
- Adds a [user:workbench-access-sections] token for the sections assigned to a user account.
- Includes tests for all tokens.

Todos:
- Add some tests for multiple-section nodes/users.

agentrickard’s picture

Niiiice.

dave reid’s picture

StatusFileSize
new18.88 KB

Tests added for multi-section nodes and users.

Found a bug in that you cannot do the following:

$node = node_load();
$node->workbench_access = new array of ids();
node_save($node);

The problem is that workbench_access_node_save() fails if $node->workbench_access_scheme['access_scheme']); is not defined - which is true for any node loaded via node_load() since that property is added in the forms themselves.

There is also a variable mis-match. workbench_access_node_load() adds the section IDs in $node->workbench_access, while the form submission contains the IDs in $node->workbench_access_ids. A temporary measure has been added in workbench_access_node_save() until this can be resolved (separate issue will be filed).

Tests should be run against the full suite of tests to ensure I didn't regress anything because of the workbench_access_node_load() and workbench_access_node_save() changes.

dave reid’s picture

Confirmed tests pass: 94 passes, 0 fails, 0 exceptions.

agentrickard’s picture

Status: Needs review » Reviewed & tested by the community

Let's commit this and then fix the other issue in a follow-up. It's non critical, even with the sloppy fix (and I say sloppy because the save function is badly designed, not because the fix is).

dave reid’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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