How To use CustomerUser Map to link images (http-link)

Dont create your support topics here! No new topics with questions allowed!

Moderator: crythias

Forum rules
Dont create your support topics here! No new topics with questions allowed!
Post Reply
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

How To use CustomerUser Map to link images (http-link)

Post by crythias »

What is this HowTo supposed to do?
Overload the "http-link" entry in the User Map to do things, like maybe calling a link to an image.
You'll like this post.

If you want to do this in stock (database) OTRS, you'll want to make sure the entire CustomerUser section is in Config.pm (copy from Defaults.pm):

Code: Select all

    $Self->{CustomerUser} = {
#################################################################################################
#... other content from Defaults.pm was not pasted in this post ... you still need to copy them #
#################################################################################################
        Map => [
            # note: Login, Email and CustomerID needed!
            # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly, http-link-target
            [ 'UserSalutation', 'Salutation', 'salutation', 1, 0, 'var', '', 0 ],
            [ 'UserFirstname',  'Firstname',  'first_name', 1, 1, 'var', '', 0 ],
            [ 'UserLastname',   'Lastname',   'last_name',  1, 1, 'var', '', 0 ],
            [ 'UserLogin',      'Username',   'login',      1, 1, 'var', '', 0 ],
            [ 'UserPassword',   'Password',   'pw',         0, 0, 'var', '', 0 ],
            [ 'UserEmail',      'Email',      'email',      1, 1, 'var', '', 0 ],
#            [ 'UserEmail',      'Email', 'email',           1, 1, 'var', '$Env{"CGIHandle"}?Action=AgentTicketCompose&ResponseID=1&TicketID=$Data{"TicketID"}&ArticleID=$Data{"ArticleID"}', 0 ],
            [ 'UserCustomerID', 'CustomerID', 'customer_id', 0, 1, 'var', '', 0 ],
#            [ 'UserCustomerIDs', 'CustomerIDs', 'customer_ids', 1, 0, 'var', '', 0 ],
            [ 'UserPhone',        'Phone',       'phone',        1, 0, 'var', '', 0 ],
            [ 'UserFax',          'Fax',         'fax',          1, 0, 'var', '', 0 ],
            [ 'UserMobile',       'Mobile',      'mobile',       1, 0, 'var', '', 0 ],
            [ 'UserStreet',       'Street',      'street',       1, 0, 'var', '', 0 ],
            [ 'UserZip',          'Zip',         'zip',          1, 0, 'var', '', 0 ],
            [ 'UserCity',         'City',        'city',         1, 0, 'var', '', 0 ],
            [ 'UserCountry',      'Country',     'country',      1, 0, 'var', '', 0 ],
            [ 'UserComment',      'Comment',     'comments',     1, 0, 'var', '', 0 ],
            [ 'ValidID',          'Valid',       'valid_id',     0, 1, 'int', '', 0 ],
        ],

    };
Note: DO NOT TOUCH Defaults.pm! It gets overwritten upon upgrade!

The code that handles index 6 (http link) and index 8 (target) is in Kernel/Output/HTML/LayoutTicket.pm:

Code: Select all

Field 6
            if ( $Field->[6] ) {
                $Record{LinkStart} = "<a href=\"$Field->[6]\"";
                if ( $Field->[8] ) {
                    $Record{LinkStart} .= " target=\"$Field->[8]\"";
                }
                $Record{LinkStart} .= "\">";
                $Record{LinkStop} = "</a>";
            }

Some background:
The entry with index 6 (after "var") is intended to be a hyperlink that surrounds the field. index 8 (last entry after read-only "0") if it exists, will be used for "target" of html. "_blank" opens new page/new window, for instance.

You can link the field to practically anything, such as

Code: Select all

            [ 'UserCity',         'City',        'city',         1, 0, 'var', 'http://maps.google.com/?q=$Data{"UserCity"},$Data{"UserZip"}', 0,"_blank" ], #What's this? a city map on click, in a new window? 
            [ 'UserLogin',      'Username',   'login',      1, 1, 'var', '$Env{"CGIHandle"}?Action=AdminCustomerUser&Subaction=Change&ID=$Data{"UserLogin"}', 0 ], #the username goes to edit screen

I'd love to put the gravatar image above the First Name using this method, but since there's no easy way to make the MD5 hash, I'd leave that in the .dtl

There's a javascript implementation of MD5, so passing $Data{UserEmail} to the MD5summer javascript function and returning http://www.gravatar.com/avatar/md5sumresult in an image tag isn't totally out of the question.
Wait. you said "image!"
oh? :)

Code: Select all

            [ 'UserFirstname',  'Firstname',  'first_name', 1, 1, 'var', '#"><img src="http://www.gravatar.com/avatar" /></a><a href="#', 0 ],
