If i use realname module - i can't send messages. There some issues relate to autocomplete widget
1. checkPrivateMessageMemberExists method in Mapper\PrivateMessageMapper.php. method can't find user by his realname. so, when you open add message form - validation of user name fails.
2. even if validation if checkPrivateMessageMemberExists success, after submit form appearing message "There are no entities matching "USERNAME". Origin in validateEntityAutocomplete (Drupal/Core/Entity/Element/EntityAutocomplete.php) which don't get uid in username, because submitted name don't have it. Submitted value is "USERNAME", instead of "USERNAME (UID)". When form loaded in first time i can see that http://prntscr.com/k8ypcn (default value like "USERNAME (UID)"), but if check value, it's already will be without uid http://prntscr.com/k8ypui . So, some javascript change it.
Hope this help and someone can continue searching to fix this incompatibility with realname module.

Problem in private_message_members_widget.js, in init method. addUserToMembers called without uid.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

cosolom created an issue. See original summary.

cosolom’s picture

Issue summary: View changes
cosolom’s picture

Issue summary: View changes
cosolom’s picture

Issue summary: View changes
adam clarey’s picture

StatusFileSize
new209.96 KB

This issue exists in version 8-1.2 too.

It can't find the entity references because the (uid) is removed. I've attached a patch that makes realname integration possible in 1.2, i suspect something similar can be used for version 2

phjou’s picture

According to the documentation of the module, only the 2.x branch should receive new features.

Development has begun on version 8.x-2.0. Version 1.0 will only receive bugfixes, and no new features. Any new features will be introduced in the 2.0 branch.

Moreover the patch is completely wrong, I suppose it should only bring this change:

-          $(this).val(username + ' (' + uid + ')');
+          $(this).val(username);

I am not sure what this change implies.

madelyncruz’s picture

This issue still exists in 8.x-1.2. I've looked at the file /private_message/js/private_message_members_widget.js. It looks like that the code change for $(this).val(username); has been merged, but looks like it does not fixed the issue.

ekulkisnek’s picture

i had the same problem and i used private_message_module_implements_alter() to prevent all realname hooks from occurring in the private message module. realnames do not show up in private message threads but it allows for realname use on the rest of the site. i'm currently working on a way to display the realname in threads. if you've found a better fix or can help with that let me know

function private_message_module_implements_alter(&$implementations, $hook) {
    switch($hook) {
        case 'entity_extra_field_info':
        case 'user_format_name_alter':
        case 'user_load':
        case 'user_update':
        case 'user_delete':
        case 'user_view':
        case 'load':
        case 'load_multiple':
        case 'update':
            unset($implementations['realname']);
            break;
        default:
            return;
    }

}
authintmedia’s picture

Private Message is not incompatible with realname module. It is incompatible with the username format that is displayed.

If you leave the default setting of the realname to [user:account-name] everything works as expected.

Any modification to how username is displayed makes it impossible to use private message.

loze’s picture

Status: Active » Needs review
StatusFileSize
new549 bytes

This one line patch get it to not break with realname, but it would be nice to fully support it so we can display realnames.

I briefly looked at the js and saw there are several places where it pulls the username from the val() of an element, I feel it should be pulling the username form the data attribute when it needs it, this way we can still show the realname to the user.

If no one is already working on this, I'll try to dig into it in the coming weeks as I would like to use this module for a project.

has there been any progress on this from the maintainers?

loze’s picture

StatusFileSize
new5.93 KB

Ok, so I sat with it for a bit and I think I got it. It was much simpler than I thought it would be,

This patch makes it work with realname, both with the name validation and the autocomplete.
Ignore the previous patch.

I'm not sure if there is a cleaner way to do the query part that I altered, but it works.

phjou’s picture

I like the fact that the display name is now split from the username value.

Please remove:
console.log(usernameInput, 'usernameInput');

loze’s picture

StatusFileSize
new5.52 KB

My bad, here ya go.

phjou’s picture

Thanks. I will have to find some time to test the patch on an installed Drupal.

