PDA

View Full Version : Fixing Who's Online Location permissions


Raakin
04-26-2014, 03:01 AM
Hi all,

There's a problem with the "Can View Detailed Location Info for Users" permission in vB 5. It allows the user to see the thread titles from private channels if set to Yes. There's a bug report for it here: http://tracker.vbulletin.com/browse/VBV-12542
But they say it can't be fixed and they are just going to add a warning in the help text for it.

Well, why don't we create a mod to get it fixed? In the onlineuser_details template, there's the following condition:
<vb:if condition="isset($user['location'])">
<div title="{vb:raw user.location}" class="wol-location h-right vb-icon vb-icon-question-blue"></div>
</vb:if>

If we add another condition along with this to check the channel id of the user's location, then we can easily prevent the thread titles from appearing.

My question is, how can I add this condition to check for the channel id?

Thanks

Lynne
04-26-2014, 04:17 PM
The condition you are listing is only for the little "?" on the page, not for the thread title.

Anyway, if you do a vardump of the $user[wol] array ( {vb:debugvardump $user[wol]} ), you'll see it doesn't have the channelid included (nor does the $user array itself). So, I'm not sure you can do it by channelid.

Raakin
04-26-2014, 06:24 PM
Is there any other way to solve this issue?

Where does the $user[wol] array get the user's location from? I mean, where is the source code for it? Maybe we can update the code there itself and supply this array with the channel name instead of the thread title whenever the user is inside a private channel.

Lynne
04-26-2014, 09:10 PM
The page gets the actual path from the session table. A channelid isn't stored there - only the actual path.

The template is rendered in the /core/vb/api/wol.php file.

Dead Eddie
04-26-2014, 09:29 PM
Just quickly looking at it, the Who's Online API gets a "page key" parameter.

On conversations, it's set with the following parameters:


$this->setPageKey('pageid', 'channelid', 'nodeid');


You could probably use that to alter what's saved to the database.

Raakin
04-27-2014, 02:47 AM
Thank you for the replies. Where does the location gets written to the session table? I tried to look for it but couldn't find it.

Dumping user[pagekey] on the /online returns NULL. Will it be safe to modify it in the conversations? I think wol checks the pagekey for differentiating between online users of the same page and the online user on the whole forum.

--------------- Added 1398571797 at 1398571797 ---------------

Added this in conversations but it doesn't seem to work. The nodeid still gets recorded in the session table.
if ('channelid' != 42) // 42 is channel id for the private forum
{
$this->setPageKey('pageid', 'channelid', 'nodeid');
}
else
{
$this->setPageKey('pageid', 'channelid', '');
}

Dead Eddie
04-27-2014, 03:31 AM
Huh. Suppose you could possibly do something there, too. Not sure, and I don't have the code in front of me.

I was in api/wol.php::register(). That's where it's written to the database.

You don't want to change the page key that's generated...but rather change the session information being persisted in the database.

Raakin
04-27-2014, 03:55 PM
There can be an easier of doing this. How can I search for a substring inside the $user['location'] string?

--------------- Added 1398625222 at 1398625222 ---------------

Finally got it working!

Replaced the following code in onlineuser_details template:
{vb:set userAction, {vb:raw user.wol.action}}
{vb:rawphrase {vb:raw userAction}, {vb:raw user.wol.params}}
<vb:if condition="isset($user['location'])">
<div title="{vb:raw user.location}" class="wol-location h-right vb-icon vb-icon-question-blue"></div>
</vb:if>


with:

{vb:set test, {vb:php substr, {vb:raw user.location}, 7, 15}}
{vb:set userAction, {vb:raw user.wol.action}}
<vb:if condition="$test != 'private-forums/'">
{vb:rawphrase {vb:raw userAction}, {vb:raw user.wol.params}}
<vb:if condition="isset($user['location'])">
<div title="{vb:raw user.location}" class="wol-location h-right vb-icon vb-icon-question-blue"></div>
</vb:if>
<vb:else />
Viewing Private Forum
</vb:if>


Now it says Viewing Private Forum for anyone who is viewing a thread inside the private forums.

Raakin
05-01-2014, 02:21 AM
There's a mistake in the above code. {vb:raw user.location} cannot be accessed by all users, so I had to replace it with {vb:raw user.wol.params.1} and the number 7 will also be replaced based on the length of the string from the beginning until the category name.