core/AdminCache.cpp
changeset 1349 0d84046ec139
parent 1330 ab94316bb52b
child 1356 4688fae59bcf
     1.1 --- a/core/AdminCache.cpp	Sat Aug 18 17:15:22 2007 +0000
     1.2 +++ b/core/AdminCache.cpp	Sat Aug 18 19:43:37 2007 +0000
     1.3 @@ -445,6 +445,7 @@
     1.4  	pUser->auth.index = 0;
     1.5  	pUser->immune_default = false;
     1.6  	pUser->immune_global = false;
     1.7 +	pUser->serialchange = 1;
     1.8  
     1.9  	if (m_FirstUser == INVALID_ADMIN_ID)
    1.10  	{
    1.11 @@ -843,6 +844,9 @@
    1.12  	pUser->next_user = m_FreeUserList;
    1.13  	m_FreeUserList = id;
    1.14  
    1.15 +	/* Unset serial change */
    1.16 +	pUser->serialchange = 0;
    1.17 +
    1.18  	return true;
    1.19  }
    1.20  
    1.21 @@ -925,6 +929,8 @@
    1.22  						pOther = (AdminGroup *)m_pMemory->GetAddress(table[j]);
    1.23  						pUser->eflags |= pOther->addflags;
    1.24  					}
    1.25 +					/* Mark as changed */
    1.26 +					pUser->serialchange++;
    1.27  					/* Break now, duplicates aren't allowed */
    1.28  					break;
    1.29  				}
    1.30 @@ -1172,6 +1178,8 @@
    1.31  		pUser->flags &= ~bits;
    1.32  		pUser->eflags &= ~bits;
    1.33  	}
    1.34 +
    1.35 +	pUser->serialchange++;
    1.36  }
    1.37  
    1.38  bool AdminCache::GetAdminFlag(AdminId id, AdminFlag flag, AccessMode mode)
    1.39 @@ -1238,6 +1246,8 @@
    1.40  	} else if (mode == Access_Effective) {
    1.41  		pUser->eflags = bits;
    1.42  	}
    1.43 +
    1.44 +	pUser->serialchange++;
    1.45  }
    1.46  
    1.47  bool AdminCache::AdminInheritGroup(AdminId id, GroupId gid)
    1.48 @@ -1312,6 +1322,8 @@
    1.49  		pUser->immune_global = true;
    1.50  	}
    1.51  
    1.52 +	pUser->serialchange++;
    1.53 +
    1.54  	return true;
    1.55  }
    1.56  
    1.57 @@ -1551,3 +1563,36 @@
    1.58  
    1.59  	return bits;
    1.60  }
    1.61 +
    1.62 +unsigned int AdminCache::GetAdminSerialChange(AdminId id)
    1.63 +{
    1.64 +	AdminUser *pUser = (AdminUser *)m_pMemory->GetAddress(id);
    1.65 +	if (!pUser || pUser->magic != USR_MAGIC_SET)
    1.66 +	{
    1.67 +		return 0;
    1.68 +	}
    1.69 +
    1.70 +	return pUser->serialchange;
    1.71 +}
    1.72 +
    1.73 +bool AdminCache::CanAdminUseCommand(int client, const char *cmd)
    1.74 +{
    1.75 +	FlagBits bits;
    1.76 +	OverrideType otype = Override_Command;
    1.77 +
    1.78 +	if (cmd[0] == '@')
    1.79 +	{
    1.80 +		otype = Override_CommandGroup;
    1.81 +		cmd++;
    1.82 +	}
    1.83 +
    1.84 +	if (!g_ConCmds.LookForCommandAdminFlags(cmd, &bits))
    1.85 +	{
    1.86 +		if (!GetCommandOverride(cmd, otype, &bits))
    1.87 +		{
    1.88 +			bits = 0;
    1.89 +		}
    1.90 +	}
    1.91 +
    1.92 +	return g_ConCmds.CheckCommandAccess(client, cmd, bits);
    1.93 +}