Page 1 of 1

given forum and topic id -> return of moderator?

Posted: Wed Dec 06, 2017 6:58 pm
by RobiX
given: viewtopic.php?f=x&t=y (x = 2, y = 1: viewtopic.php?f=2&t=1)

is it possible (and if yes, how) to return a yes/no (boolean), if the current logged-in user is a moderator of the given f=2&t=1 (forum id 2, topic id 1)?


pseudocode:

Code: Select all

<!-- IF IS_MOD and forum=2 and topic=1 -->

is id of the topic unique or forum id necessary?

Re: given forum and topic id -> return of moderator?

Posted: Thu Dec 07, 2017 2:00 am
by kinerity
Untested. This seems to work in my limited testing. Replace $forum_id with the forum id. There are no "topic moderators". Note that it will check if the user has any moderator permission in the given forum. If you want to check a specific permission, replace m_ with the permission (for example, m_lock).

Code: Select all

$template->assign_var('IS_MOD', ($auth->acl_get('m_', $forum_id) ? true : false));

Code: Select all

<div><!-- IF IS_MOD -->
content if mod
<!-- ENDIF --></div>

Re: given forum and topic id -> return of moderator?

Posted: Thu Dec 07, 2017 10:49 am
by RobiX
tnx for your answer - will try it :)

Re: given forum and topic id -> return of moderator?

Posted: Thu Dec 07, 2017 2:28 pm
by Brf
How about using the existing U_MCP variable?

Re: given forum and topic id -> return of moderator?

Posted: Thu Dec 07, 2017 6:00 pm
by RobiX
Brf wrote:
Thu Dec 07, 2017 2:28 pm
How about using the existing U_MCP variable?
but this doesnt work on a custom coding page, does it?

because you need to check before of the user has rights to view

For example,
own custom coding page#1: can only be viewed if user is moderator in forum 1 and topic 1 else "sorry, ..." (or so)
own custom coding page#2: can only be viewed if user is moderator in forum 1 and topic 2 else "sorry, ..." (or so)

Re: given forum and topic id -> return of moderator?

Posted: Thu Dec 07, 2017 6:28 pm
by RMcGirr83
RobiX wrote:
Thu Dec 07, 2017 6:00 pm
but this doesnt work on a custom coding page, does it?
You never mentioned that in your first post that I can see, hence BRF's answer.

Also you need to consider global moderators as well I would think.

Re: given forum and topic id -> return of moderator?

Posted: Thu Dec 07, 2017 6:37 pm
by Brf
RMcGirr83 wrote:
Thu Dec 07, 2017 6:28 pm
You never mentioned that in your first post that I can see, hence BRF's answer.
Indeed. In fact you said:
RobiX wrote:
Wed Dec 06, 2017 6:58 pm
given: viewtopic.php?f=x&t=y (x = 2, y = 1: viewtopic.php?f=2&t=1)
which implies it is the viewtopic.php page.