Language: 
To browser these website, it's necessary to store cookies on your computer.
The cookies contain no personal information, they are required for program control.
  the storage of cookies while browsing this website, on Login and Register.

User

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

Community



Stats

  • *Total Members: 4442
  • *Latest: Argon2

  • *Total Posts: 16406
  • *Total Topics: 2506
  • *Online Today: 14
  • *Most Online: 292
(12.11.16, 09:37:31)
  • *Users: 0
  • *Guests: 0
  • *Spiders: 4
  • *Total: 4

  • *Google
  • *Baidu (3)

Author Topic: Limit Viewable Member Lists And Stats To Own Group Only  (Read 14289 times)

0 Members and 0 Guests are viewing this topic.

Offline ahrasis

  • Full Member
  • ***
  • Posts: 134
  • Gender: Male
  • Peace2u
    • ahrasis
 wish for a user in a membergroup is limited to seeing only his group members in memberlist. And if possible in the stats as well.

My idea is to modify either source (which I am afraid to do  ;) ) or template files for both memberlist and stats (which templates are they in?)

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5786
  • Gender: Female
Re: Limit Viewable Member Lists And Stats To Own Group Only
« Reply #1 on: 30.12.12, 14:48:38 »
Well .. you can filter out the membergroups by
Code: [Select]
array_intersect($user_info['groups'], $modSettings['subforums'][$_SERVER['SERVER_NAME']]['groups'])as example ...
for more I must look at the code before I can say more.
Many are stubborn in relation to the path, a few in relation to the target.

Offline ahrasis

  • Full Member
  • ***
  • Posts: 134
  • Gender: Male
  • Peace2u
    • ahrasis
Re: Limit Viewable Member Lists And Stats To Own Group Only
« Reply #2 on: 01.01.13, 18:17:59 »
As I checked, the source for memberlist is in Memberlist.php and its template is in Memberlist.template.php but Groups.php as well as ManageMembergroup.template.php could be relevant as well.

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5786
  • Gender: Female
Re: Limit Viewable Member Lists And Stats To Own Group Only
« Reply #3 on: 02.01.13, 17:25:32 »
For the memberlist you can try follow modification you have to make on Memberlist.php

find ~line 371:
Code: [Select]
// Select the members from the database.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member
FROM {db_prefix}members AS mem' . ($_REQUEST['sort'] === 'is_online' ? '

replace with:
Code: [Select]
// Select the members from the database.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.id_group, mem.id_post_group, mem.additional_groups
FROM {db_prefix}members AS mem' . ($_REQUEST['sort'] === 'is_online' ? '

find ~line 510:
Code: [Select]
// Find the members from the database.
// !!!SLOW This query is slow.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member
FROM {db_prefix}members AS mem

replace with:
Code: [Select]
// Find the members from the database.
// !!!SLOW This query is slow.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.id_group, mem.id_post_group, mem.additional_groups
FROM {db_prefix}members AS mem

find ~line 573:
Code: [Select]
$members = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$members[] = $row['id_member'];

replace with:
Code: [Select]
$members = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if(isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]))
{
if(array_intersect(array_merge(array($row['id_group'], $row['id_post_group']), explode(',', $row['additional_groups'])), array_merge(array(1), $modSettings['subforums'][$_SERVER['SERVER_NAME']]['groups'])) != array())
$members[] = $row['id_member'];
}
else
$members[] = $row['id_member'];
}

Now the memberlist show only user they have access to the current subforum.

For the Stats I don't have a solution currently ...
Many are stubborn in relation to the path, a few in relation to the target.

Offline feline

  • CO PortaMx corp.
  • Administrator
  • *
  • Posts: 5786
  • Gender: Female
Re: Limit Viewable Member Lists And Stats To Own Group Only
« Reply #4 on: 04.01.13, 10:50:22 »
Here now the changes for the stats (Sources/Stats.php)

find ~line 230:
Code: [Select]
// Poster top 10.
// SubForums
if(isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]))
$members_result = $smcFunc['db_query']('', '
SELECT m.id_member, u.real_name, COUNT(m.id_msg) AS posts
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}members AS u ON (u.id_member = m.id_member)
WHERE posts > 0{subforums_see_board:m-id_board}
GROUP BY m.id_member, u.real_name
ORDER BY posts DESC
LIMIT 10',
array('guest' => 'Guest')
);

