Just got it working on our 1.7, requires a few code tweaks.
I diff'd the class.tickets.php files.. merged in the changes, sweet. Reset permissions on /api/soap/ when it became obvious that I'd broken the whole thing trying to require files that the web-server can't read.. ;-)
Next, got one of our reps to guinea-pig the app, wasn't sure what the url is, perhaps your documentation should say that its the Client url, even for staff.. bit of faffing about trying to figure that out, not that big of a deal I suppose.
Next, started seeing massive errors in the logs. Turns out our older version of php (the reason we haven't gone beyond 1.7 yet) baulks at lambda functions.. so, that lovely inline usort algorithm you've implemented (tickets.class.php), nuh.. had to name it to get it working. (global scope, I'm useful, but lazy), if you wished backwards compatibility, or if my 1.7 brothers attempt this, you'll need to rewrite it thusly:
usort($messages, 'sort_thread');
Create the following after the class definition:
function sort_thread($a, $b) {
return strtotime($a) - strtotime($b);
};
Next major errors preventing anything happening, the thread, it needed to be rewritten (ticket.class.php) to something like this:
if (isVersion('1.7'))
{
if($thread=$ticket->getThreadEntries(array('M', 'R'))) {
...
Which meant the "getNotes" function also needed expanding, which is admittedly a copypasta of the 1.8+ code, but with the correct $thread.
if(isVersion('1.7')){
if($thread = $ticket->getThreadEntries(array('N'))) {
foreach($thread as $entry) {
if ($entry == 'N')
$notes = array(
'created' => date(DATE_RFC3339, strtotime($entry)),
'staff' => Format:($entry),
'title' => Format:($entry),
'note' => Format:($entry)
);
}
}
}
Finally, I modified your == null thing (ticket.class.php), into:
// Do we have a valid ticket?
if (!($ticket instanceof Ticket))
I probably should have detailed that in "file order".. but that was the order I found them in.
Quick question about this "Integration ID" field in notify.php.. how would that work for more than one user?
Also, does it use your servers? (url = "http://atomiccomputers.com/eTicketAPI.php")
I'm sure there is something odd about that, just can't put my finger on it.. guess we'll stick to email notifications for now.
Hi Grizly,I applaud your work on updating the class.ticket.php file, but unfortunately you went way above and beyond what was actually needed, I'm sorry to say. I would have made one or 1.7.*, but I didn't not have that version when I made these. However, the updates I made to class.ticket.php are only for push notifications. If you do not need to use push notifications you do not need to update this file.If you do want to use push notifications, you only need to do these things. Add this to the top under all the other includes://code added by atomic computers for eticket app integrationif (file_exists(dirname(dirname(__FILE__))."/api/soap/notify.php")) { require_once(dirname(dirname(__FILE__))."/api/soap/notify.php");}Then, in all of the places where it sends and email notification, you will add this://code added by atomic computers for eticket app integration$args = array( 'action' => 'sendPushNotification', 'ticket_id' => $this->getId(), 'staff_id' => $staff->getId(), 'message' => $alert, 'type' => "notify_new");post_json($args);It is always inside this area:foreach( $recipients as $k=>$staff) { if(!is_object($staff) || !$staff->isAvailable() || in_array($staff->getEmail(), $sentlist)) continue; $alert = $this->replaceVars($msg, array('recipient' => $staff)); $email->sendAlert($staff->getEmail(), $alert, $alert, null, $options); $sentlist = $staff->getEmail(); //code added by atomic computers for eticket app integration $args = array( 'action' => 'sendPushNotification', 'ticket_id' => $this->getId(), 'staff_id' => $staff->getId(), 'message' => $alert, 'type' => "notify_new" ); post_json($args);}This will have it send a push notification to each staff member who would have been notified by email.The issue here is the 'type' key. In this example, it says 'notify_new'. But you also have 'notify_assign' for the area of the class file where it sends an email for the ticket being assigned, 'notify_overdue', 'notify_transfer', and 'notify_reply' for all of their corresponding areas. Then I use 'notify_misc' for anything else.That is all of the changes made to the ticket class file. The rest of the file should be the default file that came with your version of OSTicket.The 'Integration ID' field is for everyone using your installation of OSTicket. Everyone has the same integration ID that logs into your system. (It goes by the URL.) But yes, all push notifications go through our server. We have to use a .pem file to sign all of the push notifications before we send them to Apple, which the .pem file is on our server.Let me know if you have any other questions.Thanks,James