PDA

View Full Version : If moderator of forum, etc etc


CoffeeLovesYou
02-14-2013, 11:12 PM
Hello,
I have a quick question about an if conditional.
I know a forum that has moderators of individual categories. Here's an example.
There's a Music category, and a Television category. Jimmy is a moderator of the Music category, so when he posts in the Music category, his name shows up in a Green color (or any color). Now, there's Bob, who is a moderator of the Television category. When he posts in the Television category, his name also shows up Green (or any other color). Now, if Bob posts in the Music Area, or vice-versa, their name will not show up green because they aren't a moderator of that particular forum.

I am trying this code;
<if condition="can_moderate($forum['forumid'])">
stuff here
</if>
However, what is happening is.. every person is getting the "stuff here" part! I don't think the can_moderate condition is working. I am trying to use it in my postbit template. There are users who aren't a moderator of the current forum they posted in, and it shows the code i put in the if conditional in their post.

glennybee
02-15-2013, 05:37 PM
Try this...


<if condition="can_moderate($foruminfo['forumid'] !== X)">
stuff here
</if>

CoffeeLovesYou
02-16-2013, 02:48 AM
Well, here is the thing. It is much much easier to use an if conditional where I don't have to enter each forum ID. We have over 25 diff forums where there are diff users as moderators of that forum, henceforth that would be a really long code where it is possible to use the if condition I am seeking. But thank you though. If no one can tell me if my if condition is correct and/or why it isn't working in the postbit template, I'll try to use yours.

Max Taxable
02-16-2013, 03:01 AM
Have you tried "is_moderator?"

Everyone can moderate - their own posts. But not everyone is a moderator.

Perhaps, "is_usergroupID?"

Digital Jedi
02-16-2013, 05:53 AM
Hello,
I have a quick question about an if conditional.
I know a forum that has moderators of individual categories. Here's an example.
There's a Music category, and a Television category. Jimmy is a moderator of the Music category, so when he posts in the Music category, his name shows up in a Green color (or any color). Now, there's Bob, who is a moderator of the Television category. When he posts in the Television category, his name also shows up Green (or any other color). Now, if Bob posts in the Music Area, or vice-versa, their name will not show up green because they aren't a moderator of that particular forum.

I am trying this code;
<if condition="can_moderate($forum['forumid'])">
stuff here
</if>
However, what is happening is.. every person is getting the "stuff here" part! I don't think the can_moderate condition is working. I am trying to use it in my postbit template. There are users who aren't a moderator of the current forum they posted in, and it shows the code i put in the if conditional in their post.
This isn't working the way you want because can_moderate displays the information to the person with moderator permissions. You only use this when you want the moderators of that forum to see something you don't want others to see. I don't believe there is an is_moderator conditional or equivalent. The only way I can think to really do this would be to use a combination of user ID and forum ID.

CoffeeLovesYou
02-16-2013, 12:41 PM
--------------- Added 1361049497 at 1361049497 ---------------

Okay, I kind of figured out why.
My if condition was saying that, if the user moderated the forum and the user is apart of the usergroup IDs I specified, they could see the code. I needed it so if the user moderated the current forum and the user who moderates that forum is a member of the usergroup ID I specified, then they get the code shown in their post and is visible to everyone else.

My friend helped me get to this code;

<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid]) AND is_member_of($userinfo, 7,47)">
<div class="smallfont"><b><big>{$GLOBALS['foruminfo']['title']}Leader</big></b></div></if> <else />
<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid]) AND is_member_of($userinfo, 5,55)">
<div class="smallfont"><b><big>{$GLOBALS['foruminfo']['title']} Moderator</big></b></div>
</if>


But it isn't working for me, yet it's working for him..

Digital Jedi
02-17-2013, 01:19 AM
Well, thanks to the help with someone who also has experience with this, this is working;

<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid])">
Code
</if>

However, I am trying to combine this code with 1 more if condition, and 2 more.

<if condition="$thread['postuserid'] == $post['userid']"><div class="smallfont"><b><big>Original Poster</big></b></div><else />
<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid]) AND $thread['postuserid'] == $post['userid'] AND is_member_of($bbuserinfo, 7,47)">
<div class="smallfont"><b><big>$GLOBALS[foruminfo][title] Leader & Original Poster</big></b></div><else />
<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid]) AND $thread['postuserid'] == $post['userid']">
<div class="smallfont"><b><big>$GLOBALS[foruminfo][title] Moderator & Original Poster</big></b></div>
</if></if></if>

