News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Membergroups - Listing members that have access to forum

Started by thegymforum, August 05, 2015, 06:08:33 PM

Previous topic - Next topic

thegymforum

Goal: I'd like to display to a forum's membership to the members.

Problem: in Display.template.php template_main() I don't know how to determine the category that I'm under, the forum name, and most importantly, the Membergroups that have access.

If I figure this out, I'll write up how I did it here... but maybe it's been done? or someone can give me a hint about my aforementioned issue?

thank you for your time.  Meanwhile, I'll keep studying code, print_r 'ing variables and googling...

margarett

You don't need that. When you edit the board, just choose whatever membergroups which should access it.
Groups not included will not have any access to the board or its topics. Just remember that permissions are INCLUSIVE, which means that any group that the member is part of automatically grants him the permissions to see the board and its contents...

So, unless I missed your idea (which is likely, given how late it is in Portugal :P ) you don't need any code for it...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Illori

Quote from: margarett on August 05, 2015, 07:56:13 PM
So, unless I missed your idea (which is likely, given how late it is in Portugal :P ) you don't need any code for it...

i believe the op wants a list of who can view x board on the board index. or in the board on the message index.

thegymforum

Quotebelieve the op wants a list of who can view x board on the board index. or in the board on the message index.
Correct.

It's so members can see which other members have access to a particular forum without having to maintain the lists manually which are prone to error or being out of date etc.

Thank you

margarett

Oh ok, got it ;)

SMF does that for you ;) Go to Core Features and enable "Reports" ;)
Of course, this is just for admins...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

thegymforum

Ty Margaret!  I'll look into that and look into extending it for non admins as well

XOXO :)

thegymforum

Thanks, while that's interesting information, I want to create a list that includes the name of each of the current members

Maybe a mysql statement pseudocode might help:

SELECT smf_members.id_member,  smf_members.member_name from smf_members
WHERE
(GROUP_NUM) in smf_members.additional_groups;

But I'd need the GROUP_NUMs that have access to each forum... 


User case would be like this.

My photography forum has visibility by membergroup Photography and that contains Jim, Mike and Ben.

So at the top of each forum, there'd be a LOCKED STICKIED post that I could put __MEMBERSHIP_LIST__ in, and when it was parsed, it would replace __MEMBERSHIP_LIST__ with

Members
Jim
Mike
Ben

I can write the code to extract Jim, Mike and Ben from the membergroup Photography, BUT, I need the membergroup id of the Photography
forum while I'm INSIDE that forum (I plan on doing this substitution in Display.template.php).  So, inside Display.template.php, I need the membergroups with access to the current forum...

Hope that's more clear and not making your head ache! :)

thegymforum

I figured out A solution

Instead of using __MEMBERSHIP_LIST__  I'll use MemberList(60, 71)

where 60 and 71 are the group numbers with access.  It's less automatic than I wanted, but boohoo, until I find a better solution, this will work fine.

thanks all that wasted brain cells trying to help

margarett

Well you'll need that in 3 queries:
1- get the membergroup IDs assigned to each board
2- get the membergroups details (not required but still)
3- get the members assigned to that membergroup and relate them to the board in question.

Getting the members, especially the additional membergroups will not be a cheap query so you might want to think carefully before making this showing off often. Of course cache does exist but still...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Gluz

It requires at least 1 and 3 from what margarett says, I have some trouble getting it work for those who have 2 or more additional membergroups, as they are stored as comma separated list string.

I think that the easy and not resource wasting way is to show only the membergroups that have access to some board, and in a separate page show the membergroups and after select one, load the members in it. It requires more input from the user that want to know but is not that bad with resources when the forum gets bigger.

margarett

Actually FIND_IN_SET should do it for you easily ;)
It's just not cheap (and it has to be repeated a lot to check all boards and all associated membergroups, etc)...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

thegymforum

Since I'm using a 1 to 1 membergroup for each forum, I'm able to use:

$sql = 'select member_name, gender, id_member, additional_groups from smf_members WHERE additional_groups REGEXP "(^|,)' . $memberGroup . '(,|$)" order by gender desc, member_name asc ';

Since I don't know how to derive #1
Quote1 get the membergroup IDs assigned to each board

I'm using _MemberList(39) for search and replace for the Memberlist data.. I have it formatted to it shows a gender color icon and a link to their forum profiles.

Now if I could only "derive" the membergroup number (39) in DisplayTemplate.php ... I'd be a happy camper.  But not tonight.. 2am, brain telling me to work on this more tomorrow.  thanks again!

PS I'll also run some speed tests on a FIND_IN_SET solution versus what I have above if that works, I'll report some stats if any care.


Gluz

@margarett
Oh, is good to know that function, I do some tricky nasty stuff instead of that  :P

@OP
You mention Display.template.php, so I guess that you're going to put the list of users in the post view, so there you have a variable called $board that have the id of the current board where the thread is placed.

With something like this you will have the membergroups that can see the board in the array $view_board:
$request = $smcFunc['db_query']('', '
SELECT member_groups
FROM {db_prefix}boards
WHERE id_board = {int:board}',
array(
'board' => $board,
)
);
$view_board = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
$view_board = explode(',',$view_board[0]);


Then fetch the member list of that boards and you are done.

Also, if you are going to put some SQL Query in the files, better in the source files and with the proper SMF function($smcFunc), it's easy to use and safe.

thegymforum

Gluz, very helpful indeed! High five!

Please note, all of my queries are done with the "proper SMF function". I just offered the shortest version of my explanation to try to save others time interpreting what it was supposed to do etc.

TY. And thanks all (mainly of course Margarett) that helped on this.  Love the memberlist posts as do my members.

Advertisement: