try {
$destinations = $shout->extensions->getExtensions($curaccount);
$conferences = $shout->storage->getConferences($curaccount);
- $soundfiles = $shout->getRecordings();
+ $recordings = $shout->storage->getRecordings($curaccount);
+ // If any of these are empty, we need to coerce them to null.
+ // Otherwise we end up with a Prototype.js $H([]) (Hash of an empty
+ // Array) which causes confusion inside the library.
+ if (empty($destinations)) {
+ $destinations = null;
+ }
+ if (empty($conferences)) {
+ $conferences = null;
+ }
+ if (empty($recordings)) {
+ $recordings = null;
+ }
} catch (Exception $e) {
Horde::logMessage($e, 'ERR');
$notification->push(_("Problem getting menu information."));
$this->_connect();
$sql = 'SELECT accounts.code AS account, menus.name AS name, ' .
- 'menus.description AS description, menus.soundfile AS soundfile ' .
+ 'menus.description AS description, recording_id ' .
'FROM menus INNER JOIN accounts ON menus.account_id = accounts.id ' .
'WHERE accounts.code = ?';
$values = array($account);
$menus[$menu] = array(
'name' => $menu,
'description' => $row['description'],
- 'soundfile' => $row['soundfile']
+ 'recording_id' => $row['recording_id']
);
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
}
throw new Shout_Exception(_("Old menu not found. Edit aborted."));
} else {
$sql = 'UPDATE menus SET name = ?, description = ?, ' .
- 'soundfile = ? WHERE account_id = (SELECT id FROM ' .
- 'WHERE code = ?) AND name = ?';
+ 'recording_id = ? WHERE account_id = ' .
+ '(SELECT id FROM accounts WHERE code = ?) AND name = ?';
$values = array($details['name'], $details['description'],
- $details['soundfile'], $account,
+ $details['recording_id'], $account,
$details['oldname']);
}
} else {
- $sql = "INSERT INTO menus (account_id, name, description, soundfile) " .
+ $sql = "INSERT INTO menus (account_id, name, description, recording_id) " .
"VALUES ((SELECT id FROM accounts WHERE code = ?), ?, ?, ?)";
$values = array($account, $details['name'],
- $details['description'], $details['soundfile']);
+ $details['description'], $details['recording_id']);
}
$msg = 'SQL query in Shout_Driver_Sql#saveMenu(): ' . $sql;
}
$this->addVariable(_("Menu Name"), 'name', 'text', true);
$this->addVariable(_("Description"), 'description', 'text', false);
- $this->addVariable(_("Sound File"), 'soundfile', 'text', true);
+ $this->addVariable(_("Recording"), 'recording_id', 'enum', true);
return true;
}
$details = array(
'name' => $this->_vars->get('name'),
'description' => $this->_vars->get('description'),
- 'soundfile' => $this->_vars->get('soundfile')
+ 'recording_id' => $this->_vars->get('recording_id')
);
- // FIXME: Validate soundfile
-
if ($action == 'edit') {
$details['oldname'] = $this->_vars->get('oldname');
}
- $shout->devices->saveMenu($account, $details);
+ $shout->devices->saveMenuInfo($account, $details);
}
}
$mask = Horde_Menu::MASK_PROBLEM | Horde_Menu::MASK_LOGIN;
$menu = new Horde_Menu($mask);
- $menu->add(Horde::applicationUrl('dialplan.php'), _("Incoming Calls"), "dialplan.png");
+ $menu->add(Horde::applicationUrl('dialplan.php'), _("Call Menus"), "dialplan.png");
+ $menu->add(Horde::applicationUrl('recordings.php'), _("Recordings"), "recordings.png");
$menu->add(Horde::applicationUrl('extensions.php'), _("Extensions"), "extension.png");
$menu->add(Horde::applicationUrl('devices.php'), _("Devices"), "shout.png");
$menu->add(Horde::applicationUrl('conferences.php'), _("Conferences"), "conference.png");
- //$menu->add(Horde::applicationUrl('recordings.php'), _("Recordings"), "recordings.png");
/* Administration. */
if (Horde_Auth::isAdmin('shout:admin')) {
require_once dirname(__FILE__) . '/lib/Application.php';
$shout = Horde_Registry::appInit('shout');
-require_once SHOUT_BASE . '/lib/Forms/MenuForm.php';
+require_once SHOUT_BASE . '/lib/Forms/RecordingForm.php';
$action = Horde_Util::getFormData('action');
$curaccount = $_SESSION['shout']['curaccount'];
-$recordings = Shout::getRecordings($curaccount);
+$recordings = $shout->storage->getRecordings($curaccount);
switch($action) {
case 'add':
$vars = Horde_Variables::getDefaultVariables();
$vars->set('account', $curaccount);
- $Form = new MenuForm($vars);
+ $Form = new RecordingDetailsForm($vars);
if ($Form->isSubmitted() && $Form->validate($vars, true)) {
// Form is Valid and Submitted
try {
$Form->execute();
- $notification->push(_("Menu added."),
+ $notification->push(_("Recording added."),
'horde.success');
- $menus = $shout->storage->getMenus($curaccount);
+ $recordings = $shout->storage->getRecordings($curaccount);
$action = 'list';
} catch (Exception $e) {
$notification->push($e);
<td class="metaStatInfo" id="menu.description"></td>
</tr>
<tr>
- <td class="metaStatName">Sound File</td>
- <td class="metaStatInfo"><span id="menu.soundfile"></span></td>
+ <td class="metaStatName">Recording</td>
+ <td class="metaStatInfo"><span id="menu.recording"></span></td>
</tr>
</table>
<form id="editMenu">
<td class="metaStatInfo"><input id="menu_edit.description" name="description"></td>
</tr>
<tr>
- <td class="metaStatName">Sound File</td>
- <td class="metaStatInfo"><select id="menu_edit.soundfile" name="soundfile"></select></td>
+ <td class="metaStatName">Recording</td>
+ <td class="metaStatInfo"><select id="menu_edit.recording" name="recording_id"></select></td>
</tr>
<tr>
- <td><div class="button" onclick="saveMenu()"><?php echo _("Save"); ?></div></td>
+ <td><div class="button" onclick="saveMenuInfo()"><?php echo _("Save"); ?></div></td>
<td><div class="button" onclick="$('editMenu').hide()"><?php echo _("Cancel"); ?></div></td>
</tr>
</table>
var menuActions = $H(<?php echo Horde_Serialize::serialize(Shout::getMenuActions(), Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
var destinations = $H(<?php echo Horde_Serialize::serialize($destinations, Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
var conferences = $H(<?php echo Horde_Serialize::serialize($conferences, Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
-var soundfiles = $H(<?php echo Horde_Serialize::serialize($soundfiles, Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
+var recordings = $H(<?php echo Horde_Serialize::serialize($recordings, Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
function empty(p)
{
<div id="extensionList">
<table width="100%" cellspacing="0" class="striped">
<tr><?php // FIXME: Change Size column to recording length ?>
- <td class="uheader">Name</td>
- <td class="uheader">Size</td>
- </tr>
- <?php
- foreach ($recordings as $name => $info) {
-
- $url = Horde::applicationUrl("recordings.php");
- $url = Horde_Util::addParameter($url,
- array(
- 'name' => $name,
- )
- );
- $editurl = Horde_Util::addParameter($url, 'action', 'edit');
- $deleteurl = Horde_Util::addParameter($url, 'action', 'delete');
- ?>
- <tr class="item" style="vertical-align: top">
- <td>
- <?php echo Horde::link($editurl); echo $info['name']; ?></a>
- </td>
- <td>
- <?php echo $info['size']; ?>
- </td>
+ <td class="uheader">Recording Name</td>
+ <td class="uheader">Recording ID</td>
</tr>
<?php
+ $url = Horde::applicationUrl("recordings.php");
+ $deleteurl = Horde_Util::addParameter($url, 'action', 'delete');
+ foreach ($recordings as $info) {
+ ?>
+ <tr class="item" style="vertical-align: top">
+ <td>
+ <?php echo $info['filename']; ?>
+ </td>
+ <td>
+ <?php echo $info['id']; ?>
+ </td>
+ </tr>
+ <?php
}
- ?>
+ ?>
</table>
</div>
<ul id="controls">
<?php
- $addurl = Horde::applicationUrl('recordings.php');
- $addurl = Horde_Util::addParameter($addurl, 'action', 'add');
+ $addurl = Horde_Util::addParameter($url, 'action', 'add');
?>
<li><a class="button" href="<?php echo $addurl; ?>">
<?php echo Horde::img('recording-add.png'); ?> New Recording