MyBB Community Forums

Full Version: Additional Groups on showteam.php page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello.

I have read a lot about peoples who had the same problem and want the feature.
All the threads are over 3-4 years old, and the threads didnt help me out.

I want the additional groups to appear on the showteam.php too, so it's not just the display group.
Uhm, can't you just make sure "Yes, show this group on the 'forum team' page" is checked when you're editing the usergroup? Or is your question targeting something else?
I have one SA at my community, but he should also be an Web Dev.
So I need to add him on the two groups, so he is SA and Web Dev on the showteam.php
I had the same problem, and reported it. But it was not accepted as a bug that someone can be member of more then one forumteam groups but is displayed in only one, his default or display group (don't ask me why, that's MyBB logic I think).

I wrote a plugin (more or less a replacement for forumteam.php) for 1.8. I will see whether it works for 1.6.

OK, I tested it for 1.6 and as far I can see now it works also for 1.6. Just try it:


<?php
/**
 * Disallow direct access to this file for security reasons 
 * 
 */
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("showteam_start", "showteam_extended");
/**
 * Standard MyBB info function
 * 
 */
function showteam_extended_info()
{
    global $lang;
    return Array(
        'name'          => "showteam_extended",
        'description'   => "extended forum team list where one member can be in several teams",
        'website'       => '',
        'author'        => 'Ad Bakker',
        'authorsite'    => '',
        'version'       => '1.0',
        'guid'          => '',
        'compatibility' => '16*',
    );
}

