Permission to allow access to "Forum Maintenance"

Started by zach21uk, January 29, 2012, 03:19:09 PM

Previous topic - Next topic

zach21uk

Hi There,

I would like to create a specific group where certain trusted members can access the "Forum Maintenance" admin section ONLY and be able to take backups of the website database.

I've looked all over and not found a permission to grant access to this specific area.   

How would I be able to do this?

Thanks

Illori

you would need a mod, which i dont think exists to do that. there are no permissions by default to do that and the backup in the admin panel is often not reliable and will cause the backup to be incomplete.

hcfwesker

Quote from: Illori on January 29, 2012, 03:22:20 PMbackup in the admin panel is often not reliable and will cause the backup to be incomplete.

I agree with this.  But if you still want it, I could possibly show you what to edit to allow this.

zach21uk

I would appreciate any possible help in setting this up.

hcfwesker

#4
Ok, I need to know a couple of things.  Your SMF version?  Are these going to be members with access to the 'Moderate' menu tab ( Moderation Center permission)?   Cause it would make it easier, so I can just add a sub-menu link to Maintenance menu under there after creating the custom permission.

Or do they have other permissions that let them access the Admin tab?

OR

I could create  sub-menu under the 'Home' button only those with this access would see the sub-menu link.

zach21uk

It is SMF version 2.02 - Its a bog-standard SMF installation with no modifications currently.

Members with this permission WILL indeed have access to the moderation centre :)


hcfwesker

#6
I'm going to try this again, since SMF froze on me trying to post the first time.

these edits are from a fresh SMF 2.0.2 install

This will add a new Permission "Access the Maintenance Center" under Admin > Permissions

Sources/ManagePersmissions ( creating the permission)

Find
// Maintenance - wannabe admins.  They can do almost everything.
$groupLevels['global']['maintenance'] = array_merge($groupLevels['global']['moderator'], array


Add After
'access_maintenance',

Find
'access_mod_center' => array(false, 'maintenance', 'moderate_general'),

Add After
'access_maintenance' => array(false, 'maintenance', 'administrate'),

Admin.php ( assigning access to the Maintenance Center )

Find
'maintenance' => array(
'title' => $txt['admin_maintenance'],
'permission' => array('admin_forum'),


Replace with
'maintenance' => array(
'title' => $txt['admin_maintenance'],
'permission' => array('access_maintenance'),


Sources/Subs.php ( adding quick link under Moderation Center tab )

Find
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
'is_last' => true,
),
),
),


Replace with
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
),
'maintenance' => array(
'title' => 'Maintenance Center',
'href' => $scripturl . '?action=admin;area=maintain;sa=database',
'show' => allowedTo('access_maintenance'),
'is_last' => true,
), 
),
),


default/languages/ManagePermissions.php ( defining with language strings )

Find
?>

Add Before
$txt['permissionname_access_maintenance'] = 'Access the Maintenance Center';
$txt['permissionhelp_access_maintenance'] = 'Allows this group to access the forum Maintenance Center.  Only give this permission to those you absolutely trust.';



That should be everything, just be sure to test with a test acount with permission "access moderation center" & "Access Maintenance Center" to amke sure the group only has access to what you want.




zach21uk

Hey,

I made these file modifications and set up a test account with the permissions you specified, however, when attempting to access the "Maintenance Center" it gives an error:

QuoteAn Error Has Occurred!
You are not allowed to administrate this forum.

Please advise.
Zach

hcfwesker

D'oh!  Forgot about ading the new permission for access to an Admin menu function.

Sources/Admin.php  ( around the top of the file )

