</configswitch>
</configsection>
</configtab>
- <configtab name="vfs" desc="IVR Prompt Storage">
- <configsection name="vfs">
+ <configtab name="ivr" desc="IVR Prompt Storage">
+ <configsection name="ivr">
<configheader>IVR Prompt Storage Settings</configheader>
- <configvfs switchname="type"/>
+ <configvfs switchname="driver"/>
</configsection>
</configtab>
</configuration>
}
}
+ public function getRecordings()
+ {
+ try {
+ return Shout::getRecordings($_SESSION['shout']['curaccount']);
+ } catch (Exception $e) {
+ //FIXME: Create a way to notify the user of the failure.
+ Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
+ return false;
+ }
+ }
+
public function responseType()
{
return $this->_responseType;
$this->devices = Shout_Driver::factory('devices');
$this->dialplan = Shout_Driver::factory('dialplan');
$conf = $GLOBALS['conf'];
- $this->vfs = VFS::singleton($conf['vfs']['driver'], $conf['vfs']['params']);
+ $this->vfs = VFS::singleton($conf['ivr']['driver'], $conf['ivr']['params']);
$accounts = $this->storage->getAccounts();
} catch (Shout_Exception $e) {
return $res;
}
+ static public function getRecordings($account)
+ {
+ $rlist = $shout->vfs->listFolder($account);
+
+ // In Asterisk, filenames the same basename and different extension are
+ // functionally equivalent. Asterisk chooses the file based on the least cost
+ // to transcode. For that reason, we will drop the filename extension when
+ // handling files.
+ $recordings = array();
+ foreach ($rlist as $name => $info) {
+ $name = substr($name, 0, strrpos($name, '.'));
+ $info['name'] = $name;
+ $recordings[$name] = $info;
+ }
+
+ return $recordings;
+ }
+
}
--- /dev/null
+<?php
+/**
+ * Copyright 2010 Alkaloid Networks LLC (http://projects.alkaloid.net)
+ *
+ * See the enclosed file COPYING for license information (BSD). If you
+ * did not receive this file, see
+ * http://www.opensource.org/licenses/bsd-license.php.
+ *
+ * @author Ben Klang <ben@alkaloid.net>
+ */
+
+require_once dirname(__FILE__) . '/lib/Application.php';
+$shout = Horde_Registry::appInit('shout');
+
+require_once SHOUT_BASE . '/lib/Forms/MenuForm.php';
+
+$action = Horde_Util::getFormData('action');
+$curaccount = $_SESSION['shout']['curaccount'];
+$recordings = Shout::getRecordings($curaccount);
+
+switch($action) {
+case 'add':
+ $vars = Horde_Variables::getDefaultVariables();
+ $vars->set('account', $curaccount);
+ $Form = new MenuForm($vars);
+
+ if ($Form->isSubmitted() && $Form->validate($vars, true)) {
+ // Form is Valid and Submitted
+ try {
+ $Form->execute();
+ $notification->push(_("Menu added."),
+ 'horde.success');
+ $menus = $shout->storage->getMenus($curaccount);
+ $action = 'list';
+ } catch (Exception $e) {
+ $notification->push($e);
+ }
+ break;
+ } elseif ($Form->isSubmitted()) {
+ $notification->push(_("Problem processing the form. Please check below and try again."), 'horde.warning');
+ }
+
+ // Create a new add form
+ $vars = new Horde_Variables();
+ $vars->set('action', $action);
+ //$Form = new MenuForm($vars);
+
+ break;
+case 'edit':
+ if (!isset($menus[$menu])) {
+ $notification->push(_("That menu does not exist."), 'horde.error');
+ $action = 'list';
+ break;
+ }
+ $menu = $menus[$menu];
+ try {
+ $destinations = $shout->extensions->getExtensions($curaccount);
+ } catch (Exception $e) {
+ $notification->push(_("Problem getting destination information."));
+ }
+ break;
+case 'list':
+default:
+ $action = 'list';
+ break;
+}
+
+Horde::addScriptFile('stripe.js', 'horde');
+Horde::addScriptFile('prototype.js', 'horde');
+
+require SHOUT_TEMPLATES . '/common-header.inc';
+require SHOUT_TEMPLATES . '/menu.inc';
+
+$notification->notify();
+
+require SHOUT_TEMPLATES . '/recordings/' . $action . '.inc';
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
function changeSoundfile()
{
- alert("Changing soundfile");
+ //empty($('editSound'));
+ // FIXME: Add spinner
+ new Ajax.Request(ajax_url + 'getRecordings',
+ {
+ method: 'get',
+ onSuccess: function(r) {
+ //var form = document.createElement('form');
+ //form.name = 'selectSoundFile';
+ //form.id = 'selectSoundFile';
+ //var select = document.createElement('select');
+ //select.name = 'filename';
+ var recordings = r.responseJSON.response;
+ alert('done');
+ }
+ });
}
function playSoundfile()
// Handle the soundfile row specially
row = document.createElement('tr');
col = document.createElement('td');
+ col.id = 'editSound';
col.className = 'menuStatName';
text = document.createTextNode('<?php echo _("Sound file"); ?>');
col.appendChild(text);
--- /dev/null
+<div class="header">
+ <ul id="controls">
+ <?php
+ $addurl = Horde::applicationUrl('recordings.php');
+ $addurl = Horde_Util::addParameter($addurl, 'action', 'add');
+ ?>
+ <li><a href="<?php echo $addurl; ?>">
+ <?php echo Horde::img('recording-add.png'); ?> New Recording
+ </a>
+ </li>
+ </ul>
+ Account: <?php echo $_SESSION['shout']['accounts'][$curaccount]; ?>
+</div>
+
+<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>
+ </tr>
+ <?php
+ }
+ ?>
+ </table>
+</div>