tomolimo / mailanalyzer

Mail Analyzer GLPI Plugin may be used to combine CC mails into one Ticket
25 stars 10 forks source link

Question #2

Closed koda0601 closed 8 years ago

koda0601 commented 8 years ago

Hello, I found your mail on glpi forum and don't know how to contact you directly... I was looking exactly the same what yoe wrote: "We have implemented in a plugin the possibility to send emails to GLPI 'On Behalf Of' another requester. I explain:

This is perfect! it works and we can forward email to GLPI 'On Behalf Of' the original sender."

Question: is this plugin available anywhere?

tomolimo commented 8 years ago

Hello,

The feature is in mailanalyzer plugin, here http://plugins.glpi-project.org/#/plugin/mailanalyzer but not yet documented,

Any received emails which contains in the message body a text that matches the following regex: /##From: ([_a-z0-9-\' ]+), ([_.a-z0-9- ]+)/i will be created with requester the person mentioned after the ##From

But it has currently some restrictions: 1) The mentioned ##From requester must have one and only one 'post-only' authorization line (and 'post-only' profile has the id of 1). The entity for the 'post-only' profile authorization is used for the ticket entity (that's why one and only one 'post-only' is mandatory). 2) The fix that I showed above (http://forum.glpi-project.org/viewtopic.php?pid=165602#p165602) must be done into the GLPi sources for all versions <= 0.90. For GLPi 0.91 it's already done in the core.

From: Le Forrestier, Martin

From: L'Homme, Jean-Louis

From: Test01, Test-01

From: Carrel, John

From: Carrel-Lamers, Luke

If you need any more help, please post here: https://github.com/tomolimo/mailanalyzer/issues

Thank you, Regards, Tomolimo

koda0601 commented 8 years ago

Thank you for such a quick answer. I will test it. Thanks!!!

koda0601 commented 8 years ago

I am back. Could you explain more: 1) The mentioned ##From requester must have one and only one 'post-only' authorization line (and 'post-only' profile has the id of 1). The entity for the 'post-only' profile authorization is used for the ticket entity (that's why one and only one 'post-only' is mandatory).

I am not advanced familiar with glpi - I used it only on daily routine... The link on forum which you mentioned is broken: http://forum.glpi-project.org/viewtopic.php?pid=165603#p165603

tomolimo commented 8 years ago

Hello, 1) Sorry for the link: it is fixed in the post 2) About Tickets and Entities, A ticket is in an entity (could be 'Root entity' if you are not using the Entities). And when you create a ticket it is always assigned to the current entity (If Entities are not used then it will be 'Root Entity'). We, in my company, are using the Entities to reflect our internal subsidiary hierarchy (an entity is a company), so when creating a ticket with the web interface, a 'Post-only' (special profile = 'self-service' which uses 'simplified interface') user will create a ticket in its own Entity (= on user form you can assigned a user to a profile + entity). This special profile must be with an internal DB id of 1 (is hard coded in my plugin). Regards, Tomolimo

koda0601 commented 8 years ago

Hello, correct me if I am wrong: My emails From looks like: From: Name Surname Then I check whether this part of SQL is correct: where glpi_users.realname LIKE '".trim( $matches[2][0] )."' and glpi_users.firstname like '".trim( $matches[1][0] )."'

Then this part: // set user_id and user_entity only if 'post-only' profile is found and unique $entity = Profile_User::getEntitiesForProfileByUser( $locUser->getID(), 1 ) ; If user 'post-only' has ID =3 should I change above 1 in code to 3? Should I do anything else? I am not familiar with plugins but it is possible to debug it somehow? Is anything else what should be enabled? I found a parameter: Allow anonymous ticket creation (helpdesk.receiver) - but have no idea what is it for...

tomolimo commented 8 years ago

Hello You may need to change the regex too (the comma is hard-coded into it) /##From: ([_a-z0-9-\' ]+), ([_.a-z0-9- ]+)/i See in the middle of the regex. If your format has no comma between firstname and lastname, then you may not be able to match firstname containing spaces (=char(32)). And your regex should look like /##From: ([_.a-z0-9-]+) ([_a-z0-9-\' ]+)/i

where glpi_users.realname LIKE '".trim( $matches[2][0] )."' and glpi_users.firstname like '".trim( $matches[1][0] )."'

is correct. and

If user 'post-only' has ID =3 should I change above 1 in code to 3?

also.

Debugging plugin is possible: I do it most of my time :smile: But if you don't have the knowledge, it will be hard path to explain in posts...

Anonymous ticket creation is to authorize ticket creation for users who are not GLPI users: it has nothing to so with the ##From feature.

koda0601 commented 8 years ago

Comma between name and surname. I thought about it yesterday evening but it was too late and out of my working hours and forgot about it today... Thanks! Due to debug: I thought to use function which is responisble to write log to \files_log\php-errors It would be the easiest I think... Do you know this function? I would probably use ldap string on users - the name and surname is correct there and dont have to split it.

tomolimo commented 8 years ago

for traces into log files, use the Toolbox::logDebug( str1, str2, ...) unlimited parameter list

koda0601 commented 8 years ago

Perfecto. It works. With logInFile function. in my situation I had to set to 'self-service' profile Thank you for your help!!!! ;-)