Changed 'Operator' Level to 'Moderator'

This commit is contained in:
Steffen Schröder 2013-12-31 17:17:11 +01:00
parent 6f4320ff75
commit dcb4e3f951
9 changed files with 69 additions and 45 deletions

View File

@ -8,6 +8,6 @@
<login>kremsy</login> <login>kremsy</login>
</masteradmins> </masteradmins>
<!-- You can add other admins and operators ingame --> <!-- You can add other admins and moderators ingame -->
</authentication-config> </authentication-config>

View File

@ -28,7 +28,7 @@ class AuthCommands implements CommandListener {
// Register for commands // Register for commands
$this->maniaControl->commandManager->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin',true); $this->maniaControl->commandManager->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin',true);
$this->maniaControl->commandManager->registerCommandListener('addadmin', $this, 'command_AddAdmin',true); $this->maniaControl->commandManager->registerCommandListener('addadmin', $this, 'command_AddAdmin',true);
$this->maniaControl->commandManager->registerCommandListener('addop', $this, 'command_AddOperator',true); $this->maniaControl->commandManager->registerCommandListener('addmod', $this, 'command_AddModerator',true);
} }
/** /**
@ -94,12 +94,12 @@ class AuthCommands implements CommandListener {
} }
/** /**
* Handle //addop command * Handle //addmod command
* *
* @param array $chatCallback * @param array $chatCallback
* @param Player $player * @param Player $player
*/ */
public function command_AddOperator(array $chatCallback, Player $player) { public function command_AddModerator(array $chatCallback, Player $player) {
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) { if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
@ -107,7 +107,7 @@ class AuthCommands implements CommandListener {
$text = $chatCallback[1][2]; $text = $chatCallback[1][2];
$commandParts = explode(' ', $text); $commandParts = explode(' ', $text);
if (!array_key_exists(1, $commandParts)) { if (!array_key_exists(1, $commandParts)) {
$this->sendAddOperatorUsageInfo($player); $this->sendAddModeratorUsageInfo($player);
return; return;
} }
$target = $this->maniaControl->playerManager->getPlayer($commandParts[1]); $target = $this->maniaControl->playerManager->getPlayer($commandParts[1]);
@ -115,12 +115,12 @@ class AuthCommands implements CommandListener {
$this->maniaControl->chat->sendError("Player '{$commandParts[1]}' not found!", $player->login); $this->maniaControl->chat->sendError("Player '{$commandParts[1]}' not found!", $player->login);
return; return;
} }
$success = $this->maniaControl->authenticationManager->grantAuthLevel($player, AuthenticationManager::AUTH_LEVEL_OPERATOR); $success = $this->maniaControl->authenticationManager->grantAuthLevel($player, AuthenticationManager::AUTH_LEVEL_MODERATOR);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred.', $player->login); $this->maniaControl->chat->sendError('Error occurred.', $player->login);
return; return;
} }
$message = '$<' . $player->nickname . '$> added $<' . $target->nickname . '$> as Operator!'; $message = '$<' . $player->nickname . '$> added $<' . $target->nickname . '$> as Moderator!';
$this->maniaControl->chat->sendSuccess($message); $this->maniaControl->chat->sendSuccess($message);
} }
@ -152,8 +152,8 @@ class AuthCommands implements CommandListener {
* @param Player $player * @param Player $player
* @return bool * @return bool
*/ */
private function sendAddOperatorUsageInfo(Player $player) { private function sendAddModeratorUsageInfo(Player $player) {
$message = "Usage Example: '//addop login'"; $message = "Usage Example: '//addmod login'";
return $this->maniaControl->chat->sendUsageInfo($message, $player->login); return $this->maniaControl->chat->sendUsageInfo($message, $player->login);
} }
} }

View File

