MyBB Community Forums

Full Version: [Help Request] Permissions-Based User Images
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm hoping to find some help/advice on how to attach user images to permissions. On another software, our staff are represented by different badges:

[Image: admin.gif] [Image: mod.gif] [Image: staff.gif] [Image: vip.gif]

These badges are not based on usergroups, but rather on permissions. For example, when a staff member has moderator rights in a particular forum, her username looks like this:

[Image: mod.png]

However, in forums where the user has no moderator permissions, her username appears as follows:

[Image: staff.png]

In our current software, we have added the following code to the postbit template (abridged for space, but conveys the general idea):

<if condition="can_moderate($forum[forumid], '', $post[userid]) AND !($post[usergroupid]==6 )"><div class="smallfont"><img src ="mod.gif">&nbsp;<a class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a></div><else />
<if condition="($post[usergroupid]==11 OR IS_MEMBER_OF($post, 11))"><div class="smallfont"><img src ="staff.gif">&nbsp;<a class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a></div><else />
<div class="smallfont"><a class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a></div>
</if></if></if>
				<script type="text/javascript"> vbmenu_register("postmenu_$post[postid]", true); </script>
				<else />
				$post[musername]
				</if>
			</div>

What is the best way to achieve the same effect in MyBB? A techi friend suggested something like this to inc->functions_post.php:

if(!empty($usergroup['image']))
	{
		if(!empty($mybb->user['language']))
		{
			$language = $mybb->user['language'];
		}
		else
		{
			$language = $mybb->settings['bblanguage'];
		}
		$usergroup['image'] = str_replace("{lang}", $language, $usergroup['image']);
		$usergroup['image'] = str_replace("{theme}", $theme['imgdir'], $usergroup['image']);
		eval("\$post['groupimage'] = \"".$templates->get("postbit_groupimage")."\";");
		if($mybb->settings['postlayout'] == "classic")
		{
			$post['groupimage'] .= "<br />";
		}
	}

Followed by something like this:

if(!empty($usergroup['image']))
	{
		if(!empty($mybb->user['language']))
		{
			$language = $mybb->user['language'];
		}
		else
		{
			$language = $mybb->settings['bblanguage'];
		}
		if(is_moderator($fid, "canmanagethreads") = "yes") 
		{ 
		$usergroup['image'] = 'location of mod badge'; 
		} 
		else
		{
		$usergroup['image'] = str_replace("{lang}", $language, $usergroup['image']);
		$usergroup['image'] = str_replace("{theme}", $theme['imgdir'], $usergroup['image']);
		}
		eval("\$post['groupimage'] = \"".$templates->get("postbit_groupimage")."\";");
		if($mybb->settings['postlayout'] == "classic")
		{
			$post['groupimage'] .= "<br />";
		}
	} 

Thoughts? I'm not a techy, but I'll do my best to keep up. Smile
Bah-uhmph. I know you techi gods are out there. Big Grin
I guess, you can achieve such with Template Conditionals plugin: http://community.mybb.com/thread-31860.html
This would make a good plugin.
I'd pay for a plugin like this.

/hint

:p
I'd be willing to make it if it's paid, but you could do it with the template conditionals.
Thank you! Yaldaram and I are negotiating on the price of a custom plugin, but if this falls through or the plugin fails, I'll shoot you a PM. Big Grin