HowTo:Restricted set of account management options for 'Moderate forum members'

Started by GL700Wing, September 12, 2013, 09:20:49 AM

Previous topic - Next topic

GL700Wing

I have a small forum and have assigned the Forum Moderator membergroup (a membergroup I created based off the Global Moderator membergroup) to a few members.  One of the privileges I have granted the Forum Moderator membergroup is 'Moderate forum members'.

I've implemented some very effective anti-spam measures and set account registration to 'Admin Approval' but I also want to make sure that, in relation to account approval, the Forum Moderators must select the option for new members to activate their account.  In addition I also want to restrict most of the other account activation and deletion options to the Administrator membergroup.

In the end I decided that the Forum Moderators would only have access to the following account management options:
Approval:  Approve and require activation
Activation:  Remind and send email
Deletion:  Reject

To achieve this I only had to make the following minor changes to ./Sources/ManageMembers.php

Find:
function MembersAwaitingActivation()
{
global $txt, $context, $scripturl, $modSettings, $smcFunc;
global $sourcedir;



Replace with:
function MembersAwaitingActivation()
{
global $txt, $context, $scripturl, $modSettings, $smcFunc;
global $sourcedir;
global $user_info;



Find:
// Determine which actions we should allow on this page.
if ($context['browse_type'] == 'approve')
{
// If we are approving deleted accounts we have a slightly different list... actually a mirror ;)
if ($context['current_filter'] == 4)
$context['allowed_actions'] = array(
'reject' => $txt['admin_browse_w_approve_deletion'],
'ok' => $txt['admin_browse_w_reject'],
);
else
$context['allowed_actions'] = array(
'ok' => $txt['admin_browse_w_approve'],
'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'],
'require_activation' => $txt['admin_browse_w_approve_require_activate'],
'reject' => $txt['admin_browse_w_reject'],
'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'],
);
}
elseif ($context['browse_type'] == 'activate')
$context['allowed_actions'] = array(
'ok' => $txt['admin_browse_w_activate'],
'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'],
'delete' => $txt['admin_browse_w_delete'],
'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'],
'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'],
);



Replace with:
// Determine which actions we should allow on this page.
if ($user_info['is_admin'] && $context['browse_type'] == 'approve')
{
// If we are approving deleted accounts we have a slightly different list... actually a mirror ;)
if ($context['current_filter'] == 4)
$context['allowed_actions'] = array(
'reject' => $txt['admin_browse_w_approve_deletion'],
'ok' => $txt['admin_browse_w_reject'],
);
else
$context['allowed_actions'] = array(
'ok' => $txt['admin_browse_w_approve'],
'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'],
'require_activation' => $txt['admin_browse_w_approve_require_activate'],
'reject' => $txt['admin_browse_w_reject'],
'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'],
);
}
elseif ($user_info['is_admin'] && $context['browse_type'] == 'activate')
$context['allowed_actions'] = array(
'ok' => $txt['admin_browse_w_activate'],
'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'],
'delete' => $txt['admin_browse_w_delete'],
'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'],
'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'],
);

if (!$user_info['is_admin'] && $context['browse_type'] == 'approve')
{
// If we are approving deleted accounts we have a slightly different list... actually a mirror ;)
if ($context['current_filter'] == 4)
$context['allowed_actions'] = array(
'reject' => $txt['admin_browse_w_approve_deletion'],
);
else
$context['allowed_actions'] = array(
'require_activation' => $txt['admin_browse_w_approve_require_activate'],
);
}
elseif (!$user_info['is_admin'] && $context['browse_type'] == 'activate')
$context['allowed_actions'] = array(
'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'],
);



Hope this helps others who may want to implement something similar.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

kat

Nicely done, Wingy!

I'll move this to the ol' "Tips and tricks" board, if you don't mind, coz it kinda fits better, there. :)


GL700Wing

Quote from: K@ on September 12, 2013, 09:30:48 AM
Nicely done, Wingy!

I'll move this to the ol' "Tips and tricks" board, if you don't mind, coz it kinda fits better, there. :)
Thanks - I would have put it here to start with but I was sure that when I looked at the T&T board late last night that I didn't have the option to start a new topic - but it was very late and I have had a very busy week working 18 hours each day (looking forward to the weekend).
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

kat

No sweat! I believe someone's farting around with the board, for reasons that I've yet to discover. Maybe that affected you.

Advertisement: