I had to take a break looking at this... but finally at it again!
Okay, after some testing... this is what I've found...
PHP Code:
$show['qas_switch'] = false;
if ($vbulletin->userinfo['psi_qas'])
{
// process switch
if ($_REQUEST['do'] == 'qas_switch')
{
require_once(DIR . '/includes/functions_login.php');
$switchto = $vbulletin->input->clean_gpc('r', 'userid', TYPE_UINT);
$switchable = explode(' ', $vbulletin->userinfo['psi_qas']);
if (in_array($switchto, $switchable))
{
$getuserdata = $db->query_first("
SELECT userid, username, password, salt, styleid
FROM " . TABLE_PREFIX . "user
WHERE userid = $switchto
LIMIT 1
");
if ($getuserdata)
{
// clean out the session crap...
$db->query_write("
DELETE FROM " . TABLE_PREFIX . "cpsession
WHERE userid IN ({$vbulletin->userinfo['userid']}, {$getuserdata['userid']})
");
$db->query_write("
DELETE FROM " . TABLE_PREFIX . "session
WHERE userid IN ({$vbulletin->userinfo['userid']}, {$getuserdata['userid']})
");
// set cookie...
vbsetcookie('userid', $switchto);
vbsetcookie('password', md5($getuserdata['password'] . COOKIE_SALT));
// unstrike the user...
exec_unstrike_user($getuserdata['username']);
// create new session...
$vbulletin->session =& new vB_Session($vbulletin, '', $getuserdata['userid'], '', $getuserdata['styleid']);
$vbulletin->session->set('userid', $getuserdata['userid']);
$vbulletin->session->set('loggedin', 1);
$vbulletin->session->set('bypass', 0);
$vbulletin->session->set_session_visibility(($vbulletin->superglobal_size['_COOKIE'] > 0));
if ($_SERVER['HTTP_REFERER'])
{
exec_header_redirect($_SERVER['HTTP_REFERER']);
}
}
}
// if we got up to here, something went wrong... redirect to home
exec_header_redirect($vbulletin->options['bburl']);
}
// fetch data
$getusers = $db->query_read("
SELECT userid, username
FROM " . TABLE_PREFIX . "user
WHERE userid IN (" . $db->escape_string(str_replace(' ', ',', $vbulletin->userinfo['psi_qas'])) . ")
");
// construct switchbit
if ($db->num_rows($getusers))
{
$switchbit = '';
while ($getuserdata = $db->fetch_array($getusers))
{
$templater = vB_Template::create('qas_switchbit');
$templater->register('getuserdata', $getuserdata);
$switchbit .= $templater->render();
$show['qas_switch'] = true;
}
}
// inject into the navbar template
require_once(DIR . '/includes/adminfunctions_template.php');
$add_string = vB_Template::create('qas_navbar_link');
$add_string->register('switchbit', $switchbit);
$add_string = $add_string->render();
//$template_hook['navbar_end'] .= $add_string; Line below is fix for 4.2.0
//$template_hook['navbar_after_links'] .= $add_string; Line below is fix for 4.2.1
$vbphrase['vb_navigation_link_qas_switch_text'] = $add_string;
}
I've uncommented the two bottom lines that are commented out, and then commented out the very last line. Went into the Navigation Manager and turned off the #qas_switch# link.
Doing this, the QAS link is now the very last link in the navbar and there is no extra funky space that I was seeing. I'd prefer this to not be the last link in the navbar, but I definitely won't complain as the extra space to the side was bothering me more than the order does.
Thank you for your help, Alan!