Jump to content

Forum Children List


Dima Turchenko

Recommended Posts

Posted

Hello! For example I want to get list all children forums in forum with certain ID or Name,

but find out that all methods tied to member! current logging or that u pass in method :(

So to find out children of some forum i need do this by myself? there is no available api for this out of box

In short, my goal is - get some forum1 by ID or Name,

get all children forums in forum1, get all groups by every children forum where they have permission at least "read", and finally get all users of that groups

And like I sad before I cant use built in methods in Forum model...

Any advice would be appreciated

Thanks!

Posted

There is a small language barrier, so please accept my apologies if I didn't fully understand you. I believe you want to find all users in all groups that have read permission for children forums of forum X.

You can load a forum like so

try
{
	$forum = \IPS\forums\Forum::load( $id );
}
catch( \OutOfRangeException $e )
{
	/* Probably do something nicer here - show an error screen or something, depending on what you are doing exactly */
	die( 'forum does not exist' );
}

To get the children of this forum you can do this

$children = $forum->children();

Now, probably what I would recommend doing is the following roughly

$groupsWithAccess = array();

foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) as $group )
{
	foreach( $forum->children( NULL ) as $childForum )
	{
		if( $childForum->can( 'read', $group ) )
		{
			$groupsWithAccess[]	= $group;
			break;
		}
	}
}

 

This is untested just to give you an idea, but you can loop over all groups, then inside that loop, loop over all children forums of the parent (pass NULL to children() so all child forums are returned regardless of the current logged in user's permissions), then verify if the group can read the forum (you can pass an instance of \IPS\Member\Group to the can() method, instead of an instance of \IPS\Member). Put the group into an array.

Afterwards you could loop over that array to select all members in those groups...just be careful in case you get 50,000 members in the groups that are returned.

Posted

Many thanks! This is exactly what I need to! But I cant find any methods to get all users per group :(

ActiveRecord class dont has such method, \IPS\Db  - too, it just extends mysqli class.

What I found - class IPS\Helpers\Table\Db, that class uses to show up a members list, but I guess this is not what i need

BTW: condition for searching users per group need to contain "member_group_id OR FIND_IN_SET(?, mgroup_others)" - will be

enough? cause I saw using of table "core_admin_permission_rows" in ACP member list and I dont know what it for...

And sorry for my far from perfect english :)

Posted

Yes, you'll just need to query them directly using the WHERE clause you indicated. core_admin_permission_rows is used to determine if the user is an administrator or not - you shouldn't really need to worry about that based on what you are describing here.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...