Skip to content
Browse files

Merge branch 'release/direction_aware'

  • Loading branch information...
2 parents e097074 + b3e4d31 commit 70a79f47021ea95b35e35fbec42ed149187d0c34 @chadsmith committed
Showing with 19 additions and 11 deletions.
  1. +2 −2 applets/areacode/twiml.php
  2. +2 −2 applets/direction/twiml.php
  3. +1 −1 applets/direction/ui.php
  4. +6 −2 applets/state/twiml.php
  5. +8 −4 applets/user/twiml.php
View
4 applets/areacode/twiml.php
@@ -5,8 +5,8 @@
$menu_items = AppletInstance::assocKeyValueCombine($keys, $responses);
$areacode = null;
-if(!empty($_REQUEST['From'])) {
- $number = normalize_phone_to_E164($_REQUEST['From']);
+if(!empty($_REQUEST['Direction'])) {
+ $number = normalize_phone_to_E164(in_array($_REQUEST['Direction'], array('inbound', 'incoming')) ? $_REQUEST['From'] : $_REQUEST['To']);
if(preg_match('/^\+1([0-9]{3})[0-9]{7}$/', $number, $matches))
$areacode = $matches[1];
}
View
4 applets/direction/twiml.php
@@ -1,8 +1,8 @@
<?php
$direction = 'inbound';
-if(!empty($_REQUEST['Direction']))
- $direction = $_REQUEST['Direction'];
+if(!empty($_REQUEST['Direction']) && 'inbound' != $_REQUEST['Direction'])
+ $direction = 'outbound';
$response = new Response();
View
2 applets/direction/ui.php
@@ -5,6 +5,6 @@
</div>
<div class="vbx-full-pane">
<h2>Outbound calls</h2>
-<?php echo AppletUI::DropZone('outbound-dial'); ?>
+<?php echo AppletUI::DropZone('outbound'); ?>
</div>
</div>
View
8 applets/state/twiml.php
@@ -3,9 +3,13 @@
$keys = (array) AppletInstance::getValue('keys[]');
$responses = (array) AppletInstance::getDropZoneUrl('responses[]');
$menu_items = AppletInstance::assocKeyValueCombine($keys, $responses, 'strtolower');
+$from_or_to = 'From';
-if(!empty($_REQUEST['FromState']))
- $state = strtolower($_REQUEST['FromState']);
+if(!empty($_REQUEST['Direction']) && !in_array($_REQUEST['Direction'], array('inbound', 'incoming')))
+ $from_or_to = 'To';
+
+if(!empty($_REQUEST[$from_or_to . 'State']))
+ $state = strtolower($_REQUEST[$from_or_to . 'State']);
$response = new TwimlResponse;
View
12 applets/user/twiml.php
@@ -1,20 +1,24 @@
<?php
$allowed = AppletInstance::getUserGroupPickerValue('user_or_group');
$is_user = false;
+$from_or_to = 'From';
-if(!empty($allowed) && !empty($_REQUEST['From'])) {
- $from = normalize_phone_to_E164($_REQUEST['From']);
+if(!empty($_REQUEST['Direction']) && !in_array($_REQUEST['Direction'], array('inbound', 'incoming')))
+ $from_or_to = 'To';
+
+if(!empty($allowed) && !empty($_REQUEST[$from_or_to])) {
+ $number = normalize_phone_to_E164($_REQUEST[$from_or_to]);
switch(get_class($allowed)) {
case 'VBX_User':
foreach($allowed->devices as $device)
- if($from == $device->value)
+ if($number == $device->value)
$is_user = true;
break;
case 'VBX_Group':
foreach($allowed->users as $user) {
$user = VBX_User::get($user->user_id);
foreach($user->devices as $device)
- if($from == $device->value)
+ if($number == $device->value)
$is_user = true;
}
}

0 comments on commit 70a79f4

Please sign in to comment.
Something went wrong with that request. Please try again.