CCK User Reference autocompletion integration with Realnames

bobgeier - February 22, 2009 - 22:34
Project:Realname User Reference Widget
Version:6.x-1.0-beta1
Component:Code
Category:feature request
Priority:normal
Assigned:guix
Status:closed
Description

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?

#1

bobgeier - March 2, 2009 - 23:21
Title:Integration with Real Name Module» User Reference module selector widget integration with Real Name module

Title fix

#2

schturdark - April 19, 2009 - 16:30

This would be really useful. Subscribing.

#3

guix - April 24, 2009 - 10:16

#4

guix - April 29, 2009 - 17:31
Version:6.x-2.1» 6.x-2.2
Category:feature request» support request

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 ?

#5

guix - May 5, 2009 - 15:15

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 ?

#6

guix - May 6, 2009 - 18:26
Title:User Reference module selector widget integration with Real Name module» CCK User Reference autocompletion integration with Realnames
Project:Content Construction Kit (CCK)» RealName
Version:6.x-2.2» 6.x-1.x-dev
Component:userreference.module» Code
Category:support request» feature request
Status:active» needs review

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.

AttachmentSize
realname_userreference.zip 11.97 KB

#7

erikwebb - May 12, 2009 - 19:32

@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

#8

guix - May 12, 2009 - 20:29

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

#9

NancyDru - May 13, 2009 - 01:49

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

#10

erikwebb - May 13, 2009 - 19:50

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

#11

erikwebb - May 14, 2009 - 14:52

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);

AttachmentSize
realname_userreference-flip-join-order.patch 824 bytes

#12

guix - May 20, 2009 - 11:08

@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.

AttachmentSize
realname_userreference-380460-11.patch 490 bytes
realname_userreference.zip 12.03 KB

#13

erikwebb - May 20, 2009 - 13:51

Looks like the new package is working in whole.

Thanks,
Erik

#14

guix - May 22, 2009 - 09:56

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.

AttachmentSize
realname_userreference.zip 12.04 KB

#15

majnoona - May 29, 2009 - 18:45

subscribing

#16

bobgeier - May 31, 2009 - 21:54

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.

#17

design.er - June 1, 2009 - 10:32

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

#18

guix - June 1, 2009 - 19:34
Project:RealName» Realname User Reference Widget
Version:6.x-1.x-dev» 6.x-1.0-beta1
Assigned to:Anonymous» guix
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.

#19

guix - June 1, 2009 - 19:46
Status:fixed» closed

#20

elektrorl - July 6, 2009 - 02:16
Status: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?

#21

guix - July 14, 2009 - 09:18
Status:won't fix» closed

Please post new issues to report bugs / feature requests.

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

#22

guix - July 14, 2009 - 09:20
Status:closed» fixed

#23

System Message - July 28, 2009 - 09:30
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.