News:

Wondering if this will always be free?  See why free is better.

Main Menu

Disable "Show Stats" in Profile

Started by Blade_Runner, January 20, 2011, 03:52:51 AM

Previous topic - Next topic

Blade_Runner

Is there a way to prevent viewing other member's stats? I am referring to the "Show Stats" under "view profile summary" for non-administrators and moderators.

Illori

'statistics' => array(
'label' => $txt['statPanel'],
'file' => 'Profile-View.php',
'function' => 'statPanel',
'permission' => array(
'own' => 'profile_view_own',
'any' => 'profile_view_any',
),


by default if you can view the profile you can view the stats per the code above, you would need to add a new permission and apply it to this function as well as the member groups then you can hide it from the users.

Blade_Runner

Quote from: Illori on January 20, 2011, 06:17:39 AM
'statistics' => array(
'label' => $txt['statPanel'],
'file' => 'Profile-View.php',
'function' => 'statPanel',
'permission' => array(
'own' => 'profile_view_own',
'any' => 'profile_view_any',
),


by default if you can view the profile you can view the stats per the code above, you would need to add a new permission and apply it to this function as well as the member groups then you can hide it from the users.

Thank you for your reply. I don't know any coding. How can I do what you have explained?

Illori

check the existing code in ManagePermissions.php [i think is the file name] in the Sources folder. copy one permission edit it to have a new name/function. then edit the above code. you will also have to add the new txt properties to the language files. somewhat similar to http://www.simplemachines.org/community/index.php?topic=410758.msg2863078;topicseen#msg2863078


Matthew K.

Sure, but the action itself will still be available...what Illori suggested is quite simple.
Quote from: Blade_Runner on January 20, 2011, 12:28:34 PM
Isn't there a simpler way? Like just removing the "Show Stats" link from the menu?

Blade_Runner

Quote from: Labradoodle-360 on January 20, 2011, 12:29:47 PM
Sure, but the action itself will still be available...what Illori suggested is quite simple.
Quote from: Blade_Runner on January 20, 2011, 12:28:34 PM
Isn't there a simpler way? Like just removing the "Show Stats" link from the menu?

It might be easy for both of you. I do not know how to write codes. I just know editing or deleting with instructions.   :(

Illori

if you can wait a few hours, when I get off work I can write up exact instructions like in the post I linked for what changes are needed. You will still need to apply the changes yourself though.

Blade_Runner

Quote from: Illori on January 20, 2011, 12:45:30 PM
if you can wait a few hours, when I get off work I can write up exact instructions like in the post I linked for what changes are needed. You will still need to apply the changes yourself though.

I can make the changes with instructions. Thank you for your support. Greatly appreciate. I am still young, I can wait.  ;D Do it when you are free.

Illori

Please backup the files that need changes before doing them. there will be no message if a user attempts to access the stats page unsuccessfully, they will just see the profile summary page.

Sources/Profile.php

Code (find) Select

'statistics' => array(
'label' => $txt['statPanel'],
'file' => 'Profile-View.php',
'function' => 'statPanel',
'permission' => array(
'own' => 'profile_view_own',
'any' => 'profile_view_any',
),

Code (replace) Select
'statistics' => array(
'label' => $txt['statPanel'],
'file' => 'Profile-View.php',
'function' => 'statPanel',
'permission' => array(
'own' => 'profile_view_stats_own',
'any' => 'profile_view_stats_any',
),


Sources/ManagePermissions.php
Code (find) Select

'profile_view_own',
x2
Code (add after) Select

'profile_view_stats_own',


Code (find) Select

'profile_view_any',


Code (add after) Select
'profile_view_stats_any',

Code (find) Select

'profile_view' => array(true, 'profile', 'view_basic_info', 'view_basic_info'),

Code (add after) Select

'profile_view_stats' => array(true, 'profile', 'view_basic_info', 'view_basic_info'),


Themes/default/languages/ManagePermissions.english.php

Code (find) Select

$txt['permissiongroup_profile'] = 'Member Profiles';
$txt['permissionname_profile_view'] = 'View profile summary and stats';
$txt['permissionhelp_profile_view'] = 'This permission allows users clicking on a username to see a summary of profile settings, some statistics and all posts of the user.';
$txt['permissionname_profile_view_own'] = 'Own profile';
$txt['permissionname_profile_view_any'] = 'Any profile';


Code (replace with) Select

$txt['permissiongroup_profile'] = 'Member Profiles';
$txt['permissionname_profile_view'] = 'View profile summary';
$txt['permissionhelp_profile_view'] = 'This permission allows users clicking on a username to see a summary of profile settings, some statistics and all posts of the user.';
$txt['permissionname_profile_view_own'] = 'Own profile';
$txt['permissionname_profile_view_any'] = 'Any profile';
$txt['permissionname_profile_view_stats'] = 'View profile stats';
$txt['permissionname_profile_view_stats_own'] = 'Own profile';
$txt['permissionname_profile_view_stats_any'] = 'Any profile';


Blade_Runner

Thank you for your mod. Other than the menu terms, it's working perfectly.
The menu shows both permission as "View profile stats".

It's like the following.
--------------------------
View their own profile   
View other people's profiles   
View profile stats   
View profile stats
--------------------------

It should be
--------------------------
View their own profile   
View other people's profiles   
View their own profile stats   
View other people's profile stats
--------------------------

Illori

it should have it correct

$txt['permissionname_profile_view_stats_own'] = 'Own profile';
$txt['permissionname_profile_view_stats_any'] = 'Any profile';
controls that part. it looked ok from what i can recall when i tested it.

unless that text is found elsewhere.

Blade_Runner

OK, I found out the problem. Your mod is only display correctly in the "Change View: classic" mode. I am using "Change View: Simple".

I manage to fix this problem by adding the following codes.

Look for
$txt['permissionname_simple_profile_view_any'] = 'View other people\'s profiles';

Add after
$txt['permissionname_simple_profile_view_stats_own'] = 'View their Own profile stats';
$txt['permissionname_simple_profile_view_stats_any'] = 'View their Any profile stats';


It is working perfectly now. Thanks for the help!

Illori


Advertisement: