vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   Profile Enhancements - Quick Account Switch (https://vborg.vbsupport.ru/showthread.php?t=237286)

Raw Sugar 01-23-2015 02:09 AM

Quote:

Originally Posted by Alan_SP (Post 2533844)
Well, you need to create template hook association for this mod with existing template hook in header (I don't know if there exist one), or create association for new hook that you'll place in header in position you like.

I described procedure here and here.

Missing image in second post is because imageshack deleted it. :( I still use this system for quick change of accounts.

Thank you so much for your reply! Quick question - doing these would require that I completely uninstall the product, right? Which would then unlink all of the linked accounts and once re-installed and all that, I would have to go through and re-link them? Or am I making it more complicated than it should be?

Thank you again for your help! :)

concepts 01-23-2015 01:15 PM

Is there is a way to show notifications for those linked accounts in the dropdown? like maybe a "Total Notifications"? to show an admin someone has interacted with one of the linked accounts? If I am using a few linked accounts for different management, I want to know if there is a notification for that account without having to switch over to it first.

Alan_SP 01-23-2015 10:32 PM

Quote:

Originally Posted by Raw Sugar (Post 2534034)
Quick question - doing these would require that I completely uninstall the product, right? Which would then unlink all of the linked accounts and once re-installed and all that, I would have to go through and re-link them?

Well, you're making it too complicated. :D

Actually, you can do two things:

a) You can edit plugins (actually, one plugin of this mod in question).

b) You can edit installation xml file by yourself, or use one I attached and upload it with allowing overwrite to assure it is accepted by vB.

Everything will stay the same, except, of course, you'll have additional working hook (or completely new one) that you now can place in header template where you want it. I don't know what exactly you intend to do, but I still use things as I described in second post (much faster to see all linked accounts and it needs only one click). Sorry for missing image, imageshack dropped it. :(

Anyway, creating new, previously not existing hook is the best path and afterwards placing it in template of choice (navbar, footer, whatever someone prefers). At least I see it that way.

Quote:

Originally Posted by concepts (Post 2534102)
Is there is a way to show notifications for those linked accounts in the dropdown?

Not that easily and it would require more work on mod, if it is even possible.

Linked accounts are still completely separate. This mod just makes easy switching between them. No information (except linked accounts) is stored about them.

And I agree it would be useful to see if there are new PM's or other notifications about other accounts.

Raw Sugar 01-24-2015 08:31 PM

Quote:

Originally Posted by Alan_SP (Post 2534196)
Well, you're making it too complicated. :D

Actually, you can do two things:

a) You can edit plugins (actually, one plugin of this mod in question).

b) You can edit installation xml file by yourself, or use one I attached and upload it with allowing overwrite to assure it is accepted by vB.

Everything will stay the same, except, of course, you'll have additional working hook (or completely new one) that you now can place in header template where you want it. I don't know what exactly you intend to do, but I still use things as I described in second post (much faster to see all linked accounts and it needs only one click). Sorry for missing image, imageshack dropped it. :(

Anyway, creating new, previously not existing hook is the best path and afterwards placing it in template of choice (navbar, footer, whatever someone prefers). At least I see it that way.

I finally got the default navbar template edited to work how I want it to, so now I can keep the QAS in there and not have to worry about editing the plugin. :D

Although, now I'm seeing this issue (in fact it's been there all along, but I thought it'd be easier to take care of...)

Screenshot with space highlighted and Chrome's inspect for reference:
https://vborg.vbsupport.ru/external/2015/01/15.jpg

There's a couple of things I'm confused about...
1: There's an li with an id of "qas_switch" that was empty (it also had an empty href tag) - I have that id set to display none, because it was creating more space.

2: The QAS is in the next li, but there's a weird empty href tag in there too, before the actual link. When I inspect and do display:none on that one, the space goes away and all is well. I'm not sure why there's an empty href tag there and because the link is being added in through the Navigation Manager, there's no way for me to edit the html.

Any ideas how to get that empty href to go away? I can't do something like this (li#yui.gen0 { a: display:none; }) as that would remove all the links in that id.

Alan_SP 01-24-2015 10:22 PM

That's strange. I just checked, I don't have empty href tag. I use version given here. Interesting is, picture is back again, so you can see how it looks like.

Anyway, maybe you did something wrong?

Raw Sugar 01-24-2015 10:47 PM

Quote:

Originally Posted by Alan_SP (Post 2534402)
That's strange. I just checked, I don't have empty href tag. I use version given here. Interesting is, picture is back again, so you can see how it looks like.

Anyway, maybe you did something wrong?

I'm not the one who actually installed the plugin, so I've no idea if the person who did it did anything funky. Since it's technically not my board that I'm helping out with, I'm worried about uninstalling the old one to install a newer version of the plugin. I'm also new to vb4 (the board that I own is still running vb3), and when I click on 'edit' next to the Product, it brings up a page I've never seen before that has uninstall and install codes.

If I wanted to do this one without using the new .xml, do I need to uncomment one of the lines at the bottom of the code?

This is what is in this board's QAS: Handle Switch:
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;


Or should I just replace this with the plugin chunk in your .xml file?

Thank you, Alan for your patience! :)

Alan_SP 01-25-2015 02:06 AM

Well, I'm using hook in my version and template which I modified to create output I like as shown in the image (both are in my xml version, you only need to place hook manually where you want output).

Here is used phrase for navigation, but how vB handles it, I don't know, maybe that creates problem, maybe not, I'm not on vB4.2.1+

But, when updating, you just can reload older version and allow overwrite if you don't like new version. Every setting will stay the same this way. So you can play with different versions of QAS.

About code, you could try to uncomment hook locations and see if it will work on your version of vB.

Raw Sugar 02-03-2015 01:25 AM

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!

Alan_SP 02-03-2015 07:04 AM

If I understand you correctly, now you're using two hooks: navbar_end and navbar_after_links? As in the code isn't version you described you're using.

Anyway, from what you did if I get it correctly, there's a problem with Navigation Manager, who creates that extra space, which is probably bug in vB.

You could always add new hook location in template navbar at exact place where you want QAS switch and add it in the plugin code.

Raw Sugar 02-03-2015 02:28 PM

I've just commented out two of the hook locations, and now am using this one, which seems to work and not break anything:
PHP Code:

    $template_hook['navbar_after_links'] .= $add_string//Line below is fix for 4.2.1 

My biggest question I think is how do I add a hook into the MIDDLE of the navbar? Because in the code it's got:

PHP Code:

{vb:raw template_hook.navtab_start}
{
vb:raw navigation}
{
vb:raw template_hook.navtab_end

So it's like I can't put anything into the middle of the navbar... I can only add things to the beginning and the end. This is more like a general question, I think.

Being used to how the navbar worked in vb3, I'm considering just not using the Navigation Manager at all and just hardcoding the links in there in the order that I want them.


All times are GMT. The time now is 08:19 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01452 seconds
  • Memory Usage 1,873KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete