From 979888d353459c798c657ede32b9af7611a43b8d Mon Sep 17 00:00:00 2001
From: Stephen Packer <github@stevepacker.com>
Date: Mon, 27 Oct 2014 16:37:35 -0700
Subject: [PATCH] createTicket respects alert/autorespond negatives

It was previously not possible to use the `alert` and `autorespond` flags in a negative way to prevent those two events, since the ternary operator would have used the `false` ternary value, which was `true`.  This corrects that by allowing the default of `true` to be used only when the `$data` array does not have the appropriate keys set.  Assigning `$data['source']` was altered to use the same formatting and caution against an undefined index error.
---
 include/api.tickets.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/api.tickets.php b/include/api.tickets.php
index 6371daa63..46cb8b6e1 100644
--- a/include/api.tickets.php
+++ b/include/api.tickets.php
@@ -118,9 +118,9 @@ class TicketApiController extends ApiController {
     function createTicket($data) {
 
         # Pull off some meta-data
-        $alert = $data['alert'] ? $data['alert'] : true;
-        $autorespond = $data['autorespond'] ? $data['autorespond'] : true;
-        $data['source'] = $data['source'] ? $data['source'] : 'API';
+        $alert          = array_key_exists('alert',       $data) ? $data['alert']       : true;
+        $autorespond    = array_key_exists('autorespond', $data) ? $data['autorespond'] : true;
+        $data['source'] = array_key_exists('source',      $data) ? $data['source']      : 'API';
 
         # Create the ticket with the data (attempt to anyway)
         $errors = array();
-- 
GitLab