<case name="Sql" desc="SQL">
<configsection name="params">
<configsql switchname="driverconfig" />
- <configstring name="table" desc="Table to hold the list of contexts/customers" required="true">shout_contexts</configstring>
</configsection>
</case>
</configswitch>
</configswitch>
</configsection>
</configtab>
+ <configtab name="dialplan" desc="Dialplan">
+ <configsection name="dialplan">
+ <configheader>Dialplan Storage</configheader>
+ <configswitch name="driver" desc="What backend should we use for storing Asterisk dialplan information?">Sql
+ <case name="Ldap" desc="LDAP">
+ <configsection name="params">
+ <configldap switchname="driverconfig" />
+ </configsection>
+ </case>
+ <case name="Sql" desc="SQL">
+ <configsection name="params">
+ <configsql switchname="driverconfig" />
+ <configstring name="table" desc="Table to hold the dialplan" required="true">extensions_table</configstring>
+ </configsection>
+ </case>
+ </configswitch>
+ </configsection>
+ </configtab>
</configuration>
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';
}
}
+ /**
+ * 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;
+ }
+ }
}
-
/**
* TODO
*/
- public $contexts = null;
+ public $storage = null;
/**
* TODO
/**
* TODO
*/
+ public $dialplan = null;
+
+ /**
+ * TODO
+ */
static protected $_perms = array();
/**
*/
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;
{
$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;
$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);
}
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
*
$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;
+++ /dev/null
-<script type="text/javascript">
-<!--
-function editAction(digit)
-{
- $('digitAction').show();
-}
-
-function saveAction(digit)
-{
- $('digitAction').hide();
-}
-// -->
-</script>
-
-<div id="digitpad">
- <div id="digitAction">
- <div onClick="saveAction('x');">SAVE</div>
- </div>
- <div class="digit" onClick="editAction('1');"><span class="digitLabel">1</span></div>
- <div class="digit" onClick="editAction('2');"><span class="digitLabel">2</span></div>
- <div class="digit" onClick="editAction('3');"><span class="digitLabel">3</span></div>
- <br style="clear:both;">
- <div class="digit" onClick="editAction('4');"><span class="digitLabel">4</span></div>
- <div class="digit" onClick="editAction('5');"><span class="digitLabel">5</span></div>
- <div class="digit" onClick="editAction('6');"><span class="digitLabel">6</span></div>
- <br style="clear:both;">
- <div class="digit" onClick="editAction('7');"><span class="digitLabel">7</span></div>
- <div class="digit" onClick="editAction('8');"><span class="digitLabel">8</span></div>
- <div class="digit" onClick="editAction('9');"><span class="digitLabel">9</span></div>
- <br style="clear:both;">
- <div class="digit" onClick="editAction('*');"><span class="digitLabel">*</span></div>
- <div class="digit" onClick="editAction('0');"><span class="digitLabel">0</span></div>
- <div class="digit" onClick="editAction('#');"><span class="digitLabel">#</span></div>
-</div>
-
-<script type="text/javascript">
-<!--
-$('digitAction').hide();
-// -->
-</script>
\ No newline at end of file
<?php
// Only show the context selector if there is more than one available context
try {
- $contexts = $shout->contexts->getContexts();
+ $contexts = $shout->storage->getContexts();
} catch (Exception $e) {
$contexts = array();
}
font-style: italic;
}
+#menuInfo {
+ float: left;
+ width: 300px;
+}
+
+#menuInfo img:hover {
+ cursor: pointer;
+}
+
+.menuStatName {
+ font-weight: bold;
+}
+
#digitpad {
width: 300px;
height: 400px;
padding: 3px;
margin: 1px;
background-image: url('graphics/digit-bg.png');
+ -moz-border-radius: 10px;
+ -webkit-border-radius: 10px;
}
.digitLabel {