public/IAdminSystem.h
author David Anderson <dvander@alliedmods.net>
Wed Aug 01 01:54:53 2007 +0000 (2007-08-01)
changeset 1226 478550a4d5ec
parent 729 110c14c99545
child 1298 9cddbed74581
permissions -rw-r--r--
updated license headers for most extensions
updated sdk bases for most extensions
     1 /**
     2  * vim: set ts=4 :
     3  * ================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
     6  * ================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or 
     9  * modify it under the terms of the GNU General Public License, 
    10  * version 3.0, as published by the Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful,
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  * GNU General Public License for more details.
    16  *
    17  * You should have received a copy of the GNU General Public License
    18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to 
    21  * link the code of this program (as well as its derivative works) to 
    22  * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any 
    23  * Game MODs that run on software by the Valve Corporation.  You must 
    24  * obey the GNU General Public License in all respects for all other 
    25  * code used. Additionally, AlliedModders LLC grants this exception 
    26  * to all derivative works. AlliedModders LLC defines further 
    27  * exceptions, found in LICENSE.txt (as of this writing, version 
    28  * JULY-31-2007), or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32 
    33 #ifndef _INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_
    34 #define _INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_
    35 
    36 #include <IShareSys.h>
    37 
    38 #define SMINTERFACE_ADMINSYS_NAME		"IAdminSys"
    39 #define SMINTERFACE_ADMINSYS_VERSION	1
    40 
    41 /**
    42  * @file IAdminSystem.h
    43  * @brief Defines the interface to manage the Admin Users/Groups and Override caches.
    44  *
    45  *   The administration system is more of a volatile cache than a system.  It is designed to be 
    46  * temporary rather than permanent, in order to compensate for more storage methods.  For example,
    47  * a flat file might be read into the cache all at once.  But a MySQL-based system might only cache
    48  * admin permissions when that specific admin connects.  
    49  *
    50  *   The override cache is the simplest to explain.  Any time an override is added, any existing 
    51  * and all future commands will gain a new access level set by the override.  If unset, the default
    52  * access level is restored.  This cache is dynamically changeable.
    53  *
    54  *   The group cache contains, for each group:
    55  *	1] A set of inherent flags - fully readable/writable.
    56  *  2] An immunity table - insertion and retrieval only.
    57  *  3] An override table - insertion and retrieval only.
    58  *   Individual groups can be invalidated entirely.  It should be considered an expensive
    59  *  operation, since each admin needs to be patched up to not reference the group.
    60  *
    61  *   For more information, see the SourceMod Development wiki.
    62  */
    63 
    64 namespace SourceMod
    65 {
    66 	/**
    67 	 * @brief Access levels (flags) for admins.
    68 	 */
    69 	enum AdminFlag
    70 	{
    71 		Admin_Reservation = 0,	/**< Reserved slot */
    72 		Admin_Generic,			/**< Generic admin abilities */
    73 		Admin_Kick,				/**< Kick another user */
    74 		Admin_Ban,				/**< Ban another user */
    75 		Admin_Unban,			/**< Unban another user */
    76 		Admin_Slay,				/**< Slay/kill/damage another user */
    77 		Admin_Changemap,		/**< Change the map */
    78 		Admin_Convars,			/**< Change basic convars */
    79 		Admin_Config,			/**< Change configuration */
    80 		Admin_Chat,				/**< Special chat privileges */
    81 		Admin_Vote,				/**< Special vote privileges */
    82 		Admin_Password,			/**< Set a server password */
    83 		Admin_RCON,				/**< Use RCON */
    84 		Admin_Cheats,			/**< Change sv_cheats and use its commands */
    85 		Admin_Root,				/**< All access by default */
    86 		Admin_Custom1,			/**< First custom flag type */
    87 		Admin_Custom2,			/**< Second custom flag type */
    88 		Admin_Custom3,			/**< Third custom flag type */
    89 		Admin_Custom4,			/**< Fourth custom flag type */
    90 		Admin_Custom5,			/**< Fifth custom flag type */
    91 		Admin_Custom6,			/**< Sixth custom flag type */
    92 		/* --- */
    93 		AdminFlags_TOTAL,
    94 	};
    95 
    96 	#define ADMFLAG_RESERVATION			(1<<0)		/**< Convenience macro for Admin_Reservation as a FlagBit */
    97 	#define ADMFLAG_GENERIC				(1<<1)		/**< Convenience macro for Admin_Generic as a FlagBit */
    98 	#define ADMFLAG_KICK				(1<<2)		/**< Convenience macro for Admin_Kick as a FlagBit */
    99 	#define ADMFLAG_BAN					(1<<3)		/**< Convenience macro for Admin_Ban as a FlagBit */
   100 	#define ADMFLAG_UNBAN				(1<<4)		/**< Convenience macro for Admin_Unban as a FlagBit */
   101 	#define ADMFLAG_SLAY				(1<<5)		/**< Convenience macro for Admin_Slay as a FlagBit */
   102 	#define ADMFLAG_CHANGEMAP			(1<<6)		/**< Convenience macro for Admin_Changemap as a FlagBit */
   103 	#define ADMFLAG_CONVARS				(1<<7)		/**< Convenience macro for Admin_Convars as a FlagBit */
   104 	#define ADMFLAG_CONFIG				(1<<8)		/**< Convenience macro for Admin_Config as a FlagBit */
   105 	#define ADMFLAG_CHAT				(1<<9)		/**< Convenience macro for Admin_Chat as a FlagBit */
   106 	#define ADMFLAG_VOTE				(1<<10)		/**< Convenience macro for Admin_Vote as a FlagBit */
   107 	#define ADMFLAG_PASSWORD			(1<<11)		/**< Convenience macro for Admin_Password as a FlagBit */
   108 	#define ADMFLAG_RCON				(1<<12)		/**< Convenience macro for Admin_RCON as a FlagBit */
   109 	#define ADMFLAG_CHEATS				(1<<13)		/**< Convenience macro for Admin_Cheats as a FlagBit */
   110 	#define ADMFLAG_ROOT				(1<<14)		/**< Convenience macro for Admin_Root as a FlagBit */
   111 	#define ADMFLAG_CUSTOM1				(1<<15)		/**< Convenience macro for Admin_Custom1 as a FlagBit */
   112 	#define ADMFLAG_CUSTOM2				(1<<16)		/**< Convenience macro for Admin_Custom2 as a FlagBit */
   113 	#define ADMFLAG_CUSTOM3				(1<<17)		/**< Convenience macro for Admin_Custom3 as a FlagBit */
   114 	#define ADMFLAG_CUSTOM4				(1<<18)		/**< Convenience macro for Admin_Custom4 as a FlagBit */
   115 	#define ADMFLAG_CUSTOM5				(1<<19)		/**< Convenience macro for Admin_Custom5 as a FlagBit */
   116 	#define ADMFLAG_CUSTOM6				(1<<20)		/**< Convenience macro for Admin_Custom6 as a FlagBit */
   117 
   118 	/**
   119 	 * @brief Specifies which type of command to override (command or command group).
   120 	 */
   121 	enum OverrideType
   122 	{
   123 		Override_Command = 1,	/**< Command */
   124 		Override_CommandGroup,	/**< Command group */
   125 	};
   126 
   127 	/**
   128 	 * @brief Specifies how a command is overridden for a user group.
   129 	 */
   130 	enum OverrideRule
   131 	{
   132 		Command_Deny = 0,		/**< Deny access */
   133 		Command_Allow = 1,		/**< Allow access */
   134 	};
   135 
   136 	/**
   137 	 * @brief Specifies a generic immunity type.
   138 	 */
   139 	enum ImmunityType
   140 	{
   141 		Immunity_Default = 1,	/**< Immune from everyone with no immunity */
   142 		Immunity_Global,		/**< Immune from everyone (except root admins) */
   143 	};
   144 
   145 	/**
   146 	 * @brief Defines user access modes.
   147 	 */
   148 	enum AccessMode
   149 	{
   150 		Access_Real,		/**< Access the user has inherently */
   151 		Access_Effective,	/**< Access the user has from their groups */
   152 	};
   153 
   154 	/**
   155 	 * @brief Represents an index to one group.
   156 	 */
   157 	typedef int		GroupId;
   158 
   159 	/**
   160 	 * @brief Represents an index to one user entry.
   161 	 */
   162 	typedef int		AdminId;
   163 
   164 	/**
   165 	 * @brief Represents an invalid/nonexistent group or an erroneous operation.
   166 	 */
   167 	#define INVALID_GROUP_ID	-1
   168 
   169 	/**
   170 	 * @brief Represents an invalid/nonexistent user or an erroneous operation.
   171 	 */
   172 	#define INVALID_ADMIN_ID	-1
   173 
   174 	/**
   175 	 * @brief Represents the various cache regions.
   176 	 */
   177 	enum AdminCachePart
   178 	{
   179 		AdminCache_Overrides = 0,		/**< Global overrides */
   180 		AdminCache_Groups = 1,			/**< All groups (automatically invalidates admins too) */
   181 		AdminCache_Admins = 2,			/**< All admins */
   182 	};
   183 
   184 	/**
   185 	 * @brief Provides callbacks for admin cache operations.
   186 	 */
   187 	class IAdminListener
   188 	{
   189 	public:
   190 		virtual unsigned int GetInterfaceVersion()
   191 		{
   192 			return SMINTERFACE_ADMINSYS_VERSION;
   193 		}
   194 	public:
   195 		/**
   196 		 * @brief Called when the admin cache needs to be rebuilt.  
   197 		 *
   198 		 * @param auto_rebuild		True if this is being called because of a group rebuild.
   199 		 */
   200 		virtual void OnRebuildAdminCache(bool auto_rebuild) =0;
   201 
   202 		/**
   203 		 * @brief Called when the group cache needs to be rebuilt.
   204 		 */
   205 		virtual void OnRebuildGroupCache() =0;
   206 		
   207 		/**
   208 		 * @brief Called when the global override cache needs to be rebuilt.
   209 		 */
   210 		virtual void OnRebuildOverrideCache() =0;
   211 	};
   212 
   213 	/**
   214 	 * @brief Admin permission levels.
   215 	 */
   216 	typedef unsigned int FlagBits;
   217 
   218 	/**
   219 	 * @brief Provides functions for manipulating the admin options cache.
   220 	 */
   221 	class IAdminSystem : public SMInterface
   222 	{
   223 	public:
   224 		const char *GetInterfaceName()
   225 		{
   226 			return SMINTERFACE_ADMINSYS_NAME;
   227 		}
   228 		unsigned int GetInterfaceVersion()
   229 		{
   230 			return SMINTERFACE_ADMINSYS_VERSION;
   231 		}
   232 	public:
   233 		/**
   234 		 * @brief Adds a global command flag override.  Any command registered with this name
   235 		 * will assume the new flag.  This is applied retroactively as well.
   236 		 *
   237 		 * @param cmd			String containing command name (case sensitive).
   238 		 * @param type			Override type (specific command or group).
   239 		 * @param flags			New admin flag.
   240 		 */
   241 		virtual void AddCommandOverride(const char *cmd, OverrideType type, FlagBits flags) =0;
   242 
   243 		/**
   244 		 * @brief Returns a command override.
   245 		 *
   246 		 * @param cmd			String containing command name (case sensitive).
   247 		 * @param type			Override type (specific command or group).
   248 		 * @param pFlags		Optional pointer to the set flag.
   249 		 * @return				True if there is an override, false otherwise.
   250 		 */
   251 		virtual bool GetCommandOverride(const char *cmd, OverrideType type, FlagBits *pFlags) =0;
   252 
   253 		/**
   254 		 * @brief Unsets a command override.
   255 		 *
   256 		 * @param cmd			String containing command name (case sensitive).
   257 		 * @param type			Override type (specific command or group).
   258 		 */
   259 		virtual void UnsetCommandOverride(const char *cmd, OverrideType type) =0;
   260 
   261 		/**
   262 		 * @brief Adds a new group.  Name must be unique.
   263 		 *
   264 		 * @param group_name	String containing the group name.
   265 		 * @return				A new group id, INVALID_GROUP_ID if it already exists.
   266 		 */
   267 		virtual GroupId AddGroup(const char *group_name) =0;
   268 
   269 		/**
   270 		 * @brief Finds a group by name.
   271 		 *
   272 		 * @param group_name	String containing the group name.
   273 		 * @return				A group id, or INVALID_GROUP_ID if not found.
   274 		 */
   275 		virtual GroupId FindGroupByName(const char *group_name) =0;
   276 
   277 		/**
   278 		 * @brief Adds or removes a flag from a group's flag set.
   279 		 * Note: These are called "add flags" because they add to a user's flags.
   280 		 *
   281 		 * @param id			Group id.
   282 		 * @param flag			Admin flag to toggle.
   283 		 * @param enabled		True to set the flag, false to unset/disable.
   284 		 */
   285 		virtual void SetGroupAddFlag(GroupId id, AdminFlag flag, bool enabled) =0;
   286 
   287 		/**
   288 		 * @brief Gets the set value of an add flag on a group's flag set.
   289 		 *
   290 		 * @param id			Group id.
   291 		 * @param flag			Admin flag to retrieve.
   292 		 * @return				True if enabled, false otherwise,
   293 		 */
   294 		virtual bool GetGroupAddFlag(GroupId id, AdminFlag flag) =0;
   295 
   296 		/**
   297 		 * @brief Returns an array of flag bits that are added to a user from their group.
   298 		 * Note: These are called "add flags" because they add to a user's flags.
   299 		 *
   300 		 * @param id			GroupId of the group.
   301 		 * @return				Bit string containing the bits of each flag.
   302 		 */
   303 		virtual FlagBits GetGroupAddFlags(GroupId id) =0;
   304 
   305 		/**
   306 		 * @brief Toggles a generic immunity type.
   307 		 *
   308 		 * @param id			Group id.
   309 		 * @param type			Generic immunity type.
   310 		 * @param enabled		True to enable, false otherwise.
   311 		 */
   312 		virtual void SetGroupGenericImmunity(GroupId id, ImmunityType type, bool enabled) =0;
   313 
   314 		/**
   315 		 * @brief Returns whether or not a group has global immunity.
   316 		 *
   317 		 * @param id			Group id.
   318 		 * @param type			Generic immunity type.
   319 		 * @return				True if the group has this immunity, false otherwise.
   320 		 */
   321 		virtual bool GetGroupGenericImmunity(GroupId id, ImmunityType type) =0;
   322 
   323 		/**
   324 		 * @brief Adds immunity to a specific group.
   325 		 *
   326 		 * @param id			Group id.
   327 		 * @param other_id		Group id to receive immunity to.
   328 		 */
   329 		virtual void AddGroupImmunity(GroupId id, GroupId other_id) =0;
   330 
   331 		/**
   332 		 * @brief Returns the number of specific group immunities.
   333 		 *
   334 		 * @param id			Group id.
   335 		 * @return				Number of group immunities.
   336 		 */
   337 		virtual unsigned int GetGroupImmunityCount(GroupId id) =0;
   338 
   339 		/**
   340 		 * @brief Returns a group that this group is immune to given an index.
   341 		 *
   342 		 * @param id			Group id.
   343 		 * @param number		Index from 0 to N-1, from GetGroupImmunities().
   344 		 * @return				GroupId that this group is immune to.
   345 		 */
   346 		virtual GroupId GetGroupImmunity(GroupId id, unsigned int number) =0;
   347 
   348 		/**
   349 		 * @brief Adds a group-specific override type.
   350 		 *
   351 		 * @param id			Group id.
   352 		 * @param name			String containing command name (case sensitive).
   353 		 * @param type			Override type (specific command or group).
   354 		 * @param rule			Override allow/deny setting.
   355 		 */
   356 		virtual void AddGroupCommandOverride(GroupId id,
   357 											 const char *name,
   358 											 OverrideType type,
   359 											 OverrideRule rule) =0;
   360 
   361 		/**
   362 		 * @brief Retrieves a group-specific command override.
   363 		 *
   364 		 * @param id			Group id.
   365 		 * @param name			String containing command name (case sensitive).
   366 		 * @param type			Override type (specific command or group).
   367 		 * @param pRule			Optional pointer to store allow/deny setting.
   368 		 * @return				True if an override exists, false otherwise.
   369 		 */
   370 		virtual bool GetGroupCommandOverride(GroupId id,
   371 											 const char *name,
   372 											 OverrideType type,
   373 											 OverrideRule *pRule) =0;
   374 
   375 		/**
   376 		 * @brief Tells the admin system to dump a portion of the cache.  
   377 		 * This calls into plugin forwards to rebuild the cache.
   378 		 *
   379 		 * @param part			Portion of the cache to dump.
   380 		 * @param rebuild		If true, the rebuild forwards/events will fire.
   381 		 */
   382 		virtual void DumpAdminCache(AdminCachePart part, bool rebuild) =0;
   383 
   384 		/**
   385 		 * @brief Adds an admin interface listener.
   386 		 *
   387 		 * @param pListener		Pointer to an IAdminListener to add.
   388 		 */
   389 		virtual void AddAdminListener(IAdminListener *pListener) =0;
   390 
   391 		/**
   392 		 * @brief Removes an admin interface listener.
   393 		 *
   394 		 * @param pListener		Pointer to an IAdminListener to remove.
   395 		 */
   396 		virtual void RemoveAdminListener(IAdminListener *pListener) =0;
   397 
   398 		/**
   399 		 * @brief Registers an authentication identity type.
   400 		 * Note: Default types are "steam," "name," and "ip."
   401 		 *
   402 		 * @param name			String containing the type name.
   403 		 */
   404 		virtual void RegisterAuthIdentType(const char *name) =0;
   405 
   406 		/**
   407 		 * @brief Creates a new user entry.
   408 		 *
   409 		 * @param name		Name for this entry (does not have to be unique).
   410 		 *					Specify NULL for an anonymous admin.
   411 		 * @return			A new AdminId index.
   412 		 */
   413 		virtual AdminId CreateAdmin(const char *name) =0;
   414 
   415 		/**
   416 		 * @brief Gets an admin's user name.
   417 		 *
   418 		 * @param id		AdminId index for this admin.
   419 		 * @return			A string containing the admin's name, or NULL
   420 		 *					if the admin was created anonymously.
   421 		 */
   422 		virtual const char *GetAdminName(AdminId id) =0;
   423 
   424 		/**
   425 		 * @brief Binds a user entry to a particular auth method.
   426 		 * This bind must be unique.
   427 		 *
   428 		 * @param id		AdminId index of the admin.
   429 		 * @param auth		Auth method to use.
   430 		 * @param ident		Identity string to bind to.
   431 		 * @return			True on success, false if auth method was not found,
   432 		 *					id was invalid, or ident was already taken.
   433 		 */
   434 		virtual bool BindAdminIdentity(AdminId id, const char *auth, const char *ident) =0;
   435 
   436 		/**
   437 		 * @brief Sets whether or not a flag is enabled on an admin.
   438 		 *
   439 		 * @param id		AdminId index of the admin.
   440 		 * @param flag		Admin flag to use.
   441 		 * @param enabled	True to enable, false to disable.
   442 		 */
   443 		virtual void SetAdminFlag(AdminId id, AdminFlag flag, bool enabled) =0;
   444 
   445 		/**
   446 		 * @brief Returns whether or not a flag is enabled on an admin.
   447 		 *
   448 		 * @param id		AdminId index of the admin.
   449 		 * @param flag		Admin flag to use.
   450 		 * @param mode		Access mode to check.
   451 		 * @return			True if enabled, false otherwise.
   452 		 */
   453 		virtual bool GetAdminFlag(AdminId id, AdminFlag flag, AccessMode mode) =0;
   454 
   455 		/**
   456 		 * @brief Returns the bitstring of access flags on an admin.
   457 		 *
   458 		 * @param id		AdminId index of the admin.
   459 		 * @param mode		Access mode to use.
   460 		 * @return			A bit string containing which flags are enabled.
   461 		 */
   462 		virtual FlagBits GetAdminFlags(AdminId id, AccessMode mode) =0;
   463 
   464 		/**
   465 		 * @brief Sets the bitstring of access flags on an admin.
   466 		 *
   467 		 * @param id		AdminId index of the admin.
   468 		 * @param mode		Access mode to use (real affects both).
   469 		 * @param bits		Bitstring to set.
   470 		 */
   471 		virtual void SetAdminFlags(AdminId id, AccessMode mode, FlagBits bits) =0;
   472 
   473 		/**
   474 		 * @brief Adds a group to an admin's inherited group list.  
   475 		 * Any flags the group has will be added to the admin's effective flags.
   476 		 *
   477 		 * @param id		AdminId index of the admin.
   478 		 * @param gid		GroupId index of the group.
   479 		 * @return			True on success, false on invalid input or duplicate membership.
   480 		 */
   481 		virtual bool AdminInheritGroup(AdminId id, GroupId gid) =0;
   482 
   483 		/**
   484 		 * @brief Returns the number of groups this admin is a member of.
   485 		 * 
   486 		 * @param id		AdminId index of the admin.
   487 		 * @return			Number of groups this admin is a member of.
   488 		 */
   489 		virtual unsigned int GetAdminGroupCount(AdminId id) =0;
   490 
   491 		/**
   492 		 * @brief Returns group information from an admin.
   493 		 *
   494 		 * @param id		AdminId index of the admin.
   495 		 * @param index		Group number to retrieve, from 0 to N-1, where N
   496 		 *					is the value of GetAdminGroupCount(id).
   497 		 * @param name		Optional pointer to store the group's name.
   498 		 * @return			A GroupId index and a name pointer, or
   499 		 *					INVALID_GROUP_ID and NULL if an error occurred.
   500 		 */
   501 		virtual GroupId GetAdminGroup(AdminId id, unsigned int index, const char **name) =0;
   502 		
   503 		/**
   504 		 * @brief Sets a password on an admin.
   505 		 *
   506 		 * @param id		AdminId index of the admin.
   507 		 * @param password	String containing the password.
   508 		 */
   509 		virtual void SetAdminPassword(AdminId id, const char *password) =0;
   510 
   511 		/**
   512 		 * @brief Gets an admin's password.
   513 		 *
   514 		 * @param id		AdminId index of the admin.
   515 		 * @return			Password of the admin, or NULL if none.
   516 		 */
   517 		virtual const char *GetAdminPassword(AdminId id) =0;
   518 		
   519 		/**
   520 		 * @brief Attempts to find an admin by an auth method and an identity.
   521 		 *
   522 		 * @param auth		Auth method to try.
   523 		 * @param identity	Identity string to look up.
   524 		 * @return			An AdminId index if found, INVALID_ADMIN_ID otherwise.
   525 		 */
   526 		virtual AdminId FindAdminByIdentity(const char *auth, const char *identity) =0;
   527 
   528 		/**
   529 		 * @brief Invalidates an admin from the cache so its resources can be re-used.
   530 		 *
   531 		 * @param id		AdminId index to invalidate.
   532 		 * @return			True on success, false otherwise.
   533 		 */
   534 		virtual bool InvalidateAdmin(AdminId id) =0;
   535 
   536 		/**
   537 		 * @brief Converts a flag bit string to a bit array.
   538 		 *
   539 		 * @param bits		Bit string containing the flags.
   540 		 * @param array		Array to write the flags to.  Enabled flags will be 'true'.
   541 		 * @param maxSize	Maximum number of flags the array can store.
   542 		 * @return			Number of flags written.
   543 		 */
   544 		virtual unsigned int FlagBitsToBitArray(FlagBits bits, bool array[], unsigned int maxSize) =0;
   545 
   546 		/**
   547 		 * @brief Converts a flag array to a bit string.
   548 		 *
   549 		 * @param array		Array containing true or false for each AdminFlag.
   550 		 * @param maxSize	Maximum size of the flag array.
   551 		 * @return			A bit string composed of the array bits.
   552 		 */
   553 		virtual FlagBits FlagBitArrayToBits(const bool array[], unsigned int maxSize) =0;
   554 
   555 		/**
   556 		 * @brief Converts an array of flags to bits.
   557 		 *
   558 		 * @param array		Array containing flags that are enabled.
   559 		 * @param numFlags	Number of flags in the array.
   560 		 * @return			A bit string composed of the array flags.
   561 		 */
   562 		virtual FlagBits FlagArrayToBits(const AdminFlag array[], unsigned int numFlags) =0;
   563 
   564 		/**
   565 		 * @brief Converts a bit string to an array of flags.
   566 		 *
   567 		 * @param bits		Bit string containing the flags.
   568 		 * @param array		Output array to write flags.
   569 		 * @param maxSize	Maximum size of the flag array.
   570 		 * @return			Number of flags written.
   571 		 */
   572 		virtual unsigned int FlagBitsToArray(FlagBits bits, AdminFlag array[], unsigned int maxSize) =0;
   573 
   574 		/**
   575 		 * @brief Checks whether a user has access to a given set of flag bits.
   576 		 * Note: This is a wrapper around GetAdminFlags().
   577 		 *
   578 		 * @param id		AdminId index of admin.
   579 		 * @param bits		Bitstring containing the permissions to check.
   580 		 * @return			True if user has permission, false otherwise.
   581 		 */
   582 		virtual bool CheckAdminFlags(AdminId id, FlagBits bits) =0;
   583 
   584 		/**
   585 		 * @brief Checks whether an AdminId can target another AdminId.
   586 		 * 
   587 		 * Zeroth, if the targeting AdminId is INVALID_ADMIN_ID, targeting fails.
   588 		 * First, if the targeted AdminId is INVALID_ADMIN_ID, targeting succeeds.
   589 		 * Second, if the targeting admin is root, targeting succeeds.
   590 		 * Third, if the targeted admin has global immunity, targeting fails.
   591 		 * Fourth, if the targeted admin has default immunity,
   592 		 *  and the admin belongs to no groups, targeting fails.
   593 		 * Fifth, if the targeted admin has specific immunity from the
   594 		 *  targeting admin via group immunities, targeting fails.
   595 		 * Sixth, targeting succeeds if it passes these tests.
   596 		 *
   597 		 * @param id		AdminId index of admin doing the targeting.  Can be INVALID_ADMIN_ID.
   598 		 * @param target	AdminId index of the target admin.  Can be INVALID_ADMIN_ID.
   599 		 * @return			True if this admin has permission to target the other admin.
   600 		 */
   601 		virtual bool CanAdminTarget(AdminId id, AdminId target) =0;
   602 	};
   603 }
   604 
   605 #endif //_INCLUDE_SOURCEMOD_ADMINISTRATION_SYSTEM_H_