RankMgr: Renamed PermissionGroup to Group in API and PermGroup in DB.
"Group" is SQL keyword and shouldn't be used as table name.
This commit is contained in:
parent
a717a7e712
commit
670e94bfeb
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
//*
|
||||||
// This code is for internal testing while developing the cRankManager class
|
// This code is for internal testing while developing the cRankManager class
|
||||||
static class cRankMgrTest
|
static class cRankMgrTest
|
||||||
{
|
{
|
||||||
@ -38,7 +38,7 @@ public:
|
|||||||
std::cout << " Rank: '" << m_Mgr.GetPlayerRankName(UUID) << "'." << std::endl;
|
std::cout << " Rank: '" << m_Mgr.GetPlayerRankName(UUID) << "'." << std::endl;
|
||||||
|
|
||||||
// List all the permission groups for the player:
|
// List all the permission groups for the player:
|
||||||
AStringVector Groups = m_Mgr.GetPlayerPermissionGroups(UUID);
|
AStringVector Groups = m_Mgr.GetPlayerGroups(UUID);
|
||||||
std::cout << " Groups(" << Groups.size() << "):" << std::endl;
|
std::cout << " Groups(" << Groups.size() << "):" << std::endl;
|
||||||
for (AStringVector::const_iterator itr = Groups.begin(), end = Groups.end(); itr != end; ++itr)
|
for (AStringVector::const_iterator itr = Groups.begin(), end = Groups.end(); itr != end; ++itr)
|
||||||
{
|
{
|
||||||
@ -72,9 +72,9 @@ cRankManager::cRankManager(void) :
|
|||||||
// Create the DB tables, if they don't exist:
|
// Create the DB tables, if they don't exist:
|
||||||
m_DB.exec("CREATE TABLE IF NOT EXISTS Rank (RankID INTEGER PRIMARY KEY, Name, MsgPrefix, MsgPostfix, MsgNameColorCode)");
|
m_DB.exec("CREATE TABLE IF NOT EXISTS Rank (RankID INTEGER PRIMARY KEY, Name, MsgPrefix, MsgPostfix, MsgNameColorCode)");
|
||||||
m_DB.exec("CREATE TABLE IF NOT EXISTS PlayerRank (PlayerUUID, PlayerName, RankID INTEGER)");
|
m_DB.exec("CREATE TABLE IF NOT EXISTS PlayerRank (PlayerUUID, PlayerName, RankID INTEGER)");
|
||||||
m_DB.exec("CREATE TABLE IF NOT EXISTS PermissionGroup (GroupID INTEGER PRIMARY KEY, Name)");
|
m_DB.exec("CREATE TABLE IF NOT EXISTS PermGroup (PermGroupID INTEGER PRIMARY KEY, Name)");
|
||||||
m_DB.exec("CREATE TABLE IF NOT EXISTS RankPermissionGroups (RankID INTEGER, GroupID INTEGER)");
|
m_DB.exec("CREATE TABLE IF NOT EXISTS RankPermGroup (RankID INTEGER, PermGroupID INTEGER)");
|
||||||
m_DB.exec("CREATE TABLE IF NOT EXISTS PermissionItem (GroupID INTEGER, Permission)");
|
m_DB.exec("CREATE TABLE IF NOT EXISTS PermissionItem (PermGroupID INTEGER, Permission)");
|
||||||
|
|
||||||
// TODO: Check if tables empty, add some defaults then
|
// TODO: Check if tables empty, add some defaults then
|
||||||
}
|
}
|
||||||
@ -100,15 +100,15 @@ AString cRankManager::GetPlayerRankName(const AString & a_PlayerUUID)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
AStringVector cRankManager::GetPlayerPermissionGroups(const AString & a_PlayerUUID)
|
AStringVector cRankManager::GetPlayerGroups(const AString & a_PlayerUUID)
|
||||||
{
|
{
|
||||||
// Prepare the DB statement:
|
// Prepare the DB statement:
|
||||||
SQLite::Statement stmt(m_DB,
|
SQLite::Statement stmt(m_DB,
|
||||||
"SELECT PermissionGroup.Name FROM PermissionGroup "
|
"SELECT Group.Name FROM Group "
|
||||||
"LEFT JOIN RankPermissionGroups "
|
"LEFT JOIN RankGroups "
|
||||||
"ON PermissionGroup.GroupID = RankPermissionGroups.GroupID "
|
"ON Group.GroupID = RankGroups.GroupID "
|
||||||
"LEFT JOIN PlayerRank "
|
"LEFT JOIN PlayerRank "
|
||||||
"ON PlayerRank.RankID = RankPermissionGroups.RankID "
|
"ON PlayerRank.RankID = RankGroups.RankID "
|
||||||
"WHERE PlayerRank.PlayerUUID = ?"
|
"WHERE PlayerRank.PlayerUUID = ?"
|
||||||
);
|
);
|
||||||
stmt.bind(1, a_PlayerUUID);
|
stmt.bind(1, a_PlayerUUID);
|
||||||
@ -131,10 +131,10 @@ AStringVector cRankManager::GetPlayerPermissions(const AString & a_PlayerUUID)
|
|||||||
// Prepare the DB statement:
|
// Prepare the DB statement:
|
||||||
SQLite::Statement stmt(m_DB,
|
SQLite::Statement stmt(m_DB,
|
||||||
"SELECT PermissionItem.Permission FROM PermissionItem "
|
"SELECT PermissionItem.Permission FROM PermissionItem "
|
||||||
"LEFT JOIN RankPermissionGroups "
|
"LEFT JOIN RankGroups "
|
||||||
"ON PermissionItem.GroupID = RankPermissionGroups.GroupID "
|
"ON PermissionItem.GroupID = RankGroups.GroupID "
|
||||||
"LEFT JOIN PlayerRank "
|
"LEFT JOIN PlayerRank "
|
||||||
"ON PlayerRank.RankID = RankPermissionGroups.RankID "
|
"ON PlayerRank.RankID = RankGroups.RankID "
|
||||||
"WHERE PlayerRank.PlayerUUID = ?"
|
"WHERE PlayerRank.PlayerUUID = ?"
|
||||||
);
|
);
|
||||||
stmt.bind(1, a_PlayerUUID);
|
stmt.bind(1, a_PlayerUUID);
|
||||||
|
@ -22,23 +22,26 @@ public:
|
|||||||
/** Returns the name of the rank that the specified player has assigned to them. */
|
/** Returns the name of the rank that the specified player has assigned to them. */
|
||||||
AString GetPlayerRankName(const AString & a_PlayerUUID);
|
AString GetPlayerRankName(const AString & a_PlayerUUID);
|
||||||
|
|
||||||
/** Returns the names of PermissionGroups that the specified player has assigned to them. */
|
/** Returns the names of Groups that the specified player has assigned to them. */
|
||||||
AStringVector GetPlayerPermissionGroups(const AString & a_PlayerUUID);
|
AStringVector GetPlayerGroups(const AString & a_PlayerUUID);
|
||||||
|
|
||||||
/** Returns the permissions that the specified player has assigned to them. */
|
/** Returns the permissions that the specified player has assigned to them. */
|
||||||
AStringVector GetPlayerPermissions(const AString & a_PlayerUUID);
|
AStringVector GetPlayerPermissions(const AString & a_PlayerUUID);
|
||||||
|
|
||||||
/** Returns the names of groups that the specified rank has assigned to it. */
|
/** Returns the names of groups that the specified rank has assigned to it. */
|
||||||
AStringVector GetRankPermissionGroups(const AString & a_RankName);
|
AStringVector GetRankGroups(const AString & a_RankName);
|
||||||
|
|
||||||
/** Returns the permissions that the specified permission group has assigned to it. */
|
/** Returns the permissions that the specified group has assigned to it. */
|
||||||
AStringVector GetPermissionGroupPermissiont(const AString & a_GroupName);
|
AStringVector GetGroupPermissions(const AString & a_GroupName);
|
||||||
|
|
||||||
|
/** Returns all permissions that the specified rank has assigned to it, through all its groups. */
|
||||||
|
AStringVector GetRankPermissions(const AString & a_RankName);
|
||||||
|
|
||||||
/** Returns the names of all defined ranks. */
|
/** Returns the names of all defined ranks. */
|
||||||
AStringVector GetAllRanks(void);
|
AStringVector GetAllRanks(void);
|
||||||
|
|
||||||
/** Returns the names of all permission groups. */
|
/** Returns the names of all permission groups. */
|
||||||
AStringVector GetAllPermissionGroups(void);
|
AStringVector GetAllGroups(void);
|
||||||
|
|
||||||
/** Returns all the distinct permissions that are stored in the DB. */
|
/** Returns all the distinct permissions that are stored in the DB. */
|
||||||
AStringVector GetAllPermissions(void);
|
AStringVector GetAllPermissions(void);
|
||||||
@ -60,37 +63,42 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
/** Adds a new permission group. No action if such a group already exists. */
|
/** Adds a new permission group. No action if such a group already exists. */
|
||||||
void AddPermissionGroup(const AString & a_GroupName);
|
void AddGroup(const AString & a_GroupName);
|
||||||
|
|
||||||
/** Adds the specified permission group to the specified rank.
|
/** Adds the specified permission group to the specified rank.
|
||||||
Fails if the rank or group names are not found.
|
Fails if the rank or group names are not found.
|
||||||
Returns true if successful, false on error. */
|
Returns true if successful, false on error. */
|
||||||
bool AddPermissionGroupToRank(const AString & a_RankName, const AString & a_GroupName);
|
bool AddGroupToRank(const AString & a_RankName, const AString & a_GroupName);
|
||||||
|
|
||||||
/** Adds the specified permission to the specified permission group.
|
/** Adds the specified permission to the specified permission group.
|
||||||
Fails if the permission group name is not found.
|
Fails if the permission group name is not found.
|
||||||
Returns true if successful, false on error. */
|
Returns true if successful, false on error. */
|
||||||
bool AddPermissionToPermissionGroup(const AString & a_Permission, const AString & a_GroupName);
|
bool AddPermissionToGroup(const AString & a_Permission, const AString & a_GroupName);
|
||||||
|
|
||||||
/** Removes the specified rank.
|
/** Removes the specified rank.
|
||||||
All players assigned to that rank will be re-assigned to a_ReplacementRankName, unless it is empty. */
|
All players assigned to that rank will be re-assigned to a_ReplacementRankName, unless it is empty. */
|
||||||
void RemoveRank(const AString & a_RankName, const AString & a_ReplacementRankName);
|
void RemoveRank(const AString & a_RankName, const AString & a_ReplacementRankName);
|
||||||
|
|
||||||
/** Removes the specified permission group. */
|
/** Removes the specified group completely.
|
||||||
void RemovePermissionGroup(const AString & a_PermissionGroup);
|
The group will first be removed from all ranks using it, and then removed itself. */
|
||||||
|
void RemoveGroup(const AString & a_GroupName);
|
||||||
|
|
||||||
/** Removes the specified permission from the specified permission group. */
|
/** Removes the specified group from the specified rank.
|
||||||
void RemovePermission(const AString & a_Permission, const AString & a_PermissionGroup);
|
The group will stay defined, even if no rank is using it. */
|
||||||
|
void RemoveGroupFromRank(const AString & a_RankName, const AString & a_GroupName);
|
||||||
|
|
||||||
|
/** Removes the specified permission from the specified group. */
|
||||||
|
void RemovePermissionFromGroup(const AString & a_Permission, const AString & a_GroupName);
|
||||||
|
|
||||||
/** Renames the specified rank. No action if the rank name is not found.
|
/** Renames the specified rank. No action if the rank name is not found.
|
||||||
Fails if the new name is already used.
|
Fails if the new name is already used.
|
||||||
Returns true on success, false on failure. */
|
Returns true on success, false on failure. */
|
||||||
bool RenameRank(const AString & a_OldName, const AString & a_NewName);
|
bool RenameRank(const AString & a_OldName, const AString & a_NewName);
|
||||||
|
|
||||||
/** Renames the specified permission group. No action if the rank name is not found.
|
/** Renames the specified group. No action if the rank name is not found.
|
||||||
Fails if the new name is already used.
|
Fails if the new name is already used.
|
||||||
Returns true on success, false on failure. */
|
Returns true on success, false on failure. */
|
||||||
bool RenamePermissionGroup(const AString & a_OldName, const AString & a_NewName);
|
bool RenameGroup(const AString & a_OldName, const AString & a_NewName);
|
||||||
|
|
||||||
/** Sets the specified player's rank.
|
/** Sets the specified player's rank.
|
||||||
If the player already had rank assigned to them, it is overwritten with the new rank.
|
If the player already had rank assigned to them, it is overwritten with the new rank.
|
||||||
|
Loading…
Reference in New Issue
Block a user