Converted dialplan viewer to Horde_Tree interface
authorBen Klang <ben@alkaloid.net>
Thu, 3 Nov 2005 19:48:55 +0000 (19:48 +0000)
committerBen Klang <ben@alkaloid.net>
Thu, 3 Nov 2005 19:48:55 +0000 (19:48 +0000)
git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@80 06cd67b6-e706-0410-b29e-9de616bca6e9

andrew.webprj
dialplan.php
lib/Driver/ldap.php
lib/defines.php
main/dialplan.php

index 8939e12..1b016cd 100644 (file)
@@ -1,6 +1,6 @@
 <!DOCTYPE webproject>
 <webproject>
-  <project usePreviewPrefix="0" previewPrefix="" type="Local" usePersistentBookmarks="0" name="Shout" encoding="iso 8859-1" enableEvents="true" >
+  <project usePreviewPrefix="0" type="Local" previewPrefix="" usePersistentBookmarks="0" name="Shout" encoding="iso 8859-1" enableEvents="true" >
     <upload/>
     <defaultDTD>-//w3c//dtd xhtml 1.0 strict//en</defaultDTD>
     <item url="config/" uploadstatus="1" />
@@ -9,7 +9,7 @@
     <item modified_time="1130769960" url="dialplan/edit.php" uploadstatus="1" />
     <item url="lib/" uploadstatus="1" />
     <item url="lib/Driver/" uploadstatus="1" />
-    <item modified_time="1130864652" url="lib/Driver/ldap.php" uploadstatus="1" />
+    <item modified_time="1131046511" url="lib/Driver/ldap.php" uploadstatus="1" />
     <item modified_time="1130769961" url="lib/base.php" uploadstatus="1" />
     <item modified_time="1121689003" url="lib/Dialplan.php" uploadstatus="1" />
     <item modified_time="1130769960" url="lib/Driver.php" uploadstatus="1" />
@@ -17,7 +17,7 @@
     <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="1121689003" url="main/dialplan.php" uploadstatus="1" />
+    <item modified_time="1131047244" 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" />
@@ -46,7 +46,7 @@
     <item modified_time="1122704539" url="users/delete.php" uploadstatus="1" />
     <item modified_time="1130769962" url="users/edit.php" uploadstatus="1" />
     <item modified_time="1130769962" url="users/save.php" uploadstatus="1" />
-    <item modified_time="1121689003" url="dialplan.php" uploadstatus="1" />
+    <item modified_time="1131044239" url="dialplan.php" uploadstatus="1" />
     <item modified_time="1129871121" url="index.php" uploadstatus="1" />
     <item modified_time="1122704475" url="users.php" uploadstatus="1" />
     <item url="" uploadstatus="1" />
@@ -55,7 +55,7 @@
       <profile remote_host="picasso.v-office.biz" remote_port="22" remote_path="/srv/vhost/users/alkaloid/sites/intranet.v-office.biz/shout" remote_protocol="sftp" user="alkaloid" name="Shout" >
         <uploadeditem upload_time="0" url="config/" />
         <uploadeditem upload_time="1120073766" url="config/conf.xml" />
-        <uploadeditem upload_time="1121689003" url="dialplan.php" />
+        <uploadeditem upload_time="1131044239" url="dialplan.php" />
         <uploadeditem upload_time="0" url="dialplan/" />
         <uploadeditem upload_time="1130769960" url="dialplan/edit.php" />
         <uploadeditem upload_time="1129871121" url="index.php" />
         <uploadeditem upload_time="1121689003" url="lib/Dialplan.php" />
         <uploadeditem upload_time="1130769960" url="lib/Driver.php" />
         <uploadeditem upload_time="0" url="lib/Driver/" />
-        <uploadeditem upload_time="1130864652" url="lib/Driver/ldap.php" />
+        <uploadeditem upload_time="1131046511" url="lib/Driver/ldap.php" />
         <uploadeditem upload_time="1130769961" url="lib/Shout.php" />
         <uploadeditem upload_time="1121689003" url="lib/System.php" />
         <uploadeditem upload_time="1130769961" url="lib/User.php" />
         <uploadeditem upload_time="1130862539" url="lib/api.php" />
         <uploadeditem upload_time="1130769961" url="lib/base.php" />
-        <uploadeditem upload_time="1130864200" url="lib/defines.php" />
+        <uploadeditem upload_time="1131045729" url="lib/defines.php" />
         <uploadeditem upload_time="0" url="main/" />
-        <uploadeditem upload_time="1121689003" url="main/dialplan.php" />
+        <uploadeditem upload_time="1131047244" 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" />
       <mailinglist address="" />
     </teamdata>
     <events/>
-    <item modified_time="1130864200" url="lib/defines.php" uploadstatus="1" />
+    <item modified_time="1131045729" url="lib/defines.php" uploadstatus="1" />
     <treestatus>
       <openfolder url="config" />
       <openfolder url="dialplan" />
       <openfolder url="lib/Driver" />
       <openfolder url="main" />
       <openfolder url="templates" />
+      <openfolder url="templates/dialplan" />
       <openfolder url="users" />
     </treestatus>
   </project>
index c729ee8..6fb64ba 100644 (file)
@@ -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) {
index 3b27a4c..362df8f 100644 (file)
@@ -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++;
                 }
             }
index fd86b69..098be3c 100644 (file)
@@ -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);
 @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
index 14aedf7..3fac838 100644 (file)
@@ -1,6 +1,82 @@
 <?php
+/**
+ * $Shout: shout/main/dialplan.php,v 1.0.0.1 2005/11/03 00:05:08 ben Exp $
+ *
+ * Copyright 2005 Ben Klang <ben@alkaloid.net>
+ *
+ * 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