In the 6.x branch would be nice.

From NancyDru "Almost all other contributed modules can properly display the Real Name if they change their code to use theme('username', ...) rather than just grabbing the user name from some object."

Perhaps it's quick?

Comments

bobgeier’s picture

Title: Integration with Real Name Module » User Reference module selector widget integration with Real Name module

Title fix

schturdark’s picture

This would be really useful. Subscribing.

guillaumeduveau’s picture

guillaumeduveau’s picture

Version: 6.x-2.1 » 6.x-2.2
Category: feature » support

I'm working on a patch for Realname, but I have a sticky point with CCK (that's why I'm leaving this issue in CCK/Userreference).

In short how can I call another autocomplete function ? I don't see any [#autocomplete_path] in D6, in D5 it was apparent and easy to change.

Longer version :

In D5 I can see how NancyDru is modifying the autocomplete function, by changing [#autocomplete_path] where it appears.

    [field_user_reference] => Array
        (
            [#tree] => 1
            [#type] => fieldset
            [#description] => 
            [0] => Array
                (
                    [user_name] => Array
                        (
                            [#type] => textfield
                            [#title] => user_reference
                            [#autocomplete_path] => userreference/autocomplete/field_user_reference
                            [#default_value] => 
                            [#required] => 0
                        )

                )
        )
...

We just have to replace userreference/autocomplete/field_(name_of_userreference_field) by a custom path like realname/userreference/autocomplete/field_(name_of_userreference_field).

In D6 I can't find any [#autocomplete_path].

    [field_user_reference] => Array
        (
            [#theme] => content_multiple_values
            [#title] => Contact
            [#required] => 0
            [#description] => Pas trouvé ? Ajouter une nouvelle personne dans la nouvelle fenêtre et réessayer ici.
            [0] => Array
                (
                    [#type] => userreference_autocomplete
                    [#default_value] => Array
                        (
                            [uid] => 31
                        )

                    [#value_callback] => userreference_autocomplete_value
                    [_weight] => Array
                        (
                            [#type] => weight
                            [#delta] => 1
                            [#default_value] => 0
                            [#weight] => 100
                        )

                    [#title] => 
                    [#description] => 
                    [#required] => 
                    [#weight] => 0
                    [#delta] => 0
                    [#columns] => Array
                        (
                            [0] => uid
                        )

                    [#field_name] => field_user_reference
                    [#type_name] => testrealname
                )
        )
...

Somewhat the [#autocomplete_path] is hidden in the field [#type]=>userreference_autocomplete and the callback is defined in userreference_autocomplete_process(). I don't know CCK, fields, widgets and FAPI enough to find my way here, how do I just change the function called by the UserReference Autocomplete widget ?

guillaumeduveau’s picture

Bump, I'm trying to get help on that one in forums, IRC but nothing so far... Hints would be very appreciated ! I'm starting to think it's NOT possible to change the autocomplete function in D6 and that I would have to create a new Userreference widget ?

guillaumeduveau’s picture

Title: User Reference module selector widget integration with Real Name module » CCK User Reference autocompletion integration with Realnames
Project: Content Construction Kit (CCK) » Real Name
Version: 6.x-2.2 » 6.x-1.x-dev
Component: userreference.module » Code
Category: support » feature
Status: Active » Needs review
StatusFileSize
new11.97 KB

I've found that the only way in D6 to do the CCK User Reference autocompletion integration with Realnames is to change the autocompletion function and for this, I didn't find another way than add a new widget. I think it's better like that, because you can still use the standart CCK User Reference autocomplete widget. However it is much more code than in D5 (http://drupal.org/node/369334#comment-1515162) so I wrote a new module for this.

NancyDru, what would you prefer ? Leaving that feature in a new module or integrate the code in the Realname module ? I can do it if you want, just tell me :)

The integration with views is still basic but I don't think I'll go further, I don't need it.

erikwebb’s picture

@guix -

I like where you're going with this module, but I can't get it to even set to a field without errors. This is a sample of the 4 errors I get each time:


    * user warning: Table 'drupal.realname' doesn't exist query: SELECT n.realname, n.uid, u.name FROM realname n LEFT JOIN users_roles r ON u.uid = r.uid INNER JOIN users u ON n.uid = u.uid WHERE (n.realname LIKE '%C%') AND (r.rid IN (6,5)) AND (u.status = 1) ORDER BY n.realname ASC in /home/drupal/web/apps/drupal-6.11/sites/all/modules/realname_userreference/realname_userreference.module on line 403.
    * user warning: Table 'drupal.realname' doesn't exist query: SELECT n.realname, n.uid, u.name FROM realname n LEFT JOIN users_roles r ON u.uid = r.uid INNER JOIN users u ON n.uid = u.uid WHERE (n.realname LIKE '%Chang%') AND (r.rid IN (6,5)) AND (u.status = 1) ORDER BY n.realname ASC in /home/drupal/web/apps/drupal-6.11/sites/all/modules/realname_userreference/realname_userreference.module on line 403.
    * user warning: Table 'drupal.realname' doesn't exist query: SELECT n.realname, n.uid, u.name FROM realname n LEFT JOIN users_roles r ON u.uid = r.uid INNER JOIN users u ON n.uid = u.uid WHERE (n.realname LIKE '%h%') AND (r.rid IN (6,5)) AND (u.status = 1) ORDER BY n.realname ASC in /home/drupal/web/apps/drupal-6.11/sites/all/modules/realname_userreference/realname_userreference.module on line 403.
    * user warning: Table 'drupal.realname' doesn't exist query: SELECT n.realname, n.uid, u.name FROM realname n LEFT JOIN users_roles r ON u.uid = r.uid INNER JOIN users u ON n.uid = u.uid WHERE (n.realname LIKE '%c%') AND (r.rid IN (6,5)) AND (u.status = 1) ORDER BY n.realname ASC in /home/drupal/web/apps/drupal-6.11/sites/all/modules/realname_userreference/realname_userreference.module on line 403.

Where should this `realname` table be coming from? I have RealName installed and working for other purposes already, so I don't think it's coming from there.

Thanks,
Erik

guillaumeduveau’s picture

Erik, you need the latest dev of Realname (2009-Apr-22). Thanks for the comment and let me know what you think about it.

nancydru’s picture

@guix, I think the separate module is a better choice. The question then is it a CCK module or a RealName contrib?

erikwebb’s picture

Now I am having another, much less severe, problem. The query being used is this -

SELECT n.realname, n.uid, u.name FROM realname n LEFT JOIN users_roles r ON u.uid = r.uid INNER JOIN users u ON n.uid = u.uid WHERE (n.realname LIKE "%C%") AND (r.rid IN (6,5)) AND (u.status = 1)

The problem is that I'm getting an error because the users u alias is not appearing until the second JOIN clause, but is being referenced in the first. If I flip that query, I get the results as expected.

BTW, this is the exact error -

Unknown column &#039;u.uid&#039; in &#039;on clause&#039; query: SELECT n.realname, n.uid, u.name FROM realname n LEFT JOIN users_roles r ON u.uid = r.uid INNER JOIN users u ON n.uid = u.uid WHERE (n.realname LIKE &#039;%C%&#039;) AND (r.rid IN (6,5)) AND (u.status = 1) ORDER BY n.realname ASC in <blah>/drupal-6.11/sites/all/modules/realname_userreference/realname_userreference.module on line 403.

Thanks again,
Erik

erikwebb’s picture

StatusFileSize
new824 bytes

To fill in the gaps, here is the patch I used.

--- realname_userreference.module.orig	2009-05-14 10:50:53.000000000 -0400
+++ realname_userreference.module	2009-05-14 10:51:08.000000000 -0400
@@ -372,6 +372,8 @@ function _realname_userreference_potenti
     $where[] = "n.uid > 0";
   }
 
+  $join[] = 'INNER JOIN {users} u ON n.uid = u.uid';
+
   $roles = array();
   if (isset($field['referenceable_roles']) && is_array($field['referenceable_roles'])) {
     // keep only selected checkboxes
@@ -396,8 +398,6 @@ function _realname_userreference_potenti
     }
   }
 
-  $join[] = 'INNER JOIN {users} u ON n.uid = u.uid';
-
   $users = array();
   $where_clause = $where ? 'WHERE ('. implode(') AND (', $where) .')' : '';
   $result = db_query('SELECT n.realname, n.uid, u.name FROM {realname} n '. implode(' ', $join) ." $where_clause ORDER BY n.realname ASC", $args);
guillaumeduveau’s picture

StatusFileSize
new12.03 KB
new490 bytes

@Erik : Thanks ! In fact it was a typo, but I didn't notice it as it was working on MySQL 5. Here's a patch to apply to my first .zip (and a new .zip of the whole module). Let me know if it doesn't work for you...

@NancyDru : The module is related both to CCK and Realname. I think it's too specialized to enter into CCK as a submodule. Then for "Realname contrib", did you mean a sub-module included in Realname or a real separated module ? I think this should be a real separated module, like Node Reference URL Widget (from which it's inspired). If you agree with that I'll apply for a CVS access.

erikwebb’s picture

Looks like the new package is working in whole.

Thanks,
Erik

guillaumeduveau’s picture

StatusFileSize
new12.04 KB

Thanks Erik. New .zip with some additional security checks and some code cleanup. I'm applying for a CVS account and if I'm accepted, will publish this as a new module.

micheleannj’s picture

subscribing

bobgeier’s picture

Thank for the work, guix!

It would be great to add in widgets for select list as well.

I'll spend a bit of time this week testing.

design.er’s picture

Thanks a lot for this great module! I love it!!! :)

Is it possible to make a hybrid text field like on facebook's relationship field? That means if I'm typing a name in the text field the userreference field will provide suggestions for community users as usual... and if the person is a registered community user then it will link to the user as usual. If user is not a community user the userreference field will accept the value but doesn't link to it.

I think it makes sense for functionalities like relationship statuses and events - for speakers (registered users) and guest speakers (not registered users).

Regards,
Stefan

guillaumeduveau’s picture

Project: Real Name » Realname Userreference
Version: 6.x-1.x-dev » 6.x-1.0-beta1
Assigned: Unassigned » guillaumeduveau
Status: Needs review » Fixed

Hi and thanks for your interest !
The module is now published here : http://drupal.org/project/realname_userreference
Please add your issues there.

guillaumeduveau’s picture

Status: Fixed » Closed (fixed)
elektrorl’s picture

Status: Closed (fixed) » Closed (won't fix)

Sorry, but it does not work… But the fiel User Reference is loaded on a CCK multigroup. Is it possible there is a bug between both modules?

guillaumeduveau’s picture

Status: Closed (won't fix) » Closed (fixed)

Please post new issues to report bugs / feature requests.

Elektrorl, see #518678: Does not work with CCK multigroup ;)

guillaumeduveau’s picture

Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

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

ruchiaz’s picture

HI

I have create cck field for company name. Once user register he needs to select one of company as a referee which is already registered in the system. This user reference cck referee field needs to be auto completed with referee company and should save as reference user id in the node. My problem is this reference filed auto completed with company name and user name (eg. companyname (username) ). but once i submit form it says 'found no valid user with that name'.

Please Help.
Thanks.

nancydru’s picture

Please open a new issue. Posting in a 3 yr old issue is probably futile.