multiple functions in forumteam
#18
(2015-06-15, 04:39 PM)luiz.schmidt Wrote: Hi, this is exactly what I'm looking for. could you share your plugin? thanks!

Copy the source below and save it as "forumteam_extended.php". Copy that files to your /inc/plugins directory.

In your AdminCP go to plugins and activate it.

I think this must work, I removed some specific things for my forum, so now it is suitable for a normal MyBB 1805 install.

<?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' => '18*',
    );
}

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

	global $lang, $db, $mybb, $templates, $templatelist, $plugins, $headerinclude, $header, $footer, $theme;
	$templatelist = 	'showteam_moderators_forum,postbit_email,postbit_pm,showteam_moderators_mod,showteam_usergroup_user,showteam_moderators,showteam_usergroup,showteam';
	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=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, skype, google", $where, array('order_by' => 'username'));
	while($user = $db->fetch_array($query))
	{
		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;
		}

		$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;
			}
		}
	}

	$grouplist = '';
	foreach($usergroups as $usergroup)
	{
		if ($usergroup['showforumteam'] != 1) continue;
		$usergrouprows = $modrows = '';

		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")."\";");
			}
	
			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'];
				}
			}

			if ($user['username'] && $user['additionalgroups'])
			{
				$additionalgroups = explode(",",$user['additionalgroups']);
				foreach ($additionalgroups as $additionalgroup)
				{
					$displaygroup = usergroup_displaygroup($additionalgroup);
					if ($displaygroup['usertitle'] != "")
					{
						$usertitle .= ", ".$displaygroup['usertitle'];
					}
				}
			}

			$bgcolor = alt_trow();
			$plugins->run_hooks('showteam_user');
	
			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);
	}
	
	eval("\$showteam = \"".$templates->get("showteam")."\";");
	output_page($showteam);
	exit();
}
?>

Success!!
Regards, Ad Bakker (NL)
Reply


Messages In This Thread
multiple functions in forumteam - by Ad Bakker - 2015-01-21, 07:04 PM
RE: multiple functions in forumteam - by The_Dark - 2015-01-21, 09:49 PM
RE: multiple functions in forumteam - by Ad Bakker - 2015-06-16, 05:36 PM
RE: multiple functions in forumteam - by Leefish - 2015-01-23, 01:26 PM
RE: multiple functions in forumteam - by Leefish - 2015-01-25, 01:41 PM
RE: multiple functions in forumteam - by Leefish - 2015-01-25, 04:18 PM
RE: multiple functions in forumteam - by Leefish - 2015-01-25, 05:47 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)