Find
$admin_areas = array(
'forum' => array(
'title' => $txt['admin_main'],
'permission' => array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments'),


In that list of Permissions , add 
, 'access_maintenance'

after  'manage_attachments'

zach21uk

Thanks.  I made that change however, and its the same error as above.    Would it help if i setup a fresh install of SMF somewhere for you to see for yourself?   I really appreciate your help by the way. thank you so much

hcfwesker

I have this in a MOD package, I'll upload it to a fresh smf and test for myself.  I may have left a tiny detail out somewhere.  I'll get this to work, no worries :)   Making custom permission is one of my hobbies on my site lol  , like this one http://www.simplemachines.org/community/index.php?topic=463821.msg3238753#msg3238753

Matthew K.

Here's the issue...each administration section function has permission checks in the function itself. If just the menu items were permission-based, you'd still be able to access the section by the URL.

When you access an area by URL. You'll want to look in ./Sources/ManageMaintenance.php for isAllowedTo('something'); and change those accordingly.

Matthew K.

Here are the additional edits, not tested, but should work.

./Sources/ManageMaintenance.php:
Code (Find) Select
// The maintenance access point.
function ManageMaintenance()
{
global $txt, $modSettings, $scripturl, $context, $options;

// You absolutely must be an admin by here!
isAllowedTo('admin_forum');

Code (Replace) Select

// The maintenance access point.
function ManageMaintenance()
{
global $txt, $modSettings, $scripturl, $context, $options;

// You absolutely must be an admin by here!
isAllowedTo('access_maintenance');


Code (Find) Select
function ConvertUtf8()
{
global $scripturl, $context, $txt, $language, $db_character_set;
global $modSettings, $user_info, $sourcedir, $smcFunc, $db_prefix;

// Show me your badge!
isAllowedTo('admin_forum');

Code (Replace) Select
function ConvertUtf8()
{
global $scripturl, $context, $txt, $language, $db_character_set;
global $modSettings, $user_info, $sourcedir, $smcFunc, $db_prefix;

// Show me your badge!
isAllowedTo('access_maintenance');


Code (Find) Select
// Convert HTML-entities to their UTF-8 character equivalents.
function ConvertEntities()
{
global $db_character_set, $modSettings, $context, $sourcedir, $smcFunc;

isAllowedTo('admin_forum');

Code (Replace) Select

// Convert HTML-entities to their UTF-8 character equivalents.
function ConvertEntities()
{
global $db_character_set, $modSettings, $context, $sourcedir, $smcFunc;

isAllowedTo('access_maintenance');


Code (Find) Select
// Optimize the database's tables.
function OptimizeTables()
{
global $db_type, $db_name, $db_prefix, $txt, $context, $scripturl, $sourcedir, $smcFunc;

isAllowedTo('admin_forum');

Code (Replace) Select
// Optimize the database's tables.
function OptimizeTables()
{
global $db_type, $db_name, $db_prefix, $txt, $context, $scripturl, $sourcedir, $smcFunc;

isAllowedTo('access_maintenace');


Code (Find) Select
// Recount all the important board totals.
function AdminBoardRecount()
{
global $txt, $context, $scripturl, $modSettings, $sourcedir;
global $time_start, $smcFunc;

isAllowedTo('admin_forum');

Code (Replace) Select
// Recount all the important board totals.
function AdminBoardRecount()
{
global $txt, $context, $scripturl, $modSettings, $sourcedir;
global $time_start, $smcFunc;

isAllowedTo('access_maintenance');


Code (Find) Select
// Perform a detailed version check.  A very good thing ;).
function VersionDetail()
{
global $forum_version, $txt, $sourcedir, $context;

isAllowedTo('admin_forum');

Code (Replace) Select
// Perform a detailed version check.  A very good thing ;).
function VersionDetail()
{
global $forum_version, $txt, $sourcedir, $context;

isAllowedTo('access_maintenance');


Code (Find) Select
function MaintainMassMoveTopics()
{
global $smcFunc, $sourcedir, $context, $txt;

// Only admins.
isAllowedTo('admin_forum');

Code (Replace) Select
function MaintainMassMoveTopics()
{
global $smcFunc, $sourcedir, $context, $txt;

// Only admins.
isAllowedTo('access_maintenance');

I hereby give permission to anyone to package my edits in a mod if anyone wishes to. :P

hcfwesker

Yeah, I forgot all about the 'admin_forum' only in the Maintenace file itself.  I feel retarded now  :(

Also, I believe these need to be changed for access to each sub-menu button along with Lab's edits.  ( Thanx bud for the help
).


Sources/Admin.php

Find
'maintain' => array(
'label' => $txt['maintain_title'],
'file' => 'ManageMaintenance.php',
'icon' => 'maintain.gif',
'function' => 'ManageMaintenance',
'subsections' => array(
'routine' => array($txt['maintain_sub_routine'], 'admin_forum'),
'database' => array($txt['maintain_sub_database'], 'admin_forum'),
'members' => array($txt['maintain_sub_members'], 'admin_forum'),
'topics' => array($txt['maintain_sub_topics'], 'admin_forum'),
),
),
'scheduledtasks' => array(
'label' => $txt['maintain_tasks'],
'file' => 'ManageScheduledTasks.php',
'icon' => 'scheduled.gif',
'function' => 'ManageScheduledTasks',
'subsections' => array(
'tasks' => array($txt['maintain_tasks'], 'admin_forum'),
'tasklog' => array($txt['scheduled_log'], 'admin_forum'),
),
),


Replace with
'maintain' => array(
'label' => $txt['maintain_title'],
'file' => 'ManageMaintenance.php',
'icon' => 'maintain.gif',
'function' => 'ManageMaintenance',
'subsections' => array(
'routine' => array($txt['maintain_sub_routine'], 'admin_forum', 'access_maintenance'),
'database' => array($txt['maintain_sub_database'], 'admin_forum', 'access_maintenance'),
'members' => array($txt['maintain_sub_members'], 'admin_forum', 'access_maintenance'),
'topics' => array($txt['maintain_sub_topics'], 'admin_forum', 'access_maintenance'),
),
),
'scheduledtasks' => array(
'label' => $txt['maintain_tasks'],
'file' => 'ManageScheduledTasks.php',
'icon' => 'scheduled.gif',
'function' => 'ManageScheduledTasks',
'subsections' => array(
'tasks' => array($txt['maintain_tasks'], 'admin_forum', 'access_maintenance'),
'tasklog' => array($txt['scheduled_log'], 'admin_forum', 'access_maintenance'),
),
),

Matthew K.

Head up hcfwesker, you're doing great. No worries.

And in this case, if I'm thinking about this properly, you don't need to check for both admin_forum AND allow_maintenance, simply "allow_maintenance" will do.

hcfwesker

Quote from: Labradoodle-360 on January 30, 2012, 05:08:20 PMAnd in this case, if I'm thinking about this properly, you don't need to check for both admin_forum AND allow_maintenance, simply "allow_maintenance" will do.

Yes, since admin has all permissions, but I was rushing to hurry and get that posted and instead of pasting over, just pasted after 'admin_forum'.  Either will work and you are correct, of course.  I'm not worthy :P

thanx for the extra hand.  :)


zach21uk


zach21uk

Sorry, but it appears I was mistaken.  I just tried to actually take a database backup and it said "Only administrators can make database backups!"

Matthew K.

That means that the backup function was not converted to the new permission then.

Advertisement: