From: Ben Klang Date: Thu, 3 Nov 2005 19:48:55 +0000 (+0000) Subject: Converted dialplan viewer to Horde_Tree interface X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=3d5c3e7b9c600cd8815229a863e03a5925b47910;p=horde.git Converted dialplan viewer to Horde_Tree interface git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@80 06cd67b6-e706-0410-b29e-9de616bca6e9 --- diff --git a/andrew.webprj b/andrew.webprj index 8939e1248..1b016cdee 100644 --- a/andrew.webprj +++ b/andrew.webprj @@ -1,6 +1,6 @@ - + -//w3c//dtd xhtml 1.0 strict//en @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -63,15 +63,15 @@ - + - + - + @@ -116,7 +116,7 @@ - + @@ -124,6 +124,7 @@ + diff --git a/dialplan.php b/dialplan.php index c729ee899..6fb64ba77 100644 --- a/dialplan.php +++ b/dialplan.php @@ -9,6 +9,9 @@ */ @define('SHOUT_BASE', dirname(__FILE__)); +# FIXME Need a cleaner script prologue... probably all we need to do is check +# for some kind of sane startup vars and otherwise redirect to '/' +# This standard prologue should be consistent across every file that ends in .php $shout_configured = (@is_readable(SHOUT_BASE . '/config/conf.php'));# && #@is_readable(SHOUT_BASE . '/config/prefs.php')); if (!$shout_configured) { diff --git a/lib/Driver/ldap.php b/lib/Driver/ldap.php index 3b27a4c4a..362df8ff8 100644 --- a/lib/Driver/ldap.php +++ b/lib/Driver/ldap.php @@ -325,10 +325,10 @@ for $context")); $res = @ldap_search($this->_LDAP, SHOUT_ASTERISK_BRANCH.','.$this->_params['basedn'], - "(&(objectClass=asteriskExtensions)(context=$context))", - array('asteriskExtensionLine', 'asteriskIncludeLine', - 'asteriskIgnorePat', 'description', - 'asteriskExtensionBareLine')); + "(&(objectClass=".SHOUT_CONTEXT_EXTENSIONS_OBJECTCLASS.")(context=$context))", + array(SHOUT_DIALPLAN_EXTENSIONLINE_ATTRIBUTE, SHOUT_DIALPLAN_INCLUDE_ATTRIBUTE, + SHOUT_DIALPLAN_IGNOREPAT_ATTRIBUTE, 'description', + SHOUT_DIALPLAN_BARELINE_ATTRIBUTE)); if (!$res) { return PEAR::raiseError("Unable to locate any extensions " . "underneath ".SHOUT_ASTERISK_BRANCH.",".$this->_params['basedn'] . @@ -340,10 +340,10 @@ for $context")); $i = 0; while ($i < $res['count']) { # Handle extension lines - if (isset($res[$i]['asteriskextensionline'])) { + if (isset($res[$i][strtolower(SHOUT_DIALPLAN_EXTENSIONLINE_ATTRIBUTE)])) { $j = 0; - while ($j < $res[$i]['asteriskextensionline']['count']) { - @$line = $res[$i]['asteriskextensionline'][$j]; + while ($j < $res[$i][strtolower(SHOUT_DIALPLAN_EXTENSIONLINE_ATTRIBUTE)]['count']) { + @$line = $res[$i][strtolower(SHOUT_DIALPLAN_EXTENSIONLINE_ATTRIBUTE)][$j]; # Basic sanity check for length. FIXME if (strlen($line) < 5) { @@ -387,7 +387,7 @@ for $context")); $j = 0; while ($j < $res[$i]['asteriskincludeline']['count']) { @$line = $res[$i]['asteriskincludeline'][$j]; - $dialplans[$context]['include'][$j] = $line; + $dialplans[$context]['includes'][$j] = $line; $j++; } } @@ -397,7 +397,7 @@ for $context")); $j = 0; while ($j < $res[$i]['asteriskignorepat']['count']) { @$line = $res[$i]['asteriskignorepat'][$j]; - $dialplans[$context]['ignorepat'][$j] = $line; + $dialplans[$context]['ignorepats'][$j] = $line; $j++; } } @@ -406,7 +406,7 @@ for $context")); $j = 0; while ($j < $res[$i]['asteriskextensionbareline']['count']) { @$line = $res[$i]['asteriskextensionbareline'][$j]; - $dialplans[$context]['bareline'][$j] = $line; + $dialplans[$context]['barelines'][$j] = $line; $j++; } } diff --git a/lib/defines.php b/lib/defines.php index fd86b6915..098be3cd9 100644 --- a/lib/defines.php +++ b/lib/defines.php @@ -9,9 +9,9 @@ * * @package Shout */ -@define(SHOUT_ASTERISK_BRANCH, "ou=Asterisk"); -@define(SHOUT_USERS_BRANCH, "ou=Customers"); -@define(SHOUT_USER_OBJECTCLASS, "asteriskUser"); +@define('SHOUT_ASTERISK_BRANCH', "ou=Asterisk"); +@define('SHOUT_USERS_BRANCH', "ou=Customers"); +@define('SHOUT_USER_OBJECTCLASS', "asteriskUser"); @define('SHOUT_CONTEXT_ALL', 0xFFF); @define('SHOUT_CONTEXT_NONE', 0); @@ -28,5 +28,10 @@ @define('SHOUT_CONTEXT_CONFERENCE_OBJECTCLASS', 'asteriskMeetMe'); @define('SHOUT_CONTEXT_VOICEMAIL_OBJECTCLASS', 'asteriskVoicemail'); +@define('SHOUT_DIALPLAN_EXTENSIONLINE_ATTRIBUTE', 'asteriskExtensionLine'); +@define('SHOUT_DIALPLAN_INCLUDE_ATTRIBUTE', 'asteriskIncludeLine'); +@define('SHOUT_DIALPLAN_IGNOREPAT_ATTRIBUTE', 'asteriskIgnorePat'); +@define('SHOUT_DIALPLAN_BARELINE_ATTRIBUTE', 'asteriskExtensionBareLine'); + # FIXME Maybe these should be params instead? @define('SHOUT_ACCOUNT_ID_ATTRIBUTE', 'vofficeCustomerNumber'); \ No newline at end of file diff --git a/main/dialplan.php b/main/dialplan.php index 14aedf7ab..3fac83839 100644 --- a/main/dialplan.php +++ b/main/dialplan.php @@ -1,6 +1,82 @@ + * + * See the enclosed file COPYING for license information (GPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. + */ + if (!defined(SHOUT_BASE)) { define(SHOUT_BASE, dirname(__FILE__)); } + $dialplan = &$shout->getDialplan($context); -require SHOUT_TEMPLATES . "/dialplan/dialplanlist.inc"; \ No newline at end of file + +require_once 'Horde/Tree.php'; +require_once 'Horde/Block.php'; +require_once 'Horde/Block/Collection.php'; + +// Set up the tree. +$tree = &Horde_Tree::singleton('shout_dialplan_menu', 'javascript'); + +foreach ($dialplan as $linetype => $linedata) { + switch($linetype) { + case 'extensions': + $tree->addNode('extensions', null, 'Extensions', null); + foreach ($linedata as $extension => $priorities) { + switch($extension) { + case 'i': + $nodetext = 'Invalid Extension'; + break; + case 's': + $nodetext = 'Main'; + break; + case 't': + $nodetext = 'Timeout'; + break; + case 'o': + $nodetext = 'Operator'; + break; + case 'h': + $nodetext = 'Hangup'; + break; + default: + $nodetext = $extension; + break; + } + $tree->addNode($extension, 'extensions', $nodetext, null); + 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, 'includes', $include, null, true, array('url' => $url)); + } + break; + + # TODO Ignoring ignorepat lines for now + case 'barelines': + $tree->addNode('barelines', null, 'Extra Settings', null); + foreach ($linedata as $bareline) { + $tree->addNode($bareline, 'barelines', $bareline, null); + } + break; + } +} + +$tree->renderTree(); + +// Horde::addScriptFile('httpclient.js', 'horde', true); +// Horde::addScriptFile('hideable.js', 'horde', true); +// require HORDE_TEMPLATES . '/common-header.inc'; +// require HORDE_TEMPLATES . '/portal/sidebar.inc'; + + +// require SHOUT_TEMPLATES . "/dialplan/dialplanlist.inc"; \ No newline at end of file