From 1e28b73ec2511ec1e6271608239df9ceca9d6e78 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Fri, 22 Jan 2010 09:26:04 -0500 Subject: [PATCH] Shout: Fix query field order; set callerid to sane default --- shout/lib/Driver/Sql.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/shout/lib/Driver/Sql.php b/shout/lib/Driver/Sql.php index e10d5bcb3..33413f3fa 100644 --- a/shout/lib/Driver/Sql.php +++ b/shout/lib/Driver/Sql.php @@ -152,6 +152,11 @@ class Shout_Driver_Sql extends Shout_Driver $details['alias'] = $details['name']; $details['name'] = $details['devid']; unset($details['devid']); + // Default the caller id to something sane. + if (empty($details['callerid'])) { + $details['callerid'] = sprintf('"%s" <%s>', $details['alias'], + $details['mailbox']); + } $details['mailbox'] .= '@' . $context; // Prepare the SQL query and arguments @@ -164,13 +169,14 @@ class Shout_Driver_Sql extends Shout_Driver $context, $details['alias'], ); + if (!empty($devid)) { // This is an edit $details['name'] = $details['devid']; $sql = 'UPDATE %s SET name = ?, accountcode = ?, callerid = ?, ' . - 'mailbox = ?, secret = ?, alias = ?, canreinvite = "no", ' . - 'nat = "yes", type = "peer", host = "dynamic", ' . - 'context = ? WHERE name = ?'; + 'mailbox = ?, secret = ?, context = ?, alias = ?, ' . + 'canreinvite = "no", nat = "yes", type = "peer", ' . + 'host = "dynamic", WHERE name = ?'; $args[] = $devid; } else { // This is an add. Generate a new unique ID and secret -- 2.11.0