From: Ben Klang Date: Sun, 28 Feb 2010 22:22:23 +0000 (-0500) Subject: Shout: Continue working on dialplan editor UI X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=c899854a7187cfe8244d6960186c0ddd0fc44ea8;p=horde.git Shout: Continue working on dialplan editor UI --- diff --git a/shout/config/conf.xml b/shout/config/conf.xml index cb5ba5b53..ab0cf074d 100644 --- a/shout/config/conf.xml +++ b/shout/config/conf.xml @@ -19,7 +19,6 @@ - shout_contexts @@ -61,5 +60,23 @@ + + + Dialplan Storage + Sql + + + + + + + + + extensions_table + + + + + diff --git a/shout/dialplan.php b/shout/dialplan.php index a801ed221..a08413d76 100644 --- a/shout/dialplan.php +++ b/shout/dialplan.php @@ -14,10 +14,28 @@ $shout = Horde_Registry::appInit('shout'); require_once SHOUT_BASE . '/lib/Forms/ExtensionForm.php'; -//$action = Horde_Util::getFormData('action'); -$action = 'show'; +$action = Horde_Util::getFormData('action'); +$menu = Horde_Util::getFormData('menu'); $context = $_SESSION['shout']['context']; +$menus = $shout->storage->getMenus($context); + +switch($action) { +case 'edit': + if (!isset($menus[$menu])) { + $notification->push(_("That menu does not exist."), 'horde.error'); + $action = 'list'; + break; + } + $menu = $menus[$menu]; + break; +case 'list': +default: + $action = 'list'; + break; +} + +Horde::addScriptFile('stripe.js', 'horde'); Horde::addScriptFile('prototype.js', 'horde'); require SHOUT_TEMPLATES . '/common-header.inc'; diff --git a/shout/lib/Ajax/Application.php b/shout/lib/Ajax/Application.php index 054bd42a5..55075ff5e 100644 --- a/shout/lib/Ajax/Application.php +++ b/shout/lib/Ajax/Application.php @@ -84,5 +84,31 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base } } + /** + * TODO + */ + public function getMenuInfo() + { + $vars = $this->_vars; + $shout = Horde_Registry::appInit('shout'); + $context = $_SESSION['shout']['context']; + $menus = $shout->storage->getMenus($context); + $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'; + // FIXME notifications + return false; + } + try { + $data['meta'] = $menus[$menu]; + $data['actions'] = $shout->dialplan->getMenuActions($context, $menu); + return $data; + } 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; + } + } } - diff --git a/shout/lib/Application.php b/shout/lib/Application.php index 81dabd6ff..4110a39d4 100644 --- a/shout/lib/Application.php +++ b/shout/lib/Application.php @@ -45,7 +45,7 @@ class Shout_Application extends Horde_Registry_Application /** * TODO */ - public $contexts = null; + public $storage = null; /** * TODO @@ -60,6 +60,11 @@ class Shout_Application extends Horde_Registry_Application /** * TODO */ + public $dialplan = null; + + /** + * TODO + */ static protected $_perms = array(); /** @@ -69,12 +74,13 @@ class Shout_Application extends Horde_Registry_Application */ protected function _init() { - $this->contexts = Shout_Driver::factory('storage'); + $this->storage = Shout_Driver::factory('storage'); $this->extensions = Shout_Driver::factory('extensions'); $this->devices = Shout_Driver::factory('devices'); + $this->dialplan = Shout_Driver::factory('dialplan'); try { - $contexts = $this->contexts->getContexts(); + $contexts = $this->storage->getContexts(); } catch (Shout_Exception $e) { $GLOBALS['notification']->push($e); $contexts = false; diff --git a/shout/lib/Driver/Sql.php b/shout/lib/Driver/Sql.php index 2f5f8292a..7573d894a 100644 --- a/shout/lib/Driver/Sql.php +++ b/shout/lib/Driver/Sql.php @@ -48,8 +48,7 @@ class Shout_Driver_Sql extends Shout_Driver { $this->_connect(); - $sql = 'SELECT context_name FROM %s'; - $sql = sprintf($sql, $this->_params['table']); + $sql = 'SELECT context_name FROM shout_contexts'; $vars = array(); $msg = 'SQL query in Shout_Driver_Sql#getContexts(): ' . $sql; @@ -66,10 +65,7 @@ class Shout_Driver_Sql extends Shout_Driver $contexts = array(); while ($row && !($row instanceof PEAR_Error)) { - /* Add this new foo to the $_foo list. */ $contexts[] = $row['context_name']; - - /* Advance to the new row in the result set. */ $row = $result->fetchRow(DB_FETCHMODE_ASSOC); } @@ -77,6 +73,50 @@ class Shout_Driver_Sql extends Shout_Driver return $contexts; } + public function getMenus($context) + { + static $menus; + if (isset($menus[$context])) { + return $menus[$context]; + } + + $this->_connect(); + + $sql = 'SELECT menu_name, menu_description, menu_soundfile ' . + 'FROM shout_menus WHERE context_name = ?'; + $vars = array($context); + + $msg = 'SQL query in Shout_Driver_Sql#getContexts(): ' . $sql; + Horde::logMessage($msg, __FILE__, __LINE__, PEAR_LOG_DEBUG); + $result = $this->_db->query($sql, $vars); + if ($result instanceof PEAR_Error) { + throw new Shout_Exception($result); + } + + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + if ($row instanceof PEAR_Error) { + throw new Shout_Exception($row); + } + + $menus[$context] = array(); + while ($row && !($row instanceof PEAR_Error)) { + $menu = $row['menu_name']; + $menus[$context][$menu] = array( + 'name' => $menu, + 'description' => $row['menu_description'], + 'soundfile' => $row['menu_soundfile'] + ); + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + } + $result->free(); + return $menus[$context]; + } + + function getMenuActions($context, $menu) + { + return array(); + } + /** * Get a list of devices for a given context * diff --git a/shout/lib/Shout.php b/shout/lib/Shout.php index ebbf77744..65e7b3353 100644 --- a/shout/lib/Shout.php +++ b/shout/lib/Shout.php @@ -30,10 +30,10 @@ class Shout $menu = new Horde_Menu(Horde_Menu::MASK_ALL); + $menu->add(Horde::applicationUrl('dialplan.php'), _("Incoming Calls"), "dialplan.png"); $menu->add(Horde::applicationUrl('extensions.php'), _("Extensions"), "user.png"); $menu->add(Horde::applicationUrl('devices.php'), _("Devices"), "shout.png"); - $menu->add(Horde::applicationUrl('routes.php'), _("Call Paths")); - + $menu->add(Horde::applicationUrl('recordings.php'), _("Recordings"), "recordings.png"); if ($returnType == 'object') { return $menu; diff --git a/shout/templates/dialplan/show.inc b/shout/templates/dialplan/show.inc deleted file mode 100644 index 9123402ce..000000000 --- a/shout/templates/dialplan/show.inc +++ /dev/null @@ -1,40 +0,0 @@ - - -
-
-
SAVE
-
-
1
-
2
-
3
-
-
4
-
5
-
6
-
-
7
-
8
-
9
-
-
*
-
0
-
#
-
- - \ No newline at end of file diff --git a/shout/templates/menu.inc b/shout/templates/menu.inc index 7c08e9ece..013992828 100644 --- a/shout/templates/menu.inc +++ b/shout/templates/menu.inc @@ -10,7 +10,7 @@ $menu_view = $prefs->getValue('menu_view'); contexts->getContexts(); + $contexts = $shout->storage->getContexts(); } catch (Exception $e) { $contexts = array(); } diff --git a/shout/themes/screen.css b/shout/themes/screen.css index ed9f31aa7..f555193fc 100644 --- a/shout/themes/screen.css +++ b/shout/themes/screen.css @@ -68,6 +68,19 @@ ul { font-style: italic; } +#menuInfo { + float: left; + width: 300px; +} + +#menuInfo img:hover { + cursor: pointer; +} + +.menuStatName { + font-weight: bold; +} + #digitpad { width: 300px; height: 400px; @@ -87,6 +100,8 @@ ul { padding: 3px; margin: 1px; background-image: url('graphics/digit-bg.png'); + -moz-border-radius: 10px; + -webkit-border-radius: 10px; } .digitLabel {