replace with:
Code: [Select]
// Poster top 10.
// SubForums
if(isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]))
$members_result = $smcFunc['db_query']('', '
SELECT m.id_member, u.real_name, COUNT(m.id_msg) AS posts, u.id_group, u.id_post_group, u.additional_groups
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}members AS u ON (u.id_member = m.id_member)
WHERE posts > 0{subforums_see_board:m-id_board}
GROUP BY m.id_member, u.real_name
ORDER BY posts DESC
LIMIT 10',
array('guest' => $txt['guest_title'])
);

find ~line 255:
Code: [Select]
$context['top_posters'] = array();
$max_num_posts = 1;
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
$context['top_posters'][] = array(
'name' => $row_members['real_name'],
'id' => $row_members['id_member'],
'num_posts' => $row_members['posts'],
'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
);

if ($max_num_posts < $row_members['posts'])
$max_num_posts = $row_members['posts'];
}

replace with:
Code: [Select]
$context['top_posters'] = array();
$max_num_posts = 1;
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
if(isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]))
{
if(array_intersect(array_merge(array($row_members['id_group'], $row_members['id_post_group']), explode(',', $row_members['additional_groups'])), array_merge(array(1), $modSettings['subforums'][$_SERVER['SERVER_NAME']]['groups'])) == array())
continue;
}

$context['top_posters'][] = array(
'name' => $row_members['real_name'],
'id' => $row_members['id_member'],
'num_posts' => $row_members['posts'],
'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
);

if ($max_num_posts < $row_members['posts'])
$max_num_posts = $row_members['posts'];
}

find ~line 493:
Code: [Select]
// Topic poster top 10.
$members_result = $smcFunc['db_query']('top_topic_starters', '
SELECT id_member, real_name
FROM {db_prefix}members
WHERE id_member IN ({array_int:member_list})
ORDER BY FIND_IN_SET(id_member, {string:top_topic_posters})
LIMIT 10',
array(
'member_list' => array_keys($members),
'top_topic_posters' => implode(',', array_keys($members)),
)
);
$context['top_starters'] = array();
$max_num_topics = 1;
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
$context['top_starters'][] = array(
'name' => $row_members['real_name'],
'id' => $row_members['id_member'],
'num_topics' => $members[$row_members['id_member']],
'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
);

replace with:
Code: [Select]
// Topic poster top 10.
$members_result = $smcFunc['db_query']('top_topic_starters', '
SELECT id_member, real_name, id_group, id_post_group, additional_groups
FROM {db_prefix}members
WHERE id_member IN ({array_int:member_list})
ORDER BY FIND_IN_SET(id_member, {string:top_topic_posters})
LIMIT 10',
array(
'member_list' => array_keys($members),
'top_topic_posters' => implode(',', array_keys($members)),
)
);
$context['top_starters'] = array();
$max_num_topics = 1;
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
if(isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]))
{
if(array_intersect(array_merge(array($row_members['id_group'], $row_members['id_post_group']), explode(',', $row_members['additional_groups'])), array_merge(array(1), $modSettings['subforums'][$_SERVER['SERVER_NAME']]['groups'])) == array())
continue;
}

$context['top_starters'][] = array(
'name' => $row_members['real_name'],
'id' => $row_members['id_member'],
'num_topics' => $members[$row_members['id_member']],
'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
);

find ~ line 534:
Code: [Select]
// Time online top 10.
$temp = cache_get_data('stats_total_time_members', 600);
$members_result = $smcFunc['db_query']('', '
SELECT id_member, real_name, total_time_logged_in
FROM {db_prefix}members' . (!empty($temp) ? '
WHERE id_member IN ({array_int:member_list_cached})' : '') . '
ORDER BY total_time_logged_in DESC
LIMIT 20',
array(
'member_list_cached' => $temp,
)
);
$context['top_time_online'] = array();
$temp2 = array();
$max_time_online = 1;
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
$temp2[] = (int) $row_members['id_member'];
if (count($context['top_time_online']) >= 10)
continue;

