Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Conference Call - List Calls, Join and Listen #346

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions OpenVBX/controllers/twiml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -391,12 +395,40 @@ 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
{
$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();
}
}
Expand Down Expand Up @@ -436,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)
{
Expand Down
2 changes: 2 additions & 0 deletions plugins/standard/applets/conference/twiml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -45,6 +46,7 @@
'startConferenceOnEnter' => (!$hasModerator || $isModerator)? 'true' : 'false',
'endConferenceOnExit' => ($hasModerator && $isModerator)? 'true' : 'false',
'waitUrl' => $waitUrl,
'record' => $record,
);

$response = new TwimlResponse();
Expand Down
23 changes: 23 additions & 0 deletions plugins/standard/applets/conference/ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
?>
<div class="vbx-applet">
<h2>Moderator</h2>
Expand All @@ -33,6 +34,28 @@
<input type="hidden" name="conf-id" value="<?php echo AppletInstance::getValue('conf-id', 'conf_'.mt_rand()) ?>" />
</fieldset>
</div><!-- .vbx-full-pane -->

<h2>Call Recording</h2>
<div class="radio-table">
<table>
<tr class="radio-table-row first <?php echo ($record === 'record-from-start') ? 'on' : 'off' ?>">
<td class="radio-cell">
<input type="radio" class='dial-whom-selector-radio' name="record" value="record-from-start" <?php echo ($record === 'record-from-start') ? 'checked="checked"' : '' ?> />
</td>
<td class="content-cell">
<h4>Enable</h4>
</td>
</tr>
<tr class="radio-table-row last <?php echo ($record === 'do-not-record') ? 'on' : 'off' ?>">
<td class="radio-cell">
<input type="radio" class='dial-whom-selector-radio' name="record" value="do-not-record" <?php echo ($record === 'do-not-record') ? 'checked="checked"' : '' ?> />
</td>
<td class="content-cell">
<h4>Disable</h4>
</td>
</tr>
</table>
</div>

</div><!-- .vbx-applet -->

Expand Down
65 changes: 65 additions & 0 deletions plugins/standard/pages/conferences.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
function joinConference(params) {
params = $.extend(params, { 'Digits': 1 });
window.parent.Client.call(params)
}

$(document).ready(function(){
jQuery(function($) {
$(function(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, just noticed this, but $(document).ready(function() {});, jQuery(function($) {}); and $(function() {}); all do the same thing... so we've got 3 levels of code all waiting for DOMReady. Fortunately jQuery is smart enough to automatically fire event listeners for DOMReady if they're registered after the DOM is ready.


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;

row = '<tr class="items-row" id="' + call.friendly_name + '">';
row += '<td>' + call.date_created + '</td>';
row += '<td>' + call.friendly_name + '</td>';
row += '<td>' + call.status + '</td>';
row += '<td><a href="#" class="join">Join</a></td>';
row += '<td><a href="#" class="listen">Listen</a></td></tr>';

select.append(row);
}
});

$.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);
});

$('#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'
});
});
});
});
43 changes: 43 additions & 0 deletions plugins/standard/pages/conferences.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

if(isset($_GET['json'])):

$account = OpenVBX::getAccount();
$conferences = $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
);
}

header('Content-type: application/json');
echo json_encode($res);
exit;

endif;

OpenVBX::addJS('pages/conferences.js');

?>
<div class="vbx-content-main">
<div class="vbx-content-menu vbx-content-menu-top">
<h2 class="vbx-content-heading">Conference Calls In Progress</h2>
</div><!-- .vbx-content-menu -->
<div class="vbx-content-container">
<div class="vbx-content-section">
<table class="vbx-items-grid" border="0">
<thead>
<tr class="items-head"><th>Start Time</th><th>Conference Name</th><th>Status</th><th>Join</th><th>Listen</th></tr>
</thead>
<tbody id="calls">
</tbody>
</table>
</div><!-- .vbx-content-section -->
</div><!-- .vbx-content-container -->
</div><!-- .vbx-content-main -->
14 changes: 10 additions & 4 deletions plugins/standard/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"name" : "Standard",
"author" : "Twilio <vbx@twilio.com>",
"description" : "Standard set of applets for OpenVBX",
"url" : "http://openvbx.org"
"name" : "Standard",
"author" : "Twilio <vbx@twilio.com>",
"description" : "Standard set of applets for OpenVBX",
"url" : "http://openvbx.org",
"links" : [{
"menu" : "Conferences",
"url" : "conferences/manager",
"script" : "pages/conferences.php",
"label" : "Manager"
}]
}