From 63c2b3b83776c077a2cf015a9985ec13b765fe32 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Thu, 14 Jul 2005 00:26:24 +0000 Subject: [PATCH] Integrated Mandy's changes to userlist.inc. Activated more parts of the user forms. Added javascript popups. Moved all contexts back to drop-down box in main menu for super-admins. System Settings tab will become something else, but not entirely sure what yet. git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@52 06cd67b6-e706-0410-b29e-9de616bca6e9 --- index.php | 20 ++++---- lib/Driver/ldap.php | 10 +++- lib/Shout.php | 80 +++++++++++++++++-------------- shout.webprj | 58 ++++++++++++----------- templates/menu.inc | 60 ++++++++++++++++++++++-- templates/users/userlist.inc | 109 +++++++++++++++++++++++++++++++++---------- users.php | 2 +- 7 files changed, 240 insertions(+), 99 deletions(-) diff --git a/index.php b/index.php index 1e2fb07ee..2d753d0a6 100644 --- a/index.php +++ b/index.php @@ -19,9 +19,6 @@ if (!$shout_configured) { require_once SHOUT_BASE . '/lib/base.php'; require_once SHOUT_BASE . '/lib/Shout.php'; -#require_once SHOUT_TEMPLATES . '/comment.inc'; -#require_once 'Horde/Variables.php'; -#require_once 'Horde/Text/Filter.php'; $context = Util::getFormData("context"); $section = Util::getFormData("section"); @@ -36,19 +33,26 @@ if (count($contexts) == 1) { $context = $shout->getHomeContext(); } +$tabs = &Shout::getTabs($context, $vars); +$tabs->preserve('context', $context); +if (!$section) { + $section = $tabs->_tabs[0]['tabname']; +} + +#require_once SHOUT_TEMPLATES . '/comment.inc'; +#require_once 'Horde/Variables.php'; +#require_once 'Horde/Text/Filter.php'; + + + #$title = '[#' . $ticket->getId() . '] ' . $ticket->get('summary'); require SHOUT_TEMPLATES . '/common-header.inc'; require SHOUT_TEMPLATES . '/menu.inc'; -$tabs = &Shout::getTabs($context, $vars); -$tabs->preserve('context', $context); echo "
"; // if (!$section) { // $section = -if (!$section) { - $section = $tabs->_tabs[0]['tabname']; -} echo $tabs->render($section); switch ($section) { diff --git a/lib/Driver/ldap.php b/lib/Driver/ldap.php index bde711962..b630fb719 100644 --- a/lib/Driver/ldap.php +++ b/lib/Driver/ldap.php @@ -55,23 +55,31 @@ class Shout_Driver_ldap extends Shout_Driver # Determine which combination of contexts need to be returned if ($searchfilters == SHOUT_CONTEXT_ALL) { - $searchfilter="(objectClass=*)"; + $searchfilter="(objectClass=asteriskObject)"; } else { $searchfilter = "(|"; if ($searchfilters & SHOUT_CONTEXT_CUSTOMERS) { $searchfilter.="(objectClass=vofficeCustomer)"; + } else { + $searchfilter.="(!(objectClass=vofficeCustomer))"; } if ($searchfilters & SHOUT_CONTEXT_EXTENSIONS) { $searchfilter.="(objectClass=asteriskExtensions)"; + } else { + $searchfilter.="(!(objectClass=asteriskExtensions))"; } if ($searchfilters & SHOUT_CONTEXT_MOH) { $searchfilter.="(objectClass=asteriskMusicOnHold)"; + } else { + $searchfilter.="(!(objectClass=asteriskMusicOnHold))"; } if ($searchfilters & SHOUT_CONTEXT_CONFERENCE) { $searchfilter.="(objectClass=asteriskMeetMe)"; + } else { + $searchfilter.="(!(objectClass=asteriskMeetMe))"; } $searchfilter .= ")"; } diff --git a/lib/Shout.php b/lib/Shout.php index 6b46e2c3c..1ee50c966 100644 --- a/lib/Shout.php +++ b/lib/Shout.php @@ -22,36 +22,17 @@ class Shout */ function getMenu($returnType = 'object') { - global $conf, $page; + global $conf, $context, $section; require_once 'Horde/Menu.php'; $menu = &new Menu(HORDE_MENU_MASK_ALL); - if (@count($conf['menu']['pages'])) { - foreach ($conf['menu']['pages'] as $pagename) { - /* Determine who we should say referred us. */ - $curpage = isset($page) ? $page->pageName() : null; - $referrer = Util::getFormData('referrer', $curpage); - - /* Determine if we should depress the button. We have to do - * this on our own because all the buttons go to the same .php - * file, just with different args. */ - if (!strstr($_SERVER['PHP_SELF'], 'prefs.php') && - $curpage === _($pagename)) { - $cellclass = 'current'; - } else { - $cellclass = '__noselection'; - } - - /* Construct the URL. */ - $url = Horde::applicationUrl('display.php'); - $url = Util::addParameter($url, array('page' => $pagename, - 'referrer' => $referrer)); - - $menu->add($url, _($pagename), $pagename . '.png', null, null, -null, $cellclass); - } + if (isset($context) && isset($section) && $section == "users" && + Shout::checkRights("shout:contexts:$context:users", + PERMS_EDIT, 1)) { + $menu->add("#", _("Add User"), "add-user.gif", null, null, + "open_adduser_win('context=$context')", null); } if ($returnType == 'object') { @@ -81,26 +62,26 @@ null, $cellclass); $tabs = &new Horde_UI_Tabs('section', $vars); - if (Shout::checkRights("$permprefix:users") && + if (Shout::checkRights("$permprefix:users", null, 1) && $shout->checkContextType($context, "users")) { $tabs->addTab(_("Users"), Horde::applicationUrl("index.php?context=$context"), 'users'); } - if (Shout::checkRights("$permprefix:dialplan") && + if (Shout::checkRights("$permprefix:dialplan", null, 1) && $shout->checkContextType($context, "dialplan")) { $tabs->addTab(_("Dial Plan"), Horde::applicationUrl('index.php'), 'dialplan'); } - if (Shout::checkRights("$permprefix:conference") && + if (Shout::checkRights("$permprefix:conference", null, 1) && $shout->checkContextType($context, "conference")) { $tabs->addTab(_("Conference Rooms"), Horde::applicationUrl('index.php'), 'conference'); } - if (Shout::checkRights("$permprefix:moh") && + if (Shout::checkRights("$permprefix:moh", null, 1) && $shout->checkContextType($context, "moh")) { $tabs->addTab(_("Music on Hold"), Horde::applicationUrl('index.php'), 'moh'); @@ -119,21 +100,48 @@ null, $cellclass); return $tabs; } - function checkRights($permname, $permmask = null) + // {{{ + /** + * Checks for the given permissions for the current user on the given + * permission. Optionally check for higher-level permissions and ultimately + * test for superadmin priveleges. + * + * @param string $permname Name of the permission to check + * + * @param optional int $permmask Bitfield of permissions to check for + * + * @param options int $numparents Check for the same permissions this + * many levels up the tree + * + * @return boolean the effective permissions for the user. + */ + function checkRights($permname, $permmask = null, $numparents = 0) { if ($permmask == null) { $permmask = PERMS_SHOW|PERMS_READ; } + # Default deny all permissions + $user = 0; + $superadmin = Auth::isAdmin("shout:superadmin", $permmask); - $user = Auth::isAdmin($permname, $permmask); - $test = $superadmin | $user; - if ($test) { - return TRUE; - } else { - return FALSE; + + while ($numparents >= 0) { + $tmpuser = Auth::isAdmin($permname, $permmask); + $user = $user | $tmpuser; + if ($numparents> 0) { + $pos = strrpos($permname, ':'); + if ($pos) { + $permname = substr($permname, 0, $pos); + } + } + $numparents--; } + + $test = $superadmin | $user; + return $test; } + // }}} function getContextTypes() { diff --git a/shout.webprj b/shout.webprj index 12a188b33..86ec4adb2 100644 --- a/shout.webprj +++ b/shout.webprj @@ -9,26 +9,26 @@ - + - - + + - + - + - + - + @@ -43,10 +43,13 @@ - + - - + + + + + @@ -67,7 +70,20 @@ -//w3c//dtd xhtml 1.0 strict//en - + + + + + + + + + + + + + + Ben Klang ben@alkaloid.net Gubed @@ -78,27 +94,17 @@ - - - - - - - - - - - - - + + + - - + + diff --git a/templates/menu.inc b/templates/menu.inc index 76ecabc6d..a34f44e47 100644 --- a/templates/menu.inc +++ b/templates/menu.inc @@ -12,7 +12,7 @@ $menu_view = $prefs->getValue('menu_view');