^^ Does anyone see what is wrong with this?
When I just had..
<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid])">
Code
</if>
..it was working. Now that I combined it with the if original poster and if member of, it isn't working. Same with the other if condition, now that I combined it with original poster.

--------------- Added 1361049497 at 1361049497 ---------------

Okay, I kind of figured out why.
My if condition was saying that, if the user moderated the forum and the user is apart of the usergroup IDs I specified, they could see the code. I needed it so if the user moderated the current forum and the user who moderates that forum is a member of the usergroup ID I specified, then they get the code shown in their post and is visible to everyone else.

My friend helped me get to this code;

<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid]) AND is_member_of($userinfo, 7,47)">
<div class="smallfont"><b><big>{$GLOBALS['foruminfo']['title']}Leader</big></b></div></if> <else />
<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid]) AND is_member_of($userinfo, 5,55)">
<div class="smallfont"><b><big>{$GLOBALS['foruminfo']['title']} Moderator</big></b></div>
</if>


But it isn't working for me, yet it's working for him..

Interesting. I had not seen $globals used that way before, surprisingly.

First off, let's narrow down what you're trying to do. Because the first code you posted (which I spent a couple of hours trying to figure out earlier today) isn't doing the same thing that you're trying to do now. In the first post you seem to only want to show code that displayed Thread Starter, Thread Starter & Moderator and Thread Starter & Leader (which I'm assuming was groups 7 and 47). Now you seem to only want to demarcate Moderators from Leaders, with no regard for thread starter. Let's pick one of those and go with it, because the code would be different depending on which you're trying to accomplish.

CoffeeLovesYou
02-17-2013, 01:54 AM
Disregard the old code, and look at the new code I just posted :)
The old code, I was combining it with the Original Posting modification I had in place. Disregard it.
Here is the CURRENT code I'm trying;
<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid]) AND is_member_of($userinfo, 96)">
<div class="smallfont"><b><big>{$GLOBALS['foruminfo']['title']} Leader</big></b></div></if> <else />
<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid]) AND is_member_of($userinfo, 95)">
<div class="smallfont"><b><big>{$GLOBALS['foruminfo']['title']} Moderator</big></b></div>
</if>

Here is how the if condition is SUPPOSED to work;

If the user who posted a reply/thread is a moderator of the forum they posted it in AND that user who posted is a member of usergroup ID 96, it shows you the code provided. Else, if the user who posted a reply/thread is a moderator of the forum they posted in AND that user who posted is a member of the usergroup ID 95, it shows you the code provided.
Now, before, I was using 4 usergroup IDs (in my old post), however, my friend said that this was only working with usergroups that aren't set as 'primary' for that person, so I made 2 usergroups (IDs 95 and 96) that I added the users to as one of their additional usergroups, however, it still isn't working, yet it's working for him.

Digital Jedi
02-17-2013, 06:05 PM
I don't think it should matter whether the usergroup is primary or not, but for the postbit templates, you'll want to use is_member_of($post, X), where X is the usergroup ID. Also, the <else /> statement is only used inside an if conditional, so it's not really needed, nor does it do anything here.

<!-- Has to have moderator permissions AND be a member of Usergroup 96 -->

<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid]) AND is_member_of($post, 96)">
<div class="new_class_name">{$GLOBALS['foruminfo']['title']} Leader</div>
</if>

<!-- Has to have moderator permissions AND be a member of Usergroup 95 -->

<if condition="can_moderate($GLOBALS[forumid], 0, $post[userid]) AND is_member_of($post, 95)">
<div class="new_class_name">{$GLOBALS['foruminfo']['title']} Moderator</div>
</if>
The only reason you might need an <else /> here, is in the event both of these might be true (the user has mod permissions and belongs to both usergroups). But that would have to be written a bit differently, depending on your needs.

I would also recommend not using <big> tags here. One, because it's not really modern HTML anymore, and two, because the smallfont class and <big> would probably be fighting each other and not really displaying properly. I would suggest putting your own CSS in the Additional CSS options of your skin and use that class name for the div here.