From 74e6f46d80579f8bd2807e7f4a5de3f44b9668e8 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Wed, 17 Mar 2010 12:25:03 -0400 Subject: [PATCH] Shout: Continue creating the recordings UI --- shout/config/conf.xml | 6 +-- shout/lib/Ajax/Application.php | 11 +++++ shout/lib/Application.php | 2 +- shout/lib/Shout.php | 18 ++++++++ shout/recordings.php | 78 ++++++++++++++++++++++++++++++++ shout/templates/dialplan/edit.inc | 17 ++++++- shout/templates/recordings/list.inc | 45 ++++++++++++++++++ shout/themes/graphics/recording-add.png | Bin 0 -> 684 bytes 8 files changed, 172 insertions(+), 5 deletions(-) create mode 100644 shout/recordings.php create mode 100644 shout/templates/recordings/list.inc create mode 100755 shout/themes/graphics/recording-add.png diff --git a/shout/config/conf.xml b/shout/config/conf.xml index 9138f8d05..e07bad117 100644 --- a/shout/config/conf.xml +++ b/shout/config/conf.xml @@ -78,10 +78,10 @@ - - + + IVR Prompt Storage Settings - + diff --git a/shout/lib/Ajax/Application.php b/shout/lib/Ajax/Application.php index 8a05290f1..83f20d583 100644 --- a/shout/lib/Ajax/Application.php +++ b/shout/lib/Ajax/Application.php @@ -201,6 +201,17 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base } } + 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; diff --git a/shout/lib/Application.php b/shout/lib/Application.php index 9b230d678..1fbef59d9 100644 --- a/shout/lib/Application.php +++ b/shout/lib/Application.php @@ -85,7 +85,7 @@ class Shout_Application extends Horde_Registry_Application $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) { diff --git a/shout/lib/Shout.php b/shout/lib/Shout.php index 9ed2fff48..b59251eb3 100644 --- a/shout/lib/Shout.php +++ b/shout/lib/Shout.php @@ -217,4 +217,22 @@ class Shout 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; + } + } diff --git a/shout/recordings.php b/shout/recordings.php new file mode 100644 index 000000000..74f9454f8 --- /dev/null +++ b/shout/recordings.php @@ -0,0 +1,78 @@ + + */ + +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'; diff --git a/shout/templates/dialplan/edit.inc b/shout/templates/dialplan/edit.inc index 446a92c7e..362c494d5 100644 --- a/shout/templates/dialplan/edit.inc +++ b/shout/templates/dialplan/edit.inc @@ -144,7 +144,21 @@ function cancelEdit() 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() @@ -171,6 +185,7 @@ function refreshMenu() // Handle the soundfile row specially row = document.createElement('tr'); col = document.createElement('td'); + col.id = 'editSound'; col.className = 'menuStatName'; text = document.createTextNode(''); col.appendChild(text); diff --git a/shout/templates/recordings/list.inc b/shout/templates/recordings/list.inc new file mode 100644 index 000000000..dc4f6f46e --- /dev/null +++ b/shout/templates/recordings/list.inc @@ -0,0 +1,45 @@ +
+ + Account: +
+ +
+ + + + + + $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'); + ?> + + + + + +
NameSize
+ + + +
+
diff --git a/shout/themes/graphics/recording-add.png b/shout/themes/graphics/recording-add.png new file mode 100755 index 0000000000000000000000000000000000000000..965c503c6088f5ca20ae624ae9f9bb8f05490640 GIT binary patch literal 684 zcmV;d0#p5oP){@e)R=6tn`E0`O&UochFZ7FhGdgX0zI@b zfwou(BBezH*PQIpi)fL8z0AQtp}BZyynUTrZBg2SA`X0cGmm+n_nl#e0l@r=nEwVS z77H#}mcINopj0Xj&|*nZiK$9T94|fX&Uf=yW>Jbseo%3z8&JU=68c{18C+IKL-EK<@goWW*KkIou$FceWXN zR;;c*gQ6&qWf}Q=9;sA{&gT$|i6&ro%)LY0f_2wLyAC_e9ASq+u3Etu7u9GiKoA6Y zyE;cmU`TyT?i+$k6Byz~!4D7Y4!Pa#<`cE+CuDAd!f}ZXbiiVxce( zLZQIn5o-DIjdXP!!OAG^KN}ku5B~vbQ06k30fR6Ek~oG3E?;|b;X&0ux5We z`<%net$Dof>d@Xy!l_+?|K8aSlbnjOk;yO{4)bg<=w}7Nw_|`ZnG|^5X97IRt^WGQ zD%L;MjWyJc0Id_k^~kCIkw-$i4)6h=OtpUi7|C71tF5Q_b!>c?HvlI;Q3{%%>KgMK z(KG#$?uVkAKq#+$Cp$P!bmN>uJ&&@^o1KkltZ82T<6lQN7pT4(wtvQgk^c_UnVcJ% Sc~{E-0000