Check if post is by mod/admin (viewtopic)

Discussion forum for MOD Writers regarding MOD Development.
Locked
x Daniel
I've Been Banned!
Posts: 117
Joined: Sat Jan 16, 2010 11:51 am
Location: Somewhere
Name: Dan
Contact:

Check if post is by mod/admin (viewtopic)

Post by x Daniel » Tue Dec 21, 2010 12:54 am

What PHP code would I need to add in so I could use an if statement to determine weather a post is made a mod/admin and if it is show X? Thanks.
x Daniel, Xplozion - Get exclusive web content and phpBB support
Image

x Daniel
I've Been Banned!
Posts: 117
Joined: Sat Jan 16, 2010 11:51 am
Location: Somewhere
Name: Dan
Contact:

Re: Check if post is by mod/admin (viewtopic)

Post by x Daniel » Wed Dec 22, 2010 6:15 pm

Could anyone help me? Still haven't found a way.

I tried IF postrow.U_MCP -->bgx<!-- ELSE -->

But that didn't work :?
x Daniel, Xplozion - Get exclusive web content and phpBB support
Image

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: Check if post is by mod/admin (viewtopic)

Post by 4_seven » Thu Dec 23, 2010 7:50 pm

first: make shure the admin user-id is 2 (in most cases it is)

then add

Code: Select all

<!-- IF postrow.POSTER_ID eq 2 -->This is an Admin Post<!-- ENDIF -->
so u can use this for all desired groups (eg. main-mod-group is 15)

Code: Select all

<!-- IF postrow.POSTER_ID eq 15 -->This is a Moderator Post<!-- ENDIF -->
or more lightweight ;)

Code: Select all

<!-- IF postrow.POSTER_ID eq 2 -->This is an Admin Post
<!-- ELSEIF postrow.POSTER_ID eq 15 -->This is a Moderator Post<!-- ENDIF -->
etc..
Current Mods | Mod Base | php(BB) programming | No help via PM

x Daniel
I've Been Banned!
Posts: 117
Joined: Sat Jan 16, 2010 11:51 am
Location: Somewhere
Name: Dan
Contact:

Re: Check if post is by mod/admin (viewtopic)

Post by x Daniel » Thu Dec 23, 2010 8:53 pm

Ahh, I've used that code before to display an image next to a name but didn't think about that code for this, thank you :) It would be easier though to just check if they are in X group, how would I do that?

- x Daniel
x Daniel, Xplozion - Get exclusive web content and phpBB support
Image

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: Check if post is by mod/admin (viewtopic)

Post by 4_seven » Thu Dec 23, 2010 8:58 pm

this will require a mod/snippet, so better write this in mod-request forum.
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Check if post is by mod/admin (viewtopic)

Post by RMcGirr83 » Thu Dec 23, 2010 9:13 pm

Try placing this

Code: Select all

// Grab an array of user_id's with admin permissions
$admin_ary = $auth->acl_get_list(false, 'a_', false);
$admin_ary = (!empty($admin_ary[0]['a_'])) ? $admin_ary[0]['a_'] : array();
// Grab an array of user_id's with mod permissions
$mod_ary = $auth->acl_get_list(false,'m_', false);
$mod_ary = (!empty($mod_ary[0]['m_'])) ? $mod_ary[0]['m_'] : array();
// merge the two arrays into one
$admin_mod_ary  = array_merge($admin_ary, $mod_ary);
just above this in viewtopic.php

Code: Select all

// Posts are stored in the $rowset array while $attach_list, $user_cache
then check for it within the viewtopic postrow vars, like this (about line 1491 of viewtopic.php)

Code: Select all

	//
	$postrow = array(
		'IS_ADMIN_MOD'	=> sizeof($admin_mod_ary) ? (in_array($poster_id, $admin_mod_ary) ? true : false) : false,

the test for it within viewtopic_body.html would be like this

Code: Select all

<!-- IF postrow.IS_ADMIN_MOD -->display something here<!-- ENDIF -->
That should be a pretty good start.
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

x Daniel
I've Been Banned!
Posts: 117
Joined: Sat Jan 16, 2010 11:51 am
Location: Somewhere
Name: Dan
Contact:

Re: Check if post is by mod/admin (viewtopic)

Post by x Daniel » Thu Dec 23, 2010 9:16 pm

Thanks for that RMcGirr83 :)

*Edit: actually I'm confused about the last thing to include in viewtopic.php, what do I do with that bit? :?
x Daniel, Xplozion - Get exclusive web content and phpBB support
Image

x Daniel
I've Been Banned!
Posts: 117
Joined: Sat Jan 16, 2010 11:51 am
Location: Somewhere
Name: Dan
Contact:

Re: Check if post is by mod/admin (viewtopic)

Post by x Daniel » Thu Dec 23, 2010 9:36 pm

Oh I've done it now, the code works fine but it only shows for admins though, what would I need for moderators as well?

*Edit: I've just checked and it shows one colour for both admins and mods (mods for that specific forum).

What would I need to show a colour for admins and a different colour for mods (also I'd like the colour for mods to show up regardless of weather they are a mod in that particular forum)?

Thank you! :)

*Edit 2: Okay I've tweaked the code now but I have an issue now. I'd like to show the colour for moderators to every user with moderator permissions, even if they aren't a mod in X forum. So far I have a red colour showing for admins and a green for mods but I have some other mods that only mod a few forums, and they don't get a colour in any forum (even those they mod).

Here is the code I have... and thanks a bunch so far :)

Code: Select all

// Grab an array of user_id's with admin permissions
$admin_ary = $auth->acl_get_list(false, 'a_', false);
$admin_ary = (!empty($admin_ary[0]['a_'])) ? $admin_ary[0]['a_'] : array();
// Grab an array of user_id's with mod permissions
$mod_ary = $auth->acl_get_list(false,'m_', false);
$mod_ary = (!empty($mod_ary[0]['m_'])) ? $mod_ary[0]['m_'] : array();
And further down at the $postrow = array( part, I have this bit...

Code: Select all

		'IS_ADMIN'              => sizeof($admin_ary) ? (in_array($poster_id, $admin_ary) ? true : false) : false,
		'IS_MOD'                => sizeof($mod_ary) ? (in_array($poster_id, $mod_ary) ? true : false) : false,
So now I have it showing two different colours for admins/mods so we're half way 'in business' :)
x Daniel, Xplozion - Get exclusive web content and phpBB support
Image

User avatar
FCproductions
Registered User
Posts: 58
Joined: Sun Feb 03, 2013 8:39 am

Re: Check if post is by mod/admin (viewtopic)

Post by FCproductions » Wed Aug 14, 2013 2:08 am

Fixed.

Locked

Return to “[3.0.x] MOD Writers Discussion”