Permalink
Browse files

Fix PHP notices

  • Loading branch information...
1 parent 57a5b51 commit df3dceb90d5b01384b63a81c9a927deb69b9349d @chadsmith committed May 20, 2011
Showing with 52 additions and 25 deletions.
  1. +12 −5 applets/call/twiml.php
  2. +15 −9 applets/text/twiml.php
  3. +9 −4 outbound.php
  4. +12 −4 queue.php
  5. +4 −3 schedule.php
View
@@ -3,12 +3,19 @@
$number = AppletInstance::getValue('number');
$id = AppletInstance::getValue('flow');
-$recipient = normalize_phone_to_E164(str_replace('%sender%', $_REQUEST['From'], AppletInstance::getValue('recipient')));
-require_once(APPPATH . 'libraries/twilio.php');
-$ci->twilio = new TwilioRestClient($ci->twilio_sid, $ci->twilio_token, $ci->twilio_endpoint);
-if(($flow = OpenVBX::getFlows(array('id' => $id, 'tenant_id' => $ci->tenant->id)))&&$flow[0]->values['data'])
- $ci->twilio->request("Accounts/{$ci->twilio_sid}/Calls", 'POST', array('From' => $number, 'To' => $recipient, 'Url' => site_url('twiml/start/voice/'.$id)));
+if(!empty($_REQUEST['From'])) {
+ $recipient = normalize_phone_to_E164(str_replace('%sender%', $_REQUEST['From'], AppletInstance::getValue('recipient')));
+
+ require_once(APPPATH . 'libraries/twilio.php');
+ $ci->twilio = new TwilioRestClient($ci->twilio_sid, $ci->twilio_token, $ci->twilio_endpoint);
+ if(($flow = OpenVBX::getFlows(array('id' => $id, 'tenant_id' => $ci->tenant->id))) && $flow[0]->values['data'])
+ $ci->twilio->request("Accounts/{$ci->twilio_sid}/Calls", 'POST', array(
+ 'From' => $number,
+ 'To' => $recipient,
+ 'Url' => site_url('twiml/start/voice/' . $id)
+ ));
+}
$response = new Response();
View
@@ -5,17 +5,23 @@
$recipient = normalize_phone_to_E164(AppletInstance::getValue('recipient'));
$message = AppletInstance::getValue('sms');
-$from = normalize_phone_to_E164($_REQUEST['From']);
-$to = normalize_phone_to_E164($_REQUEST['To']);
+if(!empty($_REQUEST['From'])) {
+ $from = normalize_phone_to_E164($_REQUEST['From']);
+ $to = normalize_phone_to_E164($_REQUEST['To']);
-if(AppletInstance::getFlowType() == 'voice')
- $message = str_replace(array('%caller%', '%number%'), array($from, $to), $message);
-else
- $message = str_replace(array('%sender%', '%number%', '%body%'), array($from, $to, $_REQUEST['Body']), $message);
+ if(AppletInstance::getFlowType() == 'voice')
+ $message = str_replace(array('%caller%', '%number%'), array($from, $to), $message);
+ else
+ $message = str_replace(array('%sender%', '%number%', '%body%'), array($from, $to, $_REQUEST['Body']), $message);
-require_once(APPPATH . 'libraries/twilio.php');
-$ci->twilio = new TwilioRestClient($ci->twilio_sid, $ci->twilio_token, $ci->twilio_endpoint);
-$ci->twilio->request("Accounts/{$ci->twilio_sid}/SMS/Messages", 'POST', array('From' => $number, 'To' => $recipient, 'Body' => $message));
+ require_once(APPPATH . 'libraries/twilio.php');
+ $ci->twilio = new TwilioRestClient($ci->twilio_sid, $ci->twilio_token, $ci->twilio_endpoint);
+ $ci->twilio->request("Accounts/{$ci->twilio_sid}/SMS/Messages", 'POST', array(
+ 'From' => $number,
+ 'To' => $recipient,
+ 'Body' => $message
+ ));
+}
$response = new Response();
View
@@ -2,17 +2,22 @@
$user = OpenVBX::getCurrentUser();
$tenant_id = $user->values['tenant_id'];
$ci =& get_instance();
- if(($recipient = $_POST['recipient']) && ($number = $_POST['number']) && ($id = intval($_POST['flow']))) {
+ if(!empty($_POST['recipient'])) {
require_once(APPPATH . 'libraries/twilio.php');
$ci->twilio = new TwilioRestClient($ci->twilio_sid, $ci->twilio_token, $ci->twilio_endpoint);
- if($id && ($flow = OpenVBX::getFlows(array('id' => $id, 'tenant_id' => $tenant_id))) && $flow[0]->values['data'])
- $ci->twilio->request("Accounts/{$this->twilio_sid}/Calls", 'POST', array('From' => $number, 'To' => normalize_phone_to_E164($_POST['recipient']), 'Url' => site_url('twiml/start/voice/' . $id)));
+ $id = intval($_POST['flow']);
+ if(($flow = OpenVBX::getFlows(array('id' => $id, 'tenant_id' => $tenant_id))) && $flow[0]->values['data'])
+ $ci->twilio->request("Accounts/{$this->twilio_sid}/Calls", 'POST', array(
+ 'From' => $_POST['number'],
+ 'To' => normalize_phone_to_E164($_POST['recipient']),
+ 'Url' => site_url('twiml/start/voice/' . $id)
+ ));
}
$flows = OpenVBX::getFlows(array('tenant_id' => $tenant_id));
?>
<style>
.vbx-outbound form {
- padding:20px 5%;
+ padding: 20px 5%;
}
</style>
<div class="vbx-content-main">
View
@@ -12,9 +12,17 @@
$twilio_token = $ci->settings->get('twilio_token', $event->tenant);
$twilio = new TwilioRestClient($twilio_sid, $twilio_token, $ci->twilio_endpoint);
if('sms' == $event->type)
- $twilio->request("Accounts/{$twilio_sid}/SMS/Messages", 'POST', array('From' => $event->callerId, 'To' => $event->number, 'Body' => $event->data->message));
+ $twilio->request("Accounts/{$twilio_sid}/SMS/Messages", 'POST', array(
+ 'From' => $event->callerId,
+ 'To' => $event->number,
+ 'Body' => $event->data->message
+ ));
else
- $twilio->request("Accounts/{$twilio_sid}/Calls", 'POST', array('From' => $event->callerId, 'To' => $event->number, 'Url' => site_url(($tenant->url_prefix ? $tenant->url_prefix . '/' : '') . 'twiml/start/voice/' . $event->data->id)));
+ $twilio->request("Accounts/{$twilio_sid}/Calls", 'POST', array(
+ 'From' => $event->callerId,
+ 'To' => $event->number,
+ 'Url' => site_url(($tenant->url_prefix ? $tenant->url_prefix . '/' : '') . 'twiml/start/voice/' . $event->data->id)
+ ));
$ci->db->delete('outbound_queue', array('id' => $event->id));
}
}
@@ -26,8 +34,8 @@
foreach($queries as $query)
if(trim($query))
$ci->db->query($query);
- if($remove = intval($_POST['remove'])) {
- $ci->db->delete('outbound_queue', array('id' => $remove, 'tenant' => $tenant_id));
+ if(!empty($_POST['remove'])) {
+ $ci->db->delete('outbound_queue', array('id' => intval($_POST['remove']), 'tenant' => $tenant_id));
die;
}
$events = $ci->db->query(sprintf('SELECT id, number, type, time, callerId, data FROM outbound_queue WHERE tenant=%d ORDER BY time ASC', $tenant_id))->result();
View
@@ -6,12 +6,13 @@
foreach($queries as $query)
if(trim($query))
$ci->db->query($query);
- if($_POST['type']) {
+ if(!empty($_POST['number'])) {
$type = $_POST['type'];
$number = normalize_phone_to_E164($_POST['number']);
$callerId = normalize_phone_to_E164($_POST['callerId']);
$time = strtotime($_POST['date'] . ' ' . $_POST['time']);
- if('sms' == $type && $_POST['message']) {
+ if('sms' == $type && !empty($_POST['message'])) {
+ if($number)
$ci->db->insert('outbound_queue', array(
'tenant' => $tenant_id,
'number' => $number,
@@ -25,7 +26,7 @@
}
elseif('call' == $type) {
$flow = OpenVBX::getFlows(array('id' => $_POST['flow'], 'tenant_id' => $tenant_id));
- if($flow && $flow[0]->values['data'])
+ if($number && $flow && $flow[0]->values['data'])
$ci->db->insert('outbound_queue', array(
'tenant' => $tenant_id,
'number' => $number,

0 comments on commit df3dceb

Please sign in to comment.