Page 1 of 1

Category select by user via email (POP3 Fetching)

Posted: Tue Nov 19, 2013 7:40 am
by slide
Hello! I really like HESK, it is a very good product that really helped me.

The only thing I need is the automatic assignment of categories from mail using pop3 fetching. That is, we give the client, for example, the pattern in which the:
1 - general category, 2 - problems, etc.
User wrote in a letter category id, for example at the beginning of the letter:
"category = 1"
And the ticket created in category equal to the id, which is indicated by the user.

Something like this ) it is even possible to do?

Re: Category select by user via email (POP3 Fetching)

Posted: Sat Jan 04, 2014 10:19 pm
by holographic
I would like to do something like this as well..

I want to use a custom (HTML) form to send an email to hesk. Can I use a hidden field to specify the category?

I have tried several ways but none seem to work. Any ideas?

Re: Category select by user via email (POP3 Fetching)

Posted: Sun Jan 05, 2014 11:10 am
by Klemen
There is no built-in way of doing it.

The quickest way to get this working would be to add something like this to the email message somewhere (at start, end, ... doesn't matter):

Code: Select all

{CATEGORY=1}
Then you could change this code in "inc/pipe_functions.inc.php"

Code: Select all

$tmpvar['category'] 	= 1;
to

Code: Select all

$tmpvar['category'] = ( preg_match('/\{CATEGORY=([0-9]{1,})\}/', $tmpvar['message'], $m) ) ? $m[1] : 1;
So, if you wanted to select category with ID 15 you would include this in the email message:

{CATEGORY=15}

Re: Category select by user via email (POP3 Fetching)

Posted: Wed Jan 08, 2014 10:17 pm
by dr_patso
Beautiful.

Re: Category select by user via email (POP3 Fetching)

Posted: Sun Mar 09, 2014 7:58 am
by alfredm
Any way to get this mod to work with the pop3 functionality?

Re: Category select by user via email (POP3 Fetching)

Posted: Sun Mar 09, 2014 11:56 am
by Klemen
It's the same file/code.

Re: Category select by user via email (POP3 Fetching)

Posted: Thu Feb 05, 2015 8:47 pm
by dr_patso
what kind of logic can be added for a user to make this change in a reply? adding this code only works for brand new tickets.

Re: Category select by user via email (POP3 Fetching)

Posted: Fri Feb 13, 2015 11:54 pm
by dr_patso
okay, this works. Maybe not the best way but from my testing it appears to work.


in /inc/pipe_functions.inc.php below this line

Code: Select all

	if ($is_reply)
	{

Add

Code: Select all

		// Set category
		if ( preg_match('/\{CATEGORY=([0-9]{1,})\}/', $tmpvar['message'], $matches) )
		{
			$tmpvar['category'] = ( preg_match('/\{CATEGORY=([0-9]{1,})\}/', $tmpvar['message'], $m) ) ? $m[1] : 1;
			hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `category`='{$tmpvar['category']}' WHERE `id`='".intval($ticket['id'])."' LIMIT 1");
		}
This will give you the ability to update category in a reply.. It will not modify category if there is no match for {CATEGORY=ID} in the message