Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-21-2012, 03:59 PM
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Location: Indiana
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom "User Location" for Who's Online

Hey all! I am trying to add locations for custom pages (mods) I am using that have different pages using one file, i.e. pages.php?pageid=1 is different than pages.php?pageid=6. Currently, I have the following code:

First Plugin Hook Location: online_location_process
PHP Code:
if ($filename == 'pages.php') {
    switch ($_GET['pageid']) {
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
        case 10:
        case 11:
        case 12:
        case 13:
        case 14:
        case 16:
        case 17:
            $userinfo['activity'] = 'ltc';
            break;
        case 15:
        case 20:
            $userinfo['activity'] = 'rosters';
            break;
        case 18:
            $userinfo['activity'] = 'finances';
            break;
        default:
            $userinfo['activity'] = 'pages';
            break;
    }
}
elseif ($filename == 'forms.php') {
    switch ($_GET['fid']) {
        case 1:
            $userinfo['activity'] = 'form_complaint';
            break;
        case 2:
            $userinfo['activity'] = 'newapp';
            break;
        case 3:
            $userinfo['activity'] = 'appeal';
            break;
        case 4:
            $userinfo['activity'] = 'goapp';
            break;
        case 5:
            $userinfo['activity'] = 'poapp';
            break;
        case 6:
            $userinfo['activity'] = 'dlapp';
            break;
        case 7:
            $userinfo['activity'] = 'offteam';
            break;
        case 8:
            $userinfo['activity'] = 'eaapp';
            break;
        case 9:
            $userinfo['activity'] = 'adminreq';
            break;
        case 10:
            $userinfo['activity'] = 'joapp';
            break;
        case 12:
            $userinfo['activity'] = 'awardnom';
            break;
        case 14:
            $userinfo['activity'] = 'moapp';
            break;
        case 15:
            $userinfo['activity'] = 'webreq';
            break;
        case 16:
            $userinfo['activity'] = 'gaapp';
            break;
        case 17:
            $userinfo['activity'] = 'unoffteam';
            break;
        case 18:
            $userinfo['activity'] = 'expreq';
            break;
        default:
            $userinfo['activity'] = 'forms';
            break;
    }
} 
Second Plugin Hook Location: online_location_unknown
PHP Code:
switch ($userinfo['activity']) {
    case 'ltc':
        $userinfo['action'] = 'Viewing the Leadership Training Center';
        $handled = true;
        break;
    case 'rosters':
        $userinfo['action'] = 'Viewing Clan Rosters';
        $handled = true;
        break;
    case 'finances':
        $userinfo['action'] = 'Viewing Clan Finances';
        $handled = true;
        break;
    case 'form_complaint':
        $userinfo['action'] = 'Submitting a User Comaplint';
        $handled = true;
        break;
    case 'newapp':
        $userinfo['action'] = 'Applying to the Clan';
        $handled = true;
        break;
    case 'appeal':
        $userinfo['action'] = 'Submitting an Appeal';
        $handled = true;
        break;
    case 'goapp':
        $userinfo['action'] = 'Applying for GO';
        $handled = true;
        break;
    case 'poapp':
        $userinfo['action'] = 'Applying for PO';
        $userinfo['where'] = '';
        $handled = true;
        break;
    case 'dlapp':
        $userinfo['action'] = 'Applying for DL';
        $handled = true;
        break;
    case 'offteam':
        $userinfo['action'] = 'Applying for an Official Team';
        $handled = true;
        break;
    case 'eaapp':
        $userinfo['action'] = 'Applying for EA';
        $handled = true;
        break;
    case 'adminreq':
        $userinfo['action'] = 'Submitting an Admin Request';
        $handled = true;
        break;
    case 'joapp':
        $userinfo['action'] = 'Applying for JO';
        $handled = true;
        break;
    case 'awardnom':
        $userinfo['action'] = 'Nominating a Member for an Award';
        $handled = true;
        break;
    case 'moapp':
        $userinfo['action'] = 'Applying for MO';
        $handled = true;
        break;
    case 'webreq':
        $userinfo['action'] = 'Submitting Web Content';
        $handled = true;
        break;
    case 'gaapp':
        $userinfo['action'] = 'Applying for GA';
        $handled = true;
        break;
    case 'unoffteam':
        $userinfo['action'] = 'Applying for an Unofficial Team';
        $handled = true;
        break;
    case 'expreq':
        $userinfo['action'] = 'Submitting an Expansion Request';
        $handled = true;
        break;
    case 'forms':
        $userinfo['action'] = 'Viewing Forms';
        $handled = true;
        break;
    case 'pages':
        $userinfo['action'] = 'Viewing Custom Page';
        $handled = true;
        break;
} 
Currently, for both cases it only recognized the default cast of the switch. My $_GET doesn't seem to be passing the variable to the code, so I am unable to differentiate. Any help would be greatly appreciated!
Reply With Quote
  #2  
Old 07-21-2012, 05:12 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...I'm not very familiar with that area, but I don't know why what you're doing wouldn't work. But, I see that the rest of the code in that function seems to work with the $userinfo['location'] string and splits the parameters into a $values array, so maybe try doing a switch on $values['pageid'] instead.
Reply With Quote
  #3  
Old 07-21-2012, 05:24 PM
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Location: Indiana
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And just like that, kh99 does it again. changing from $_GET to $values worked like a charm. You're the best mate!

Edit, you seem to help me so much I can't even like you post, but I really appreciate your help!
Reply With Quote
  #4  
Old 07-21-2012, 07:09 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Glad you got it working. FWIW I realized (I think) why $_GET didn't work - I think that hook is executed when someone else is displaying what the user is doing, not when your pages.php script is executed, so $_GET wouldn't be set at that point.
Reply With Quote
  #5  
Old 07-21-2012, 11:28 PM
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Location: Indiana
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yea that makes sense. I also wasnt sure whether it would be getting it since it was being executed on a different page as well, but the examples I saw elsewhere of people doing this used get, so I tried the same. Good to know though!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:11 PM.


Powered by vBulletin® Version 3.9.0
Copyright ©2000 - 2017, vBulletin Solutions Inc.