View Full Version : Closed forum and admins
chefy
08-12-2012, 03:23 AM
On my forum I have 7 admins. As you know, when the forum is closed, the only ones who can still browse and even post on the forums just like if these were open are the admins. I want to remove this ability from 2 of my 7 admins so when they log in they will see the same message that every user get: "the forum is closed" and they will not be able to do anything until the forums come back to the open status just like any regular user. Is this possible?
watty005
08-12-2012, 11:09 AM
Can you not create a different usergroup for these 2 admins and apply the permissions from there??
chefy
08-12-2012, 02:51 PM
I don't believe that there is a specific setting to prevent admins from browsing the forums when closed.
Lynne
08-12-2012, 03:11 PM
I think you would have to modify the class_bootstrap.php file manually in order to add in the userids for those two admins. Basically, if they have admin permissions and have access to the admincp, then they have access to the forum when it is off.
chefy
08-12-2012, 03:18 PM
Can't locate the file class_bootstrap.php on my vB 3.8.7 installation :(
Lynne
08-12-2012, 04:08 PM
Ah, I was looking at the vB4 files. Check global.php
chefy
08-12-2012, 04:23 PM
Here is the code snippet that controls that:
// ################################################## ###########################
// check that board is active - if not admin, then display error
if (!$vbulletin->options['bbactive'] AND THIS_SCRIPT != 'login')
{
if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']))
{
if (THIS_SCRIPT == 'external')
{
// don't output HTML for external data
exit;
}
$show['enableforumjump'] = true;
eval('standard_error("' . str_replace("\\'", "'", addslashes($vbulletin->options['bbclosedreason'])) . '");');
unset($db->shutdownqueries['lastvisit']);
}
else
{
// show the board disabled warning message so that admins don't leave the board turned off by accident
eval('$warning = "' . fetch_template('board_inactive_warning') . '";');
$header = $warning . $header;
$footer .= $warning;
}
}
So I think that I should play with this line:
if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']))
With that conditional, the system will detect all my admins (there are 7 of them) and allow them to use the forums even when closed. How can I also evaluate if they are let's say userid=1 and userid=2 to disallow them access i.e. send them to the else part of the code?
Lynne
08-13-2012, 02:29 AM
Maybe... (not testing and I'm not sure my parenthesis add up correctly):
if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) AND (!in_array($vbulletin->userinfo['userid'],array(1,2)))
I always play with these things on my test site when it comes to conditions, but that's the basic idea.
chefy
08-16-2012, 07:51 PM
Lynne, just tested your code and not only it didn't work but also made every .php of my forum (i.e. index.php, forumdisplay.php, showthread.php) to result in a blank page :D
Could you please review the code again?
Lynne
08-16-2012, 08:20 PM
$vbulletin['userid'] should actually be $vbulletin->userinfo['userid'], so that was wrong. (But, you'll still need to check the parenthesis as that will cause issues if they don't add up correctly.)
chefy
08-16-2012, 08:43 PM
In your code snippet (https://vborg.vbsupport.ru/showpost.php?p=2356547&postcount=8) you were already using $vbulletin->userinfo['userid']
Or you mean that instead of that I should use $vbulletin['userid']?
chefy
08-18-2012, 02:37 PM
Any ideas please?
Lynne
08-18-2012, 03:46 PM
Whoops, I misread my code - the variable name is incorrect. But, I don't think the parenthesis are correct which I stated before. Please check them before trying that code.
chefy
08-22-2012, 04:33 PM
What variable name is incorrect? $vbulletin['userid'] or $vbulletin->userinfo['userid']?
Or even better, this is the code that you posted:
if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) AND (!in_array($vbulletin->userinfo['userid'],array(1,2)))
I have been playing with the parenthesis for hours with no luck. Maybe because I'm not a programmer. Could you please take a look?
Lynne
08-22-2012, 11:08 PM
I meant my variable name was correct (argh, I guess I didn't have enough coffee before I posted).
I see 5 left parenthesis and 4 right parenthesis. That isn't going to work.
if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) AND (!in_array($vbulletin->userinfo['userid'],array(1,2))))
chefy
08-22-2012, 11:23 PM
Not working :(
Tried with these variations, still no luck:
if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) AND !in_array($vbulletin->userinfo['userid'],array(1,2)))
This one makes no effect at all.
if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] & in_array($vbulletin->userinfo['userid'],array(1,2))))
This one partially works: prevents any admin (and not only the ones in the array) to access the forums when closed.
Lynne
08-23-2012, 01:02 AM
if (!($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) OR in_array($vbulletin->userinfo['userid'],array(1,2)))
Try OR and forget the not... I have the in_array part right, but wasn't looking at the logic. This is why I do things on my test site - so I can try them out and keep modifying them until they work! I love logic problems, but always hated doing logic in code - go figure!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.