@ -19,12 +19,11 @@ class AuthenticationManager {
* Constants * Constants
*/ */
const AUTH_LEVEL_PLAYER = 0; const AUTH_LEVEL_PLAYER = 0;
const AUTH_LEVEL_OPERATOR = 1; const AUTH_LEVEL_MODERATOR = 1;
const AUTH_LEVEL_ADMIN = 2; const AUTH_LEVEL_ADMIN = 2;
const AUTH_LEVEL_SUPERADMIN = 3; const AUTH_LEVEL_SUPERADMIN = 3;
const AUTH_LEVEL_MASTERADMIN = 4; const AUTH_LEVEL_MASTERADMIN = 4;
const CB_AUTH_LEVEL_CHANGED = 'AuthenticationManager.AuthLevelChanged';
const CB_AUTH_LEVEL_CHANGED = 'AuthenticationManager.AuthLevelChanged';
/** /**
* Private properties * Private properties
*/ */
@ -87,8 +86,10 @@ class AuthenticationManager {
$adminStatement->bind_param('si', $login, $xAdminLevel); $adminStatement->bind_param('si', $login, $xAdminLevel);
$success = true; $success = true;
foreach ($xAdmins as $xAdmin) { foreach ($xAdmins as $xAdmin) {
/** @noinspection PhpUnusedLocalVariableInspection */ /**
$login = (string) $xAdmin; * @noinspection PhpUnusedLocalVariableInspection
*/
$login = (string) $xAdmin;
$adminStatement->execute(); $adminStatement->execute();
if ($adminStatement->error) { if ($adminStatement->error) {
trigger_error($adminStatement->error); trigger_error($adminStatement->error);
@ -132,10 +133,11 @@ class AuthenticationManager {
} }
$authStatement->close(); $authStatement->close();
if($success){ if ($success) {
// Trigger callback // Trigger callback
$player->authLevel = $authLevel; $player->authLevel = $authLevel;
$this->maniaControl->callbackManager->triggerCallback(self::CB_AUTH_LEVEL_CHANGED, array(self::CB_AUTH_LEVEL_CHANGED, $player)); $this->maniaControl->callbackManager->triggerCallback(self::CB_AUTH_LEVEL_CHANGED,
array(self::CB_AUTH_LEVEL_CHANGED, $player));
} }
return $success; return $success;
@ -181,12 +183,34 @@ class AuthenticationManager {
if ($authLevelInt == self::AUTH_LEVEL_ADMIN) { if ($authLevelInt == self::AUTH_LEVEL_ADMIN) {
return 'Admin'; return 'Admin';
} }
if ($authLevelInt == self::AUTH_LEVEL_OPERATOR) { if ($authLevelInt == self::AUTH_LEVEL_MODERATOR) {
return 'Operator'; return 'Moderator';
} }
return 'Player'; return 'Player';
} }
/**
* Get the Abbreviation of the Authentication Level from Level Int
*
* @param int $authLevelInt
* @return string
*/
public static function getAuthLevelAbbreviation($authLevelInt) {
if ($authLevelInt == self::AUTH_LEVEL_MASTERADMIN) {
return 'MA';
}
if ($authLevelInt == self::AUTH_LEVEL_SUPERADMIN) {
return 'SA';
}
if ($authLevelInt == self::AUTH_LEVEL_ADMIN) {
return 'AD';
}
if ($authLevelInt == self::AUTH_LEVEL_MODERATOR) {
return 'MOD';
}
return 'PL';
}
/** /**
* Get Authentication Level Int from Level Name * Get Authentication Level Int from Level Name
* *
@ -204,8 +228,8 @@ class AuthenticationManager {
if ($authLevelName == 'Admin') { if ($authLevelName == 'Admin') {
return self::AUTH_LEVEL_ADMIN; return self::AUTH_LEVEL_ADMIN;
} }
if ($authLevelName == 'Operator') { if ($authLevelName == 'Moderator') {
return self::AUTH_LEVEL_OPERATOR; return self::AUTH_LEVEL_MODERATOR;
} }
return self::AUTH_LEVEL_PLAYER; return self::AUTH_LEVEL_PLAYER;
} }

View File

@ -50,7 +50,7 @@ class MapCommands implements CommandListener {
* @param \ManiaControl\Players\Player $player * @param \ManiaControl\Players\Player $player
*/ */
public function command_RemoveMap(array $chat, Player $player) { public function command_RemoveMap(array $chat, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
@ -76,7 +76,7 @@ class MapCommands implements CommandListener {
* @param \ManiaControl\Players\Player $player * @param \ManiaControl\Players\Player $player
*/ */
public function command_AddMap(array $chatCallback, Player $player) { public function command_AddMap(array $chatCallback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
@ -98,7 +98,7 @@ class MapCommands implements CommandListener {
* @param \ManiaControl\Players\Player $player * @param \ManiaControl\Players\Player $player
*/ */
public function command_NextMap(array $chat, Player $player) { public function command_NextMap(array $chat, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
@ -112,7 +112,7 @@ class MapCommands implements CommandListener {
* @param \ManiaControl\Players\Player $player * @param \ManiaControl\Players\Player $player
*/ */
public function command_RestartMap(array $chat, Player $player) { public function command_RestartMap(array $chat, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }

View File

@ -358,7 +358,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$descriptionLabel->setText("Remove Map: {$map->name}"); $descriptionLabel->setText("Remove Map: {$map->name}");
$script->addTooltip($eraseQuad, $descriptionLabel); $script->addTooltip($eraseQuad, $descriptionLabel);
} }
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)){ //TODO SET as setting who can add maps if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)){ //TODO SET as setting who can add maps
//switch to map quad //switch to map quad
//$switchToQuad = new Quad_Icons64x64_1(); //TODO change name to label //$switchToQuad = new Quad_Icons64x64_1(); //TODO change name to label
$switchToQuad = new Label_Button(); $switchToQuad = new Label_Button();

View File

@ -54,7 +54,7 @@ class PlayerCommands implements CommandListener {
* @param Player $player * @param Player $player
*/ */
public function command_TeamBalance(array $chatCallback, Player $player) { public function command_TeamBalance(array $chatCallback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
@ -73,7 +73,7 @@ class PlayerCommands implements CommandListener {
* @param Player $player * @param Player $player
*/ */
public function command_Kick(array $chat, Player $player) { public function command_Kick(array $chat, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
@ -103,7 +103,7 @@ class PlayerCommands implements CommandListener {
* @param Player $player * @param Player $player
*/ */
public function command_ForceSpectator(array $chat, Player $player) { public function command_ForceSpectator(array $chat, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
@ -140,7 +140,7 @@ class PlayerCommands implements CommandListener {
* @param Player $player * @param Player $player
*/ */
public function command_ForcePlayer(array $chat, Player $player) { public function command_ForcePlayer(array $chat, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }

View File

@ -126,7 +126,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$frame->add($headFrame); $frame->add($headFrame);
$headFrame->setY($y - 5); $headFrame->setY($y - 5);
// $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85); // $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85);
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91, "Actions" => $x + 135); $array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91, "Actions" => $x + 135);
} }
else { else {
@ -270,13 +270,13 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
case authenticationManager::AUTH_LEVEL_ADMIN: case authenticationManager::AUTH_LEVEL_ADMIN:
$rightLabel->setText("AD"); $rightLabel->setText("AD");
break; break;
case authenticationManager::AUTH_LEVEL_OPERATOR: case authenticationManager::AUTH_LEVEL_MODERATOR:
$rightLabel->setText("MOD"); $rightLabel->setText("MOD");
} }
$rightLabel->setTextColor("fff"); $rightLabel->setTextColor("fff");
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
// Further Player actions Quad // Further Player actions Quad
$playerQuad = new Quad_Icons64x64_1(); $playerQuad = new Quad_Icons64x64_1();
$playerFrame->add($playerQuad); $playerFrame->add($playerQuad);
@ -567,7 +567,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$label->setText("Set Moderator"); $label->setText("Set Moderator");
$label->setTextColor($textColor); $label->setTextColor($textColor);
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$y -= 5; $y -= 5;
// Revoke Rights // Revoke Rights
$quad = new Quad_BgsPlayerCard(); $quad = new Quad_BgsPlayerCard();
@ -664,7 +664,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
break; break;
case self::ACTION_ADD_AS_MOD: case self::ACTION_ADD_AS_MOD:
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, $this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
AuthenticationManager::AUTH_LEVEL_OPERATOR); AuthenticationManager::AUTH_LEVEL_MODERATOR);
break; break;
case self::ACTION_REVOKE_RIGHTS: case self::ACTION_REVOKE_RIGHTS:
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin); $this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);

View File

@ -368,7 +368,7 @@ class ServerCommands implements CallbackListener, CommandListener {
* @param Player $player * @param Player $player
*/ */
public function command_EnableHorns(array $chatCallback, Player $player) { public function command_EnableHorns(array $chatCallback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
@ -387,7 +387,7 @@ class ServerCommands implements CallbackListener, CommandListener {
* @param Player $player * @param Player $player
*/ */
public function command_DisableHorns(array $chatCallback, Player $player) { public function command_DisableHorns(array $chatCallback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }

View File

@ -38,7 +38,7 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
// Init settings // Init settings
$this->maniaControl->settingManager->initSetting($this, self::SETTING_JUMPTOAUTHLEVEL, $this->maniaControl->settingManager->initSetting($this, self::SETTING_JUMPTOAUTHLEVEL,
AuthenticationManager::AUTH_LEVEL_OPERATOR); AuthenticationManager::AUTH_LEVEL_MODERATOR);
// Register for commands // Register for commands
$this->maniaControl->commandManager->registerCommandListener('jumpto', $this, 'command_JumpTo'); $this->maniaControl->commandManager->registerCommandListener('jumpto', $this, 'command_JumpTo');