PDA

View Full Version : Closed Board - Mod & Admin Access


NTLDR
09-08-2002, 08:23 PM
My board is currently closed when while I hack up 2.2.7 and finish off the new style for it, by default only admins can access a closed board, but I want a supermod to as well, I changed:

// check that board is active - if not admin, then display error
if (!$bbactive) {
if (!$permissions['cancontrolpanel']) {
eval("standarderror(\"".str_replace("\'", "'", addslashes($bbclosedreason))."\");");
exit;
}
}

in global.php to:

// check that board is active - if not admin, then display error
if (!$bbactive) {
if ((!$permissions['cancontrolpanel']) or (!$permissions['ismoderator'])) {
eval("dooutput(\"".gettemplate("classic_bbclosed")."\");");
exit;
}
}

classic_bbclosed is a template with the entire page to be displayed instead of the standard error, now this worked for a few days then suddenly stoped, I didn't do anything to change it and have tried every way I can think of. ismoderator is set to 1 for the usergroup (the default sup mod group).

Any ideas?

g-force2k2
09-08-2002, 08:31 PM
NTLDR try this code...

// check that board is active - if not admin, then display error
if (!$bbactive) {
if (!$permissions['cancontrolpanel']) {
if (!$permissions['ismoderator']) {
eval("dooutput(\"".gettemplate("classic_bbclosed")."\");");
exit;
}
}
}

regards...

g-force2k2

NTLDR
09-08-2002, 08:38 PM
Thank you g-force2k2, that seems to be doing the trick :D its been a nightmare trying to get that to work. Thanks once again :)

g-force2k2
09-08-2002, 08:42 PM
np NTLDR... it was very perplexing to me as well O_o i was trying to short hand it into one line... but the statement that you had stated...

if they can't access the control panel 'or' they aren't a moderator

see the thing is moderators can't access the control panel so no matter what that part will always return false meaning it wont work...

how my works is

if they can't access the control panel... then

if they aren't a moderator... then...

hope that helps you see the light :) regards...

g-force2k2

NTLDR
09-08-2002, 08:53 PM
After a little confusion I see now that my code would never work and how yours does.

I hade:

if (!$permissions['cancontrolpanel'] or !$permissions['ismoderator']) {

origional which I know worked for a couple of days which is why I couldn't see what was wrong. Do the extra set of brackets around each !$permissions bit have any effect or just make the statment clearer?

Thanks for the explanation though, I helped me see what was obviously wrong :D

g-force2k2
09-08-2002, 08:58 PM
yeah i see what you mean about the brackets :p i guess we both learn something out of it... glad to see the one liner working again :) regards...

g-force2k2

NTLDR
09-08-2002, 09:08 PM
I don't think I explained very well *lol*

The one liner just suddenly stopped working. Anyway your code works a treat and I'm not going to play and break it again ;)

Scott MacVicar
09-09-2002, 07:14 AM
if (!$permissions['cancontrolpanel'] or !$permissions['ismoderator']) {

that should be

if (!$permissions['cancontrolpanel'] and !$permissions['ismoderator']) {

because a mod will match the ismoderator but not cancontrol panel and since one of them will return true they get the error.

NTLDR
09-09-2002, 11:58 AM
I realise how stupid I've been now, not taking the fact that each one was negated so 'and' would work :rolleyes:

g-force2k2
09-09-2002, 02:01 PM
yeah thanks PPN :)

im been toasting my brain :p

g-force2k2

Scott MacVicar
09-09-2002, 10:09 PM
You have no idea how many times I've done that myself :)