Fixed the form on the users page. Now to draw out a list of found users.
authorBen Klang <ben@alkaloid.net>
Fri, 1 Jul 2005 17:54:04 +0000 (17:54 +0000)
committerBen Klang <ben@alkaloid.net>
Fri, 1 Jul 2005 17:54:04 +0000 (17:54 +0000)
Fixed some other bugs in various places, a.k.a. more progress made.

git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@43 06cd67b6-e706-0410-b29e-9de616bca6e9

lib/Driver.php
lib/Driver/ldap.php
lib/Shout.php
lib/Users.php
shout.webprj
users.php

index dedafe8..1f0ef73 100644 (file)
@@ -25,7 +25,6 @@ class Shout_Driver {
      * @var array $_params
      */
     var $_params = array();
-    var $contexts = array();
     // }}}
 
     // {{{ Shout_Driver constructor
@@ -83,10 +82,10 @@ class Shout_Driver {
             }
 
             if ((($userperms | $superadmin) ^ ($filterperms)) == 0) {
-                $this->contexts[] = $context;
+                $retcontexts[] = $context;
             }
         }
-        return $this->contexts;
+        return $retcontexts;
     }
     // }}}
 
index 31f91b8..4ca2bfc 100644 (file)
@@ -42,8 +42,11 @@ class Shout_Driver_ldap extends Shout_Driver
     *
     * @access private
     */
