From: Ben Klang Date: Sun, 28 Mar 2010 02:33:14 +0000 (-0400) Subject: Shout: Enable removing actions from digits X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b4940ff9ea3cf1cdd31b03c23a87a4311ba397a0;p=horde.git Shout: Enable removing actions from digits --- diff --git a/shout/lib/Ajax/Application.php b/shout/lib/Ajax/Application.php index 449dfaf2a..3d42a16e1 100644 --- a/shout/lib/Ajax/Application.php +++ b/shout/lib/Ajax/Application.php @@ -139,6 +139,13 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base $digit = $vars->get('digit'); $menu = $vars->get('menu'); $action = $vars->get('action'); + + if ($action == 'none') { + // Remove the menu action and return + $shout->dialplan->deleteMenuAction($account, $menu, $digit); + return true; + } + $actions = Shout::getMenuActions(); if (!isset($actions[$action])) { throw new Shout_Exception('Invalid action requested.'); @@ -148,6 +155,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base $args[$name] = $vars->get($name); } $shout->dialplan->saveMenuAction($account, $menu, $digit, $action, $args); + return true; } catch (Exception $e) { //FIXME: Create a way to notify the user of the failure. Horde::logMessage($e, 'ERR'); diff --git a/shout/lib/Driver/Sql.php b/shout/lib/Driver/Sql.php index 93e55ae4c..47c5680f2 100644 --- a/shout/lib/Driver/Sql.php +++ b/shout/lib/Driver/Sql.php @@ -208,7 +208,7 @@ class Shout_Driver_Sql extends Shout_Driver return $menuActions[$menu]; } - public function saveMenuAction($account, $menu, $digit, $action, $args) + public function deleteMenuAction($account, $menu, $digit) { // Remove any existing action $sql = 'DELETE FROM menu_entries WHERE menu_id = ' . @@ -222,6 +222,11 @@ class Shout_Driver_Sql extends Shout_Driver if ($result instanceof PEAR_Error) { throw new Shout_Exception($result); } + } + + public function saveMenuAction($account, $menu, $digit, $action, $args) + { + $this->deleteMenuAction($account, $menu, $digit); $sql = 'INSERT INTO menu_entries (menu_id, digit, action_id, args) ' . 'VALUES((SELECT id FROM menus WHERE account_id = ' . diff --git a/shout/lib/Shout.php b/shout/lib/Shout.php index d88a9c553..6291daafc 100644 --- a/shout/lib/Shout.php +++ b/shout/lib/Shout.php @@ -205,7 +205,12 @@ class Shout 'description' => _("Restart menu"), 'args' => array() ), - // TODO: Actions to implement: Queue + 'none' => array( + 'description' => _("No action"), + 'args' => array() + ) + + // TODO: Actions to implement: Queue, VoicemailLogin ); } diff --git a/shout/templates/dialplan/edit.inc b/shout/templates/dialplan/edit.inc index 5e25c9e0d..6ca77ee1d 100644 --- a/shout/templates/dialplan/edit.inc +++ b/shout/templates/dialplan/edit.inc @@ -132,11 +132,6 @@ function editAction(digit) if (menuInfo.get(curmenu).actions[digit] != null) { select.value = menuInfo.get(curmenu).actions[digit].action } - var option = document.createElement('option'); - option.value = 'none'; - var text = document.createTextNode(''); - option.appendChild(text); - select.appendChild(option); $('selectAction').appendChild(select); // Cancel button @@ -234,6 +229,7 @@ function editAction(digit) div.appendChild(img); break; + case 'directory': case 'rewind': case 'none': break;