<item modified_time="1130769960" url="dialplan/edit.php" uploadstatus="1" />
<item url="lib/" uploadstatus="1" />
<item url="lib/Driver/" uploadstatus="1" />
- <item modified_time="1131599873" url="lib/Driver/ldap.php" uploadstatus="1" />
+ <item modified_time="1131765770" url="lib/Driver/ldap.php" uploadstatus="1" />
<item modified_time="1131497449" url="lib/base.php" uploadstatus="1" />
- <item modified_time="1121689003" url="lib/Dialplan.php" uploadstatus="1" />
+ <item modified_time="1131769562" url="lib/Dialplan.php" uploadstatus="1" />
<item modified_time="1130769960" url="lib/Driver.php" uploadstatus="1" />
<item modified_time="1131593364" url="lib/Shout.php" uploadstatus="1" />
<item modified_time="1121689003" url="lib/System.php" uploadstatus="1" />
<item modified_time="1130769961" url="lib/User.php" uploadstatus="1" />
<item url="main/" uploadstatus="1" />
- <item modified_time="1131735732" url="main/dialplan.php" uploadstatus="1" />
+ <item modified_time="1131765933" url="main/dialplan.php" uploadstatus="1" />
<item modified_time="1121401845" url="main/moh.php" uploadstatus="1" />
<item modified_time="1130769962" url="main/system.php" uploadstatus="1" />
<item modified_time="1121689003" url="main/users.php" uploadstatus="1" />
<item modified_time="1131594877" url="templates/users/userlist.inc" uploadstatus="1" />
<item modified_time="1120174958" url="templates/common-header.inc" uploadstatus="1" />
<item modified_time="1120073766" url="templates/content_page" uploadstatus="1" />
- <item modified_time="1131593241" url="templates/menu.inc" uploadstatus="1" />
+ <item modified_time="1131772201" url="templates/menu.inc" uploadstatus="1" />
<item modified_time="1121578596" url="templates/table-limiter-begin.inc" uploadstatus="1" />
<item modified_time="1121578596" url="templates/table-limiter-end.inc" uploadstatus="1" />
<item url="themes/" uploadstatus="1" />
<uploadeditem upload_time="1130769960" url="dialplan/edit.php" />
<uploadeditem upload_time="1131593241" url="index.php" />
<uploadeditem upload_time="0" url="lib/" />
- <uploadeditem upload_time="1121689003" url="lib/Dialplan.php" />
+ <uploadeditem upload_time="1131769562" url="lib/Dialplan.php" />
<uploadeditem upload_time="1130769960" url="lib/Driver.php" />
<uploadeditem upload_time="0" url="lib/Driver/" />
- <uploadeditem upload_time="1131599873" url="lib/Driver/ldap.php" />
+ <uploadeditem upload_time="1131765770" url="lib/Driver/ldap.php" />
<uploadeditem upload_time="1131593364" url="lib/Shout.php" />
<uploadeditem upload_time="1121689003" url="lib/System.php" />
<uploadeditem upload_time="1130769961" url="lib/User.php" />
<uploadeditem upload_time="1131497449" url="lib/base.php" />
<uploadeditem upload_time="1131045729" url="lib/defines.php" />
<uploadeditem upload_time="0" url="main/" />
- <uploadeditem upload_time="1131735732" url="main/dialplan.php" />
+ <uploadeditem upload_time="1131765933" url="main/dialplan.php" />
<uploadeditem upload_time="1121401845" url="main/moh.php" />
<uploadeditem upload_time="1130769962" url="main/system.php" />
<uploadeditem upload_time="1121689003" url="main/users.php" />
<uploadeditem upload_time="0" url="templates/dialplan/" />
<uploadeditem upload_time="1131723538" url="templates/dialplan/contexttree.inc" />
<uploadeditem upload_time="1131593241" url="templates/dialplan/dialplanlist.inc" />
- <uploadeditem upload_time="1131744370" url="templates/dialplan/extensiondetail.inc" />
+ <uploadeditem upload_time="1131767776" url="templates/dialplan/extensiondetail.inc" />
+ <uploadeditem upload_time="1131768673" url="templates/dialplan/manager.inc" />
<uploadeditem upload_time="1121689030" url="templates/dialplan/priority-form-begin.inc" />
<uploadeditem upload_time="1121689030" url="templates/dialplan/priority-form-end.inc" />
<uploadeditem upload_time="1121689030" url="templates/dialplan/priority-form-line.inc" />
<uploadeditem upload_time="0" url="templates/javascript/" />
- <uploadeditem upload_time="1131744813" url="templates/javascript/dialplan.js" />
- <uploadeditem upload_time="1131593241" url="templates/menu.inc" />
+ <uploadeditem upload_time="1131782749" url="templates/javascript/dialplan.js" />
+ <uploadeditem upload_time="1131772201" url="templates/menu.inc" />
<uploadeditem upload_time="1121578596" url="templates/table-limiter-begin.inc" />
<uploadeditem upload_time="1121578596" url="templates/table-limiter-end.inc" />
<uploadeditem upload_time="0" url="templates/users/" />
</teamdata>
<events/>
<item modified_time="1131045729" url="lib/defines.php" uploadstatus="1" />
- <item modified_time="1131723538" url="templates/dialplan/contexttree.inc" uploadstatus="1" />
- <item modified_time="1131744370" url="templates/dialplan/extensiondetail.inc" uploadstatus="1" />
+ <item modified_time="1131767776" url="templates/dialplan/extensiondetail.inc" uploadstatus="1" />
<item modified_time="1131497712" url="security.php" uploadstatus="1" />
<item url="templates/javascript/" uploadstatus="1" />
- <item modified_time="1131744813" url="templates/javascript/dialplan.js" uploadstatus="1" />
+ <item modified_time="1131782749" url="templates/javascript/dialplan.js" uploadstatus="1" />
+ <item modified_time="1131768673" url="templates/dialplan/manager.inc" />
<treestatus>
<openfolder url="lib" />
<openfolder url="lib/Driver" />
* @package Shout
*/
// {{{
-class ExtensionDetailsForm extends Horde_Form {
+/**
+ * The Shout_Dialplan:: class provides an interactive view of an Asterisk dialplan.
+ * It allows for expanding/collapsing of extensions and priorities and maintains their state.
+ * It can work together with the Horde_Tree javascript class to achieve this in
+ * DHTML on supported browsers.
+ *
+ * Copyright 2005 Ben Klang <ben@alkaloid.net>
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * $Horde: framework/Tree/Tree.php,v 1.46.6.7 2005/07/03 05:22:36 selsky Exp $
+ *
+ * @author Ben Klang <ben@alkaloid.net>
+ * @package Shout_Dialplan
+ * @since Shout 0.1
+ */
+class Shout_Dialplan
+{
+ /**
+ * The name of this instance.
+ *
+ * @var string
+ */
+ var $_instance = null;
- function ExtensionDetailsForm(&$vars)
- {
- global $shout;
- $context = $vars->get("context");
- $extension = $vars->get("extension");
-
- $dialplan = &$shout->getDialplan($context);
- $extendata = $dialplan['extensions'][$extension];
- if (array_key_exists($extension, $dialplan['extensions'])) {
- $formtitle = "Edit Extension";
- } else {
- $formtitle = "Add Extension";
- }
-
- parent::Horde_Form($vars, _("$formtitle - Context: $context"));
-
- $this->addHidden('', 'context', 'text', true);
- $this->addHidden('', 'oldextension', 'text', true);
- $vars->set('oldextension', $extension);
- $this->addHidden('', 'action', 'text', true);
-// $vars->set('action', 'save');
- $this->addVariable(_("Extension"), 'extension', 'text', true);
- $this->addVariable(_("Priority"), 'priority', 'priority', true);
-// foreach ($extendata as $priority => $application) {
-// $vars->set("priority$priority", $application);
-// $this->addVariable("Priority $priority", "priority$priority",
-// 'text', false);
-// }
- }
-
- // {{{ fillUserForm method
/**
- * Fill in the blanks for the UserDetailsForm
+ * The array of dialplan information to render the form
*
- * @param object Reference to a Variables object to fill in
+ * @var array
+ */
+ var $_dialplan = array();
+
+ /**
+ * Object containing the instantiation of the Horde_Tree class
*
- * @param array User details
+ * @var object
+ */
+ var $_tree = null;
+
+ /**
+ * Create or return a unique instance of the Shout_Dialplan object
*
- * @return boolean True if successful, Pear::raiseError object on failure
+ * @param string $instance Unique identifier for this instance
+ * @param array $dialplan Dialplan array as returned by the driver
+ * @return object Instantiation of the Shout_Dialplan object
*/
- function fillExtensionFormPriority(&$vars, $extensiondetails)
- {
- #Array ( [dialopts] => Array ( [0] => m [1] => t ) [mailboxopts] => Array (
- #) [mailboxpin] => 1234 [name] => Ricardo Paul [phonenumbers] => Array ( )
- #[dialtimeout] => 30 [email] => ricardo.paul@v-office.biz [pageremail] => )
- $vars->set('name', $userdetails['name']);
- $vars->set('email', @$userdetails['email']);
- $vars->set('pin', $userdetails['mailboxpin']);
-
- $i = 1;
- foreach($userdetails['phonenumbers'] as $number) {
- $vars->set("telephone$i", $number);
- $i++;
- }
-
- if (in_array('m', $userdetails['dialopts'])) {
- $vars->set('moh', true);
- } else {
- $vars->set('moh', false);
- }
-
- if (in_array('t', $userdetails['dialopts'])) {
- $vars->set('transfer', true);
- } else {
- $vars->set('transfer', false);
+ function &singleton($instance, $dialplan)
+ {
+ static $instances = array();
+
+ if (isset($instances[$instance])) {
+ return $instances[$instance];
}
-
- return true;
+ $instances[$instance] = new Shout_Dialplan($instance, $dialplan);
+ return $instances[$instance];
}
- // }}}
-}
-// }}}
-
-class Horde_Form_Type_priority extends Horde_Form_Type {
-
-// var $_regex;
-// var $_size;
-// var $_maxlength;
/**
- * The initialisation function for the text variable type.
- *
- * @access private
+ * Instantiator for the Shout_Dialplan
*
- * @param string $regex Any valid PHP PCRE pattern syntax that
- * needs to be matched for the field to be
- * considered valid. If left empty validity
- * will be checked only for required fields
- * whether they are empty or not.
- * If using this regex test it is advisable
- * to enter a description for this field to
- * warn the user what is expected, as the
- * generated error message is quite generic
- * and will not give any indication where
- * the regex failed.
- * @param integer $size The size of the input field.
- * @param integer $maxlength The max number of characters.
+ * @param string $instance Unique identifier for this instance
+ * @param array $dialplan Dialplan array as returned by the driver
+ * @return Shout_Dialplan Instantiation of the Shout_Dialplan object
*/
- function init()
- {
- }
-// function init($regex = '', $size = 40, $maxlength = null)
-// {
-// $this->_regex = $regex;
-// $this->_size = $size;
-// $this->_maxlength = $maxlength;
-// }
-
- function isValid(&$var, &$vars, $value, &$message)
+ function Shout_Dialplan($instance, $dialplan)
{
- $valid = true;
+ require_once 'Horde/Tree.php';
+ require_once 'Horde/Block.php';
+ require_once 'Horde/Block/Collection.php';
-// if ($var->isRequired() && empty($this->_regex)) {
-// $valid = strlen(trim($value)) > 0;
-//
-// if (!$valid) {
-// $message = _("This field is required.");
-// }
-// } elseif (!empty($this->_regex)) {
-// $valid = preg_match($this->_regex, $value);
-//
-// if (!$valid) {
-// $message = _("You have to enter a valid value.");
-// }
-// }
+ $this->_instance = $instance;
+ $this->_dialplan = $dialplan;
+ $this->_tree = Horde_Tree::singleton('shout_dialplan_nav_'.$instance, 'javascript');
- return $valid;
- }
+ foreach ($this->_dialplan as $linetype => $linedata) {
+ switch($linetype) {
+ case 'extensions':
+ $url = '#top';
+ $this->_tree->addNode('extensions', null, 'Extensions', null, array('url' => $url));
+ foreach ($linedata as $extension => $priorities) {
+ $nodetext = Shout::exten2name($extension);
+ $url = Horde::applicationUrl('index.php?section=dialplan' .
+ '&extension=' . $extension . '&context=' . $this->_dialplan['name']);
+ $url = "#$extension";
+ $this->_tree->addNode("extension_".$extension, 'extensions', $nodetext,
+ null, false,
+ array(
+ 'url' => $url,
+ 'onclick' =>
+ 'shout_dialplan_object_'.$this->_instance.
+ '.highlightExten(\''.$extension.'\')',
+ )
+ );
+ // foreach ($priorities as $priority => $application) {
+ // $this->_tree->addNode("$extension-$priority", $extension, "$priority: $application", null);
+ // }
+ }
+ break;
- function getSize()
- {
- return $this->_size;
- }
+ case 'includes':
+ $this->_tree->addNode('includes', null, 'Includes', null);
+ foreach ($linedata as $include) {
+ $url = Horde::applicationUrl('index.php?section=dialplan&context='.$include);
+ $this->_tree->addNode("include_$include", 'includes', $include, null,
+ true, array('url' => $url));
+ }
+ break;
- function getMaxLength()
- {
- return $this->_maxlength;
+ # TODO Ignoring ignorepat lines for now
+
+ case 'barelines':
+ $this->_tree->addNode('barelines', null, 'Extra Settings', null);
+ $i = 0;
+ foreach ($linedata as $bareline) {
+ $this->_tree->addNode("bareline_".$i, 'barelines', $bareline, null);
+ $i++;
+ }
+ break;
+ }
+ }
}
/**
- * Return info about field type.
+ * Render dialplan side navigation tree
*/
- function about()
+ function renderNavTree()
+ {
+ print '<div id=\'contextTree\'>'."\n";
+ $this->_tree->renderTree(true);
+ print ' <br />'."\n";
+ print ' <a href="#top" class="small">Back to Top</a>'."\n";
+ print '</div>'."\n";
+ return true;
+ }
+
+ function renderAppList()
{
- $about = array();
- $about['name'] = _("Extension Priority");
- $about['params'] = array(
- 'priority' => array('label' => _("Priority"),
- 'type' => 'int'),
- 'application' => array('label' => _("Application"),
- 'type' => 'stringlist'),
- 'args' => array('label' => _("Arguments"),
- 'type' => 'text'),
- );
- return $about;
+ # $applist = Shout::getApplist();
+ print '<script language="JavaScript" type="text/javascript">'."\n";
+ print '<!--'."\n";
+ print 'var shout_dialplan_applist_'.$this->_instance.' = new Array();'."\n";
+
+ $i = 0;
+ $app = "APPLICATION";
+ # foreach ($applist as $app) {
+ print 'shout_dialplan_applist_'.$this->_instance.'['.$i.'] = \''.$app.'\''."\n";
+ # }
+ print '//-->'."\n";
+ print '</script>'."\n";
+ return true;
}
-}
+ function renderExtensions()
+ {
+ if(!isset($this->_dialplan['extensions'])) {
+ print '<div id="extensionDetail">'."\n";
+ print ' <div class="extensionBox">No Configured Extensions</div>'."\n";
+ print '</div>'."\n";
+ } else {
+ print '<script language="JavaScript" type="text/javascript"';
+ print ' src="/services/javascript.php?file=dialplan.js&app=shout"></script>'."\n";
+ print '<script language="JavaScript" type="text/javascript">'."\n";
+ print '<!--'."\n";
+ print 'var shout_dialplan_entry_'.$this->_instance.' = new Array();'."\n";
+ foreach($this->_dialplan['extensions'] as $extension => $priorities) {
+ print 'shout_dialplan_entry_'.$this->_instance.'[\''.$extension.'\'] = new Array();'."\n";
+ print 'shout_dialplan_entry_'.$this->_instance.'[\''.$extension.'\'][\'name\'] =';
+ print '\''.Shout::exten2name($extension).'\';'."\n";
+ print 'shout_dialplan_entry_'.$this->_instance.'[\''.$extension.'\'][\'priorities\']';
+ print ' = new Array();'."\n";
+ foreach($priorities as $priority => $data) {
+ print 'shout_dialplan_entry_'.$this->_instance.'[\''.$extension.'\']';
+ print '[\'priorities\']['.$priority.'] = new Array();'."\n";
+ print 'shout_dialplan_entry_'.$this->_instance.'[\''.$extension.'\']';
+ print '[\'priorities\']['.$priority.'][\'application\'] = ';
+ print '\''.$data['application'].'\';'."\n";
+ print 'shout_dialplan_entry_'.$this->_instance.'[\''.$extension.'\'][\'priorities\']';
+ print '['.$priority.'][\'args\'] = \''.$data['args'].'\';'."\n";
+ }
+ }
+ print 'var shout_dialplan_object_'.$this->_instance.' = new Dialplan(\''.$this->_instance.'\');'."\n";
+ print '//-->'."\n";
+ print '</script>'."\n";
-// require_once HORDE_BASE . '/lib/Horde/UI/VarRenderer.php';
-// require_once HORDE_BASE . '/lib/Horde/UI/VarRenderer/html.php';
-// class Horde_UI_VarRenderer_html_priority extends Horde_UI_VarRenderer_html
-// {
-// function _renderVarInput_priority(&$form, &$var, &$vars)
-// {
-// echo '<input type="text" name="priority[0]" value="88" size="3" ';
-// echo 'id="priority[0]" />';
-// echo '<select><option>GotoSelf</option></select>\n';
-// echo '<input type="text" name="application[0]" ';
-// echo 'size="40" value="101" id="application[0]" />';
-// }
-//
-// function _renderVarDisplay_priority(&$form, &$var, &$vars)
-// {
-// echo '<input type="text" name="priority[0]" value="88" size="3" ';
-// echo 'id="priority[0]" />';
-// echo '<select><option>GotoSelf</option></select>\n';
-// echo '<input type="text" name="application[0]" ';
-// echo 'size="40" value="101" id="application[0]" />';
-// }
-// }
\ No newline at end of file
+ print '<div id="extensionDetail">'."\n";
+ $e = 0;
+ foreach($this->_dialplan['extensions'] as $extension => $priorities) {
+ print '<div class="extension" ';
+ print 'id="extension_'.$extension.'" ';
+ print '<a name="'.$extension.'" />'."\n";
+ print '<div class="extensionBox" ';
+ print 'id="eBox-'.$extension.'" ';
+ print 'onclick="javascript:shout_dialplan_object_'.$this->_instance.'.highlightExten';
+ print '('.$extension.');">'."\n";
+ print Shout::exten2name($extension);
+ print '</div>'."\n";
+ print '<div id="pList-'.$extension.'">'."\n";
+ print '</div>'."\n";
+ $e++;
+ print '</div>'."\n";
+ print '<br />'."\n";
+ print '<script language="JavaScript" type="text/javascript">'."\n";
+ print '<!--'."\n";
+ print 'shout_dialplan_object_'.$this->_instance.'.drawPrioTable(\''.$extension.'\');'."\n";
+ print '//-->'."\n";
+ print '</script>'."\n";
+ }
+ print '</div>'."\n";
+ }
+ }
+}
\ No newline at end of file
$res = ldap_get_entries($this->_LDAP, $res);
$dialplans[$context] = array();
+ $dialplans[$context]['name'] = $context;
$i = 0;
while ($i < $res['count']) {
# Handle extension lines
define(SHOUT_BASE, dirname(__FILE__));
}
-$dialplan = &$shout->getDialplan($context);
+require_once SHOUT_BASE . '/lib/Dialplan.php';
-require_once 'Horde/Tree.php';
-require_once 'Horde/Block.php';
-require_once 'Horde/Block/Collection.php';
+$dialplan = &$shout->getDialplan($context);
// Set up the tree.
-$tree = &Horde_Tree::singleton('shout_dialplan_menu', 'javascript');
-foreach ($dialplan as $linetype => $linedata) {
- switch($linetype) {
- case 'extensions':
- $url = '#top';
- $tree->addNode('extensions', null, 'Extensions', null, array('url' => $url));
- foreach ($linedata as $extension => $priorities) {
- $nodetext = Shout::exten2name($extension);
- $url = Horde::applicationUrl('index.php?section=dialplan' .
- '&extension=' . $extension . '&context=' . $context);
- $url = "#$extension";
- $tree->addNode("extension_".$extension, 'extensions', $nodetext,
- null, false,
- array(
- 'url' => $url,
- 'onclick' => 'dp.highlightExten(\''.$extension.'\')',
- )
- );
-// foreach ($priorities as $priority => $application) {
-// $tree->addNode("$extension-$priority", $extension, "$priority: $application", null);
-// }
- }
- break;
-
- case 'includes':
- $tree->addNode('includes', null, 'Includes', null);
- foreach ($linedata as $include) {
- $url = Horde::applicationUrl('index.php?section=dialplan&context='.$include);
- $tree->addNode("include_$include", 'includes', $include, null,
- true, array('url' => $url));
- }
- break;
-
- # TODO Ignoring ignorepat lines for now
-
- case 'barelines':
- $tree->addNode('barelines', null, 'Extra Settings', null);
- $i = 0;
- foreach ($linedata as $bareline) {
- $tree->addNode("bareline_".$i, 'barelines', $bareline, null);
- $i++;
- }
- break;
- }
-}
-
-require SHOUT_TEMPLATES . '/dialplan/contexttree.inc';
-require SHOUT_TEMPLATES . '/dialplan/extensiondetail.inc';
+$dpgui = Shout_Dialplan::singleton('x', $dialplan);
+require SHOUT_TEMPLATES . '/dialplan/manager.inc';
// Horde::addScriptFile('httpclient.js', 'horde', true);
// Horde::addScriptFile('hideable.js', 'horde', true);
-<?php
-if(!isset($dialplan['extensions'])) {
- ?>
- <div id="extensionDetail">
- <div class="extensionBox">No Configured Extensions</div>
- </div>
- <?php
-} else {
- ?>
- <script language="JavaScript" type="text/javascript"
- src="/services/javascript.php?file=dialplan.js&app=shout"></script>
- <script language="JavaScript" type="text/javascript">
- <!--
- var shout_dialplan_x = new Array();
- <?php
- foreach($dialplan['extensions'] as $extension => $priorities) {
- print "shout_dialplan_x['$extension'] = new Array();\n";
- print "shout_dialplan_x['$extension']['name'] = '".Shout::exten2name($extension)."'\n";
- print "shout_dialplan_x['$extension']['priorities'] = new Array();\n";
- foreach($priorities as $priority => $data) {
- print "shout_dialplan_x['$extension']['priorities']['$priority'] = new Array();\n";
- print "shout_dialplan_x['$extension']['priorities']['$priority']['application'] = '".$data['application']."'\n";
- print "shout_dialplan_x['$extension']['priorities']['$priority']['args'] = '".$data['args']."'\n";
- }
- }
- ?>
-
- var dp = new Dialplan('x');
-
// -->
</script>
- <div id='extensionDetail' cellspacing="0">
- <?
- $e = 0;
- foreach($dialplan['extensions'] as $extension => $priorities) { ?>
- <div class="extension"
- id="extension_<?php echo $extension; ?>"
- name="extension_<?php echo $extension; ?>">
- <a name="<?php echo $extension; ?>">
- <div class="extensionBox"
- name="<?php echo "eBox-$extension"; ?>"
- id="<?php echo "eBox-$extension"; ?>"
- onclick="dp.highlightExten('<?php echo $extension; ?>');">
- <?php echo Shout::exten2name($extension); ?>
- </div>
- </a>
- <div id="<?php echo "pList-$extension"; ?>"
- name="<?php echo "pList-$extension"; ?>">
- <table class="pList" cellspacing="0">
+ <?php
+}
+?>
+<table class="pList" cellspacing="0">
<?php
$p = 0;
foreach($priorities as $priority => $data) {
$p++;
}
?>
- </table>
- </div>
- <?php
- $e++;
- ?>
- </div>
- <br />
- <?php
- } ?>
- </div>
- <?php
-}
-?>
+ </table>
\ No newline at end of file
{
this._instanceName = instanceName;
this.dp = new Array();
- this.dp = eval('shout_dialplan_'+instanceName);
+ this.dp = eval('shout_dialplan_entry_'+instanceName);
+ this.applist = eval('shout_dialplan_applist_'+instanceName);
+ this.object = 'shout_dialplan_object_'+instanceName;
this.curExten = '';
this.curPrio = '';
}
alert('Must first choose an extension to draw');
return false;
}
- alert(document.getElementById('pList-'+exten).innerHTML);
+ //alert(document.getElementById('pList-'+exten).innerHTML);
table = '<table class="pList" cellspacing="0">';
table += ' <tbody>\n';
table += ' <tr class="priority">\n';
for (var p in this.dp[exten]['priorities']) {
table += ' <td class="pButtons" id="pButtons-'+exten+'-'+p+'"\n';
table += ' name="pButtons-'+exten+'-'+p+'">\n';
- table += ' <span class="add" onclick="javascript:dp.addPrio(\''+exten+'\', \''+p+'\');">+</span>\n';
- table += ' <span class="remove" onclick="javascript:dp.delPrio(\''+exten+'\', \''+p+'\');">-</span>\n';
+ table += ' <span class="add" onclick="javascript:'+this.object+'.addPrio(\''+exten+'\', \''+p+'\');">+</span>\n';
+ table += ' <span class="remove" onclick="javascript:'+this.object+'.delPrio(\''+exten+'\', \''+p+'\');">-</span>\n';
table += ' </td>\n';
table += ' <td class="pElement" id="pNumber-'+exten+'-'+p+'"\n';
table += ' name="pNumber-'+exten+'-'+p+'"\n';
- table += ' onclick="javascript:dp.activatePriority(\''+exten+'\', \''+p+'\')">\n';
+ table += ' onclick="javascript:'+this.object+'.activatePriority(\''+exten+'\', \''+p+'\')">\n';
table += ' <span class="priorityBox">'+p+'</span>\n';
table += ' </td>\n';
table += ' <td class="pElement" id="pApp-'+exten+'-'+p+'"\n';
table += ' name="pApp-'+exten+'-'+p+'">\n';
table += ' <span class="applicationBox"></span>\n';
- table += ' <select name="app['+exten+']['+p+']">\n';
- table += ' <option value="APPLICATION">APPLICATION</option>\n';
+ table += ' <select name="app['+exten+']['+p+']">\n';;
+ table += this.genAppList(this.dp[exten]['priorities'][p]['application']);
table += ' </select>\n';
table += ' </span>\n';
table += ' </td>\n';
table += ' </tr>\n';
table += ' </tbody>\n';
table += '</table>\n';
- alert(table);
+ //alert(table);
document.getElementById('pList-'+exten).innerHTML = table;
}
+Dialplan.prototype.genAppList = function (app)
+{
+ applist = '<option value="APPLICATION">APPLICATION</option>\n';
+ return applist;
+}
+
Dialplan.prototype.addExten = function (exten, extenName)
{
this.dp[exten] = new Array();
this.drawPrioTable(exten);
}
+Dialplan.prototype._numCompare = function(a, b)
+{
+ return (a - b);
+}
+
Dialplan.prototype._incrPrio = function (exten, prio)
{
- p = Number(prio) + 1;
- h = Number(prio) + 101;
+ // Due to javascript's inability to remove an array element while maintaining
+ // associations, we copy the elements into a tmp array and ultimately replace
+ // the object's copy. We will also have to sort the resulting array manually
+ // so it renders correctly.
+ var tmp = new Array();
+ var plist = new Array();
+ var i = 0;
+ var p;
- // Check for error handlers
- if (this.dp[exten]['priorities'][h] != 'undefined') {
- alert(this.dp[exten][h]);
- //this._incrPrio(exten, h);
+ for (p in this.dp[exten]['priorities']) {
+ p = Number(p);
+ // Make a notch for the new priority by incrementing all priorities greater
+ // than the requested one
+ if (p > prio) {
+ tmp[p + 1] = this.dp[exten]['priorities'][p];
+ plist[i] = p + 1;
+ } else {
+ tmp[p] = this.dp[exten]['priorities'][p];
+ plist[i] = p;
+ }
+ i++;
}
+ // Seed the new priority
+ prio = Number(prio) + 1;
+ tmp[prio] = new Array();
+ tmp[prio]['application'] = '';
+ tmp[prio]['args'] = '';
+ plist[i] = prio;
- // Make sure the next slot is empty. If not move it first.
- if (this.dp[exten]['priorities'][p] != 'undefined') {
- alert(p);
- //this._incrPrio(exten, p);
- }
+ // Empty the original array
+ this.dp[exten]['priorities'] = new Array();
- // Copy the existing prio to its new home
- this.dp[exten]['priorities'][p] = this.dp[exten]['priorities'][prio];
+ // Sort the priorities and put them back into the original array
+ plist.sort(this._numCompare);
+ for (i = 0; i < plist.length; i++) {
+ p = Number(plist[i]);
+ this.dp[exten]['priorities'][p] = tmp[p];
+ }
+ return true;
}
\ No newline at end of file
<div id="menu">
- <span style="float:right">
- <form action="index.php" method="get" name="menu">
+
+ <form action="index.php" method="get" name="contextMenu">
+ <span style="float:right">
<?php Util::pformInput() ?>
<label for="context" accesskey="<?php echo $accesskey ?>">
<select id="context" name="context" onchange="contextSubmit()">
<?php
$contexts = &$shout->getContexts();
foreach ($contexts as $c => $cdata) {
- print "<option name=\"$c\" value=\"$c\"";
+ print "<option value=\"$c\"";
if ($c == $context) {
print " selected";
}
<?php
}
?>
- </form>
- </span>
- <span style="float:right">
+ </span>
+ </form>
+
+ <div style="float:right">
<?php
$link = Horde::link('#', _("Select Context"), '', '', 'contextSubmit(true);
return false;');
($menu_view != 'icon') ?
Horde::highlightAccessKey(_("Select _Context"), $accesskey) : '');
?>
- </span>
+ </div>
<?php echo Shout::getMenu('string') ?>
</div>
function contextSubmit(clear)
{
- if (document.menu.context[document.menu.context.selectedIndex].name != '') {
+ if (document.contextMenu.context[document.contextMenu.context.selectedIndex].name != '') {
if ((loading == null) || (clear != null)) {
loading = true;
- document.menu.submit();
+ document.contextMenu.submit();
}
}
}