Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Removing moderator on forum is reseting gid
#1
Strange bug: when I'm removing moderator on any forum, his gid is "reseting" to standard user gid (2).
His previous gid isn't important (no matter: admin, mod or super-mod).

Can you reproduce?

MyBB v1.4.8
[Image: moderator-btn.png]
#2
I believe that's the way it's supposed to work. We don't keep track of the user's original usergroup (that would be a pain).
Dennis Tsang
Former MyBB Team Member
Web: http://dennistt.net
#3
Without adding an entirely new column to track the users previous usergroup, for one small function, this is currently not possible and as such won't be fixed. This is the intended behavior.
#4
You didn't understand Smile
I don't want to track gids changes.

Moderator changing or removing on forum shouldn't take an effect on somebody GID, because every forum have independent moderator settings. Am I right?
[Image: moderator-btn.png]
#5
You don't understand. In order to revert to an old gid, you have to track them. It is one in the same.
#6
(2009-07-09, 07:29 PM)Ryan Gordon Wrote: You don't understand. In order to revert to an old gid, you have to track them. It is one in the same.

Do you set gid of user, when you add moderator to specific forum? No.
Does MyBB Engine change gid, when you remove moderator from specific forum? Yes.

It's the bug.
[Image: moderator-btn.png]
#7
The way I see it is, your not a moderator anymore if you don't moderate any forums.
#8
(2009-07-09, 11:52 PM)Ryan Gordon Wrote: The way I see it is, your not a moderator anymore if you don't moderate any forums.

So add administrator-user as moderator to forum. Next remove moderator (administrator-user) from this forum. Administrator loose his privileges and his gid will change to 2 (normal user).
[Image: moderator-btn.png]
#9
He is right..I found the problem.

Inside /admin/modules/forum/management.php (deletemod action)

		$db->delete_query("moderators", "mid='{$mid}'");
		$query = $db->simple_select("moderators", "*", "uid='{$mod['uid']}'");
		if($db->num_rows($query) == 0)
		{
			$updatequery = array(
				"usergroup" => "2"
			);
			$db->update_query("users", $updatequery, "uid='{$mod['uid']}' AND usergroup != '4' AND usergroup != '3'");
		}

As you can see if the user is not in group 3 or 4 it reverts them to 2. There might be a group they were in besides 2. Mybb doesn't have to track it and imho shouldn't alter it when adding a forum moderator.

Here is what I think is the add function same file.

		elseif($mybb->input['add'] == "moderators")
		{
			
			$forum = get_forum($fid);
			if(!$forum)
			{
				flash_message($lang->error_invalid_forum, 'error');
				admin_redirect("index.php?module=forum/management&fid={$fid}#tab_moderators");
			}
			$query = $db->simple_select("users", "uid, username", "username='".$db->escape_string($mybb->input['username'])."'", array('limit' => 1));
			$user = $db->fetch_array($query);
			if($user['uid'])
			{
				$query = $db->simple_select("moderators", "uid", "uid='".$user['uid']."' AND fid='".$fid."'", array('limit' => 1));
				$mod = $db->fetch_array($query);
				if(!$mod['uid'])
				{
					$new_mod = array(
						"fid" => $fid,
						"uid" => $user['uid'],
						"caneditposts" => 1,
						"candeleteposts" => 1,
						"canviewips" => 1,
						"canopenclosethreads" => 1,
						"canmanagethreads" => 1,
						"canmovetononmodforum" => 1
					);
					$mid = $db->insert_query("moderators", $new_mod);
					$db->update_query("users", array('usergroup' => 6), "uid='{$user['uid']}' AND usergroup='2'");
					$cache->update_moderators();
					
					$plugins->run_hooks("admin_forum_management_start_moderators_commit");
					
					// Log admin action
					log_admin_action('addmod', $new_mod['fid'], $user['username'], $fid, $forum['name']);
					
					flash_message($lang->success_moderator_added, 'success');
					admin_redirect("index.php?module=forum/management&action=editmod&mid={$mid}");
				}
				else
				{
					flash_message($lang->error_moderator_already_added, 'error');
					admin_redirect("index.php?module=forum/management&fid={$fid}#tab_moderators");
				}
			}
			else
			{
				flash_message($lang->error_moderator_not_found, 'error');
				admin_redirect("index.php?module=forum/management&fid={$fid}#tab_moderators");
			}

Does the moderator group have to be main? Why can't it be an additional usergroup? Personally I have come across this same problem and why I have not assigned individual forum moderators at HF. I am not liking the way Mybb handles it. Since it's only a forum moderator the group should imho be an additional usergroup.

Example of problem.

Member as VIP membership (usergroup 8)
Member is assigned to moderate forum X
Member is now in group 6 as main group when he should be in 8
Member looses all group 8 privileges
Member is eventually removed from forum moderator
Member is now group 2

I hope this clarifies some of the problems with the way it's handled. A few alterations to this one file should fix it. I am assuming all the checks for someone being a forum moderator are based off both usergroup and displaygroup columns. Someone from dev team can hopefully double check that.

The way it's setup now is poor. It's why I don't have any forum moderators on HF yet I need them. Problem is I set someone as a forum moderator and then they can't have the assigned VIP privileges.

Please advise.

EDIT: I have reviewed is_moderator function and apparently it doesn't care about usergroup and read the cache of the moderators table. I don't see where a usergroup is even needed to be group 6. So I believe a good fix is to just assign it an additional usergroup (check it make sure they are not already additional 6) and upon removal just take it out of additionalgroups. I don't see a need to make this the main usergroup.

EDIT 2: On my test forums I have taken a test member and placed them in usergroup 8 with additionalgroup 6 and a moderator on one forum. All the moderator functions appear normal. As a matter of if remove the additionalgroup 6 the moderarator powers still work just fine since the basis of forum moderator is off the table mybb_moderators. This can and should be fixed to be more logical and allow greater control. The need to check for groups 3 or 4 won't even be neccessary under this change. Just make sure they are already not in additionalgroup 6.

Thank you.
#10
(2009-07-10, 01:08 AM)labrocca Wrote: He is right..I found the problem.

Inside /admin/modules/forum/management.php (deletemod action)

/.../

EDIT: I have reviewed is_moderator function and apparently it doesn't care about usergroup and read the cache of the moderators table. I don't see where a usergroup is even needed to be group 6. So I believe a good fix is to just assign it an additional usergroup (check it make sure they are not already additional 6) and upon removal just take it out of additionalgroups. I don't see a need to make this the main usergroup.

That's the point! Smile I have many additional gids, so when I was removing moderators from forums, I didn't know what happened when removed user comes back to gid 2.
Your fix seems to be good. Moderator gid is set as secondary gid and when you remove mod privileges, secondary gid is unset. Any changes in primary group, so user can keep his initial gid.
[Image: moderator-btn.png]


Forum Jump:


Users browsing this thread: 1 Guest(s)