PDA

View Full Version : Which hook for users online (online.php)?


aileron79
12-21-2010, 01:12 PM
Hi everybody,

I want to write a plugin that displays a little flag just beside every user in the user's online list (online.php). I wonder which hook that should be, there is one named online_users on line 511 in online.php, but this seems to be executed only for guests, not for all users:


395 if ($users['userid'])
...
437 else
438 { // Guest or Spider..
...
...
509 $count++;
510
511 ($hook = vBulletinHook::fetch_hook('online_user')) ? eval($hook) : false;
512 }
513 }
514
515 if (!$foundviewer AND $vbulletin->userinfo['userid'] AND ($vbulletin->GPC['who'] == '' OR $vbulletin->GPC['who'] == 'members'))
...


I got a couple of questions:

- Is there a description of all the hooks available?
- What is the meaning of this hook and why is it only executed for guests? Is that a bug, should likes 511 and 512 be swapped?
- Which hook am I supposed to use for that purpose?

Admittedly, I am quite familiar with PHP but not with vB's plugin system. Anyone can provide some information?

Thanks in advance!

Boofo
12-21-2010, 01:27 PM
Why don't you just edit the template itself?

aileron79
12-21-2010, 03:57 PM
Why don't you just edit the template itself?

Well, that's basically because the plugin system is there and if possible, I'd prefer to use it - because I (and maybe others) can install and uninstall the whole thing as a product. I wonder if I can make changes to templates by product XML files? (As mentioned before, this probably is a dump question but I'm not yet into this plugin system...)

Editing the template should not be a problem at all, but isn't there a "nicer" way so that my addon/plugin/package/product (however these things are called) can be packed into a single XML file?

Thanks for your answer!

Boofo
12-21-2010, 04:07 PM
You can do str_replaces in templates via xml files. I do it all the time. It's a little trickier to do on vb 4 than it was on vb 3, though, when there are raw phrases and variables included. Plus, if you are going to add your own variables, they need to be pre-registered for whatever template you are going to use them in. There are some good articles on that, too.

aileron79
12-22-2010, 09:55 AM
Thanks heaps, mate!