From 7340c7435c749a2039d3e47ebedd14b2764b80a6 Mon Sep 17 00:00:00 2001 From: donal72 Date: Fri, 12 Jan 2007 01:10:36 +0000 Subject: [PATCH] Mnet: Remove 'Hide remote users' if there are no remote users: MDL-8068 --- admin/user.php | 79 +++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/admin/user.php b/admin/user.php index f2d0369ea8..f1d9aec397 100644 --- a/admin/user.php +++ b/admin/user.php @@ -18,24 +18,34 @@ $lu = optional_param('lu', '2', PARAM_INT); // show local users $acl = optional_param('acl', '0', PARAM_INT); // id of user to tweak mnet ACL (requires $access) - // Determine which users we are looking at (local, remote, or both). Start with both. - if (!isset($_SESSION['admin-user-remoteusers'])) { - $_SESSION['admin-user-remoteusers'] = 1; - $_SESSION['admin-user-localusers'] = 1; - } - if ($ru == 0 or $ru == 1) { - $_SESSION['admin-user-remoteusers'] = $ru; - } - if ($lu == 0 or $lu == 1) { - $_SESSION['admin-user-localusers'] = $lu; + // Let's see if we have *any* mnet users. Just ask for a single record + $mnet_users = get_records_select('user', " auth='mnet' AND mnethostid != '{$CFG->mnet_localhost_id}' ", '', '*', '0', '1'); + if(is_array($mnet_users) && count($mnet_users) > 0) { + $mnet_auth_users = true; + } else { + $mnet_auth_users = false; } - $remoteusers = $_SESSION['admin-user-remoteusers']; - $localusers = $_SESSION['admin-user-localusers']; - - // if neither remote nor local, set to sensible local only - if (!$remoteusers and !$localusers) { - $_SESSION['admin-user-localusers'] = 1; - $localusers = 1; + + if($mnet_auth_users) { + // Determine which users we are looking at (local, remote, or both). Start with both. + if (!isset($_SESSION['admin-user-remoteusers'])) { + $_SESSION['admin-user-remoteusers'] = 1; + $_SESSION['admin-user-localusers'] = 1; + } + if ($ru == 0 or $ru == 1) { + $_SESSION['admin-user-remoteusers'] = $ru; + } + if ($lu == 0 or $lu == 1) { + $_SESSION['admin-user-localusers'] = $lu; + } + $remoteusers = $_SESSION['admin-user-remoteusers']; + $localusers = $_SESSION['admin-user-localusers']; + + // if neither remote nor local, set to sensible local only + if (!$remoteusers and !$localusers) { + $_SESSION['admin-user-localusers'] = 1; + $localusers = 1; + } } if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID)) { // Should never happen @@ -275,12 +285,9 @@ // tell the query which users we are looking at (local, remote, or both) $remotewhere = ''; - if ($localusers) { - $remotewhere .= " and mnethostid = {$CFG->mnet_localhost_id} "; - } - if ($remoteusers) { + if($mnet_auth_users && ($localusers XOR $remoteusers)) { if ($localusers) { - $remotewhere = ''; // more efficient SQL + $remotewhere .= " and mnethostid = {$CFG->mnet_localhost_id} "; } else { $remotewhere .= " and mnethostid <> {$CFG->mnet_localhost_id} "; } @@ -459,18 +466,24 @@ } } - echo "

"; - if ($remoteusers == 1) { - echo "Hide remote users | "; - } else { - echo "Show remote users | "; - } - if ($localusers == 1) { - echo "Hide local users"; - } else { - echo "Show local users"; + if($mnet_auth_users) { + echo "

"; + if ($localusers == 1 && $remoteusers == 1) { + echo ''.get_string('hidelocal','mnet').' | '; + } elseif ($localusers == 0) { + echo ''.get_string('showlocal','mnet').' | '; + } else { + echo get_string('hidelocal','mnet').' | '; + } + if ($localusers == 1 && $remoteusers == 1) { + echo ''.get_string('hideremote','mnet').''; + } elseif ($remoteusers == 0) { + echo ''.get_string('showremote','mnet').''; + } else { + echo get_string('hideremote','mnet'); + } + echo "

"; } - echo "

"; echo "
"; echo "
"; -- 2.39.5