Page 1 of 1

any help on assigning user on ticket created from e-mail?

Posted: Sun Sep 29, 2013 7:55 am
by dr_patso
Need just some direction on modifying logic of pipe_functions.inc.php

Code: Select all

	// Auto assign tickets if aplicable
	$tmpvar['owner']   = 0;
If I modify that 0 to a specific user ID, it works and tickets are assigned to that user. I need it to work like this

Code: Select all

	// Auto assign tickets if aplicable
	$tmpvar['owner']   = If FROM e-mail address matches hesk_users.e-mail set corresponding to their user id;
I couldn't think of any similar query that exists in hesk I could steal this from..

Basically I've already modified the customer name and e-mail on ticket to be set as the TO: from the e-mail sent to hesk. Now I want the ticket to get assigned to the users e-mail it came FROM:. Any help much appreciated.. I will be digging on this for the next few weeks.

How I want my e-mail piping to work is (User sends response to customer and BCCs hesk pop account. This way when the staff sends a response, a ticket is generated for that end user and assigned to the particular staff member in hesk.

Re: any help on assigning user on ticket created from e-mail

Posted: Sun Sep 29, 2013 5:11 pm
by Klemen
Please note that teaching how to perform SQL queries is beyond the scope of this forum, there are hundreds of online PHP/MySQL tutorials.

That said, something like this should get you started:

Code: Select all

$res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `email` LIKE '".hesk_dbEscape(hesk_dbLike($tmpvar['email']))."' LIMIT 1");
if (hesk_dbNumRows($res) == 1)
{
	$row = hesk_dbFetchAssoc($res);
	$tmpvar['owner'] = $row['id'];
}

Re: any help on assigning user on ticket created from e-mail

Posted: Sun Sep 29, 2013 11:44 pm
by dr_patso
hehe, that worked. You freakin rock Klemen. Since i modified $tmpvar['email'] to use the To: address, I just created a new $tmpvar['from_email'] and used that in the query.

I understand SQL queries a bit and might have figured it out eventually but i am not familiar with all the hesk query functions like you included there. If you feel like you can chime in, what is the best way to get familiar with the RAW code for those functions like hesk_dbquery hes_dblike, hesk_dbnumrows etc.? when i do a find in files search it's hard to locate the source when so many files are using the function.

Re: any help on assigning user on ticket created from e-mail

Posted: Mon Sep 30, 2013 12:26 pm
by Klemen
Most functions used are in files located inside the "inc" folder. The database ones for example are in the "database.inc.php" and "database-mysqli.inc.php" files (one is loaded for MySQL and one for MySQLi extension).