From f32ff19dea1083f11a3424436df99f0354d1273b Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Fri, 1 Jul 2005 17:54:04 +0000 Subject: [PATCH] Fixed the form on the users page. Now to draw out a list of found users. 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 | 5 ++--- lib/Driver/ldap.php | 23 ++++++++++--------- lib/Shout.php | 2 +- lib/Users.php | 12 +++++----- shout.webprj | 29 ++++++++++++------------ users.php | 63 ++++++++++++++++++++++++++++++++++++++--------------- 6 files changed, 81 insertions(+), 53 deletions(-) diff --git a/lib/Driver.php b/lib/Driver.php index dedafe841..1f0ef73b3 100644 --- a/lib/Driver.php +++ b/lib/Driver.php @@ -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; } // }}} diff --git a/lib/Driver/ldap.php b/lib/Driver/ldap.php index 31f91b8f1..4ca2bfc5a 100644 --- a/lib/Driver/ldap.php +++ b/lib/Driver/ldap.php @@ -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++; diff --git a/lib/Shout.php b/lib/Shout.php index bd9bae709..ed4bc43ef 100644 --- a/lib/Shout.php +++ b/lib/Shout.php @@ -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'); diff --git a/lib/Users.php b/lib/Users.php index 044a7d9e4..4ea141994 100644 --- a/lib/Users.php +++ b/lib/Users.php @@ -1,24 +1,24 @@ + * Copyright 2005 Ben Klang * * 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 + * @author Ben Klang * @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")); diff --git a/shout.webprj b/shout.webprj index b291d0956..644e802a2 100644 --- a/shout.webprj +++ b/shout.webprj @@ -9,9 +9,9 @@ - + - + @@ -22,13 +22,13 @@ - + - + - - + + @@ -38,7 +38,7 @@ - + @@ -57,10 +57,9 @@ -//w3c//dtd xhtml 1.0 strict//en - - + Ben Klang ben@alkaloid.net Gubed @@ -71,12 +70,12 @@ - - - - - - + + + + + + diff --git a/users.php b/users.php index d5a60b678..33972a24c 100644 --- 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 -- 2.11.0