-    function _getContexts($filter = "both")
+    function _getContexts($filter = "all")
     {
+        # TODO Add caching mechanism here.  Possibly cache results per
+        # filter $this->contexts['customer'] and return either data
+        # or possibly a reference to that data
         switch ($filter) {
             case "customer":
                 $searchfilter="(objectClass=vofficeCustomer)";
@@ -60,7 +63,7 @@ class Shout_Driver_ldap extends Shout_Driver
         # Collect all the possible contexts from the backend
         $res = ldap_search($this->_LDAP,
             SHOUT_ASTERISK_BRANCH.','.$this->_params['basedn'],
-            "(&(objectClass=asteriskObject))",
+            "(&(objectClass=asteriskObject)$searchfilter)",
             array('context'));
         if (!$res) {
             return PEAR::raiseError("Unable to locate any customers " .
@@ -107,28 +110,28 @@ class Shout_Driver_ldap extends Shout_Driver
             $extension = $res[$i]['voicemailbox'][0];
             $entries[$extension] = array();
 
-            $entries[$extension]['dialopts'] =
+            @$entries[$extension]['dialopts'] =
                 $res[$i]['asteriskuserdialoptions'];
 
-            $entries[$extension]['mailboxopts'] =
+            @$entries[$extension]['mailboxopts'] =
                 $res[$i]['asteriskvoicemailboxoptions'];
 
-            $entries[$extension]['mailboxpin'] =
+            @$entries[$extension]['mailboxpin'] =
                 $res[$i]['voicemailboxpin'][0];
 
-            $entries[$extension]['name'] =
+            @$entries[$extension]['name'] =
                 $res[$i]['cn'][0];
 
-            $entries[$extension]['phonenumbers'] =
+            @$entries[$extension]['phonenumbers'] =
                 $res[$i]['telephonenumber'];
 
-            $entries[$extension]['dialtimeout'] =
+            @$entries[$extension]['dialtimeout'] =
                 $res[$i]['asteriskuserdialtimeout'][0];
 
-            $entries[$extension]['email'] =
+            @$entries[$extension]['email'] =
                 $res[$i]['mail'][0];
 
-            $entries[$extension]['pageremail'] =
+            @$entries[$extension]['pageremail'] =
                 $res[$i]['asteriskpager'][0];
 
             $i++;
index bd9bae7..ed4bc43 100644 (file)
@@ -71,7 +71,7 @@ null, $cellclass);
             return false;
         }
         $tabs = &new Horde_UI_Tabs('section', $vars);
-        if (count($shout->contexts) > 1 ||
+        if (count($shout->getContexts()) > 1 ||
             Auth::isAdmin("shout:superadmin", PERMS_SHOW|PERMS_READ)) {
             $tabs->addTab(_("Contexts"),
                     Horde::applicationUrl('index.php'), 'contexts');
index 044a7d9..4ea1419 100644 (file)
@@ -1,24 +1,24 @@
 <?php
 /**
- * CreateStep1Form Class
+ * SelectContextForm Class
  *
- * $Horde: whups/lib/Create.php,v 1.56 2005/01/03 14:35:44 jan Exp $
+ * $Horde: shout/lib/Users.php,v 1.56 2005/01/03 14:35:44 jan Exp $
  *
- * Copyright 2001-2005 Robert E. Coyle <robertecoyle@hotmail.com>
+ * Copyright 2005 Ben Klang <ben@alkaloid.net>
  *
  * See the enclosed file LICENSE for license information (BSD). If you
  * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
  *
- * @author  Robert E. Coyle <robertecoyle@hotmail.com>
+ * @author  Ben Klang <ben@alkaloid.net>
  * @package Whups
  */
 class SelectContextForm extends Horde_Form {
 
     var $_useFormToken = false;
 
-    function CreateStep1Form(&$vars)
+    function SelectContextForm(&$vars)
     {
-        global $whups;
+        global $shout;
 
         parent::Horde_Form($vars, _("Choose a context"));
 
index b291d09..644e802 100644 (file)
@@ -9,9 +9,9 @@
     <item url="templates/" uploadstatus="2" />
     <item url="lib/" uploadstatus="2" />
     <item url="lib/Driver/" uploadstatus="2" />
-    <item modified_time="1120174215" url="lib/Driver/ldap.php" uploadstatus="2" />
+    <item modified_time="1120239794" url="lib/Driver/ldap.php" uploadstatus="2" />
     <item modified_time="1120171344" url="lib/base.php" uploadstatus="2" />
-    <item modified_time="1120174564" url="lib/Driver.php" uploadstatus="2" />
+    <item modified_time="1120229109" url="lib/Driver.php" uploadstatus="2" />
     <item modified_time="1120169139" url="contexts.php" uploadstatus="2" />
     <item modified_time="1120163478" url="index.php" uploadstatus="2" />
     <uploadprofiles showtreeviews="true" defaultProfile="Shout" >
         <uploadeditem upload_time="1120163478" url="index.php" />
         <uploadeditem upload_time="1120021874" url="index.php~" />
         <uploadeditem upload_time="0" url="lib/" />
-        <uploadeditem upload_time="1120174564" url="lib/Driver.php" />
+        <uploadeditem upload_time="1120229109" url="lib/Driver.php" />
         <uploadeditem upload_time="1120022560" url="lib/Driver.php~" />
         <uploadeditem upload_time="0" url="lib/Driver/" />
-        <uploadeditem upload_time="1120174215" url="lib/Driver/ldap.php" />
+        <uploadeditem upload_time="1120239794" url="lib/Driver/ldap.php" />
         <uploadeditem upload_time="1120026921" url="lib/Driver/ldap.php~" />
-        <uploadeditem upload_time="1120171890" url="lib/Shout.php" />
-        <uploadeditem upload_time="1120174424" url="lib/Users.php" />
+        <uploadeditem upload_time="1120229142" url="lib/Shout.php" />
+        <uploadeditem upload_time="1120236336" url="lib/Users.php" />
         <uploadeditem upload_time="1120171344" url="lib/base.php" />
         <uploadeditem upload_time="1120073766" url="lib/defines.php" />
         <uploadeditem upload_time="1120027019" url="shout.webprj" />
@@ -38,7 +38,7 @@
         <uploadeditem upload_time="0" url="templates/context/" />
         <uploadeditem upload_time="1120169761" url="templates/context/contextline.inc" />
         <uploadeditem upload_time="1120165707" url="templates/menu.inc" />
-        <uploadeditem upload_time="1120174608" url="users.php" />
+        <uploadeditem upload_time="1120237884" url="users.php" />
       </profile>
     </uploadprofiles>
     <debuggers>
       <pathmapper/>
     </debuggers>
     <defaultDTD>-//w3c//dtd xhtml 1.0 strict//en</defaultDTD>
-    <item modified_time="1120073766" url="lib/defines.php" uploadstatus="1" />
     <item modified_time="1120073766" url="config/conf.xml" uploadstatus="1" />
     <item url="config/" uploadstatus="1" />
-    <item modified_time="1120171890" url="lib/Shout.php" uploadstatus="1" />
+    <item modified_time="1120229142" url="lib/Shout.php" uploadstatus="1" />
     <author>Ben Klang</author>
     <email>ben@alkaloid.net</email>
     <debuggerclient>Gubed</debuggerclient>
       <mailinglist address="" />
     </teamdata>
     <events/>
-    <item modified_time="1120158044" url="templates/common-header.inc" />
-    <item modified_time="1120165707" url="templates/menu.inc" />
-    <item modified_time="1120174608" url="users.php" />
-    <item url="templates/context/" />
-    <item modified_time="1120169761" url="templates/context/contextline.inc" />
-    <item modified_time="1120174424" url="lib/Users.php" />
+    <item modified_time="1120158044" url="templates/common-header.inc" uploadstatus="1" />
+    <item modified_time="1120165707" url="templates/menu.inc" uploadstatus="1" />
+    <item modified_time="1120237884" url="users.php" uploadstatus="1" />
+    <item url="templates/context/" uploadstatus="1" />
+    <item modified_time="1120169761" url="templates/context/contextline.inc" uploadstatus="1" />
+    <item modified_time="1120236336" url="lib/Users.php" uploadstatus="1" />
     <treestatus>
       <openfolder url="lib" />
       <openfolder url="lib/Driver" />
index d5a60b6..33972a2 100644 (file)
--- a/users.php
+++ b/users.php
@@ -4,16 +4,22 @@ if (!defined(SHOUT_BASE)) {
 }
 
 # Check that we are properly initialized
-if (!isset($contexts) || is_a($contexts, 'PEAR_Error')) {
+if (is_a($contexts, 'PEAR_Error')) {
     $notification->push(_("Internal error viewing requested page"),
                         'horde.error');
+    $notification->notify();
+    require $registry->get('templates', 'horde') . '/common-footer.inc';
+    exit();
 }
 
-if (!in_array($context, $contexts)) {
+if (($context != "") && !in_array($context, $contexts)) {
     $notification->push("You do not have permission to access this system.",
         'horde.error');
+    $notification->notify();
+    require $registry->get('templates', 'horde') . '/common-footer.inc';
+    exit();
 }
-$notification->notify();
+
 require_once SHOUT_BASE . "/lib/Users.php";
 
 $RENDERER = &new Horde_Form_Renderer();
@@ -23,20 +29,41 @@ $formname = $vars->get('formname');
 
 $title = "Users";
 
-$form = &Horde_Form::singleton('SelectContextForm', $vars);
-$valid = $form->validate($vars, true);
-/*
-if ($valid) {
-} else {*/
-    if ($formname != 'selectcontext') {
-        $form->clearValidation();
-    }
-    $form->open($RENDERER, $vars, 'users.php', 'post');
-    $RENDERER->beginActive($form->getTitle());
-    $RENDERER->renderFormActive($form, $vars);
-    $RENDERER->submit();
-    $RENDERER->end();
-    $form->close($RENDERER);
-// }
+$contexts = $shout->getContexts("customer");
+
+if (count($contexts) < 1) {
+    # We should never get here except by malformed request
+    # (intentional or otherwise)
+    $notification->push(_("Internal error viewing requested page"),
+        'horde.error');
+    $notification->notify();
+    require $registry->get('templates', 'horde') . '/common-footer.inc';
+    exit();
+}
+
+if (count($contexts) > 1) {
+    # User is allowed to view more than one context.  Prompt him
+    # for the context to view
+
+    $form = &Horde_Form::singleton('SelectContextForm', $vars);
+    $valid = $form->validate($vars, true);
+    /*
+    if ($valid) {
+    } else {*/
+        if ($formname != 'selectcontext') {
+            $form->clearValidation();
+        }
+        $form->open($RENDERER, $vars, 'users.php', 'post');
+        $RENDERER->beginActive($form->getTitle());
+        $RENDERER->renderFormActive($form, $vars);
+        $RENDERER->submit();
+        $RENDERER->end();
+        $form->close($RENDERER);
+    // }
+} else {
+    # Based on the logic above, count($contexts) must == 1
+    # Force the user to veiw that context
+    $context = $contexts[0];
+}
 
 print_r($shout->getUsers($context));
\ No newline at end of file