vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Custom "User Location" for Who's Online (https://vborg.vbsupport.ru/showthread.php?t=285807)

KGodel 07-21-2012 04:59 PM

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!

kh99 07-21-2012 06:12 PM

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.

KGodel 07-21-2012 06:24 PM

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!

kh99 07-21-2012 08:09 PM

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.

KGodel 07-22-2012 12:28 AM

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!


All times are GMT. The time now is 12:14 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.01055 seconds
  • Memory Usage 1,786KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete