* @var array $_params
*/
var $_params = array();
- var $contexts = array();
// }}}
// {{{ Shout_Driver constructor
}
if ((($userperms | $superadmin) ^ ($filterperms)) == 0) {
- $this->contexts[] = $context;
+ $retcontexts[] = $context;
}
}
- return $this->contexts;
+ return $retcontexts;
}
// }}}
*
* @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)";
# 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 " .
$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++;
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');
<?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"));
<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" />
<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" />
}
# 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();
$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