It would be awesome to have a test to be sure it is working with or without realname. This module is huge and we have almost no tests.

nishruu’s picture

StatusFileSize
new5.8 KB

Hi.
The displayed name was not inserted if the user used the down key and enter, so I added a small modification to the patch.

Apart from that, I think there's still one problem left : when we reload the page, the logic in the init() function retrieves the username to recreate the user tags, not the displayname.

inputWrapper.find('input[type="text"]').each(function () {
        var trimmedVal = $.trim($(this).val());
        if (trimmedVal.length) {
          trimmedVal = trimmedVal.replace(/\s\(\d+\)$/, '');
          $(this).val(trimmedVal);
          addUserToMembers(trimmedVal, true); // <-- No displayname
        }
});

I tried to add a data-displayname attribute to the input tag, but it cannot be preserved between page refresh so it was useless. I suppose we could make an ajax call to convert the usernames to the matching displaynames before recreating the tags ?

phjou’s picture

@Nishruu I think that the one problem left you are talking about might be that one? #3098859: The members widget is broken

drupgirl’s picture

+1 for a 8.x-3.x patch - edited - this patch is in the latest

loze’s picture

Version: 8.x-2.x-dev » 3.0.x-dev

loze changed the visibility of the branch 2987189-realname-support to hidden.

loze changed the visibility of the branch 2987189-realname-support to active.

loze’s picture

StatusFileSize
new5.23 KB

Its been some time since the original issue and patches.

Since then this module now uses the users display name instead of the username, which resolves 1/2 of what was being addressed in the original patches.

I have created MR!121 which adds realname support to the autocomplete query for the members widget if realname is installed.

here is a patch for the MR to use with composer.

loze’s picture

loze’s picture

StatusFileSize
new4.11 KB

Last patch in #22 was wrong, some unintended changes made it in there.
this one should work with composer

claudiu.cristea’s picture

Isn't this reduced to the idea of using User::getDisplayName()?

loze’s picture

@claudiu.cristea I dont believe that getDisplayName() is a queryable field, right?

I'm trying to get the auto complete search to use the compiled display name that is stored in the realname table. Otherwise the search is limited to the username which in my case my users dont know.

claudiu.cristea’s picture

Thank you. I think you're right. I'm not a very big fan of adding module soft dependencies (aka "if module exists..."). Is there any way you can hook in from a 3rd-party and alter the suggestions? At least maybe we can create a submodule to add realname support. I admit I didn't have time to give a deeper look at this

loze’s picture

Status: Needs review » Closed (works as designed)
Related issues: +#3501017: Private Message module support

Thanks. Since the original post, this module now has its own entity reference selection plugin instead of using a direct query. So I created an issue in realname to support private_message which is just a small change and it appears to be working with the 3.0 branch.

#3501017: Private Message module support

claudiu.cristea’s picture

Status: Closed (works as designed) » Active

I think now, with 4.x, it still can be fixed here.

claudiu.cristea’s picture

Version: 3.0.x-dev » 4.x-dev
claudiu.cristea’s picture

Status: Active » Needs review

@loze, could you please try MR!175 but without the Real Name patch?

loze’s picture

Yes, MR!175 does appear to do the job with version 4.0 alpha

thanks!

claudiu.cristea’s picture

Thank you, @loze

I have fixed also the schema alteration for default:user plugin settings just in case. I will merge this MR as soon as you test again the latest version MR against 4.0.0-alpha1 and confirm that works as expected by setting this issue status to RTBC

loze’s picture

Status: Needs review » Reviewed & tested by the community

Tested with alpha2 and dev and it seems to do the trick. Thanks!

  • claudiu.cristea committed 044e5de6 on 4.x
    Issue #2987189 by loze, claudiu.cristea, nishruu, adam clarey, cosolom,...
claudiu.cristea’s picture

Status: Reviewed & tested by the community » Fixed

Merged. Thank you!

claudiu.cristea’s picture

Included in 4.0.0-alpha3

Status: Fixed » Closed (fixed)

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