From: Ben Klang Date: Mon, 8 Mar 2010 23:15:27 +0000 (-0500) Subject: Shout: Fix displaying dialplan editor X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1711266fd3cb67fde350a538fb445421a5aae98f;p=horde.git Shout: Fix displaying dialplan editor ...and while we're at it, optimize away one unnecessary AJAX call. --- diff --git a/shout/lib/Ajax/Application.php b/shout/lib/Ajax/Application.php index fee3d148f..a5f50acea 100644 --- a/shout/lib/Ajax/Application.php +++ b/shout/lib/Ajax/Application.php @@ -34,7 +34,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base { $vars = $this->_vars; $shout = Horde_Registry::appInit('shout'); - $account = $_SESSION['shout']['account']; + $account = $_SESSION['shout']['curaccount']; try { $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); $shout->extensions->addDestination($account, $vars->extension, $vars->type, $vars->destination); @@ -54,7 +54,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base { $vars = $this->_vars; $shout = Horde_Registry::appInit('shout'); - $account = $_SESSION['shout']['account']; + $account = $_SESSION['shout']['curaccount']; try { // FIXME: Use Form? $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); @@ -93,25 +93,27 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base try { $vars = $this->_vars; $shout = Horde_Registry::appInit('shout'); - $account = $_SESSION['shout']['account']; + $account = $_SESSION['shout']['curaccount']; $menus = $shout->storage->getMenus($account); $menu = $vars->menu; if (!isset($menus[$menu])) { Horde::logMessage("User requested a menu that does not exist.", __FILE__, __LINE__, PEAR_LOG_ERR); - $notification->push(_("That menu does not exist."), 'horde.error'); - $action = 'list'; + //$GLOBALS['notification']->push(_("That menu does not exist."), 'horde.error'); // FIXME notifications return false; } + $data['meta'] = $menus[$menu]; $data['actions'] = $shout->dialplan->getMenuActions($account, $menu); return $data; } catch (Exception $e) { //FIXME: Create a way to notify the user of the failure. + die(var_dump($e)); Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR); return false; } } + /** * TODO */ @@ -120,7 +122,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base try { $vars = $this->_vars; $GLOBALS['shout'] = Horde_Registry::appInit('shout'); - $account = $_SESSION['shout']['account']; + $account = $_SESSION['shout']['curaccount']; $actions = Shout::getMenuActions($contex, $menu); return $actions; } catch (Exception $e) { @@ -138,7 +140,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base throw new Shout_Exception("Invalid action requested."); } $GLOBALS['shout'] = Horde_Registry::appInit('shout'); - $account = $_SESSION['shout']['account']; + $account = $_SESSION['shout']['curaccount']; $actions = Shout::getMenuActions(); $action = $actions[$action]; $form = new Horde_Form($vars, $action['description'], 'editActionForm'); diff --git a/shout/lib/Driver/Sql.php b/shout/lib/Driver/Sql.php index 839d21f4e..303e44285 100644 --- a/shout/lib/Driver/Sql.php +++ b/shout/lib/Driver/Sql.php @@ -102,11 +102,11 @@ class Shout_Driver_Sql extends Shout_Driver $menus[$account] = array(); while ($row && !($row instanceof PEAR_Error)) { - $menu = $row['menu_name']; + $menu = $row['name']; $menus[$account][$menu] = array( 'name' => $menu, - 'description' => $row['menu_description'], - 'soundfile' => $row['menu_soundfile'] + 'description' => $row['description'], + 'soundfile' => $row['soundfile'] ); $row = $result->fetchRow(DB_FETCHMODE_ASSOC); } @@ -121,18 +121,18 @@ class Shout_Driver_Sql extends Shout_Driver return $menuActions[$menu]; } - $sql = "SELECT accounts.accountcode AS account, menus.name AS description, " . + $sql = "SELECT accounts.code AS account, menus.name AS description, " . "actions.name AS action, menu_entries.digit AS digit, " . "menu_entries.args AS args FROM menu_entries " . "INNER JOIN menus ON menu_entries.menu_id = menus.id " . "INNER JOIN actions ON menu_entries.action_id = actions.id " . "INNER JOIN accounts ON menus.account_id = accounts.id " . - "WHERE accounts.accountcode = ? AND menus.name = ?"; - $values = array($account, $menuid); + "WHERE accounts.code = ? AND menus.name = ?"; + $values = array($account, $menu); $msg = 'SQL query in Shout_Driver_Sql#getMenuActions(): ' . $sql; Horde::logMessage($msg, __FILE__, __LINE__, PEAR_LOG_DEBUG); - $result = $this->_db->query($sql, $vars); + $result = $this->_db->query($sql, $values); if ($result instanceof PEAR_Error) { throw new Shout_Exception($result); } @@ -152,7 +152,8 @@ class Shout_Driver_Sql extends Shout_Driver $row = $result->fetchRow(DB_FETCHMODE_ASSOC); } $result->free(); - return $menus[$menu]; + + return $menuActions[$menu]; } /** diff --git a/shout/templates/dialplan/edit.inc b/shout/templates/dialplan/edit.inc index b1543a817..712a331c8 100644 --- a/shout/templates/dialplan/edit.inc +++ b/shout/templates/dialplan/edit.inc @@ -31,7 +31,7 @@ var ajax_url = ''; var menu = ''; var menuInfo = $H(); -var menuActions = $H(); +var menuActions = $H(); var curDigit = null; function editAction(digit) @@ -191,13 +191,5 @@ new Ajax.Request(ajax_url + 'getMenuInfo', refreshMenu(); } }); -new Ajax.Request(ajax_url + 'getMenuActions', -{ - method: 'post', - onSuccess: function(r) { - menuActions = $H(r.responseJSON.response); - refreshMenu(); - } -}); // --> \ No newline at end of file