From 6385078e92c77ec521da36b3a5805675645669ef Mon Sep 17 00:00:00 2001 From: "James P. Walters" Date: Tue, 6 Oct 2015 22:01:23 -0400 Subject: [PATCH 1/6] Conference Call Applet: New Feature - Record Call Option The conference call applet now has the ability to optionally record a call when setting up the flow. --- plugins/standard/applets/conference/twiml.php | 2 ++ plugins/standard/applets/conference/ui.php | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/plugins/standard/applets/conference/twiml.php b/plugins/standard/applets/conference/twiml.php index b3c6ae76..fac5a113 100644 --- a/plugins/standard/applets/conference/twiml.php +++ b/plugins/standard/applets/conference/twiml.php @@ -8,6 +8,7 @@ $isModerator = false; $defaultWaitUrl = 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient'; $waitUrl = AppletInstance::getValue('wait-url', $defaultWaitUrl); +$record = AppletInstance::getValue('record','do-not-record'); $hasModerator = false; @@ -45,6 +46,7 @@ 'startConferenceOnEnter' => (!$hasModerator || $isModerator)? 'true' : 'false', 'endConferenceOnExit' => ($hasModerator && $isModerator)? 'true' : 'false', 'waitUrl' => $waitUrl, + 'record' => $record, ); $response = new TwimlResponse(); diff --git a/plugins/standard/applets/conference/ui.php b/plugins/standard/applets/conference/ui.php index 820e17f5..1e62745d 100644 --- a/plugins/standard/applets/conference/ui.php +++ b/plugins/standard/applets/conference/ui.php @@ -15,6 +15,7 @@ array("url" => "http://twimlets.com/holdmusic?Bucket=com.twilio.music.soft-rock", "name" => "Soft Rock"), ); +$record = AppletInstance::getValue('record','do-not-record'); ?>

Moderator

@@ -33,6 +34,28 @@
+ +

Call Recording

+
+ + + + + + + + + +
+ /> + +

Enable

+
+ /> + +

Disable

+
+
From 6d81cb1ac37c140a4348f7db90fa8e874bd32762 Mon Sep 17 00:00:00 2001 From: "James P. Walters" Date: Sat, 10 Oct 2015 19:41:54 -0400 Subject: [PATCH 2/6] Conference Call List and Optional Join/Listen 1. The standard conference call plugin now has a "Conference Calls" menu under the "Call Log" parent menu. 2. The conference calls page show you a list of all active conference calls plus gives you the option to Join or Listen to the call. The list is updated every 5 seconds and will add and remove entries. 3. Join Call - Clicking "Join" will immedately connect you to the call via your web browser, it beep when you enter or leave and let you full listen and talk on the call. 4. Listen - Clicking "Listen" will immedately connect you to the call viaw your web browser, it will not beep as you enter or leave and auto mute your voice so that you'll never be heard on the call. -- Note: Clicking Mute/Unmute will effectively do nothing if you clicked the listen link. --- OpenVBX/controllers/twiml.php | 36 ++++++- .../applets/conference/conference-calls.php | 97 +++++++++++++++++++ plugins/standard/plugin.json | 8 +- 3 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 plugins/standard/applets/conference/conference-calls.php diff --git a/OpenVBX/controllers/twiml.php b/OpenVBX/controllers/twiml.php index a5d87de1..6c6411fd 100644 --- a/OpenVBX/controllers/twiml.php +++ b/OpenVBX/controllers/twiml.php @@ -320,6 +320,7 @@ public function dial() $rest_access = $this->input->get_post('rest_access'); $to = $this->input->get_post('to'); + $conference_name = $this->input->get_post('conference_name'); $callerid = $this->input->get_post('callerid'); if(!$this->session->userdata('loggedin') @@ -360,8 +361,11 @@ public function dial() { $this->dial_user_by_client_id($this->input->get_post('to'), $options); } - else + elseif(strlen($conference_name) > 0) { + $this->join_conference($conference_name, $this->input->get_post('muted'), $this->input->get_post('beep')); + } + else { $to = normalize_phone_to_E164($to); $this->response->dial($to, $options); } @@ -396,7 +400,35 @@ protected function dial_user_by_client_id($client_id, $options) } else { - $this->reponse->say('Unknown client id: '.$user_id.'. Goodbye.'); + $this->response->say('Unknown client id: '.$user_id.'. Goodbye.'); + $this->response->hangup(); + } + } + + /** + * Join A Conference Call + * + * @param string $conference_name + * @param string $muted + * @param string $beep + * @return void + */ + protected function join_conference($conference_name,$muted,$beep) + { + if (strlen($conference_name)>2) + { + $confOptions = array( + 'muted' => $muted, + 'beep' => $beep, + 'startConferenceOnEnter' => 'false' + ); + + $dial = $this->response->dial(NULL, NULL); + $dial->conference($conference_name, $confOptions); + } + else + { + $this->response->say('Invalid confernce call name. Goodbye.'); $this->response->hangup(); } } diff --git a/plugins/standard/applets/conference/conference-calls.php b/plugins/standard/applets/conference/conference-calls.php new file mode 100644 index 00000000..59986430 --- /dev/null +++ b/plugins/standard/applets/conference/conference-calls.php @@ -0,0 +1,97 @@ +twilio_sid, $ci->twilio_token); + + $conferences = $service->account->conferences->getIterator(0, 50, array("Status" => "in-progress")); + + $res = array(); + + foreach($conferences as $call) { + $res[$call->friendly_name] = array( + 'date_created' => date("F j, Y, g:i a",strtotime($call->date_created)), + 'friendly_name' => $call->friendly_name, + 'status' => $call->status, + 'duration' => $call->duration + ); + } + + die(json_encode($res)); + +endif; + +?> + + + + +
+
+

