From dcb4e3f951acb9aa516ad49a19857fbae163e04c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Tue, 31 Dec 2013 17:17:11 +0100 Subject: [PATCH] Changed 'Operator' Level to 'Moderator' --- application/configs/authentication.xml | 2 +- application/core/Admin/AuthCommands.php | 16 ++--- .../core/Admin/AuthenticationManager.php | 62 +++++++++++++------ application/core/Maps/MapCommands.php | 8 +-- application/core/Maps/MapList.php | 2 +- application/core/Players/PlayerCommands.php | 8 +-- application/core/Players/PlayerList.php | 10 +-- application/core/Server/ServerCommands.php | 4 +- application/plugins/Obstacle.php | 2 +- 9 files changed, 69 insertions(+), 45 deletions(-) diff --git a/application/configs/authentication.xml b/application/configs/authentication.xml index 6a77afbb..4bcf7639 100644 --- a/application/configs/authentication.xml +++ b/application/configs/authentication.xml @@ -8,6 +8,6 @@ kremsy - + diff --git a/application/core/Admin/AuthCommands.php b/application/core/Admin/AuthCommands.php index 36b1d530..d32840c4 100644 --- a/application/core/Admin/AuthCommands.php +++ b/application/core/Admin/AuthCommands.php @@ -28,7 +28,7 @@ class AuthCommands implements CommandListener { // Register for commands $this->maniaControl->commandManager->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin',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 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)) { $this->maniaControl->authenticationManager->sendNotAllowed($player); return; @@ -107,7 +107,7 @@ class AuthCommands implements CommandListener { $text = $chatCallback[1][2]; $commandParts = explode(' ', $text); if (!array_key_exists(1, $commandParts)) { - $this->sendAddOperatorUsageInfo($player); + $this->sendAddModeratorUsageInfo($player); return; } $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); return; } - $success = $this->maniaControl->authenticationManager->grantAuthLevel($player, AuthenticationManager::AUTH_LEVEL_OPERATOR); + $success = $this->maniaControl->authenticationManager->grantAuthLevel($player, AuthenticationManager::AUTH_LEVEL_MODERATOR); if (!$success) { $this->maniaControl->chat->sendError('Error occurred.', $player->login); return; } - $message = '$<' . $player->nickname . '$> added $<' . $target->nickname . '$> as Operator!'; + $message = '$<' . $player->nickname . '$> added $<' . $target->nickname . '$> as Moderator!'; $this->maniaControl->chat->sendSuccess($message); } @@ -152,8 +152,8 @@ class AuthCommands implements CommandListener { * @param Player $player * @return bool */ - private function sendAddOperatorUsageInfo(Player $player) { - $message = "Usage Example: '//addop login'"; + private function sendAddModeratorUsageInfo(Player $player) { + $message = "Usage Example: '//addmod login'"; return $this->maniaControl->chat->sendUsageInfo($message, $player->login); } } diff --git a/application/core/Admin/AuthenticationManager.php b/application/core/Admin/AuthenticationManager.php index 92185360..aecbbadc 100644 --- a/application/core/Admin/AuthenticationManager.php +++ b/application/core/Admin/AuthenticationManager.php @@ -19,12 +19,11 @@ class AuthenticationManager { * Constants */ const AUTH_LEVEL_PLAYER = 0; - const AUTH_LEVEL_OPERATOR = 1; + const AUTH_LEVEL_MODERATOR = 1; const AUTH_LEVEL_ADMIN = 2; const AUTH_LEVEL_SUPERADMIN = 3; const AUTH_LEVEL_MASTERADMIN = 4; - - const CB_AUTH_LEVEL_CHANGED = 'AuthenticationManager.AuthLevelChanged'; + const CB_AUTH_LEVEL_CHANGED = 'AuthenticationManager.AuthLevelChanged'; /** * Private properties */ @@ -34,7 +33,7 @@ class AuthenticationManager { /** * Construct authentication manager * - * @param \ManiaControl\ManiaControl $maniaControl + * @param \ManiaControl\ManiaControl $maniaControl */ public function __construct(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; @@ -87,8 +86,10 @@ class AuthenticationManager { $adminStatement->bind_param('si', $login, $xAdminLevel); $success = true; foreach ($xAdmins as $xAdmin) { - /** @noinspection PhpUnusedLocalVariableInspection */ - $login = (string) $xAdmin; + /** + * @noinspection PhpUnusedLocalVariableInspection + */ + $login = (string) $xAdmin; $adminStatement->execute(); if ($adminStatement->error) { trigger_error($adminStatement->error); @@ -102,8 +103,8 @@ class AuthenticationManager { /** * Grant the auth level to the player * - * @param Player $player - * @param int $authLevel + * @param Player $player + * @param int $authLevel * @return bool */ public function grantAuthLevel(Player $player, $authLevel) { @@ -131,13 +132,14 @@ class AuthenticationManager { return false; } $authStatement->close(); - - if($success){ + + if ($success) { // Trigger callback $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; } @@ -158,7 +160,7 @@ class AuthenticationManager { * Check if the player has enough rights * * @param Player $player - * @param int $neededAuthLevel + * @param int $neededAuthLevel * @return bool */ public static function checkRight(Player $player, $neededAuthLevel) { @@ -168,7 +170,7 @@ class AuthenticationManager { /** * Get Name of the Authentication Level from Level Int * - * @param int $authLevelInt + * @param int $authLevelInt * @return string */ public static function getAuthLevelName($authLevelInt) { @@ -181,16 +183,38 @@ class AuthenticationManager { if ($authLevelInt == self::AUTH_LEVEL_ADMIN) { return 'Admin'; } - if ($authLevelInt == self::AUTH_LEVEL_OPERATOR) { - return 'Operator'; + if ($authLevelInt == self::AUTH_LEVEL_MODERATOR) { + return 'Moderator'; } 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 * - * @param string $authLevelName + * @param string $authLevelName * @return int */ public static function getAuthLevel($authLevelName) { @@ -204,8 +228,8 @@ class AuthenticationManager { if ($authLevelName == 'Admin') { return self::AUTH_LEVEL_ADMIN; } - if ($authLevelName == 'Operator') { - return self::AUTH_LEVEL_OPERATOR; + if ($authLevelName == 'Moderator') { + return self::AUTH_LEVEL_MODERATOR; } return self::AUTH_LEVEL_PLAYER; } diff --git a/application/core/Maps/MapCommands.php b/application/core/Maps/MapCommands.php index d3a898ec..641caf6b 100644 --- a/application/core/Maps/MapCommands.php +++ b/application/core/Maps/MapCommands.php @@ -50,7 +50,7 @@ class MapCommands implements CommandListener { * @param \ManiaControl\Players\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); return; } @@ -76,7 +76,7 @@ class MapCommands implements CommandListener { * @param \ManiaControl\Players\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); return; } @@ -98,7 +98,7 @@ class MapCommands implements CommandListener { * @param \ManiaControl\Players\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); return; } @@ -112,7 +112,7 @@ class MapCommands implements CommandListener { * @param \ManiaControl\Players\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); return; } diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index 84b8d496..5ce6c2b1 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -358,7 +358,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $descriptionLabel->setText("Remove Map: {$map->name}"); $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 //$switchToQuad = new Quad_Icons64x64_1(); //TODO change name to label $switchToQuad = new Label_Button(); diff --git a/application/core/Players/PlayerCommands.php b/application/core/Players/PlayerCommands.php index 540d8586..a6a23dfe 100644 --- a/application/core/Players/PlayerCommands.php +++ b/application/core/Players/PlayerCommands.php @@ -54,7 +54,7 @@ class PlayerCommands implements CommandListener { * @param 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); return; } @@ -73,7 +73,7 @@ class PlayerCommands implements CommandListener { * @param 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); return; } @@ -103,7 +103,7 @@ class PlayerCommands implements CommandListener { * @param 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); return; } @@ -140,7 +140,7 @@ class PlayerCommands implements CommandListener { * @param 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); return; } diff --git a/application/core/Players/PlayerList.php b/application/core/Players/PlayerList.php index 4d619ae4..1ca9a903 100644 --- a/application/core/Players/PlayerList.php +++ b/application/core/Players/PlayerList.php @@ -126,7 +126,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { $frame->add($headFrame); $headFrame->setY($y - 5); // $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); } else { @@ -270,13 +270,13 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { case authenticationManager::AUTH_LEVEL_ADMIN: $rightLabel->setText("AD"); break; - case authenticationManager::AUTH_LEVEL_OPERATOR: + case authenticationManager::AUTH_LEVEL_MODERATOR: $rightLabel->setText("MOD"); } $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 $playerQuad = new Quad_Icons64x64_1(); $playerFrame->add($playerQuad); @@ -567,7 +567,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { $label->setText("Set Moderator"); $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; // Revoke Rights $quad = new Quad_BgsPlayerCard(); @@ -664,7 +664,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { break; case self::ACTION_ADD_AS_MOD: $this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, - AuthenticationManager::AUTH_LEVEL_OPERATOR); + AuthenticationManager::AUTH_LEVEL_MODERATOR); break; case self::ACTION_REVOKE_RIGHTS: $this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin); diff --git a/application/core/Server/ServerCommands.php b/application/core/Server/ServerCommands.php index 953f0896..78c490d0 100644 --- a/application/core/Server/ServerCommands.php +++ b/application/core/Server/ServerCommands.php @@ -368,7 +368,7 @@ class ServerCommands implements CallbackListener, CommandListener { * @param 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); return; } @@ -387,7 +387,7 @@ class ServerCommands implements CallbackListener, CommandListener { * @param 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); return; } diff --git a/application/plugins/Obstacle.php b/application/plugins/Obstacle.php index 29e9d1a3..0a61abb1 100644 --- a/application/plugins/Obstacle.php +++ b/application/plugins/Obstacle.php @@ -38,7 +38,7 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin { // Init settings $this->maniaControl->settingManager->initSetting($this, self::SETTING_JUMPTOAUTHLEVEL, - AuthenticationManager::AUTH_LEVEL_OPERATOR); + AuthenticationManager::AUTH_LEVEL_MODERATOR); // Register for commands $this->maniaControl->commandManager->registerCommandListener('jumpto', $this, 'command_JumpTo');