Skip to content
Snippets Groups Projects
Commit 5d0ddb65 authored by Stephen Packer's avatar Stephen Packer Committed by Stephen Packer
Browse files

XML supports false alert/autorespond, using isset

- Allows the string "false" to be used in the XML payload as the documentation demonstrates, and have that be interpreted as a boolean false.
- Switching $alert/$autorespond to use isset(), and forcing those variables to be type-casted to booleans.
parent 979888d3
No related branches found
No related tags found
No related merge requests found
......@@ -118,9 +118,11 @@ class TicketApiController extends ApiController {
function createTicket($data) {
# Pull off some meta-data
$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';
$alert = (bool) (isset($data['alert']) ? $data['alert'] : true);
$autorespond = (bool) (isset($data['autorespond']) ? $data['autorespond'] : true);
# Assign default value to source if not defined, or defined as NULL
$data['source'] = isset($data['source']) ? $data['source'] : 'API';
# Create the ticket with the data (attempt to anyway)
$errors = array();
......
......@@ -330,9 +330,9 @@ class ApiXmlDataParser extends XmlDataParser {
if ($key == "phone" && is_array($value)) {
$value = $value[":text"];
} else if ($key == "alert") {
$value = (bool)$value;
$value = (bool) (strtolower($value) === 'false' ? false : $value);
} else if ($key == "autorespond") {
$value = (bool)$value;
$value = (bool) (strtolower($value) === 'false' ? false : $value);
} else if ($key == "message") {
if (!is_array($value)) {
$value = array(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment