Mnet: Remove 'Hide remote users' if there are no remote users: MDL-8068

This commit is contained in:
donal72 2007-01-12 01:10:36 +00:00
parent 1f4cd1bef5
commit 7340c7435c

View file

@ -18,6 +18,15 @@
$lu = optional_param('lu', '2', PARAM_INT); // show local users $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) $acl = optional_param('acl', '0', PARAM_INT); // id of user to tweak mnet ACL (requires $access)
// 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;
}
if($mnet_auth_users) {
// Determine which users we are looking at (local, remote, or both). Start with both. // Determine which users we are looking at (local, remote, or both). Start with both.
if (!isset($_SESSION['admin-user-remoteusers'])) { if (!isset($_SESSION['admin-user-remoteusers'])) {
$_SESSION['admin-user-remoteusers'] = 1; $_SESSION['admin-user-remoteusers'] = 1;
@ -37,6 +46,7 @@
$_SESSION['admin-user-localusers'] = 1; $_SESSION['admin-user-localusers'] = 1;
$localusers = 1; $localusers = 1;
} }
}
if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID)) { // Should never happen if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID)) { // Should never happen
redirect('index.php'); redirect('index.php');
@ -275,12 +285,9 @@
// tell the query which users we are looking at (local, remote, or both) // tell the query which users we are looking at (local, remote, or both)
$remotewhere = ''; $remotewhere = '';
if($mnet_auth_users && ($localusers XOR $remoteusers)) {
if ($localusers) { if ($localusers) {
$remotewhere .= " and mnethostid = {$CFG->mnet_localhost_id} "; $remotewhere .= " and mnethostid = {$CFG->mnet_localhost_id} ";
}
if ($remoteusers) {
if ($localusers) {
$remotewhere = ''; // more efficient SQL
} else { } else {
$remotewhere .= " and mnethostid <> {$CFG->mnet_localhost_id} "; $remotewhere .= " and mnethostid <> {$CFG->mnet_localhost_id} ";
} }
@ -459,18 +466,24 @@
} }
} }
if($mnet_auth_users) {
echo "<p style=\"text-align:center\">"; echo "<p style=\"text-align:center\">";
if ($remoteusers == 1) { if ($localusers == 1 && $remoteusers == 1) {
echo "<a href=\"?ru=0\">Hide remote users</a> | "; echo '<a href="?lu=0">'.get_string('hidelocal','mnet').'</a> | ';
} elseif ($localusers == 0) {
echo '<a href="?lu=1">'.get_string('showlocal','mnet').'</a> | ';
} else { } else {
echo "<a href=\"?ru=1\">Show remote users</a> | "; echo get_string('hidelocal','mnet').' | ';
} }
if ($localusers == 1) { if ($localusers == 1 && $remoteusers == 1) {
echo "<a href=\"?lu=0\">Hide local users</a>"; echo '<a href="?ru=0">'.get_string('hideremote','mnet').'</a>';
} elseif ($remoteusers == 0) {
echo '<a href="?ru=1">'.get_string('showremote','mnet').'</a>';
} else { } else {
echo "<a href=\"?lu=1\">Show local users</a>"; echo get_string('hideremote','mnet');
} }
echo "</p>"; echo "</p>";
}
echo "<table class=\"searchbox\" align=\"center\" cellpadding=\"10\"><tr><td>"; echo "<table class=\"searchbox\" align=\"center\" cellpadding=\"10\"><tr><td>";
echo "<form action=\"user.php\" method=\"get\">"; echo "<form action=\"user.php\" method=\"get\">";