I need to know how to allow a user to be logged on and see the boards during maintenance mode without making them an administrator.
I plan to do allot of work to my forums this upcoming weekend and need to be able to shut the forum down but allow the test account to be on to test everything im changing. Is there a permission that can be granted to allow this?
I need this feature as well.
Thanks
In index.php find
// Is the forum in maintenance mode? (doesn't apply to administrators.)
if (!empty($maintenance) && !allowedTo('admin_forum'))
{
// You can only login.... otherwise, you're getting the "maintenance mode" display.
if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'login2' || $_REQUEST['action'] == 'logout'))
{
require_once($sourcedir . '/LogInOut.php');
return $_REQUEST['action'] == 'login2' ? 'Login2' : 'Logout';
}
// Don't even try it, sonny.
else
{
require_once($sourcedir . '/Subs-Auth.php');
return 'InMaintenance';
}
}
You should be able to add into the
if (!empty($maintenance) && !allowedTo('admin_forum'))
something on the lines of && !$user_info['username'] == 'test'
Another option to minimize down time would be to create a copy of the forum, make all the changes there. Then once your happy, put the forum in maintenance mode and replace the modified files.
Wow I just looked at the date of the original post and way to resurrect a thread. ;) I was kind of wondering why SleePy who has 9k+ posts was asking how to made such a simple change and then realized that was only 4 months after he registered on the SMF board.
I just opened a Mod Request here:
http://www.simplemachines.org/community/index.php?topic=199935.0
I was kind of surprised as well to find it was by SleePy and had never been answered.
As to doing all this on a test system and roll into Production, I really wish I could. Editing Production goes against everything I've done in 25 years of Systems work, but this is someone else's forum. I'm the new tech admin and trying to keep it stable and up. That's why the first thing I'll do on going to Maintenance Mode is a full cpanel backup.
Thank you for the code suggestion. I'm going to see about it if the Mod request doesn't fly.
rsw686,
Your idea would work.
As well you could do user ids and then have a simple array
in_array($user_info['id'], array(1, 5, 21, 64))
Is it possible to put these code pieces together into an example I can cut and paste? My PHP isn't quite up to speed (in PL/1 or REXX it wouldn't be a problem ;) ).
Thanks!
Cal
Lainaus käyttäjältä: cal.oshaw - lokakuu 15, 2007, 11:13:09 IP
Is it possible to put these code pieces together into an example I can cut and paste? My PHP isn't quite up to speed (in PL/1 or REXX it wouldn't be a problem ;) ).
Thanks!
Cal
It's already cut and paste. Find the section of code I quoted above. Change out the line to either
if (!empty($maintenance) && !allowedTo('admin_forum') && !$user_info['username'] == 'test')
or
if (!empty($maintenance) && !allowedTo('admin_forum') && !in_array($user_info['id'], array(1, 5, 21, 64)))
Make sure to replace the username or id's with the user(s) you want to use the forum while in maintenance mode.
Thanks!
Greatly appreciated!
Hi,
I tried it and it didn't work. The users in the array were determined by looking at the profile of each and pulling the ";u=xxx" from the end of the URL.
I suspect something like || instead of && or parens missing or misplaced. I tried walking the logic to find how to get someone during Maintenance Mode who is not an admin but in the array to get to login but came up short. Maybe there's an additional check in the login2 code?
I'm including my code here, and perhaps one of you guys can take a look, suppress a chuckle as you tell me where I messed this up:
// Is the forum in maintenance mode? (doesn't apply to administrators.)
// if (!empty($maintenance) && !allowedTo('admin_forum'))
// ACCESS MOD -- Cal
// mod to allow other users to log on in maintenance mode
// update /forum/index.php
// userids to allow: 10=Moe 14=Larry 361=Curly
if (!empty($maintenance) && !allowedTo('admin_forum') && !in_array($user_info['id'], array(10, 14, 361)))
// ACCESS MOD -- Cal
I really appreciate any assistance that can be given.
Grazie mille,
Cal
Actually you didn't mess it up. I just looked at Load.php and id is not stored from the database.
In Load.php around line 480 find
// Set up the $user_info array.
$user_info += array
'username' => $username,
Replace with
// Set up the $user_info array.
$user_info += array
'id' => $user_settings['ID_MEMBER'],
'username' => $username,
I have not tested this, but I'm 99% positive it will work now.
Hi,
I put in the code (haven't tested in Maintenance Mode) but it does cause a problem if one has Guests. My error log is filling with:
8: Undefined index: ID_MEMBER
/home/mcgarden/public_html/forum/Sources/Load.php
484
So, I'm going to test the code today, but unless a workaround can be found, I'll have to comment it out during normal operation.
Is there a place in Load.php where a default can be defined, even if I have to create a member as a placeholder?
I really do thank you for all your help on this. I know a number of other sites will really appreciate your efforts if we can make this work.
Thanks!
Cal
Alright I went and tested this on my development forum and figured out an easy way to make it work. Remove the change to Load.php.
On the index.php file it should look like this
if (!empty($maintenance) && !allowedTo('admin_forum') && !in_array($GLOBALS['ID_MEMBER'], array(10, 14, 361)))
The member id is stored in ID_MEMBER. Let me know if this works for you.
Hello,
Yes, this did work. For what I need, it's great.
There were two items I saw, but they don't impact the usability, it's more cosmetics.
1) Under Firefox 2.0.0.8, when I entered the userid and password, it accepted, then reported a validation error. I clicked the back button and saw the login panel, still filled in. I clicked to login again and this time it worked. I closed and restarted Firefox a few times to confirm this is consistant behavior.
2) The Maintenance Mode message is not in the info block at top (likely it just checks for maintenance mode).
Again, nothing that will keep me from using this.
If you are open to seeing if these nits can be cleaned up and a MOD produced, or getting SMF to incorporate it in the base code, that would be super.
I do thank you very much for all the help you've given me. I really do appreciate it!
Regards,
Cal
Lainaus käyttäjältä: cal.oshaw - lokakuu 24, 2007, 01:31:09 IP
1) Under Firefox 2.0.0.8, when I entered the userid and password, it accepted, then reported a validation error. I clicked the back button and saw the login panel, still filled in. I clicked to login again and this time it worked. I closed and restarted Firefox a few times to confirm this is consistant behavior.
2) The Maintenance Mode message is not in the info block at top (likely it just checks for maintenance mode).
1) I noticed that too, but I just clicked on the home button again and the page came up.
2) This is easy to fix. In your theme folder index.template.php around line 283
// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '
<b>', $txt[616], '</b><br />';
I would just remove the && $context['user']['is_admin'] since nobody is going to be looged in but the admin and users you specify and it is just the maintenance message. However you could also add the && !in_array($GLOBALS['ID_MEMBER'], array(10, 14, 361)) to it, but then you would need to keep both arrays identical with the members you want on in maintenance mode.