One thing I keep running into with project* related views is that there's currently no way to validate a user argument to convert a username into that user's UID. E.g.

http://d6.drupal.org/project/issues/user/dww

That doesn't do the right thing, since it's not really using a UID under the covers.

It should be incredibly easy to add an argument validator plugin for usernames...

Comments

dww’s picture

Assigned: Unassigned » dww

Looks like I'm writing the code for this... stay tuned.

dww’s picture

Status: Active » Needs review
StatusFileSize
new1.98 KB
merlinofchaos’s picture

Status: Needs review » Needs work

This will be better if how it validates is specified as an option. I can see a need for validating both but some uses may prefer just one or the other.

It probably also should allow validating by role similar to validating by type.

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new32.91 KB
new4.29 KB

Adds:

A) Set of radios to control what type of user argument to allow

B) Checkbox if you want to restrict based on role

C) If (B) is checked, a multi-select to chose which roles you want to restrict to.

See attached patch and screenie.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed. I thought about saying the select needed to be checkboxes, then I remembered what a pain it is to make checkboxes work with the dependencies. It can but that can be patched later if anybody notices the inconsistency and cares.

aclight’s picture

Status: Fixed » Active

By the way, I'm seeing these radio boxes and the restrict based on role checkbox regardless of what validator I have selected. This is using the Taxonomy: Term ID argument type, but I doubt it's specific to just that argument handler.

dww’s picture

Assigned: dww » Unassigned
Category: task » bug

Argh, yup, I see that now, too.

@merlinofchaos: What did I do wrong? ;) I thought views automagically got this right for me... Please show me the error of my ways.

Thanks/sorry,
-Derek

bobgeier’s picture

Derek (and merlin),

Thanks for the coding on this. The role selection in particular is very helpful for some work I'm doing currently. Or will be as soon as a few of the other 2.3 issues get cleaned up!

merlinofchaos’s picture

Status: Active » Needs review
StatusFileSize
new4.21 KB

dww: Sorry no, it's actually a pain in the ass right now. Here's a patch. I don't trust myself right now or I'd just commit it. Please test this for me?

dww’s picture

Assigned: Unassigned » dww
Status: Needs review » Needs work

Sorry Earl, I've been away from work for the last week. Just getting caught up now. I tested this and it's not working properly. The "Type of user argument to allow:" header is still always present regardless of what kind of validator you select, and the radios themselves don't appear, even if you do choose "user". I'll work on debugging and fixing the patch, stay tuned.

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new4.34 KB

That was relatively painless. ;)

A) We forgot to keep expand_radios in the #process array

B) We apparently needed a wrapper div around the whole radios form element to catch the label.

This patch works with my testing. Someone else verifying would be appreciated.

merlinofchaos’s picture

Status: Needs review » Fixed
cdale’s picture

Does this mean that User:UID and User:name arguments could be merged into one, as they both would be able to function interchangeably? Or would it need to wait for a 'multiple validators per argument' feature so you could still use the node/taxonomy validations at the same time as one of UID or Name, but not both?

dww’s picture

@cdale: No.

"User: Name" is a username, a string. The underlying value passed to the query is a string.

"User: UID" is a UID, an integer. The underlying value passed to the query is a number. There's now an argument validator that takes usernames and converts them into the UID integer to pass into the query but the value is still the integer in this case.

Therefore, these are still separate arguments. Hope that helps clarify.

eikes’s picture

has this been committed and is it in the dev version? when will 2.4 be released?

dww’s picture

has this been committed and is it in the dev version?

Yes.

when will 2.4 be released?

When it's ready. ;)

eikes’s picture

Thank You

Status: Fixed » Closed (fixed)
Issue tags: -drupal.org upgrade

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