vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB5 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=263)
-   -   Fixing Who's Online Location permissions (https://vborg.vbsupport.ru/showthread.php?t=310810)

Raakin 04-26-2014 03:01 AM

Fixing Who's Online Location permissions
 
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:
Code:

<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:

PHP Code:

$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 [DATE]1398571797[/DATE] at [TIME]1398571797[/TIME] ---------------

Added this in conversations but it doesn't seem to work. The nodeid still gets recorded in the session table.
Code:

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 [DATE]1398625222[/DATE] at [TIME]1398625222[/TIME] ---------------

Finally got it working!

Replaced the following code in onlineuser_details template:
Code:

                {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:
Code:

{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.


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

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.01039 seconds
  • Memory Usage 1,738KB
  • 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_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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