There's a little "injection" in this that terminates the original anchor, includes and hyperlinks the img, and begins another anchor tag so the tags end rather/mostly cleanly.
The first occurrence of "#" is the address that applies to the img tag. Because of the code above, the img *must* be hyperlinked. If you don't want that, change the .dtl, not this.
The second occurrence of "#" is the address that applies to the field (text). It is necessary to be there because the code forces the termination of (it appends "> to) the hyperlink string, since it exists in the entry.
Of course, you can replace "#" with something more relevant.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To use CustomerUser Map to link images (http-link)

Post by crythias »

so, what else can you do?

If you love to manipulate things with javascript You could use something like:

Code: Select all

'#" id="findme" class="red" title="$Data{"UserEmail"}" onmouseover="doSomethingWith($Data{"UserCountry"})'
Note: the code here is an example. If you plug it in verbatim, you'll get errors because there is no function called "dosomethingwith", the class of "red" may not exist, the id "findme" may not be relevant to your CSS (though you can make easy reference in javascript: document.getElementById("findme");), and of course "#" goes nowhere.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
suntzu
Znuny newbie
Posts: 4
Joined: 28 Jul 2010, 15:01
Znuny Version: 2.4.7

Re: How To use CustomerUser Map to link images (http-link)

Post by suntzu »

Sorry, my coding skills are not great. Could you elaborate on where the "customer custom field" is within your posted example in this forum? We really want to get the integration between zenoss and otrs as solid as possible, so any additional pointers you have would be greatly appreciated. We think that otrs and zenoss are a killer combination - thank you!

Re: http://community.zenoss.org/docs/DOC-10247

/s
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To use CustomerUser Map to link images (http-link)

Post by crythias »

I don't know what explicitly you're requesting, but let's assume that the variable you're requesting has been added as an ALTER to the customer database.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Harty
Znuny newbie
Posts: 21
Joined: 11 Apr 2013, 12:25
Znuny Version: 4.0.8

Re: How To use CustomerUser Map to link images (http-link)

Post by Harty »

Hello,

I want to add a link to the UserPhone variable. Something like this:

[ 'UserPhone', 'Phone', 'phone', 1, 0, 'var', 'tel:$Data{"UserPhone"}, 0 ],

Actually it doesn't work. The phone number is clickable, but the link is truncated to "tel:$Data{".
Any idea? Whats wrong in my syntax? The example in the thread with UserCity and "http://maps.google.com/..." doesn't work too.

Thanks
OTRS: 4.0.8
OS: OTRS Appliance
DB: PostgreSQL
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: How To use CustomerUser Map to link images (http-link)

Post by crythias »

In version 4, the links are generated with the new Template code. See Defaults.pm example: .

Code: Select all

            [ 'UserEmail',      'Email', 'email',           1, 1, 'var', '[% Env.CGIHandle %]?Action=AgentTicketCompose;ResponseID=1;TicketID=[% Data.TicketID | uri %];ArticleID=[% Data.ArticleID | uri %]', 0, '', 'AsPopup OTRSPopup_TicketAction' ],
$Data{"UserEmail"} should be replaced by

Code: Select all

[% Data.UserEmail | uri %]
(Don't forget to terminate apostrophe delimiter!)

Code: Select all

[ 'UserPhone', 'Phone', 'phone', 1, 0, 'var', 'tel:$Data{"UserPhone"}', 0 ],
should be replaced by

Code: Select all

[ 'UserPhone', 'Phone', 'phone', 1, 0, 'var', 'tel:[% Data.UserPhone | uri %]', 0 ],
(untested, but should follow suit)
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Harty
Znuny newbie
Posts: 21
Joined: 11 Apr 2013, 12:25
Znuny Version: 4.0.8

Re: How To use CustomerUser Map to link images (http-link) [Solved]

Post by Harty »

Thanks a lot for your reply. That's what I'm looking for.

####
should be replaced by
CODE: ALLES AUSWÄHLEN
[ 'UserPhone', 'Phone', 'phone', 1, 0, 'var', 'tel:[% Data.UserPhone | uri %]', 0 ],
####
OTRS: 4.0.8
OS: OTRS Appliance
DB: PostgreSQL
carstenF
Znuny newbie
Posts: 1
Joined: 29 Jan 2016, 11:51
Znuny Version: 5.0.6

Re: How To use CustomerUser Map to link images (http-link)

Post by carstenF »

Hi

I added the following line in my ldap-configfile:
[ 'UserHomeDir', 'HomeDir', 'homeDirectory', 1, 0, 'var', '', 0 ],
thats working fine!

now i want insert a link to the homedirectory. something like this:

[ 'UserHomeDir', 'HomeDir', 'homeDirectory', 1, 0, 'var', '\\servername\sharename\userhome', 0, _blank ],

is this possible? I can't find the correct syntax!

greez
Carsten
Post Reply