*/
@define('SHOUT_BASE', dirname(__FILE__));
-require_once SHOUT_BASE . '/lib/base.php';
-require_once SHOUT_BASE . '/lib/Shout.php';
-
-// Variable handling libraries
-require_once 'Horde/Variables.php';
-require_once 'Horde/Text/Filter.php';
-
-$context = Util::getFormData("context");
-$section = Util::getFormData("section");
-
-$contexts = &$shout->getContexts();
-# Check that we are properly initialized
-if (is_a($contexts, 'PEAR_Error')) {
- $notification->push($contexts, 'horde.error');
- $contexts = false;
-} elseif (count($contexts) == 1) {
- # Default to the user's only context
- $context = $contexts[0];
-} elseif (!$context) {
- # Attempt to locate the user's "home" context
- $context = $shout->getHomeContext();
- if (is_a($context, 'PEAR_Error')) {
- $notification->push($context);
- }
- $context = '';
-}
-
-$vars = &Variables::getDefaultVariables();
-$tabs = &Shout::getTabs($context, $vars);
-$tabs->preserve('context', $context);
-
-switch ($section) {
- case "conference":
- case "dialplan":
- case "security":
- case "usermgr":
- case "moh":
- break;
- default:
- $section = $tabs->_tabs[0]['tabname'];
- break;
+$shout_configured = (is_readable(SHOUT_BASE . '/config/conf.php') &&
+ is_readable(SHOUT_BASE . '/config/applist.xml') &&
+ is_readable(SHOUT_BASE . '/config/defines.php'));
+
+if (!$shout_configured) {
+require SHOUT_BASE . '/../lib/Test.php';
+ Horde_Test::configFilesMissing('Shout', SHOUT_BASE,
+ array('conf.php', 'applist.xml', 'defines.php'));
}
-# We've passed the initialization tests. This flag allows other pages to run.
-$SHOUT_RUNNING = true;
-
-require SHOUT_BASE . "/$section.php";
-#print '<div style="width:95%;left:10px;position:relative">';
-
-#print '</div>';
-require $registry->get('templates', 'horde') . '/common-footer.inc';
+require_once SHOUT_BASE . '/lib/base.php';
+header('Location: ' . Horde::applicationUrl('usermgr.php'));
# Make Shout methods available
require_once SHOUT_BASE . '/lib/Shout.php';
-// {{{ Shout_Driver_ldap class
class Shout_Driver_ldap extends Shout_Driver
{
var $_ldapKey; // Index used for storing objects
var $_appKey; // Index used for moving info to/from the app
- // {{{ Class local variables
/**
* Handle for the current database connection.
* @var object LDAP $_LDAP
*/
var $_connected = false;
- // }}}
- // {{{ Shout_Driver_ldap constructor
/**
* Constructs a new Shout LDAP driver object.
*
break;
}
}
- // }}}
- // {{{ getContexts method
/**
* Get a list of contexts from the backend
*
# return the array
return $entries[$searchfilters];
}
- // }}}
- // {{{ checkContextType method
/**
* For the given context and type, make sure the context has the
* appropriate properties, that it is effectively of that "type"
return false;
}
}
- // }}}
- // {{{ getUsers method
/**
* Get a list of users valid for the contexts
*
*
* @return array User information indexed by voice mailbox number
*/
- function &getUsers($context)
+ function getUsers($context)
{
static $entries = array();
return($entries[$context]);
}
- // }}}
- // {{{ getHomeContext method
/**
* Returns the name of the user's default context
*
# Assume the user only has one context. The schema enforces this
# FIXME: Handle cases where the managing user isn't a valid telephone
# system user
- # FIXME: Handle cases where no attribute is found?
+ # FIXME: Do we want to warn? If so, how? This PEAR::Error shows up
+ # in unfavorable places (ie. perms screen)
if ($res['count'] != 1) {
- return PEAR::raiseError(_("Unable to determine default context"));
+ //return PEAR::raiseError(_("Unable to determine default context"));
+ return '';
}
return $res[0]['context'][0];
}
}
return $properties;
}
- // }}}
- // {{{ getDialplan method
/**
* Get a context's dialplan and return as a multi-dimensional associative
* array
}
return $dialplans[$context];
}
- // }}}
- // {{{
/**
* Get the limits for the current user, the user's context, and global
* Return the most specific values in every case. Return default values
return $cachedlimits[$context];
}
}
- // }}}
- // {{{
/**
* Save a user to the LDAP tree
*
# We must have been successful
return true;
}
- // }}}
- // {{{ deleteUser method
/**
* Deletes a user from the LDAP tree
*
}
return true;
}
- // }}}
/* Needed because uksort can't take a classed function as its callback arg */
return $ret;
}
- // {{{ connect method
/**
* Attempts to open a connection to the LDAP server.
*
}
return true;
}
- // }}}
}
*/
require_once SHOUT_BASE . "/config/defines.php";
-// {{{ Class Shout
class Shout
{
var $applist = array();
var $_applist_curapp = '';
var $_applist_curfield = '';
- // {{{ getMenu method
/**
* Build Shout's list of menu items.
*
return $menu->render();
}
}
- // }}}
- // {{{
/**
* Generate the tabs at the top of each Shout pages
*
*
* @return object Horde_UI_Tabs
*/
- function &getTabs($context, &$vars)
+ function getTabs($context, &$vars)
{
global $shout;
- # FIXME Is this right?
- if (!Auth::isAdmin("shout", PERMS_SHOW|PERMS_READ)) {
- return false;
- }
- $permprefix = "shout:contexts:$context";
+ $permprefix = 'shout:contexts:' . $context;
$tabs = &new Horde_UI_Tabs('section', $vars);
- if (Shout::checkRights("$permprefix:users", null, 1) &&
- $shout->checkContextType($context, "users")) {
- $tabs->addTab(_("User Manager"),
- Horde::applicationUrl("index.php?context=$context"),
- 'usermgr');
+ if (Shout::checkRights($permprefix . ':users', null, 1) &&
+ $shout->checkContextType($context, 'users')) {
+
+ $url = Horde::applicationUrl('usermgr.php');
+ $url = Util::addParameter($url, 'context', $context);
+ $tabs->addTab(_("_User Manager"), $url, 'usermgr');
}
- if (Shout::checkRights("$permprefix:dialplan", null, 1) &&
- $shout->checkContextType($context, "dialplan")) {
- $tabs->addTab(_("Dial Plan"),
- Horde::applicationUrl('index.php'), 'dialplan');
+ if (Shout::checkRights($permprefix . ':dialplan', null, 1) &&
+ $shout->checkContextType($context, 'dialplan')) {
+
+ $url = Horde::applicationUrl('dialplan.php');
+ $url = Util::addParameter($url, 'context', $context);
+ $tabs->addTab(_("_Dial Plan"), $url, 'dialplan');
}
- if (Shout::checkRights("$permprefix:conference", null, 1) &&
- $shout->checkContextType($context, "conference")) {
- $tabs->addTab(_("Conference Rooms"),
- Horde::applicationUrl('index.php'), 'conference');
+ if (Shout::checkRights($permprefix . ':conference', null, 1) &&
+ $shout->checkContextType($context, 'conference')) {
+
+ $url = Horde::applicationUrl('conference.php');
+ $url = Util::addParameter($url, 'context', $context);
+ $tabs->addTab(_("_Conference Rooms"), $url, 'conference');
}
- if (Shout::checkRights("$permprefix:moh", null, 1) &&
+ if (Shout::checkRights($permprefix . ':moh', null, 1) &&
$shout->checkContextType($context, "moh")) {
- $tabs->addTab(_("Music on Hold"),
- Horde::applicationUrl('index.php'), 'moh');
+
+ $url = Horde::applicationUrl('moh.php');
+ $url = Util::addParameter($url, 'context', $context);
+ $tabs->addTab(_("_Music on Hold"), $url, 'moh');
}
- if (Auth::isAdmin("shout:superadmin", PERMS_SHOW|PERMS_READ)) {
- $tabs->addTab(_("Security"),
- Horde::applicationUrl('index.php'), 'security');
+ if (Perms::hasPermission('shout:superadmin', Auth::getAuth(), PERMS_SHOW|PERMS_READ)) {
+ $url = Horde::applicationUrl('security.php');
+ $url = Util::addParameter($url, 'context', $context);
+ $tabs->addTab(_("_Security"), $url, 'security');
}
return $tabs;
}
- // {{{
/**
* Checks for the given permissions for the current user on the given
* permission. Optionally check for higher-level permissions and ultimately
$user = 0;
$superadmin = 0;
- $superadmin = $perms->hasPermission("shout:superadmin",
+ $superadmin = $perms->hasPermission('shout:superadmin',
Auth::getAuth(), $permmask);
while ($numparents >= 0) {
$numparents--;
}
$test = $superadmin | $user;
+$ret = ($test & $permmask) == $permmask;
+print "Shout::checkRights() returning $ret";
return ($test & $permmask) == $permmask;
}
- // }}}
function getContextTypes()
{
}
}
}
-// }}}
\ No newline at end of file
$perms['tree']['shout']['superadmin'] = false;
$perms['title']['shout:superadmin'] = _("Super Administrator");
- $contexts = $GLOBALS['shout']->getContexts();
+ $contexts = $shout->getContexts();
$perms['tree']['shout']['contexts'] = false;
$perms['title']['shout:contexts'] = _("Contexts");
}
}
-
// function _shout_getContexts($searchfilters = SHOUT_CONTEXT_ALL,
// $filterperms = null)
-
+ return $perms;
}
function _shout_attributes()
);
return $shoutAttributes;
-}
\ No newline at end of file
+}
require_once SHOUT_BASE . '/lib/Driver.php';
// Form libraries.
-// require_once 'Horde/Form.php';
-// require_once 'Horde/Form/Renderer.php';
+require_once 'Horde/Form.php';
+require_once 'Horde/Form/Renderer.php';
// Variable handling libraries
-// require_once 'Horde/Variables.php';
-// require_once 'Horde/Text/Filter.php';
+require_once 'Horde/Variables.php';
+require_once 'Horde/Text/Filter.php';
// UI classes.
require_once 'Horde/UI/Tabs.php';
-$GLOBALS['shout'] = &Shout_Driver::singleton();
+$shout = Shout_Driver::singleton();
// Horde libraries.
-require_once 'Horde/Help.php';
\ No newline at end of file
+require_once 'Horde/Help.php';
+
+$context = Util::getFormData('context');
+$section = Util::getFormData('section');
+
+$contexts = $shout->getContexts();
+
+// Check that we are properly initialized
+if (is_a($contexts, 'PEAR_Error')) {
+ $notification->push($contexts);
+ $contexts = false;
+} elseif (count($contexts) == 1) {
+ // Default to the user's only context
+ $context = $contexts[0];
+} elseif (!$context) {
+ // Attempt to locate the user's "home" context
+ $context = $shout->getHomeContext();
+ if (is_a($context, 'PEAR_Error')) {
+ $notification->push($context);
+ }
+ $context = '';
+}
+
+// We've passed the initialization tests. This flag allows other pages to run.
+$SHOUT_RUNNING = true;
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*/
+@define('SHOUT_BASE', dirname(__FILE__));
+require_once SHOUT_BASE . '/lib/base.php';
+require_once SHOUT_BASE . '/lib/Shout.php';
if (!isset($SHOUT_RUNNING) || !$SHOUT_RUNNING) {
+ # FIXME! This needs to redirect somewhere more sensical
header('Location: /');
exit();
}
-// Form libraries.
-require_once 'Horde/Form.php';
-require_once 'Horde/Form/Renderer.php';
+$action = Util::getFormData('action');
+$extension = Util::getFormData('extension');
-$action = Util::getFormData("action");
-$extension = Util::getFormData("extension");
+$vars = Variables::getDefaultVariables();
+$tabs = Shout::getTabs($context, $vars);
+$tabs->preserve('context', $context);
+
+$section = 'usermgr';
$title = _("User Manager: ");
+
switch ($action) {
- case "add":
+ case 'add':
$title .= _("Add User");
# Treat adds just like an empty edit
- $action = "edit";
+ $action = 'edit';
$extension = 0;
break;
- case "edit":
- $title .= _("Edit User (Extension ") . "$extension)";
+ case 'edit':
+ $title .= sprintf(_("Edit User (Extension %s)"), $extension);
break;
- case "save":
- $title .= _("Save User (Extension ") . "$extension)";
+ case 'save':
+ $title .= sprintf(_("Save User (Extension %s)"), $extension);
break;
- case "delete":
- $title .= _("Delete User (Extension ") . "$extension)";
+ case 'delete':
+ $title .= sprintf(_("Delete User (Extension %s)"), $extension);
break;
- case "list":
+ case 'list':
default:
$title .= _("List Users");
- $action = "list";
+ $action = 'list';
break;
}
-
+require SHOUT_BASE . '/usermgr/' . $action . '.php';
require SHOUT_TEMPLATES . '/common-header.inc';
require SHOUT_TEMPLATES . '/menu.inc';
echo $tabs->render($section);
-require SHOUT_BASE . "/usermgr/$action.php";
+require SHOUT_TEMPLATES . '/usermgr/' . $action . '.inc';
-require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
+require $registry->get('templates', 'horde') . '/common-footer.inc';
}
$users = &$shout->getUsers($context);
-ksort($users);
-$notification->notify();
-require SHOUT_TEMPLATES . "/users/userlist.inc";
\ No newline at end of file