Closed (fixed)
Project:
Content Construction Kit (CCK)
Version:
6.x-2.x-dev
Component:
userreference.module
Priority:
Critical
Category:
Feature request
Assigned:
Reporter:
Created:
14 Aug 2008 at 23:11 UTC
Updated:
12 Mar 2009 at 17:01 UTC
Jump to comment: Most recent file
Comments
Comment #1
yched commentedTrue - patch welcome.
Comment #2
crizsubscribed
Comment #3
CPyle commentedCode is finished and in testing. Needs commenting and I will submit the patch.
Comment #4
CPyle commentedDiff'd from CCK 6.2 RC6.
This patch adds the ability to use views to populate the allowed values for a userreference field. It is implemented in exactly the same way as the functionality in nodereference.
Comment #5
yched commentedCool - thanks for working on this, I'll try to review shortly.
Patch is strange, though. It removes (-) the whole current content of userrefermence.module, and then adds (+) the whole new file, instead of diffing only the parts that need to be diffed...
Comment #6
CPyle commentedI noticed that too. I used Tortoise SVN to create it. I'll install CVS and recreate it if necessary.
Comment #7
CPyle commentedDon't know what the problem was. I had a coworker create the patch and it worked fine, no wonkiness.
No code changes, just a correct patch file.
Edit: I might add, I am currently using this in a project to limit selections to users within the current node's og group context, and it is working wonderfully. I have not tested any more complex use cases, but this was a common request that I've seen with regards to those wanting this functionality.
Comment #8
yched commentedThx, looks better.
Comments are invalid :-) (there might be a few others left)
Refering to
'node', 'name'field and filters look strange - we shouldn't be referring to nodes, right ?Although looking in views/modules/users.views.inc, it seems 'users'/'name' doesn't provide any filter ?
Comment #9
yched commentedFor the autocomplete behavior, we need a way to filter users whose name starts with a given string.
Views currently doesn't provide any 'filter' for this. There's an 'argument' that does it, so we could use that argument instead, but this is probably going to be more complicated. This will make the code too different from the one in nodereference, and I wish we could merge them at some point.
Best thing would be a patch for views that adds the filter we need - others might need it too.
Faster way would probably be to add this filter ourselves in hook_views_data_alter().
Comment #10
CPyle commentedYou're right. There was no filter set for the name field. I've tried adding it via hook_views_data_alter, but it really should probably be done via a patch to views.
I've fixed the other stuff left over from nodereference.
New patch version.
Thanks for reviewing this, it's a feature I've been wanting since Drupal 5, but views didn't support users at the time.
Comment #11
yched commentedCool - please submit the patch for Views, referencing this issue. Let's see if merlinofchaos is willing to add it in views directly.
Comment #12
CPyle commentedI've submitted the patch to views. The hook_views_data_alter function in my userreference patch can obviously be removed when/if merlinofchaos puts this through.
#298396: Add string filter to users/name field.
Comment #13
yched commentedMany thanks, CPyle. I'll try to actually test your patch asap.
Comment #14
yched commentedSeems to work quite right, except for with autocomplete widget : we never get any completion results.
Comment #15
yched commentedProblem is that in userreference_autocomplete() :
$name is an array, so
$matches[$name] = check_plain($name);breaks.I'd say the problem lies in userreference_plugin_style_php_array::render()
Comment #16
CPyle commentedLooks like userreference by original design expects it's results to come in as uid->value, whereas nodereference accepts a views themed array.
I removed the extra array from userreference_plugin_style_php_array::render() and reverted the changes to userreference_allowed_values(). Seems to work great.
Also, name filter operator is now "Starts with" instead of "Contains."
Thanks for the input.
Comment #17
yched commentedProblem was rather that userreference_autocomplete was not mimicking nodereference_autocomplete.
I fixed that and committed the thing - result is closer from patch #10.
Thanks for this !
Side note : there's now a lot of code duplication between nodereference.module and userreference.module... Food for though. Some of this (Views mode, in particular) might be worth abstracting out...
Comment #18
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #19
gunzip commentedwill this ever implemented in the cck core ?
Comment #20
gunzip commentedComment #21
yched commentedgunzip : The feature has been in CCK 6.x-2.1 for several months.
If the question is 'will this be backported to CCK D5 ?', the answer is 'no, because CCK D5 receives no new feature, *and* Views D5 does not lists users to begin with :-D'