Adding table with calculated realnames

NickSI - March 5, 2009 - 05:33
Project:RealName
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:NickSI
Status:closed
Description

NancyDru, first of all thank you for keeping this module evolving!

In you comments to #385126: Cache user_load or do something smaller... I saw that you thinking about table to keep calculated realnames. I think this is great idea. In addition to potential performance improvement this will make possible:

  • Integration of realnames into views (as filter and as field, of course)
  • Fast and straight-forward implementation of autocomplete for user and userreference fields

What are your plans on that? The reason I ask is that I'll need both features mentioned above for some of my projects and I have to implement them one way or another. Although this is a serious change in the way module works and I want to know if I should do start working on the patch to your module or do it as separate custom module derived from yours.

#1

NancyDru - March 5, 2009 - 14:15

Views would be very simple, but you would have to create an issue for Views (actually one is needed because it is broken right now). When the "link to user" option is chosen, it needs to use theme('username',...).

A patch would be helpful. I support 20+ modules and try to give some time to the others.

#2

NickSI - March 5, 2009 - 15:59

Ok. I'll try to come up with something in a few days.

#3

NickSI - March 6, 2009 - 18:38

Well, here is the patch. Following has been changed:

  • New table has been created in order to store calculated real names (for existing installations update script will populate it)
  • New administration page for realname recalculation after you change you settings
  • Module updates realname in table after user changes his profile/content profile fields
  • New field in Views - displays realname and make it possible to sort by real name
  • New filter in Views
  • New argument in views - based user uid argument class but filter on realname
  • New argument validation plugin - based on user validation plugin but show realname insted of user name in title
  • New option in admin menu - to override user view fields with realname handlers. Both user name filter and user name field will use realname. No need to change views, just update views cache

I am quite sure that module works with profile.module however it will be nice if someone will test it with content_profile.module as I am not familiar with it.

todo (on this weekend I hope):

  • Replace view filters for CCK userreference fields to show realnames instead of user names
  • Add extra autocomplete/list widgets for CCK userreference field capable to deal with realnames

This patch has been generated against Mar 04 dev version of module.

AttachmentSize
realnames.patch 26.5 KB

#4

NancyDru - March 6, 2009 - 20:17
Status:active» needs review

Fabulous, Nikolai. I will take a look at it. I just made some changes to the module that probably affect this patch though. Please update the "Assigned" to yourself.

#5

NancyDru - March 6, 2009 - 22:05

Awesome stuff!

Is there a reason for 254 as the length of the "realname" column? It is more normal to see 255.

drupal_set_message(t('In order to apply new settings you need to !rebuild your realnames', array('!rebuild' => '<b>'. l(t('rebuild'), 'admin/user/realname/recalc') .'</b>')), 'warning');

Should be
drupal_set_message(t('In order to apply new settings you need to <a href="!rebuild">rebuild</a> your realnames', array('!rebuild' => url('admin/user/realname/recalc')), 'warning');

I'd kind of prefer to see use of drupal_write_record.

#6

NickSI - March 7, 2009 - 06:54
Assigned to:Anonymous» NickSI

Thank you, Nancy!

There is no reason for 254 as length except my typing skills :-).

When do you plan to submit next dev release? I'll need another day or two to sort out CCK fields. That means that there are two options. I can either quickly fix errors and recreate current patch against Mar 07 release and you'll include it in dev version, or I can proceed working on cck and do the patch with all functionality in place (against dev version which will be available by that time). Which of them suit you better?

#7

NancyDru - March 7, 2009 - 14:41

I just committed a patch, so there will be a new release at midnight GMT. I need to give some time to other modules, so you can have a few days break.

BTW, some of the stuff in the patch is over my head, so I couldn't comment on it.

#8

NickSI - March 8, 2009 - 09:24

Well, after some experiments with CCK fields I've figured out that there is no easy way to override CCK userreference widget without duplication at least 90% of module code. On the other hand the patch to CCK userreference to make it work with new version of realname is quite small and I'll try to propose it to CCK mainatiner if you agree to accept my change to your module.

Attached patch done against Mar 07 vdev version and includes all functionality mentioned in #3 with changes you've suggested in #5.

AttachmentSize
realname.2.patch 29.8 KB

#9

NancyDru - March 10, 2009 - 05:07

in #351648: Working with Views module it is suggested that Views works after rescanning templates, so do we still need the Views changes here?

#10

NickSI - March 10, 2009 - 08:35

Well. Without changes proposed in the patch you can SEE real names but you cannot SEARCH on realnames or SORT by realnames. Views needs field in the table in order to handle sort or search.
If realname based on profile fields you can serach/sort by profile field directly, however this aproach does not work in case of realname based on content_profile.

#11

NancyDru - March 10, 2009 - 13:08

Hmm, I can sort of them but I don't know about filtering.

I'm thinking that I should probably roll a new release before I make this change. There are a lot of changes already available and some are significant.

#12

NickSI - March 10, 2009 - 14:01

OK. No problem with release. Re sorting: sure you can (you have checkbox/field in views UI), however sort will be done on username, not realname.

I also think that we should probably postpone my patch as it seems that I am the only one who really needs it. There is a lot of changes in this patch which can lead (I hope not, but still...) to a lot of bugs. If somebody else will show interest in such functionality we can return to it...

#13

NancyDru - March 10, 2009 - 18:33

