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 5 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
43 changes: 43 additions & 0 deletions plugins/standard/applets/conference/conference-calls.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('applets/conference/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 -->
62 changes: 62 additions & 0 deletions plugins/standard/applets/conference/conferences.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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;

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 onclick="join_call(\'' + call.friendly_name + '\');">Join</a></td>';
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd still like all JS actions to be handled via listeners. We only really use onclick for window.open and I'd even like to go through and nuke all of those too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I didn't use $('#calls').on('click', '.listen', function(e) ... is because the version of jquery the project is using doesn't support the .on function. As best I can tell the project is using jquery v1.6.2 and the .on function wasn't added to jquery until v1.7. Version 1.7 was only released a few months after 1.6.2 so possibly upgrading jquery wouldn't be a breaking change. Let me know how you want to proceed.

row += '<td><a onclick="listen_call(\'' + call.friendly_name + '\');">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);
});
});
});
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
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 <[email protected]>",
"description" : "Standard set of applets for OpenVBX",
"url" : "http://openvbx.org"
"name" : "Standard",
"author" : "Twilio <[email protected]>",
"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"
}]
}