Conference Calls In Progress

+
+
+
+ + + +
Start TimeConference NameStatusJoinListen
+
+
+
diff --git a/plugins/standard/plugin.json b/plugins/standard/plugin.json index 25ceb188..f47e4603 100644 --- a/plugins/standard/plugin.json +++ b/plugins/standard/plugin.json @@ -2,5 +2,11 @@ "name" : "Standard", "author" : "Twilio ", "description" : "Standard set of applets for OpenVBX", - "url" : "http://openvbx.org" + "url" : "http://openvbx.org", + "links" : [{ + "menu" : "Call Log", + "url" : "applets/conference/conference-calls", + "script" : "applets/conference/conference-calls.php", + "label" : "Conference Calls" + }] } \ No newline at end of file From a305e726d34a0b46e31111c1ff343dfea54e5502 Mon Sep 17 00:00:00 2001 From: "James P. Walters" Date: Wed, 14 Oct 2015 01:33:42 -0400 Subject: [PATCH 3/6] Conference Call List/Listen: Pull Request Changes 1. Changed upper case NULL to lower. 2. Added spaces after function parameter names. 3. Using the shared object OpenVBX::getAccount() instead of some other way. 4. Added the json content type header. 5. Changed die to exit. 6. Wrapped the jquery functions inside of jQuery(function($) {}; 7. Fixed some tabbing issues in the plugin.json file. --- OpenVBX/controllers/twiml.php | 10 +-- .../applets/conference/conference-calls.php | 66 ++++++++++--------- plugins/standard/plugin.json | 18 ++--- 3 files changed, 48 insertions(+), 46 deletions(-) diff --git a/OpenVBX/controllers/twiml.php b/OpenVBX/controllers/twiml.php index 6c6411fd..83949703 100644 --- a/OpenVBX/controllers/twiml.php +++ b/OpenVBX/controllers/twiml.php @@ -395,7 +395,7 @@ protected function dial_user_by_client_id($client_id, $options) $user = VBX_User::get(array('id' => $user_id)); if ($user instanceof VBX_User) { - $dial = $this->response->dial(NULL, $options); + $dial = $this->response->dial(null, $options); $dial->client($user_id); } else @@ -413,9 +413,9 @@ protected function dial_user_by_client_id($client_id, $options) * @param string $beep * @return void */ - protected function join_conference($conference_name,$muted,$beep) + protected function join_conference($conference_name, $muted, $beep) { - if (strlen($conference_name)>2) + if (strlen($conference_name) > 2) { $confOptions = array( 'muted' => $muted, @@ -423,7 +423,7 @@ protected function join_conference($conference_name,$muted,$beep) 'startConferenceOnEnter' => 'false' ); - $dial = $this->response->dial(NULL, NULL); + $dial = $this->response->dial(null, null); $dial->conference($conference_name, $confOptions); } else @@ -468,7 +468,7 @@ protected function dial_user_by_email($user_email, $options) { if (count($user->devices)) { $options['sequential'] = 'true'; - $dial = $this->response->dial(NULL, $options); + $dial = $this->response->dial(null, $options); foreach ($user->devices as $device) { diff --git a/plugins/standard/applets/conference/conference-calls.php b/plugins/standard/applets/conference/conference-calls.php index 59986430..2ab18622 100644 --- a/plugins/standard/applets/conference/conference-calls.php +++ b/plugins/standard/applets/conference/conference-calls.php @@ -2,11 +2,8 @@ if(isset($_GET['json'])): - $ci =& get_instance(); - - $service = new Services_Twilio($ci->twilio_sid, $ci->twilio_token); - - $conferences = $service->account->conferences->getIterator(0, 50, array("Status" => "in-progress")); + $account = OpenVBX::getAccount(); + $conferences = $account->conferences->getIterator(0, 50, array('Status' => 'in-progress')); $res = array(); @@ -19,7 +16,9 @@ ); } - die(json_encode($res)); + header('Content-type: application/json'); + echo json_encode($res); + exit; endif; @@ -49,37 +48,40 @@ function listen_call(conference_name){ return false; } + - var $ = jQuery; - - $(function(){ - - var - calls = {}, - select = $('#calls'), - updateCalls = function() { - $.getJSON(window.location + '/?json=1', function(data) { - $.each(data, function(conference_name, call) { - if(!calls[conference_name]) { - calls[conference_name] = call; - select.append('' + call.date_created + '' + call.friendly_name + '' + call.status + 'JoinListen'); - } - }); - - $.each(calls, function(conference_name, call) { - if(!data[conference_name]) { - delete calls[conference_name]; - $('#' + conference_name).fadeOut(250, function() { - $(this).remove(); + jQuery(function($) { + $(function(){ + + var + calls = {}, + select = $('#calls'), + updateCalls = function() { + $.getJSON(window.location + '/?json=1', function(data) { + $.each(data, function(conference_name, call) { + if(!calls[conference_name]) { + calls[conference_name] = call; + select.append('' + call.date_created + '' + call.friendly_name + '' + call.status + 'JoinListen'); + } + }); + + $.each(calls, function(conference_name, call) { + if(!data[conference_name]) { + delete calls[conference_name]; + $('#' + conference_name).fadeOut(250, function() { + $(this).remove(); + }); + } }); - } }); - }); - }; + }; - updateCalls(); - setInterval(updateCalls, 5000); + updateCalls(); + setInterval(updateCalls, 5000); + }); }); + +
diff --git a/plugins/standard/plugin.json b/plugins/standard/plugin.json index f47e4603..7ccb2d60 100644 --- a/plugins/standard/plugin.json +++ b/plugins/standard/plugin.json @@ -1,12 +1,12 @@ { - "name" : "Standard", - "author" : "Twilio ", - "description" : "Standard set of applets for OpenVBX", - "url" : "http://openvbx.org", + "name" : "Standard", + "author" : "Twilio ", + "description" : "Standard set of applets for OpenVBX", + "url" : "http://openvbx.org", "links" : [{ - "menu" : "Call Log", - "url" : "applets/conference/conference-calls", - "script" : "applets/conference/conference-calls.php", - "label" : "Conference Calls" - }] + "menu" : "Call Log", + "url" : "applets/conference/conference-calls", + "script" : "applets/conference/conference-calls.php", + "label" : "Conference Calls" + }] } \ No newline at end of file From 9694a7eeeb947f7876f69cc2dd19ce3b003348a8 Mon Sep 17 00:00:00 2001 From: "James P. Walters" Date: Wed, 14 Oct 2015 01:53:29 -0400 Subject: [PATCH 4/6] Conference Call List/Listen: Pull Request Changes 1. Moved all the javascript to its own conferences.js file. 2. Wrapped the javascript in a document.ready function like the script.js file in dial plugin. 3. Removed the jquery include. 4. Added the conferences.js file via a php include function. --- .../applets/conference/conference-calls.php | 62 +------------------ .../applets/conference/conferences.js | 54 ++++++++++++++++ 2 files changed, 56 insertions(+), 60 deletions(-) create mode 100644 plugins/standard/applets/conference/conferences.js diff --git a/plugins/standard/applets/conference/conference-calls.php b/plugins/standard/applets/conference/conference-calls.php index 2ab18622..3c6e999a 100644 --- a/plugins/standard/applets/conference/conference-calls.php +++ b/plugins/standard/applets/conference/conference-calls.php @@ -22,67 +22,9 @@ endif; -?> - - - +?>
diff --git a/plugins/standard/applets/conference/conferences.js b/plugins/standard/applets/conference/conferences.js new file mode 100644 index 00000000..c5229974 --- /dev/null +++ b/plugins/standard/applets/conference/conferences.js @@ -0,0 +1,54 @@ +function join_call(conference_name){ + + window.parent.Client.call({ + 'conference_name' : conference_name, + 'muted' : 'false', + 'beep' : 'true', + 'Digits' : 1}); + + return false; +} + +function listen_call(conference_name){ + + window.parent.Client.call({ + 'conference_name' : conference_name, + 'muted' : 'true', + 'beep' : 'false', + 'Digits' : 1}); + + return false; +} + +$(document).ready(function(){ + jQuery(function($) { + $(function(){ + + var + calls = {}, + select = $('#calls'), + updateCalls = function() { + $.getJSON(window.location + '/?json=1', function(data) { + $.each(data, function(conference_name, call) { + if(!calls[conference_name]) { + calls[conference_name] = call; + select.append('' + call.date_created + '' + call.friendly_name + '' + call.status + 'JoinListen'); + } + }); + + $.each(calls, function(conference_name, call) { + if(!data[conference_name]) { + delete calls[conference_name]; + $('#' + conference_name).fadeOut(250, function() { + $(this).remove(); + }); + } + }); + }); + }; + + updateCalls(); + setInterval(updateCalls, 5000); + }); + }); +}); \ No newline at end of file From 2c168986e6cb97412d8ffc80fa1e45230aee8763 Mon Sep 17 00:00:00 2001 From: "James P. Walters" Date: Wed, 14 Oct 2015 03:01:20 -0400 Subject: [PATCH 5/6] Conference Call List/Listen: Pull Request Changes 1. Made the print of the conference call rows a little more readable. 2. Added thead and tbody like the usage plugin. --- .../standard/applets/conference/conference-calls.php | 10 ++++++---- plugins/standard/applets/conference/conferences.js | 10 +++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/standard/applets/conference/conference-calls.php b/plugins/standard/applets/conference/conference-calls.php index 3c6e999a..e3c47373 100644 --- a/plugins/standard/applets/conference/conference-calls.php +++ b/plugins/standard/applets/conference/conference-calls.php @@ -25,16 +25,18 @@ OpenVBX::addJS('applets/conference/conferences.js'); ?> -

Conference Calls In Progress

- - - +
Start TimeConference NameStatusJoinListen
+ + + + +
Start TimeConference NameStatusJoinListen
diff --git a/plugins/standard/applets/conference/conferences.js b/plugins/standard/applets/conference/conferences.js index c5229974..33bcc0fc 100644 --- a/plugins/standard/applets/conference/conferences.js +++ b/plugins/standard/applets/conference/conferences.js @@ -32,7 +32,15 @@ $(document).ready(function(){ $.each(data, function(conference_name, call) { if(!calls[conference_name]) { calls[conference_name] = call; - select.append('' + call.date_created + '' + call.friendly_name + '' + call.status + 'JoinListen'); + + row = ''; + row += '' + call.date_created + ''; + row += '' + call.friendly_name + ''; + row += '' + call.status + ''; + row += 'Join'; + row += 'Listen'; + + select.append(row); } }); From 630abe79316b5d950e562631a4658a1c90b8a9d6 Mon Sep 17 00:00:00 2001 From: "James P. Walters" Date: Sun, 18 Oct 2015 15:49:17 -0400 Subject: [PATCH 6/6] Conference Call: Join/Listen - Pull Request Changes. 1. Moved the conference-calls.php and conferences.js to a new folder named pages. 2. Updated the plugin.json file to reflect the file moves plus changed the menu, url and label. 3. Renamed conference-calls.php to conferences.php. 4. Removed the usage of onclick from the conference.js page and changed it use a jquery click listener. --- .../conference => pages}/conferences.js | 47 ++++++++++--------- .../conferences.php} | 2 +- plugins/standard/plugin.json | 8 ++-- 3 files changed, 30 insertions(+), 27 deletions(-) rename plugins/standard/{applets/conference => pages}/conferences.js (58%) rename plugins/standard/{applets/conference/conference-calls.php => pages/conferences.php} (95%) diff --git a/plugins/standard/applets/conference/conferences.js b/plugins/standard/pages/conferences.js similarity index 58% rename from plugins/standard/applets/conference/conferences.js rename to plugins/standard/pages/conferences.js index 33bcc0fc..6f6fbb39 100644 --- a/plugins/standard/applets/conference/conferences.js +++ b/plugins/standard/pages/conferences.js @@ -1,23 +1,6 @@ -function join_call(conference_name){ - - window.parent.Client.call({ - 'conference_name' : conference_name, - 'muted' : 'false', - 'beep' : 'true', - 'Digits' : 1}); - - return false; -} - -function listen_call(conference_name){ - - window.parent.Client.call({ - 'conference_name' : conference_name, - 'muted' : 'true', - 'beep' : 'false', - 'Digits' : 1}); - - return false; +function joinConference(params) { + params = $.extend(params, { 'Digits': 1 }); + window.parent.Client.call(params) } $(document).ready(function(){ @@ -37,8 +20,8 @@ $(document).ready(function(){ row += '' + call.date_created + ''; row += '' + call.friendly_name + ''; row += '' + call.status + ''; - row += 'Join'; - row += 'Listen'; + row += 'Join'; + row += 'Listen'; select.append(row); } @@ -58,5 +41,25 @@ $(document).ready(function(){ updateCalls(); setInterval(updateCalls, 5000); }); + + $('#calls').delegate('.join', 'click', function(e) { + e.preventDefault(); + + joinConference({ + 'conference_name': $(this).closest('tr').attr('id'), + 'muted': 'false', + 'beep': 'true' + }); + }); + + $('#calls').delegate('.listen', 'click', function(e) { + e.preventDefault(); + + joinConference({ + 'conference_name': $(this).closest('tr').attr('id'), + 'muted': 'true', + 'beep': 'false' + }); + }); }); }); \ No newline at end of file diff --git a/plugins/standard/applets/conference/conference-calls.php b/plugins/standard/pages/conferences.php similarity index 95% rename from plugins/standard/applets/conference/conference-calls.php rename to plugins/standard/pages/conferences.php index e3c47373..9e82afcf 100644 --- a/plugins/standard/applets/conference/conference-calls.php +++ b/plugins/standard/pages/conferences.php @@ -22,7 +22,7 @@ endif; -OpenVBX::addJS('applets/conference/conferences.js'); +OpenVBX::addJS('pages/conferences.js'); ?>
diff --git a/plugins/standard/plugin.json b/plugins/standard/plugin.json index 7ccb2d60..2a907c73 100644 --- a/plugins/standard/plugin.json +++ b/plugins/standard/plugin.json @@ -4,9 +4,9 @@ "description" : "Standard set of applets for OpenVBX", "url" : "http://openvbx.org", "links" : [{ - "menu" : "Call Log", - "url" : "applets/conference/conference-calls", - "script" : "applets/conference/conference-calls.php", - "label" : "Conference Calls" + "menu" : "Conferences", + "url" : "conferences/manager", + "script" : "pages/conferences.php", + "label" : "Manager" }] } \ No newline at end of file