function showteam_extended()
{
	define("IN_MYBB", 1);
	define('THIS_SCRIPT', 'showteam_extended.php');

	global $lang, $db, $mybb, $templates, $templatelist, $plugins, $headerinclude, $header, $footer, $theme;
	require_once "./global.php";
	require_once "./inc/functions.php";
	$timecut = TIME_NOW - $mybb->settings['wolcutoff'];
	$usergroups = array();
	$moderators = array();
	$users = array();
	
	// Fetch the list of groups which are to be shown on the page
	$mygroup = $mybb->user['usergroup'];
//	$query = $db->simple_select("usergroups", "gid, title, usertitle, showforumteam, cansendemail", "showforumteam=1 OR gid={$mygroup}", array('order_by' => 'disporder'));
	$query = $db->simple_select("usergroups", "gid, title, usertitle, showforumteam, cansendemail, showforumteam", "1=1", array('order_by' => 'disporder'));

	while($usergroup = $db->fetch_array($query))
	{
		if ($usergroup['gid'] == $mygroup) $Icansendemail = $usergroup['cansendemail'];
		if ($usergroup['showforumteam'] != 1) continue;
		$usergroups[$usergroup['gid']] = $usergroup;
	}
	
	if(empty($usergroups))
	{
		error($lang->error_noteamstoshow);
	}
	
	// Fetch specific forum moderator details
	if($usergroups[6]['gid'])
	{
		$query = $db->query("
			SELECT m.*, f.name
			FROM ".TABLE_PREFIX."moderators m
			LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=m.id)
			LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=m.fid)
			WHERE f.active = 1 AND m.isgroup = 0
			ORDER BY u.username
		");
		while($moderator = $db->fetch_array($query))
		{
			$moderators[$moderator['id']][] = $moderator;
		}
	}
	$groups_in = implode(",", array_keys($usergroups));
	$users_in = implode(",", array_keys($moderators));
	if(!$groups_in)
	{
		$groups_in = 0;
	}
	if(!$users_in)
	{
		$users_in = 0;
	}
	$forum_permissions = forum_permissions();
	$where = "uid IN ($users_in) OR usergroup IN ($groups_in)";
	if ($groups_in != 0)
	{
		$groups = explode(',',$groups_in);
		foreach ($groups as $group)
		{
			$where .= " OR {$group} IN (additionalgroups)";
		}
	}
	$query = $db->simple_select("users", "uid, username, displaygroup, usergroup, additionalgroups, usertitle, ignorelist, email, hideemail, receivepms, lastactive, lastvisit, invisible", $where, array('order_by' => 'username'));
	while($user = $db->fetch_array($query))
	{
		// If this user is a moderator
		if(isset($moderators[$user['uid']]))
		{
			foreach($moderators[$user['uid']] as $forum)
			{
				if($forum_permissions[$forum['fid']]['canview'] == 1)
				{
					$forum_url = get_forum_link($forum['fid']);
					eval("\$forumlist .= \"".$templates->get("showteam_moderators_forum")."\";");
				}
				else
				{
					$forumlist .= $lang->forum_hidden."<br /";
				}
			}
			$user['forumlist'] = $forumlist; 
			$forumlist = '';
			
			$usergroups[6]['user_list'][$user['uid']] = $user;
		}
		// Is this user also in other group(s) which is being shown on the list?
		$groups = array();
		if ($user['usergroup'] !=6)
		{
			$groups[] = $user['usergroup'];
		}
		if ($user['additionalgroups'])
		{
			$groups = array_merge($groups,explode(',',$user['additionalgroups']));
		}
		foreach ($groups as $group)
		{
			if($group !=6 && $usergroups[$group])
			{
				$usergroups[$group]['user_list'][$user['uid']] = $user;
			}
		}
	}
	// Now we have all of our user details we can display them.
	$grouplist = '';
	foreach($usergroups as $usergroup)
	{
		if ($usergroup['showforumteam'] != 1) continue;
		$usergrouprows = $modrows = '';
		// If we have no users - don't show this group
		if(!isset($usergroup['user_list']))
		{
			continue;
		}
	
		$bgcolor = '';
		foreach($usergroup['user_list'] as $user)
		{
			$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
			$user['profilelink'] = get_profile_link($user['uid']);
	
			$emailcode = $pmcode = '';

			if($user['hideemail'] != 1 && $Icansendemail == 1)
			{
				eval("\$emailcode = \"".$templates->get("postbit_email")."\";");
			}
	
			if($user['receivepms'] != 0 && $mybb->settings['enablepms'] != 0 && my_strpos(",".$user['ignorelist'].",", ",".$mybb->user['uid'].",") === false)
			{
				eval("\$pmcode = \"".$templates->get("postbit_pm")."\";");
			}
	
			// For the online image
			if($user['lastactive'] > $timecut && ($user['invisible'] == 0 || $mybb->usergroup['canviewwolinvis'] == 1) && $user['lastvisit'] != $user['lastactive'])
			{
				$status = "online";
			}
			else
			{
				$status = "offline";
			}
	
			if($user['invisible'] == 1 && $mybb->usergroup['canviewwolinvis'] != 1 && $user['uid'] != $mybb->user['uid'])
			{
				if($user['lastactive'])
				{
					$user['lastvisit'] = $lang->lastvisit_hidden;
				}
				else
				{
					$user['lastvisit'] = $lang->lastvisit_never;
				}
			}
			else
			{
				$user['lastvisit'] = my_date('relative', $user['lastactive']);
			}
			
			if ($user['usertitle'])
			{
				$usertitle = $user['usertitle'];
			}
			else
			{
				if ($user['displaygroup'])
				{
					$displaygroup = usergroup_displaygroup($user['displaygroup']);
					$usertitle = $displaygroup['usertitle'];
				}
				else
				{
					$displaygroup = usergroup_displaygroup($user['usergroup']);
					$usertitle = $displaygroup['usertitle'];
				}
			}
			// Toevoeging voor usertitles in regels
			if ($user['username'] && $user['additionalgroups'])
			{
				$additionalgroups = explode(",",$user['additionalgroups']);
				foreach ($additionalgroups as $additionalgroup)
				{
					$displaygroup = usergroup_displaygroup($additionalgroup);
					if ($displaygroup['usertitle'] != "")
					{
						$usertitle .= ", ".$displaygroup['usertitle'];
					}
				}
			}
	// Einde toevoeging 
			// Einde toevoeging voor usertitles in regels

			$bgcolor = alt_trow();
			$plugins->run_hooks('showteam_user');
	
			// If the current group is a moderator group
			if($usergroup['gid'] == 6 && !empty($user['forumlist']))
			{
				$forumslist = $user['forumlist'];
				eval("\$modrows .= \"".$templates->get("showteam_moderators_mod")."\";");
			}
			else
			{
				eval("\$usergrouprows .= \"".$templates->get("showteam_usergroup_user")."\";");
			}
		}
	
		if($modrows && $usergroup['gid'] == 6)
		{
			eval("\$grouplist .= \"".$templates->get("showteam_moderators")."\";");
		}
	
		if($usergrouprows)
		{
			eval("\$grouplist .= \"".$templates->get("showteam_usergroup")."\";");
		}
	}
	
	if(empty($grouplist))
	{
		error($lang->error_noteamstoshow);
	}
	
//	$plugins->run_hooks("showteam_end");
	eval("\$showteam = \"".$templates->get("showteam")."\";");
	output_page($showteam);
	exit();
}
?>


Save this as e.g. forumteam_extended.php and copy it to your inc/plugins folder. Activate the plugin in AdminCP and try it out.
I suppose you mean you tested it for 1.8 Smile

Copied your code, saved as .php file and uploaded it to my plugins directory but it won't show up as a plugin so I can activate it.... Undecided

@"Avalanche1992", did you have better luck?
(2015-06-29, 09:06 PM)luiz.schmidt Wrote: [ -> ]I suppose you mean you tested it for 1.8 Smile

No, I tested it on my clean install of 1.6.17, and it worked. I just checked, and it is still activated. Did you save it as "showteam_extended.php"? I just see that I made a mistake in my message with the name.

[attachment=34530]

There is, however, again discussion about this in the bugs and issues forum, and it now looks that there will be an improvement. But for now the plugin should work.
Ok, renamed it and recognized now. However, says it's incompatible... it won't work with MyBB 1.8.4 (my version) then?
This is the 1.6 support forum, that's why I tested it on 1.6. But I made it for 1.8, so just change the 16* into 18* and it will work.