znuny / Znuny

Znuny/Znuny LTS is a fork of the ((OTRS)) Community Edition, one of the most flexible web-based ticketing systems used for Customer Service, Help Desk, IT Service Management.
https://www.znuny.org
GNU General Public License v3.0
332 stars 82 forks source link

Bug - Mention with @ is wrong #532

Closed BurtGummer closed 1 week ago

BurtGummer commented 5 months ago

Hello,

that's the only reason why we can't use this great feature: We use a number as login, not the real name. This means that @12345 and not @firstname lastname is displayed in the ticket body. I can search with the Realname and I got a list with "Firstname Lastname". But after I select a User, its changed to @12345.

Is there any way to configure WHAT is displayed at this point?

Znuny 6.5.5, Debian 11, OpenLDAP.

tgurr commented 5 months ago

I initially tried to fix this but failed with https://github.com/znuny/Znuny/pull/436 (and failed because sadly its not that simple as I initially thought) and was adviced to create an issue in the feature-request repository instead https://github.com/znuny/znuny-feature-requests/issues/51. So effectivly this is a "duplicate" however I also consider this rather a bug than a feature and sadly there hasn't been any activity in trying to address this issue yet as we're in exactly the same boat as @BurtGummer.

BurtGummer commented 5 months ago

there is also a thread about in the forum: https://community.znuny.org/viewtopic.php?f=35&t=43841&p=177871

mo-azfar commented 5 months ago

Mention fullname has been put as roadmap for 7.x here.. https://www.znuny.org/en/roadmap

Quick work around:

  1. Admin > Mentions::RichTextEditor###Templates

    • Users > OutputTemplate > {fullname} (<a class="Mention" href="#" title="{fullname}">@{username}</a>)
  2. https://github.com/znuny/Znuny/blob/dc3ab69eda71887841fc65602e6321002fe21167/Kernel/Output/HTML/TicketZoom/Mentions.pm#L54

UserEmail => $User{UserEmail},
(+) UserFullname => $User{UserFullname},
  1. https://github.com/znuny/Znuny/blob/dc3ab69eda71887841fc65602e6321002fe21167/Kernel/Output/HTML/Templates/Standard/AgentTicketZoom/MentionsTable.tt#L20
(-) <span>[% Data.UserLogin | html %]</span>
(+) <span>[% Data.UserFullname | html %] - [% Data.UserLogin | html %]</span>

Mention text mention

Mention dashboard mention-dashboard

Mention history mention-history

Mention toolbar mention-toolbar

Mention ticket widget mention-widget

I DID NOT CHECK AGAINST EMAIL. DO TEST YOURSELF

hanneshal commented 5 months ago

Hi,

you both are correct. It is not that simple and it would be nice to have it changed.

Maybe it helps @tgurr when I explain how this all works together:

A user creates a mention in the gui. We store this info in a link, which is later identified by this code:

Kernel::System::Ticket::Event::Mentions; L:70

my $MentionedUserIDs = $MentionObject->GetMentionedUserIDsFromString(
    HTMLString      => $HTMLBody,
    PlainTextString => $Article{Body} // '',
    Limit           => $MentionsLimit,
);
In 
> Kernel::System::Mention;
> L:559

the check against that is performed. 

```Perl
sub GetMentionedUserIDsFromString {
    ...
    ...
    my @MentionedUsers = (
        $Param{HTMLString}
            =~ m{<a\b[^>]*?\bclass="Mention"[^>]*?>\Q$MentionsTriggerConfig->{User}\E(.*?)<\/a>}sg
    );

    my @MentionedGroups = (
        $Param{HTMLString}
            =~ m{<a\b[^>]*?\bclass="GroupMention"[^>]*?>\Q$MentionsTriggerConfig->{Group}\E(.*?)<\/a>}sg
    );

There are multiple ways to change this:

and of course, replace the output template.

    <Setting Name="Mentions::RichTextEditor###Templates" Required="0" Valid="1">
        <Description Translatable="1">Frontend registration of input/output templates for mention plugin of CKEditor.</Description>
        <Navigation>Core</Navigation>
        <Value>
            <Hash>
                <Item Key="Users">
                    <Hash>
                        <Item Key="ItemTemplate">&lt;li class="Mention" data-id="{id}"&gt;{fullname}&lt;/li&gt;</Item>
                        <Item Key="OutputTemplate">&lt;a class="Mention" href="#"&gt;@{username}&lt;/a&gt; </Item>
                    </Hash>
                </Item>
                <Item Key="Groups">
                    <Hash>
                        <Item Key="ItemTemplate">&lt;li class="Mention" data-id="{id}"&gt;{name} ({mentionLabel})&lt;/li&gt;</Item>
                        <Item Key="OutputTemplate">&lt;a class="GroupMention" href="#"&gt;{name}&lt;/a&gt; </Item>
                    </Hash>
                </Item>
            </Hash>
        </Value>
    </Setting>

maybe this points to the correct direction to update the PR. As already mentioned, it is on the roadmap for 7.1. A backport is not planned at the moment.

Regards and thank you for contributing. Johannes

BurtGummer commented 3 months ago

Mention fullname has been put as roadmap for 7.x here.. https://www.znuny.org/en/roadmap

Quick work around:

  1. Admin > Mentions::RichTextEditor###Templates
  • Users > OutputTemplate > {fullname} (<a class="Mention" href="#" title="{fullname}">@{username}</a>) [...]

Does someone try this solution? Normaly I dont like changing the code .. 🤔

NiklasSchmitt commented 1 week ago

The feature to use the user fullname as mention label will be fixed within the upcoming Znuny 7.1.1