First off, I really like this program and am very impressed with it. I decided to add a feature for my personal use, I only spent about 15 minutes on it so its kinda hacky but I am willing to improve it (with some help from you guys) and get it into the next version if you guys want.
FEATURE: If level is Emergency and topic is "Support" send me a SMS message
Step One) Enable Emergency Level - There may be a way to do this in the admin area but I could find it.....open ost_ticket_priority and setup ispublic to 1 for Emergency in database
Step Two) Add filter statement to /open.php that does the main work....
Replace
//Ticket:...checks for errors..
if(($ticket=Ticket:($_POST,$errors,SOURCE))){
$msg='Support ticket request created';
if($thisclient && $thisclient->isValid()) //Logged in...simply view the newly created ticket.
<USERMENTION username="header">@header</USERMENTION>('Location: tickets.php?id='.$ticket->getExtId());
//Thank the user and promise speedy resolution!
$inc='thankyou.inc.php';
}else{
$errors=$errors?$errors:'Unable to create a ticket. Please correct errors below and try again!';
}
with
//Ticket:...checks for errors..
if(($ticket=Ticket:($_POST,$errors,SOURCE))){
$msg='Support ticket request created';
if ($_POST == "4" && $_POST == "1"){
$sql='SELECT email, smsuser '.
' FROM `'.EMAIL_TABLE.'`';
$emails=db_query($sql.' ORDER BY email');
while ($row = db_fetch_array($emails)) {
if ($row == "1"){
$message_to = $row;
$message_from = "noreply@yourdomain.com";
$message_subject = "Emergency Ticket";
$message_body = "Emergency Ticket Just Got Sent";
$headers = 'From: '.$message_from. "\r\n" .
'Reply-To: '. $message_from . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($message_to, $message_subject, $message_body, $headers);
}
}
}
if($thisclient && $thisclient->isValid()) //Logged in...simply view the newly created ticket.
<USERMENTION username="header">@header</USERMENTION>('Location: tickets.php?id='.$ticket->getExtId());
//Thank the user and promise speedy resolution!
$inc='thankyou.inc.php';
}else{
$errors=$errors?$errors:'Unable to create a ticket. Please correct errors below and try again!';
}
Step 3) Add checkbox to email system...../include/staff/email.inc.php I put it on line 81....
<tr><th>SMS User</th>
<td>
<input type="checkbox" name="smsuser" value=1 <?=$info? 'checked': ''?> ><b>If priority is level 4 (Emergency) and (Billing)</b> email this address.
</td>
</tr>
Step 4) Edit save and load functions in include/class.email.php
Line #50
$sql='SELECT * FROM '.EMAIL_TABLE.' WHERE email_id='.db_input($this->id);
if(($res=db_query($sql)) && db_num_rows($res)) {
$info=db_fetch_array($res);
$this->id=$info;
$this->email=$info;
$this->name=$info;
$this->address=$info?($info.'<'.$info.'>'):$info;
$this->deptId=$info;
$this->priorityId=$info;
$this->autoresp=$info?false;
$this->smsuser=$info?false;
$this->info=$info;
return true;
}
Line #363
$sql='updated=NOW(),mail_errors=0, mail_lastfetch=NULL'.
',email='.db_input($vars).
',name='.db_input(Format:($vars)).
',dept_id='.db_input($vars).
',priority_id='.db_input($vars).
',noautoresp='.db_input(isset($vars)?1).
',smsuser='.db_input(isset($vars)?1).
',userid='.db_input($vars).
',userpass='.db_input(Misc:($vars,SECRET_SALT)).
',mail_active='.db_input($vars).
',mail_host='.db_input($vars).
',mail_protocol='.db_input($vars?$vars:'POP').
',mail_encryption='.db_input($vars).
',mail_port='.db_input($vars?$vars).
',mail_fetchfreq='.db_input($vars?$vars).
',mail_fetchmax='.db_input($vars?$vars).
',mail_delete='.db_input(isset($vars)?$vars).
',smtp_active='.db_input($vars).
',smtp_host='.db_input($vars).
',smtp_port='.db_input($vars?$vars).
',smtp_auth='.db_input($vars);
Your code will have the same queries except the smsuser is not there...just add it in.
Step 5) Add field to table ost_email
ALTER TABLE `ost_email` CHANGE `smsuser` `smsuser` TINYINT( 1 ) NOT NULL DEFAULT '0'
Step 6) Bug Test...
Notes:
This setup does not handle email automatic parsing....I don't know anything about that part of the system but I bet if you moved the filter out of open and into Ticket:() then it would work in both places. I only want it on the web site part of my site however.
This script assumes that topicID for support is 1.
When echoing $_POST, do a intro echo of some random string to see output, I think this has something do with php flush..not 100% but I would be interested to know.
Enjoy, I subscribed to this thread so I'll come back if I wasn't clear about anything.
-J