From: Ben Klang Date: Thu, 4 Mar 2010 01:41:07 +0000 (-0500) Subject: Shout: Continue creating dialplan UI X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=db952ba034d8a2d9e4117f6f876f424ffb70573d;p=horde.git Shout: Continue creating dialplan UI --- diff --git a/shout/lib/Ajax/Application.php b/shout/lib/Ajax/Application.php index 55075ff5e..b466f7ed3 100644 --- a/shout/lib/Ajax/Application.php +++ b/shout/lib/Ajax/Application.php @@ -13,6 +13,7 @@ */ class Shout_Ajax_Application extends Horde_Ajax_Application_Base { + protected $_responseType = 'json'; /** * Returns a notification handler object to use to output any * notification messages triggered by the action. @@ -89,19 +90,19 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base */ 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 { + $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; + } $data['meta'] = $menus[$menu]; $data['actions'] = $shout->dialplan->getMenuActions($context, $menu); return $data; @@ -111,4 +112,61 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base return false; } } + /** + * TODO + */ + public function getMenuActions() + { + try { + $vars = $this->_vars; + $GLOBALS['shout'] = Horde_Registry::appInit('shout'); + $context = $_SESSION['shout']['context']; + $actions = Shout::getMenuActions(); + return $actions; + } 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 getActionForm() + { + try { + $vars = $this->_vars; + if (!($action = $vars->get('action'))) { + throw new Shout_Exception("Invalid action requested."); + } + $GLOBALS['shout'] = Horde_Registry::appInit('shout'); + $context = $_SESSION['shout']['context']; + $actions = Shout::getMenuActions(); + $action = $actions[$action]; + $form = new Horde_Form($vars, $action['description']); + foreach($action['args'] as $name => $info) { + $defaults = array( + 'required' => true, + 'readonly' => false, + 'description' => null, + 'params' => array() + ); + //$info = array_merge($info, $defaults); + $form->addVariable($info['name'], $name, $info['type'], + $info['required'], $info['readonly'], + $info['description'], $info['params']); + } + $this->_responseType = 'html'; + $form->renderActive(); + $output = ob_get_clean(); + return $output; + } 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/Shout.php b/shout/lib/Shout.php index d35a14244..2b0c02fae 100644 --- a/shout/lib/Shout.php +++ b/shout/lib/Shout.php @@ -136,4 +136,84 @@ class Shout return array($devid, $password); } + + static public function getMenuActions() + { + global $shout; + $context = $_SESSION['shout']['context']; + + return array( + 'menu' => array( + 'description' => _("Jump to menu."), + 'args' => array ( + 'menu' => array( + 'name' => _("Menu"), + 'type' => 'enum', + 'required' => true, + 'params' => array(self::getNames($shout->dialplan->getMenus($context))) + ) + ) + ), + 'ringexten' => array( + 'description' => _("Ring an extension."), + 'args' => array( + 'exten' => array( + 'name' => _("Extension"), + 'type' => 'enum', + 'required' => true, + 'params' => array(self::getNames($shout->extensions->getExtensions($context))) + ) + ) + ), + 'voicemail' => array( + 'description' => _("Leave a message."), + 'args' => array( + 'mailbox' => array( + 'name' => _("Mailbox"), + 'type' => 'enum', + 'required' => true, + 'params' => array(self::getNames($shout->extensions->getExtensions($context))) + ) + ) + ), + 'conference' => array( + 'description' => _("Enter conference room"), + 'args' => array( + 'roomno' => array( + 'name' => _("Room Number"), + 'type' => 'number', + 'required' => false + ) + ) + ), + 'directory' => array( + 'description' => _("Enter company directory."), + 'args' => array() + ), + 'dial' => array( + 'description' => _("Place an outgoing call."), + 'args' => array( + 'number' => array( + 'name' => _("Phone Number"), + 'type' => 'phone', + 'required' => true + ) + ) + ), + 'rewind' => array( + 'description' => _("Restart the current menu."), + 'args' => array() + ), + ); + } + + static public function getNames($array) + { + $res = array(); + foreach ($array as $id => $info) { + $res[$id] = $info['name']; + } + return $res; + } + } diff --git a/shout/templates/dialplan/edit.inc b/shout/templates/dialplan/edit.inc index c859b1d91..56867543d 100644 --- a/shout/templates/dialplan/edit.inc +++ b/shout/templates/dialplan/edit.inc @@ -2,24 +2,26 @@
-
+
SAVE
-
1
-
2
-
3
+
1
+
2
+
3

-
4
-
5
-
6
+
4
+
5
+
6

-
7
-
8
-
9
+
7
+
8
+
9

-
*
-
0
-
#
+
*
+
0
+
#
+
+
Default Action
\ No newline at end of file diff --git a/shout/themes/screen.css b/shout/themes/screen.css index f555193fc..9ceef3479 100644 --- a/shout/themes/screen.css +++ b/shout/themes/screen.css @@ -104,6 +104,22 @@ ul { -webkit-border-radius: 10px; } +#defaultAction { + width: 288px; + height: 38px; + border-top: 4px solid #aaa; + border-left: 4px solid #aaa; + border-right: 4px solid #444; + border-bottom: 4px solid #444; + padding: 3px; + margin: 1px; + background-image: url('graphics/digit-bg.png'); + background-repeat: no-repeat; + background-color: #999; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; +} + .digitLabel { font-style: italic; font-family: Sans-serif; @@ -112,9 +128,9 @@ ul { color: #666; } -#digitAction { +#editAction { width: 290px; - height: 390px; + height: 440px; margin: 5px; position: absolute; top: 0px;