Disallowing changing to global mod...

Started by Az, October 08, 2005, 07:03:25 PM

Previous topic - Next topic

Az

When a user has the permission given to them to change their membergroup through the user profile. They cannot choose to be an admin, but they can still become a global mod if they want. How do I remove the global mod part for everyone except admins?

In Profile.php:
// The account page allows the change of your ID_GROUP - but not to admin!.
if (isset($_POST['ID_GROUP']) && (allowedTo('admin_forum') || ((int) $_POST['ID_GROUP'] != 1 && $old_profile['ID_GROUP'] != 1)))
$profile_vars['ID_GROUP'] = (int) $_POST['ID_GROUP'];


What do I add after this to change it? If this the right place..

Dannii

Why are you letting them change their usergroup? For people I would let do that, I would trust enough anyway.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Elmacik

Quote from: eldacar on October 08, 2005, 11:30:22 PM
Why are you letting them change their usergroup? For people I would let do that, I would trust enough anyway.
he doesnt let them change their OWN usergroup only. he lets some people to control the user groups.
and he says they can control the groups that are higher than themselves.
for example, if both moderators and global moderators are allowed to control usergroups, moderators will be able to remove someone from or add someone to the global moderators usergroup.

i think thats not really nice and should be changed in 1.1 final
Home of Elmacik

Oldiesmann

If I remember, I'll take a look at this tomorrow and see what I can come up with.

* Oldiesmann listens to the live Project 86 concert going on in the background
Michael Eshom
Christian Metal Fans

Oldiesmann

#4
Ok...

1.0.5:

Sources/Load.php

Find
'is_admin' => in_array(1, $user_info['groups']),

Add after
'is_gmod' => in_array(2, $user_info['groups']),

Sources/ManageMembers.php

Find
if ($context['group']['id'] == 1 && !allowedTo('admin_forum'))
$context['group']['assignable'] = 0;


Replace
if (($context['group']['id'] == 1 || ($context['group']['id'] == 2 && !$user_info['is_gmod'])) && !allowedTo('admin_forum'))
$context['group']['assignable'] = 0;


Sources/Profile.php

Find
// Assigning membergroups (you need admin_forum permissions to change an admins' membergroups).
if (allowedTo('manage_membergroups'))
{
// The account page allows the change of your ID_GROUP - but not to admin!.
if (isset($_POST['ID_GROUP']) && (allowedTo('admin_forum') || ((int) $_POST['ID_GROUP'] != 1 && $old_profile['ID_GROUP'] != 1)))
$profile_vars['ID_GROUP'] = (int) $_POST['ID_GROUP'];

// Find the additional membergroups (if any)
if (isset($_POST['additionalGroups']) && is_array($_POST['additionalGroups']))
{
foreach ($_POST['additionalGroups'] as $i => $group_id)
{
if ((int) $group_id == 0 || (!allowedTo('admin_forum') && (int) $group_id == 1))
unset($_POST['additionalGroups'][$i]);
else
$_POST['additionalGroups'][$i] = (int) $group_id;
}

// Put admin back in there if you don't have permission to take it away.
if (!allowedTo('admin_forum') && in_array(1, explode(',', $old_profile['additionalGroups'])))
$_POST['additionalGroups'][] = 1;

$profile_vars['additionalGroups'] = '\'' . implode(',', $_POST['additionalGroups']) . '\'';
}
}


Replace
// Assigning membergroups (you need admin_forum permissions to change an admins' membergroups).
if (allowedTo('manage_membergroups'))
{
// The account page allows the change of your ID_GROUP - but not to admin!.
if (isset($_POST['ID_GROUP']) && (allowedTo('admin_forum') || ((int) $_POST['ID_GROUP'] != 1 && $old_profile['ID_GROUP'] != 1) || (((int) $_POST['ID_GROUP'] !=2 && $old_profile['ID_GROUP'] != 2) || $user_info['is_gmod'])))
$profile_vars['ID_GROUP'] = (int) $_POST['ID_GROUP'];

// Find the additional membergroups (if any)
if (isset($_POST['additionalGroups']) && is_array($_POST['additionalGroups']))
{
foreach ($_POST['additionalGroups'] as $i => $group_id)
{
if ((int) $group_id == 0 || (!allowedTo('admin_forum') && ((int) $group_id == 1 || ((int) $group_id == 2 && !$user_info['is_gmod']))))
unset($_POST['additionalGroups'][$i]);
else
$_POST['additionalGroups'][$i] = (int) $group_id;
}

// Put admin back in there if you don't have permission to take it away.
if (!allowedTo('admin_forum') && in_array(1, explode(',', $old_profile['additionalGroups'])))
$_POST['additionalGroups'][] = 1;
// Put global mod back in there if you don't have permission to take it away.
if (!allowedTo('admin_forum') && (!$user_info['is_gmod'] && in_array(2, explode(',', $old_profile['additionalGroups']))))
$_POST['additionalGroups'][] = 2;

$profile_vars['additionalGroups'] = '\'' . implode(',', $_POST['additionalGroups']) . '\'';
}
}