replace with:
Code: [Select]
// Time online top 10.
$temp = cache_get_data('stats_total_time_members', 600);
$members_result = $smcFunc['db_query']('', '
SELECT id_member, real_name, total_time_logged_in, id_group, id_post_group, additional_groups
FROM {db_prefix}members' . (!empty($temp) ? '
WHERE id_member IN ({array_int:member_list_cached})' : '') . '
ORDER BY total_time_logged_in DESC
LIMIT 20',
array(
'member_list_cached' => $temp,
)
);
$context['top_time_online'] = array();
$temp2 = array();
$max_time_online = 1;
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
if(isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]))
{
if(array_intersect(array_merge(array($row_members['id_group'], $row_members['id_post_group']), explode(',', $row_members['additional_groups'])), array_merge(array(1), $modSettings['subforums'][$_SERVER['SERVER_NAME']]['groups'])) == array())
continue;
}

$temp2[] = (int) $row_members['id_member'];
if (count($context['top_time_online']) >= 10)
continue;

Now the Stats shows only members the have access to the subforum...
Many are stubborn in relation to the path, a few in relation to the target.

Offline ahrasis

  • Full Member
  • ***
  • Posts: 134
  • Gender: Male
  • Peace2u
    • ahrasis
Re: Limit Viewable Member Lists And Stats To Own Group Only
« Reply #5 on: 15.01.13, 16:12:59 »
Thank you very much feline. I am planning to test this when I have a better time. I will report the development in a week or two.

Offline ahrasis

  • Full Member
  • ***
  • Posts: 134
  • Gender: Male
  • Peace2u
    • ahrasis
Re: Limit Viewable Member Lists And Stats To Own Group Only
« Reply #6 on: 27.01.13, 07:33:54 »
I was about to reply to this soonest but I have something coming up. In short this is working but not as expected especially for memberlist. It shows a list of empty pages except to the one where there is member in it. My best guess is it is still calling all members but filter to show only subforum members. Thus, the pages where members are not shown is still there but blank page. I wanna provide samples (access) to this but I cant do it now. I will provide this later. I think the Stats are shown correctly but I'll have to do further test which I am unable to do until quite some times.

I am currently booked by my real work. I will be back back when I have freer time for this.

Offline ahrasis

  • Full Member
  • ***
  • Posts: 134
  • Gender: Male
  • Peace2u
    • ahrasis
Re: Limit Viewable Member Lists And Stats To Own Group Only
« Reply #7 on: 12.01.15, 06:53:46 »
For the memberlist you can try follow modification you have to make on Memberlist.php

Was checking this line by line while converting this for ElkArte. The issue was actually not globalizing $modSettings. My bad. Your code for memberlist is actually already perfect feline.

Offline ahrasis

  • Full Member
  • ***
  • Posts: 134
  • Gender: Male
  • Peace2u
    • ahrasis
Re: Limit Viewable Member Lists And Stats To Own Group Only
« Reply #8 on: 13.01.15, 05:15:48 »
Here now the changes for the stats (Sources/Stats.php)

I forgot to mention, since the Online Top 10 was not covered by the above code for stats, I made some additional modifications based on the above code.

Find:
Code: [Select]
// Time online top 10.
$temp = cache_get_data('stats_total_time_members', 600);
$members_result = $smcFunc['db_query']('', '
SELECT id_member, real_name, total_time_logged_in
FROM {db_prefix}members' . (!empty($temp) ? '
WHERE id_member IN ({array_int:member_list_cached})' : '') . '
ORDER BY total_time_logged_in DESC
LIMIT 20',
array(
'member_list_cached' => $temp,
)
);
$context['top_time_online'] = array();
$temp2 = array();
$max_time_online = 1;
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
Change to:
Code: [Select]
// Time online top 10.
$temp = cache_get_data('stats_total_time_members', 600);
$members_result = $smcFunc['db_query']('', '
SELECT id_member, real_name, total_time_logged_in, id_group, id_post_group, additional_groups
FROM {db_prefix}members' . (!empty($temp) ? '
WHERE id_member IN ({array_int:member_list_cached})' : '') . '
ORDER BY total_time_logged_in DESC
LIMIT 20',
array(
'member_list_cached' => $temp,
)
);
$context['top_time_online'] = array();
$temp2 = array();
$max_time_online = 1;
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
if(isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]))
{
if(array_intersect(array_merge(array($row_members['id_group'], $row_members['id_post_group']), explode(',', $row_members['additional_groups'])), array_merge(array(1), $modSettings['subforums'][$_SERVER['SERVER_NAME']]['groups'])) == array())
continue;
}

Now Online Top 10 will also limited to the respective subforum only.