You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2023-08-14 12:42:41

Lafkis
Member
Registered: 2023-08-14
Posts: 1

GLPI Notification Tags

Hello.

I am self-hosting GLPI 10.0.9 on Windows using WAMP.
For E-mail receivers and Notifications I am using OAuth Plugin for Outlook365 connection.

Because of the plugin, BASE_URL for GLPI is "http : // localhost", but as it is locally hosted, it doesn't matter for me.
On DNS server, I've got an A HOST to redirect all traffic to http : // glpi.local for ease of use for users, instead of using the IP address.

In the E-mail notifications, there is a ##ticket.urlapprove## / ##glpi.url## and other possible tags that return the URL of the ticket.
I would like to change the behavior of this dynamic variable to only spit out the end of the URL without the BASE_URL.

From: h t t p : // localhost /index.php ?redirect=ticket_123_Ticket%123&noAUTO=1  [Because obviously, if this is sent out in the e-mail, the user won't be able to access it]
To:     /index.php?redirect=ticket_123_Ticket%123&noAUTO=1

So I could manually write the start of the URL in there, but I can't find where this behaviour is coded, went through the DB, Files, SRC, countless of .HTML files, .PHP files etc, but I can't seem to find where it has been coded and where could I change it.

Any help will be appreciated.

Offline

#2 2023-08-15 13:17:55

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,813
Website

Re: GLPI Notification Tags

Hello,

I answered on Discord, but here is a summary of my response for you or others that may find the post.

1. URLs in notifications should all be processed by the "formatURL" function in the "src/NotificationTarget.php" file. That is where the relative URLs have the base URL prepended to them.
2. The preferred method of handling this is not to modify the GLPI source code (which would make updating more complex), but have a custom plugin that adds new tags with the alternate base URL. The related plugin hook is named "get_item_datas" and the "credit" plugin would be a good reference for how to implement that plugin hook.

Related documentation and links:
Developer documentation: https://glpi-developer-documentation.re … index.html
Credit plugin code: https://github.com/pluginsGLPI/credit


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

Board footer

Powered by FluxBB