1.1:

Sources/Load.php

Find
'is_admin' => in_array(1, $user_info['groups']),

Add after
'is_gmod' => in_array(2, $user_info['groups']),

Sources/ManageMemberGroups.php

Find
if ($context['group']['id'] == 1 && !allowedTo('admin_forum'))
$context['group']['assignable'] = 0;


Replace
if (($context['group']['id'] == 1 || ($context['group']['id'] == 2 && !$user_info['is_gmod'])) && !allowedTo('admin_forum'))
$context['group']['assignable'] = 0;


Sources/Profile.php

Find
// The account page allows the change of your ID_GROUP - but not to admin!.
if (isset($_POST['ID_GROUP']) && (allowedTo('admin_forum') || ((int) $_POST['ID_GROUP'] != 1 && $old_profile['ID_GROUP'] != 1)))
$profile_vars['ID_GROUP'] = (int) $_POST['ID_GROUP'];

// Find the additional membergroups (if any)
if (isset($_POST['additionalGroups']) && is_array($_POST['additionalGroups']))
{
foreach ($_POST['additionalGroups'] as $i => $group_id)
{
if ((int) $group_id == 0 || (!allowedTo('admin_forum') && (int) $group_id == 1))
unset($_POST['additionalGroups'][$i]);
else
$_POST['additionalGroups'][$i] = (int) $group_id;
}

// Put admin back in there if you don't have permission to take it away.
if (!allowedTo('admin_forum') && in_array(1, explode(',', $old_profile['additionalGroups'])))
$_POST['additionalGroups'][] = 1;

$profile_vars['additionalGroups'] = '\'' . implode(',', $_POST['additionalGroups']) . '\'';
}


Replace
// The account page allows the change of your ID_GROUP - but not to admin!.
if (isset($_POST['ID_GROUP']) && (allowedTo('admin_forum') || ((int) $_POST['ID_GROUP'] != 1 && $old_profile['ID_GROUP'] != 1) || (((int) $_POST['ID_GROUP'] !=2 && $old_profile['ID_GROUP'] != 2) || $user_info['is_gmod'])))
$profile_vars['ID_GROUP'] = (int) $_POST['ID_GROUP'];

// Find the additional membergroups (if any)
if (isset($_POST['additionalGroups']) && is_array($_POST['additionalGroups']))
{
foreach ($_POST['additionalGroups'] as $i => $group_id)
{
if ((int) $group_id == 0 || (!allowedTo('admin_forum') && ((int) $group_id == 1 || ((int) $group_id == 2 && !$user_info['is_gmod']))))
unset($_POST['additionalGroups'][$i]);
else
$_POST['additionalGroups'][$i] = (int) $group_id;
}

// Put admin back in there if you don't have permission to take it away.
if (!allowedTo('admin_forum') && in_array(1, explode(',', $old_profile['additionalGroups'])))
$_POST['additionalGroups'][] = 1;

// Put global moderator back in there if you don't have permission to take it away.
if ((!allowedTo('admin_forum') && !$user_info['is_gmod']) && in_array(2, explode(',', $old_profile['additionalGroups'])))
$_POST['additionalGroups'][] = 1;

$profile_vars['additionalGroups'] = '\'' . implode(',', $_POST['additionalGroups']) . '\'';
}
Michael Eshom
Christian Metal Fans

Az

Amazing - thankyou very much, exactly what I wanted. I appreciate your help.
To extend upon this is there any way that you can limit other groups other than admin and gmods?
For example I have made a group called 'ArC', and I wouldn't like users to be able to change to that either. How do I stop the option from being displayed?

Thanks again. :)

Advertisement: