From c0b6f11d3ca747de3dd39b329fca31d83a79f5a0 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Mon, 29 Mar 2010 16:46:01 -0400 Subject: [PATCH] Shout: Convert to recording_id --- shout/dialplan.php | 14 ++++++++++++- shout/lib/Driver/Sql.php | 14 ++++++------- shout/lib/Forms/MenuForm.php | 8 +++---- shout/lib/Shout.php | 4 ++-- shout/recordings.php | 10 ++++----- shout/templates/dialplan/edit.inc | 12 +++++------ shout/templates/recordings/list.inc | 42 +++++++++++++++---------------------- 7 files changed, 53 insertions(+), 51 deletions(-) diff --git a/shout/dialplan.php b/shout/dialplan.php index 564ef5573..17828158a 100644 --- a/shout/dialplan.php +++ b/shout/dialplan.php @@ -61,7 +61,19 @@ if ($action == 'edit') { 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.")); diff --git a/shout/lib/Driver/Sql.php b/shout/lib/Driver/Sql.php index 05befc48a..59c60bf9b 100644 --- a/shout/lib/Driver/Sql.php +++ b/shout/lib/Driver/Sql.php @@ -103,7 +103,7 @@ class Shout_Driver_Sql extends Shout_Driver $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); @@ -126,7 +126,7 @@ class Shout_Driver_Sql extends Shout_Driver $menus[$menu] = array( 'name' => $menu, 'description' => $row['description'], - 'soundfile' => $row['soundfile'] + 'recording_id' => $row['recording_id'] ); $row = $result->fetchRow(DB_FETCHMODE_ASSOC); } @@ -142,17 +142,17 @@ class Shout_Driver_Sql extends Shout_Driver 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; diff --git a/shout/lib/Forms/MenuForm.php b/shout/lib/Forms/MenuForm.php index e962483c8..63a4e6bb6 100644 --- a/shout/lib/Forms/MenuForm.php +++ b/shout/lib/Forms/MenuForm.php @@ -35,7 +35,7 @@ class MenuForm extends Horde_Form { } $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; } @@ -49,16 +49,14 @@ class MenuForm extends Horde_Form { $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); } } diff --git a/shout/lib/Shout.php b/shout/lib/Shout.php index 9b2ee0294..6d1e363e9 100644 --- a/shout/lib/Shout.php +++ b/shout/lib/Shout.php @@ -27,11 +27,11 @@ class Shout $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')) { diff --git a/shout/recordings.php b/shout/recordings.php index 74f9454f8..c7eb52002 100644 --- a/shout/recordings.php +++ b/shout/recordings.php @@ -12,25 +12,25 @@ 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); diff --git a/shout/templates/dialplan/edit.inc b/shout/templates/dialplan/edit.inc index 69968900d..346d87297 100644 --- a/shout/templates/dialplan/edit.inc +++ b/shout/templates/dialplan/edit.inc @@ -11,8 +11,8 @@ - Sound File - + Recording +
@@ -26,11 +26,11 @@ - Sound File - + Recording + -
+
@@ -89,7 +89,7 @@ var menuInfo = $H(); var menuActions = $H(); var destinations = $H(); var conferences = $H(); -var soundfiles = $H(); +var recordings = $H(); function empty(p) { diff --git a/shout/templates/recordings/list.inc b/shout/templates/recordings/list.inc index f13e927ec..82769e811 100644 --- a/shout/templates/recordings/list.inc +++ b/shout/templates/recordings/list.inc @@ -5,38 +5,30 @@
- - - - $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
- - - - Recording NameRecording ID
+ + + +