I was going to wait until after I created a new release so that this patch would be available to those who would test it. Hopefully there are no bugs.

In the mean time, if you want, I just submitted a patch for searching that might be easier with this patch in place. Also I was thinking that the file name could simply be "realname". We should also mention on the "Fields" tab in the settings that the resulting name is limited to 255 characters. And I noticed that in "_realname_rebuild_batch_finished" the message has a misspelling.

#14

NickSI - March 10, 2009 - 19:36

OK. Let's wait for new release.

#15

pauline_perren - March 30, 2009 - 04:41

You wondered if anyone else wanted this functionality, I do for one. :-)

#16

NancyDru - March 30, 2009 - 07:54

Thank you.

#17

NancyDru - April 21, 2009 - 23:00
Status:needs review» needs work

The first thing I tested was changing my RealName and it takes two saves to be effective. This only seems to happen with Profile_Privacy.

#18

NancyDru - April 21, 2009 - 22:56

I also noticed that the index is not defined on an update. I fixed this.

#19

NancyDru - April 21, 2009 - 23:19
Status:needs work» fixed

Committed

#20

System Message - May 5, 2009 - 23:20
Status:fixed» closed

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

#21

DrakeRemory - June 30, 2009 - 17:44

Hi,

first of all great module! When I installed the current dev (May 13) I had some trouble with realname in views filter. You forgot to include 2 handlers (realname_handler_filter_user_name.inc, realname_plugin_argument_validate_user.inc). There was also a bug in patch from #2. In the realname_nodeapi() function in the first switch you have to delete "case 'insert':" und "case: 'delete':". Also in realname.views.inc you used "field" instead of "filter".

#22

voxpelli - July 14, 2009 - 12:45
Category:feature request» bug report

Since #21 didn't change the status of the issue I'm changing it

#23

voxpelli - July 14, 2009 - 12:46
Status:closed» active

#24

tstackhouse - August 3, 2009 - 19:50

Not sure if I should make a new issue or not, but the realname table does not update when I run rebuild realnames. I'm only seeing my regular usernames, not the fields from my content_profile.

#25

tstackhouse - August 3, 2009 - 21:22

I've done some research on this, and it appears that in the _realname_make_name(&$account) function on like 664, $account does not contain a fully loaded user object. Adding $account = user_load($account->uid); before the function code gives a fully loaded user object with access to the core profile fiends, however the content profile fields are absent. I'm still very new to programming Drupal, but I'm a PHP vet and I'm glad to be of help with this.

Redacted upon further review of the code, however I am still having difficulty getting the values to populate. A dsm($account) on line 709 after the profile has supposedly been loaded shows only uid, name and mail fields. I will continue to investigate this and will post anything I find.

It should also be noted that I am on PHP4.

#26

NancyDru - August 3, 2009 - 23:28

Given that D7 requires PHP 5.2.5 or higher and that PHP4 is no longer supported, I will not support PHP4.

#27

guix - August 4, 2009 - 14:05

@ #24 maybe that can help : #502708: Realnames not rebuilt

#28

tstackhouse - August 4, 2009 - 15:53

@ #26, Thanks for the quick response, I'll continue to dig around and figure out if I can either make this work in PHP4 or get our server upgraded to PHP5. I would love to be able to use this functionality for the site that I m building.

@ #27, I've looked into that, the names are getting rebuilt just fine, however in the code that is actually doing it, the data isn't getting pulled through into the table, once it's loaded.

I'll post any findings I come across as I research this more.

Edit: I've managed to get this working and will share my findings in the hopes that I'll be able to help out others in my situation.

PHP4 handles passing by reference poorly, and as such that was what was breaking. When a profile was loaded using the load_profile hook, the account is passed by reference, but in PHP4 this appears to be ignored. The hook architecture allows a function to return a value, so by modifying realname_content_profile.inc, in my case, and adding return $acocunt; on line 44, and changing the call in realname.module to $account = module_invoke($module, 'load_profile', $account, $type); I was able to get the proper functionality in my PHP4 installation.

I sincerely hope that this helps out someone and woill be glad to provide any more information if necessary.

#29

BettyJJ - September 30, 2009 - 13:32

First, thanks for this great module.

One pity is that if used together with views, it only display realnames when linking to the user's homepage. Otherwise it displays the Drupal username.

According to this thread, the dev version seems to have solved this problem, so I tried with the dev (2009-Jul-08) version.

Everything seems fine, and the realnames are calculated well. Then I saw the "Overwrite user fields in view to show realnames" option, which was unchecked by default. So I checked it and click the save button. The page refreshed, and the option was still there unchecked. I tried several times with no luck.

I checked the code and add

variable_set('realname_view', $form_state['values']['realname_view']);

at line 150 in realname.admin.inc. Then the option "Overwrite user fields in view to show realnames" can be checked.

But realname is still not working with views. I can't see the advertised new filter or field. Nor can it display realname when not linking to user's homepage. I'm using views version 6.x-2.6.

I've spent two days on this and I'm almost desperate now...

#30

NancyDru - October 1, 2009 - 15:27
Status:active» fixed

Fixed by #579040: Some bugfixes.

#31

NancyDru - October 14, 2009 - 23:14
Status:fixed» closed

Included in 6.x-1.3

 
 

Drupal is a registered trademark of Dries Buytaert.