$vars = &Variables::getDefaultVariables();
#$ticket->setDetails($vars);
+if (count($contexts) == 1) {
+ $context = $contexts[0];
+}
+
#$title = '[#' . $ticket->getId() . '] ' . $ticket->get('summary');
require SHOUT_TEMPLATES . '/common-header.inc';
require SHOUT_TEMPLATES . '/menu.inc';
-$tabs = &Shout::getTabs($vars);
+$tabs = &Shout::getTabs($context, $vars);
$tabs->preserve('context', $context);
-echo $tabs->render();
+echo "<br />";
+echo $tabs->render($section);
switch ($section) {
- case "contexts":
- require "contexts.php";
- break;
-
+ case "conference":
+ case "dialplan":
case "users":
- require "users.php";
- break;
-
case "moh":
- require "moh.php";
- break;
-
- case "global":
- require "global.php";
+ require "$section.php";
break;
default:
break;
}
-// $form = &new TicketDetailsForm($vars);
-// $form->addAttributes($whups->getAllTicketAttributesWithNames(
-// $ticket->getId()));
-//
-// $RENDERER = &new Horde_Form_Renderer();
-// $RENDERER->beginInactive($title);
-// $RENDERER->renderFormInactive($form, $vars);
-// $RENDERER->end();
-//
-// echo '<br />';
-//
-// $COMMENT = &new Comment();
-// $COMMENT->begin(_("History"));
-// $history = Whups::permissionsFilter($whups->getHistory($ticket->getId()),
-// 'comment', PERMS_READ);
-// $chtml = array();
-// foreach ($history as $comment_values) {
-// $chtml[] = $COMMENT->render(new Variables($comment_values));
-// }
-// if ($prefs->getValue('comment_sort_dir')) {
-// $chtml = array_reverse($chtml);
-// }
-// echo implode('', $chtml);
-// $COMMENT->end();
+
require $registry->get('templates', 'horde') . '/common-footer.inc';
# Narrow down the list of contexts to those valid for this user.
- global $perms;
-
- $superadminPermName = "shout:superadmin";
- if ($perms->exists($superadminPermName)) {
- $superadmin = $perms->getPermissions($superadminPermName) &
- ($filterperms);
- } else {
- $superadmin = 0;
- }
-
- foreach($contexts as $context) {
- $permName = "shout:contexts:".$context;
- if ($perms->exists($permName)) {
- $userperms = $perms->getPermissions($permName) &
- ($filterperms);
- } else {
- $userperms = 0;
- }
-
- if ((($userperms | $superadmin) ^ ($filterperms)) == 0) {
+// global $perms;
+//
+// $superadminPermName = "shout:superadmin";
+// if ($perms->exists($superadminPermName)) {
+// $superadmin = $perms->getPermissions($superadminPermName) &
+// ($filterperms);
+// } else {
+// $superadmin = 0;
+// }
+//
+// foreach($contexts as $context) {
+// $permName = "shout:contexts:".$context;
+// if ($perms->exists($permName)) {
+// $userperms = $perms->getPermissions($permName) &
+// ($filterperms);
+// } else {
+// $userperms = 0;
+// }
+//
+// if ((($userperms | $superadmin) ^ ($filterperms)) == 0) {
+// $retcontexts[$context] = $context;
+// }
+// }
+ foreach ($contexts as $context) {
+ if (Shout::checkRights("shout:contexts:$context", $filterperms)) {
$retcontexts[] = $context;
}
}
return $retcontexts;
}
// }}}
+
+ // {{{ checkContextType
+ /**
+ * For the given context and type, make sure the context has the
+ * appropriate properties, that it is effectively of that "type"
+ *
+ * @param string $context the context to check type for
+ *
+ * @param string $type the type to verify the context is of
+ *
+ * @return boolean true of the context is of type, false if not
+ *
+ * @access public
+ */
+ function checkContextType($context, $type)
+ {
+ return $this->_checkContextType($context, $type);
+ }
+ //}}}
// {{{
/**
case "customer":
$searchfilter="(objectClass=vofficeCustomer)";
break;
- case "system":
- $searchfilter="(!(objectClass=vofficeCustomer))";
+ case "extensions":
+ $searchfilter="(objectClass=asteriskExtensions)";
+ break;
+ case "moh":
+ $searchfilter="(objectClass=asteriskMusicOnHold)";
+ break;
+ case "conference":
+ $searchfilter="(objectClass=asteriskMeetMe)";
break;
case "all":
default:
return $entries;
}
// }}}
+
+ // {{{ _checkContextType method
+ /**
+ * For the given context and type, make sure the context has the
+ * appropriate properties, that it is effectively of that "type"
+ *
+ * @param string $context the context to check type for
+ *
+ * @param string $type the type to verify the context is of
+ *
+ * @return boolean true of the context is of type, false if not
+ *
+ * @access public
+ */
+ function _checkContextType($context, $type) {
+ switch ($type) {
+ case "dialplan":
+ $searchfilter = "(objectClass=asteriskExtensions)";
+ break;
+ case "moh":
+ $searchfilter="(objectClass=asteriskMusicOnHold)";
+ break;
+ case "conference":
+ $searchfilter="(objectClass=asteriskMeetMe)";
+ break;
+ case "all":
+ default:
+ $searchfilter="";
+ break;
+ }
+
+ $res = ldap_search($this->_LDAP,
+ SHOUT_ASTERISK_BRANCH.','.$this->_params['basedn'],
+ "(&(objectClass=asteriskObject)$searchfilter(context=$context))",
+ array("context"));
+ if (!$res) {
+ return PEAR::raiseError("Unable to search directory for context
+type");
+ }
+
+ $res = ldap_get_entries($this->_LDAP, $res);
+ if (!$res) {
+ return PEAR::raiseError("Unable to get results from LDAP query");
+ }
+ print_r($res);
+ if ($res['count'] == 1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ // }}}
// {{{ _getUsers method
/**
*
* @return object Horde_UI_Tabs
*/
- function &getTabs(&$vars)
+ function &getTabs($context, &$vars)
{
global $shout;
if (!Auth::isAdmin("shout", PERMS_SHOW|PERMS_READ)) {
return false;
}
+
+ $permprefix = "shout:contexts:$context";
+
$tabs = &new Horde_UI_Tabs('section', $vars);
- if (count($shout->getContexts()) > 1 ||
- Auth::isAdmin("shout:superadmin", PERMS_SHOW|PERMS_READ)) {
- $tabs->addTab(_("Contexts"),
- Horde::applicationUrl('index.php'), 'contexts');
+
+ if (Shout::checkRights("$permprefix:users") &&
+ $shout->checkContextType($context, "conference")) {
+ $tabs->addTab(_("Users"),
+ Horde::applicationUrl("index.php?context=$context"),
+ 'users');
}
- $tabs->addTab(_("Users"),
- Horde::applicationUrl('index.php'), 'users');
- $tabs->addTab(_("Music on Hold"),
- Horde::applicationUrl('index.php'), 'moh');
- // $tabs->addTab(_("Watch"), Horde::applicationUrl('ticket/watch.php'));
- if (Auth::isAdmin('shout:superadmin', PERMS_READ|PERMS_SHOW)) {
- $tabs->addTab(_("Global Settings"),
- Horde::applicationUrl('index.php'), 'global');
+
+ if (Shout::checkRights("$permprefix:dialplan") &&
+ $shout->checkContextType($context, "conference")) {
+ $tabs->addTab(_("Dial Plan"),
+ Horde::applicationUrl('index.php'), 'dialplan');
}
-
+
+ if (Shout::checkRights("$permprefix:conference") &&
+ $shout->checkContextType($context, "conference")) {
+ $tabs->addTab(_("Conference Rooms"),
+ Horde::applicationUrl('index.php'), 'conference');
+ }
+
+ if (Shout::checkRights("$permprefix:moh") &&
+ $shout->checkContextType($context, "conference")) {
+ $tabs->addTab(_("Music on Hold"),
+ Horde::applicationUrl('index.php'), 'moh');
+ }
+
return $tabs;
}
+ function checkRights($permname, $permmask = null)
+ {
+ if ($permmask == null) {
+ $permmask = PERMS_SHOW|PERMS_READ;
+ }
+
+ $superadmin = Auth::isAdmin("shout:superadmin", $permmask);
+ $user = Auth::isAdmin($permname, $permmask);
+ $test = $superadmin | $user;
+ if ($test) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
}
// }}}
\ No newline at end of file
--- /dev/null
+<?php
+if (!defined(SHOUT_BASE)) {
+ define(SHOUT_BASE, dirname(__FILE__));
+}
+
+# Check that we are properly initialized
+if (is_a($contexts, 'PEAR_Error')) {
+ # FIXME change this to a Horde::fatal
+ $notification->push(_("Internal error viewing requested page"),
+ 'horde.error');
+ $notification->notify();
+ require $registry->get('templates', 'horde') . '/common-footer.inc';
+ exit();
+}
+
+<?php
+$accesskey = $prefs->getValue('widget_accesskey') ?
+ Horde::getAccessKey(_("Select _Context")) : '';
+$menu_view = $prefs->getValue('menu_view');
+?>
+
<div id="menu">
- <?php echo Shout::getMenu('string') ?>
+
+ <span style="float:right">
+ <form action="index.php" method="get" name="menu">
+ <?php Util::pformInput() ?>
+ <label for="context" accesskey="<?php echo $accesskey ?>">
+ <select id="context" name="context" onchange="contextSubmit()">
+ <?php
+ foreach ($shout->getContexts() as $item) {
+ print "<option name=\"$item\"";
+ if ($item == $context) {
+ print " selected";
+ }
+ print ">$item</option>\n";
+ }
+ ?>
+ </select>
+ </label>
+ </form>
+ </span>
+ <span style="float:right">
+ <?php
+ $link = Horde::link('#', _("Select Context"), '', '', 'contextSubmit(true);
+ return false;');
+ printf('<ul><li>%s%s<br />%s</a></li></ul>',
+ $link, Horde::img('folders/folder_open.png'),
+ ($menu_view != 'icon') ?
+ Horde::highlightAccessKey(_("Select _Context"), $accesskey) : '');
+ ?>
+ </span>
+
+ <?php echo Shout::getMenu('string') ?>
</div>
-<br />
-<?php $GLOBALS['notification']->notify(array('listeners' => 'status')) ?>
\ No newline at end of file
+
+<script language="JavaScript" type="text/javascript">
+<!--
+var loading;
+function contextSubmit(clear)
+{
+ if (document.menu.context[document.menu.context.selectedIndex].value !=
+'') {
+ if ((loading == null) || (clear != null)) {
+ loading = true;
+ document.menu.submit();
+ }
+ }
+}
+// -->
+</script>
+
+
+
define(SHOUT_BASE, dirname(__FILE__));
}
-# Check that we are properly initialized
-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 (($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();
-}
-
-require_once SHOUT_BASE . "/lib/Users.php";
-
-$RENDERER = &new Horde_Form_Renderer();
-$empty = '';
-$vars = &Variables::getDefaultVariables($empty);
-$formname = $vars->get('formname');
-
-$title = "Users";
-
-$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
+// # Check that we are properly initialized
+// if (is_a($contexts, 'PEAR_Error')) {
+// # FIXME change this to a Horde::fatal
+// $notification->push(_("Internal error viewing requested page"),
+// 'horde.error');
+// $notification->notify();
+// require $registry->get('templates', 'horde') . '/common-footer.inc';
+// exit();
+// }
+//
+//
+// print_r($shout->getUsers($context));
\ No newline at end of file