<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Themusicase.com &#187; osticket</title>
	<atom:link href="http://www.themusicase.com/blog/tag/osticket/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.themusicase.com/blog</link>
	<description>Royalty free music</description>
	<lastBuildDate>Sun, 17 Mar 2013 18:36:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<p class="updated" itemscope itemtype="http://schema.org/WebPage" itemid="http://www.themusicase.com/blog/osticket-staff-reply-from-email-technique/">By <span class="author vcard"><span class="fn"><a rel="author" href="http://www.themusicase.com/blog/author/admin/" class="authorsure-author-link">Themusicase.com</a></span></span> at <time itemprop="dateModified" datetime="2012-07-13T11:59:44+00:00">July 13, 2012</time>.</p>	<item>
		<title>OsTicket Staff Reply from Email Technique</title>
		<link>http://www.themusicase.com/blog/osticket-staff-reply-from-email-technique/</link>
		<comments>http://www.themusicase.com/blog/osticket-staff-reply-from-email-technique/#comments</comments>
		<pubDate>Fri, 25 May 2012 10:55:47 +0000</pubDate>
		<dc:creator>Bill Kirimkiridis</dc:creator>
				<category><![CDATA[Developing]]></category>
		<category><![CDATA[osticket]]></category>
		<category><![CDATA[stuff email reply]]></category>

		<guid isPermaLink="false">http://www.themusicase.com/blog/?p=201</guid>
		<description><![CDATA[We have recently installed osticket 1.6 for support ticket system. One of the features that osTicket 1.6 does not have is the ability for the staffs to reply on a ticket thought email. Think that you are on vacations and a customer creates a ticket that you receive on your smartphone and the answer is <a class="read-more-link" href="http://www.themusicase.com/blog/osticket-staff-reply-from-email-technique/"><br />...read more</a>]]></description>
				<content:encoded><![CDATA[<p>We have recently installed osticket 1.6 for support ticket system.</p>
<p>One of the features that osTicket 1.6 does <strong>not</strong> have is the ability for the staffs to reply on a ticket thought email.</p>
<p>Think that you are on vacations and a customer creates a ticket that you receive on your smartphone and the answer is something that you can send it right away.</p>
<p>Well with a little hack this can be done so i am posting here the solution.<br />
<strong>This technique only works if you enable piping.</strong></p>
<p><strong>on /api/pipe.php<br />
osTicket 1.6 code Line 93</strong><br />
<code><br />
$ticket=null;<br />
if(preg_match ("[[#][0-9]{1,10}]",$var['subject'],$regs)) {<br />
$extid=trim(preg_replace("/[^0-9]/", "", $regs[0]));<br />
$ticket= new Ticket(Ticket::getIdByExtId($extid));<br />
//Allow mismatched emails?? For now hell NO.<br />
if(!is_object($ticket) || strcasecmp($ticket-&gt;getEmail(),$var['email']))<br />
$ticket=null;<br />
}<br />
$errors=array();<br />
$msgid=0;<br />
if(!$ticket){ //New tickets...<br />
$ticket=Ticket::create($var,$errors,'email');<br />
if(!is_object($ticket) || $errors){<br />
api_exit(EX_DATAERR,'Ticket create Failed '.implode("\n",$errors)."\n\n");<br />
}<br />
$msgid=$ticket-&gt;getLastMsgId();<br />
}else{<br />
$message=$var['message'];<br />
//Strip quoted reply...TODO: figure out how mail clients do it without special tag..<br />
if($cfg-&gt;stripQuotedReply() &amp;&amp; ($tag=$cfg-&gt;getReplySeparator()) &amp;&amp; strpos($var['message'],$tag))<br />
list($message)=split($tag,$var['message']);<br />
//post message....postMessage does the cleanup.<br />
if(!($msgid=$ticket-&gt;postMessage($message,'Email',$var['mid'],$var['header']))) {<br />
api_exit(EX_DATAERR,"Unable to post message \n\n $message\n");<br />
}<br />
}<br />
</code></p>
<p><strong>Replace with new code</strong><br />
<code><br />
$ticket=null;<br />
$response_stuff=0;<br />
$staff_id=0;<br />
if(preg_match ("[[#][0-9]{1,10}]",$var['subject'],$regs)) {<br />
$extid=trim(preg_replace("/[^0-9]/", "", $regs[0]));<br />
$ticket= new Ticket(Ticket::getIdByExtId($extid));<br />
//Allow mismatched emails?? For now hell NO.<br />
if(!is_object($ticket) || strcasecmp($ticket-&gt;getEmail(),$var['email'])){<br />
//$ticket=null;<br />
$sql="SELECT username,staff_id FROM " . STAFF_TABLE . " WHERE email='" . $var['email'] . "' ";<br />
$query=db_query($sql);<br />
while($row = mysql_fetch_array($query)) {<br />
$senderUsername = $row['username'];<br />
$staff_id=$row['staff_id'];<br />
}</p>
<p>if (!$senderUsername){<br />
$ticket=null;<br />
}<br />
else<br />
{<br />
$response_stuff=1;<br />
}<br />
}<br />
}<br />
$errors=array();<br />
$msgid=0;<br />
if(!$ticket){ //New tickets...<br />
$ticket=Ticket::create($var,$errors,'email');<br />
if(!is_object($ticket) || $errors){<br />
api_exit(EX_DATAERR,'Ticket create Failed '.implode("\n",$errors)."\n\n");<br />
}<br />
$msgid=$ticket-&gt;getLastMsgId();<br />
}else{<br />
$message=$var['message'];<br />
//Strip quoted reply...TODO: figure out how mail clients do it without special tag..<br />
if($cfg-&gt;stripQuotedReply() &amp;&amp; ($tag=$cfg-&gt;getReplySeparator()) &amp;&amp; strpos($var['message'],$tag))<br />
list($message)=split($tag,$var['message']);<br />
//post message....postMessage does the cleanup.<br />
if($response_stuff==1){<br />
if(!($ticket-&gt;postResponse($ticket-&gt;getMessageId(),$message,'none',false,true,$staff_id))){<br />
api_exit(EX_DATAERR,"Unable to post message \n\n $message\n");<br />
}<br />
}<br />
else<br />
{<br />
if(!($msgid=$ticket-&gt;postMessage($message,'Email',$var['mid'],$var['header']))) {<br />
api_exit(EX_DATAERR,"Unable to post message \n\n $message\n");<br />
}<br />
}<br />
}<br />
</code><br />
<strong>on /include/class.ticket.php<br />
add this function<br />
</strong><br />
<code><br />
function getMessageId(){<br />
$cur_mes_id=0;<br />
$sql ='SELECT max(msg_id) FROM '.TICKET_MESSAGE_TABLE.' WHERE ticket_id='.db_input($this-&gt;getId());<br />
if(($res=db_query($sql)) &amp;&amp; db_num_rows($res))<br />
list($cur_mes_id)=db_fetch_row($res);<br />
return $cur_mes_id;<br />
}<br />
</code></p>
<p><strong>and add this on function postResponse</strong><br />
<code><br />
function postResponse($msgid,$response,$signature='none',$attachment=false,$canalert=true,$_staff_id=0){<br />
global $thisuser,$cfg;<br />
//global $cfg;<br />
if($_staff_id!=0){<br />
$ip="0.0.0.0";<br />
$thisuser=new Staff($_staff_id);<br />
}<br />
else<br />
{<br />
$ip=$thisuser-&gt;getIP();<br />
}</p>
<p>if(!$thisuser || !$thisuser-&gt;getId() || !$thisuser-&gt;isStaff()) //just incase<br />
return 0;</p>
<p>$sql= 'INSERT INTO '.TICKET_RESPONSE_TABLE.' SET created=NOW()'.<br />
',ticket_id='.db_input($this-&gt;getId()).<br />
',msg_id='.db_input($msgid).<br />
',response='.db_input(Format::striptags($response)).<br />
',staff_id='.db_input($thisuser-&gt;getId()).<br />
',staff_name='.db_input($thisuser-&gt;getName()).<br />
',ip_address='.db_input($ip);<br />
</code><br />
the rest are the same&#8230;..</p>

<div class="jwsharethis">
Share this: 
<br />
<a href="mailto:?subject=OsTicket%20Staff%20Reply%20from%20Email%20Technique&amp;body=http%3A%2F%2Fwww.themusicase.com%2Fblog%2Fosticket-staff-reply-from-email-technique%2F">
<img src="http://www.themusicase.com/blog/wp-content/plugins/jw-share-this/email.png" alt="Share this page via Email" />
</a>
<a target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.themusicase.com%2Fblog%2Fosticket-staff-reply-from-email-technique%2F&amp;title=OsTicket+Staff+Reply+from+Email+Technique">
<img src="http://www.themusicase.com/blog/wp-content/plugins/jw-share-this/su.png" alt="Share this page via Stumble Upon" />
</a>
<a target="_blank" href="http://digg.com/submit?url=http%3A%2F%2Fwww.themusicase.com%2Fblog%2Fosticket-staff-reply-from-email-technique%2F&amp;title=OsTicket+Staff+Reply+from+Email+Technique">
<img src="http://www.themusicase.com/blog/wp-content/plugins/jw-share-this/digg.png" alt="Share this page via Digg this" />
</a>
<a target="_blank" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.themusicase.com%2Fblog%2Fosticket-staff-reply-from-email-technique%2F&amp;t=OsTicket+Staff+Reply+from+Email+Technique">
<img src="http://www.themusicase.com/blog/wp-content/plugins/jw-share-this/fb.png" alt="Share this page via Facebook" />
</a>
<a target="_blank" href="http://twitter.com/intent/tweet?text=I+like+http%3A%2F%2Fwww.themusicase.com%2Fblog%2Fosticket-staff-reply-from-email-technique%2F&amp;title=OsTicket+Staff+Reply+from+Email+Technique">
<img src="http://www.themusicase.com/blog/wp-content/plugins/jw-share-this/twitter.png" alt="Share this page via Twitter" />
</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.themusicase.com/blog/osticket-staff-reply-from-email-technique/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
