permission levels
This commit is contained in:
parent
f825c0c111
commit
aa642a7ef1
@ -144,8 +144,9 @@ class AuthenticationManager implements CallbackListener {
|
||||
return false;
|
||||
}
|
||||
$authLevel = (int)$authLevel;
|
||||
if ($authLevel >= self::AUTH_LEVEL_MASTERADMIN)
|
||||
if ($authLevel >= self::AUTH_LEVEL_MASTERADMIN) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$authQuery = "INSERT INTO `" . PlayerManager::TABLE_PLAYERS . "` (
|
||||
@ -182,9 +183,10 @@ class AuthenticationManager implements CallbackListener {
|
||||
* @return bool
|
||||
*/
|
||||
public function sendNotAllowed(Player $player) {
|
||||
if (!$player)
|
||||
if (!$player) {
|
||||
return false;
|
||||
return $this->maniaControl->chat->sendError('You do not have the required Rights to perform this Command!', $player->login);
|
||||
}
|
||||
return $this->maniaControl->chat->sendError('You do not have the required Rights to perform this Action!', $player->login);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,7 @@ use FML\Controls\Label;
|
||||
use FML\Controls\Labels\Label_Text;
|
||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||
use FML\Script\Script;
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\ManiaControl;
|
||||
@ -26,6 +27,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
const TITLE = 'ManiaControl Settings';
|
||||
const ACTION_PREFIX_SETTING = 'ManiaControlSettings';
|
||||
const ACTION_SETTING_BOOL = 'ManiaControlSettings.ActionBoolSetting.';
|
||||
const SETTING_PERMISSION_CHANGE_MC_SETTINGS = 'Change ManiaControl Settings';
|
||||
|
||||
/**
|
||||
* Private Properties
|
||||
@ -42,6 +44,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
|
||||
// Register for callbacks
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MC_SETTINGS, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,14 +111,14 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$prevClass = '';
|
||||
foreach($settings as $id => $setting) {
|
||||
//Don't display Plugin Settings
|
||||
if(array_search($setting->class, $pluginClasses) !== FALSE) {
|
||||
if (array_search($setting->class, $pluginClasses) !== FALSE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!isset($pageFrame)) {
|
||||
if (!isset($pageFrame)) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->add($pageFrame);
|
||||
if(!empty($pageFrames)) {
|
||||
if (!empty($pageFrames)) {
|
||||
$pageFrame->setVisible(false);
|
||||
}
|
||||
array_push($pageFrames, $pageFrame);
|
||||
@ -128,7 +131,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$settingFrame->setY($y);
|
||||
|
||||
//Headline Label
|
||||
if($prevClass != $setting->class) {
|
||||
if ($prevClass != $setting->class) {
|
||||
$headLabel = new Label_Text();
|
||||
$settingFrame->add($headLabel);
|
||||
$headLabel->setHAlign(Control::LEFT);
|
||||
@ -142,10 +145,10 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$y -= $settingHeight;
|
||||
|
||||
|
||||
if($index % $pageMaxCount == $pageMaxCount - 1) {
|
||||
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->add($pageFrame);
|
||||
if(!empty($pageFrames)) {
|
||||
if (!empty($pageFrames)) {
|
||||
$pageFrame->setVisible(false);
|
||||
}
|
||||
array_push($pageFrames, $pageFrame);
|
||||
@ -184,10 +187,10 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$entry->setDefault($setting->value);
|
||||
|
||||
|
||||
if($setting->type == "bool") {
|
||||
if($setting->value == "0") {
|
||||
if ($setting->type == "bool") {
|
||||
if ($setting->value == "0") {
|
||||
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlRed;
|
||||
} else if($setting->value == "1") {
|
||||
} else if ($setting->value == "1") {
|
||||
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
|
||||
}
|
||||
|
||||
@ -206,7 +209,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$prevClass = $setting->class;
|
||||
|
||||
$y -= $settingHeight;
|
||||
if($index % $pageMaxCount == $pageMaxCount - 1) {
|
||||
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
||||
unset($pageFrame);
|
||||
}
|
||||
|
||||
@ -223,8 +226,13 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function saveConfigData(array $configData, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_MC_SETTINGS)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
$prefix = explode(".", $configData[3][0]['Name']);
|
||||
if($prefix[0] != self::ACTION_PREFIX_SETTING) {
|
||||
if ($prefix[0] != self::ACTION_PREFIX_SETTING) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -236,7 +244,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
$settingName = substr($setting['Name'], $prefixLength + 1);
|
||||
|
||||
$oldSetting = $maniaControlSettings[$settingName];
|
||||
if($setting['Value'] == $oldSetting->value || $oldSetting->type == 'bool') {
|
||||
if ($setting['Value'] == $oldSetting->value || $oldSetting->type == 'bool') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -256,7 +264,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
public function handleManialinkPageAnswer(array $callback) {
|
||||
$actionId = $callback[1][2];
|
||||
$boolSetting = (strpos($actionId, self::ACTION_SETTING_BOOL) === 0);
|
||||
if(!$boolSetting) {
|
||||
if (!$boolSetting) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -281,15 +289,20 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function toggleBooleanSetting($setting, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_MC_SETTINGS)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
$oldSetting = $this->maniaControl->settingManager->getSettingByIndex($setting);
|
||||
|
||||
if(!isset($oldSetting)) {
|
||||
if (!isset($oldSetting)) {
|
||||
var_dump('no setting ' . $setting);
|
||||
return;
|
||||
}
|
||||
|
||||
//Toggle value
|
||||
if($oldSetting->value == "1") {
|
||||
if ($oldSetting->value == "1") {
|
||||
$this->maniaControl->settingManager->updateSetting($oldSetting->class, $oldSetting->setting, "0");
|
||||
} else {
|
||||
$this->maniaControl->settingManager->updateSetting($oldSetting->class, $oldSetting->setting, "1");
|
||||
|
@ -16,6 +16,7 @@ use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\PluginManager;
|
||||
use ManiaControl\Server\Server;
|
||||
use ManiaControl\Server\ServerCommands;
|
||||
use ManiaControl\Settings\SettingManager;
|
||||
use ManiaControl\Statistics\StatisticManager;
|
||||
use Maniaplanet\DedicatedServer\Connection;
|
||||
@ -39,6 +40,8 @@ class ManiaControl implements CommandListener {
|
||||
const OS_WIN = 'Windows';
|
||||
const CONNECT_TIMEOUT = 20;
|
||||
const SCRIPT_TIMEOUT = 20;
|
||||
const SETTING_PERMISSION_SHUTDOWN = 'Shutdown ManiaControl';
|
||||
const SETTING_PERMISSION_RESTART = 'Restart ManiaControl';
|
||||
|
||||
/**
|
||||
* Public properties
|
||||
@ -99,6 +102,10 @@ class ManiaControl implements CommandListener {
|
||||
$this->pluginManager = new PluginManager($this);
|
||||
$this->updateManager = new UpdateManager($this);
|
||||
|
||||
//Define Permission Levels
|
||||
$this->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SHUTDOWN, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_RESTART, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
|
||||
// Register for commands
|
||||
$this->commandManager->registerCommandListener('version', $this, 'command_Version');
|
||||
$this->commandManager->registerCommandListener('restart', $this, 'command_Restart', true);
|
||||
@ -159,7 +166,7 @@ class ManiaControl implements CommandListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_Restart(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
if (!$this->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_RESTART)) {
|
||||
$this->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -173,7 +180,7 @@ class ManiaControl implements CommandListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_Shutdown(array $chat, Player $player) {
|
||||
if (!$this->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
if (!$this->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_SHUTDOWN)) {
|
||||
$this->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -280,7 +287,7 @@ class ManiaControl implements CommandListener {
|
||||
// Yield for next tick
|
||||
$loopEnd = microtime(true);
|
||||
|
||||
$sleepTime = (int) (1000 - $loopEnd + $loopStart);
|
||||
$sleepTime = (int)(1000 - $loopEnd + $loopStart);
|
||||
if ($sleepTime > 0) {
|
||||
usleep($sleepTime);
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ namespace ManiaControl\Maps;
|
||||
use FML\Controls\Quad;
|
||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
@ -157,7 +156,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function command_AddMap(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -178,7 +177,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function command_NextMap(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_SKIP_MAP)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -195,7 +194,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function command_RestartMap(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_RESTART_MAP)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ class MapManager implements CallbackListener {
|
||||
const SETTING_PERMISSION_REMOVE_MAP = 'Remove Maps';
|
||||
const SETTING_PERMISSION_SHUFFLE_MAPS = 'Shuffle Maps';
|
||||
const SETTING_PERMISSION_CHECK_UPDATE = 'Check Map Update';
|
||||
const SETTING_PERMISSION_SKIP_MAP = 'Skip Map';
|
||||
const SETTING_PERMISSION_RESTART_MAP = 'Restart Map';
|
||||
|
||||
/**
|
||||
* Public Properties
|
||||
@ -74,6 +76,8 @@ class MapManager implements CallbackListener {
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_REMOVE_MAP, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SHUFFLE_MAPS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CHECK_UPDATE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SKIP_MAP, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_RESTART_MAP, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,8 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
*/
|
||||
const ACTION_BALANCE_TEAMS = 'PlayerCommands.BalanceTeams';
|
||||
const ACTION_OPEN_PLAYERLIST = 'PlayerCommands.OpenPlayerList';
|
||||
const SETTING_PERMISSION_ADD_BOT = 'Add Bot';
|
||||
const SETTING_PERMISSION_TEAM_BALANCE = 'Balance Teams';
|
||||
|
||||
/**
|
||||
* Private Properties
|
||||
@ -55,6 +57,10 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
$this->maniaControl->commandManager->registerCommandListener('player', $this, 'command_playerList');
|
||||
$this->maniaControl->commandManager->registerCommandListener('players', $this, 'command_playerList');
|
||||
|
||||
//Define Rights
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_ADD_BOT, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_TEAM_BALANCE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
|
||||
// Action Balance Teams
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
|
||||
$itemQuad = new Quad_Icons128x32_1();
|
||||
@ -78,7 +84,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_TeamBalance(array $chatCallback, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_TEAM_BALANCE)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -100,18 +106,18 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_Kick(array $chat, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, PlayerActions::SETTING_PERMISSION_KICK_PLAYER)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2], 3);
|
||||
if(count($params) <= 1) {
|
||||
if (count($params) <= 1) {
|
||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
$message = '';
|
||||
if(isset($params[2])) {
|
||||
if (isset($params[2])) {
|
||||
$message = $params[2];
|
||||
}
|
||||
$this->maniaControl->playerManager->playerActions->kickPlayer($player->login, $targetLogin, $message);
|
||||
@ -125,7 +131,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
*/
|
||||
public function command_Warn(array $chat, Player $player) {
|
||||
$params = explode(' ', $chat[1][2], 3);
|
||||
if(count($params) <= 1) {
|
||||
if (count($params) <= 1) {
|
||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
|
||||
return;
|
||||
}
|
||||
@ -140,18 +146,18 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_ForceSpectator(array $chat, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2]);
|
||||
if(count($params) <= 1) {
|
||||
if (count($params) <= 1) {
|
||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forcespec login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
|
||||
if(isset($params[2]) && is_numeric($params[2])) {
|
||||
if (isset($params[2]) && is_numeric($params[2])) {
|
||||
$type = (int)$params[2];
|
||||
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($player->login, $targetLogin, $type);
|
||||
} else {
|
||||
@ -166,23 +172,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_ForcePlay(array $chat, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2]);
|
||||
if(!isset($params[1])) {
|
||||
if (!isset($params[1])) {
|
||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forceplay login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
|
||||
$type = 2;
|
||||
if(isset($params[2]) && is_numeric($params[2])) {
|
||||
if (isset($params[2]) && is_numeric($params[2])) {
|
||||
$type = intval($params[2]);
|
||||
}
|
||||
$selectable = false;
|
||||
if($type == 2) {
|
||||
if ($type == 2) {
|
||||
$selectable = true;
|
||||
}
|
||||
|
||||
@ -196,12 +202,12 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_ForceBlue(array $chat, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2]);
|
||||
if(!isset($params[1])) {
|
||||
if (!isset($params[1])) {
|
||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forceblue login'", $player->login);
|
||||
return;
|
||||
}
|
||||
@ -217,12 +223,12 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_ForceRed(array $chat, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2]);
|
||||
if(!isset($params[1])) {
|
||||
if (!isset($params[1])) {
|
||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forcered login'", $player->login);
|
||||
return;
|
||||
}
|
||||
@ -238,13 +244,13 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_AddFakePlayers(array $chatCallback, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$amount = 1;
|
||||
$messageParts = explode(' ', $chatCallback[1][2]);
|
||||
if(isset($messageParts[1]) && is_numeric($messageParts[1])) {
|
||||
if (isset($messageParts[1]) && is_numeric($messageParts[1])) {
|
||||
$amount = intval($messageParts[1]);
|
||||
}
|
||||
try {
|
||||
@ -266,7 +272,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_RemoveFakePlayers(array $chatCallback, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -289,7 +295,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
*/
|
||||
public function command_MutePlayer(array $chatCallback, Player $admin) {
|
||||
$commandParts = explode(' ', $chatCallback[1][2]);
|
||||
if(count($commandParts) <= 1) {
|
||||
if (count($commandParts) <= 1) {
|
||||
$this->maniaControl->chat->sendUsageInfo("No login specified! Example: '//mute login'");
|
||||
return;
|
||||
}
|
||||
@ -305,7 +311,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
||||
*/
|
||||
public function command_UnmutePlayer(array $chatCallback, Player $admin) {
|
||||
$commandParts = explode(' ', $chatCallback[1][2]);
|
||||
if(count($commandParts) <= 1) {
|
||||
if (count($commandParts) <= 1) {
|
||||
$this->maniaControl->chat->sendUsageInfo("No login specified! Example: '//unmute login'");
|
||||
return;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ use FML\Controls\Labels\Label_Text;
|
||||
use FML\Controls\Quads\Quad_Icons128x32_1;
|
||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||
use FML\Script\Script;
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Configurators\ConfiguratorMenu;
|
||||
@ -34,6 +35,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
const ACTION_PREFIX_SETTING = 'PluginMenuSetting';
|
||||
const ACTION_SETTING_BOOL = 'PluginMenuActionBoolSetting.';
|
||||
const ACTION_BACK_TO_PLUGINS = 'PluginMenu.BackToPlugins';
|
||||
const SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS = 'Change Plugin Settings';
|
||||
|
||||
/**
|
||||
* Private properties
|
||||
@ -51,6 +53,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_BACK_TO_PLUGINS, $this, 'backToPlugins');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -326,6 +329,11 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
|
||||
*/
|
||||
public function saveConfigData(array $configData, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
$prefix = explode(".", $configData[3][0]['Name']);
|
||||
if($prefix[0] != self::ACTION_PREFIX_SETTING) {
|
||||
return;
|
||||
@ -420,6 +428,11 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
* @param Player $player
|
||||
*/
|
||||
public function toggleBooleanSetting($setting, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
$oldSetting = $this->maniaControl->settingManager->getSettingByIndex($setting);
|
||||
|
||||
if(!isset($oldSetting)) {
|
||||
|
@ -25,6 +25,11 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
const ACTION_SET_PAUSE = 'ServerCommands.SetPause';
|
||||
const ACTION_CANCEL_VOTE = 'ServerCommands.CancelVote';
|
||||
const CB_VOTE_CANCELED = 'ServerCommands.VoteCanceled';
|
||||
const SETTING_PERMISSION_CANCEL_VOTE = 'Cancel Vote';
|
||||
const SETTING_PERMISSION_SET_PAUSE = 'Set Pause';
|
||||
const SETTING_PERMISSION_SHOW_SYSTEMINFO = 'Show SystemInfo';
|
||||
const SETTING_PERMISSION_SHUTDOWN_SERVER = 'Shutdown Server';
|
||||
const SETTING_PERMISSION_CHANGE_SERVERSETTINGS = 'Change ServerSettings';
|
||||
|
||||
/**
|
||||
* Private properties
|
||||
@ -64,7 +69,14 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleOnInit(array $callback) {
|
||||
//Check if Pause exists in current gamemode
|
||||
//Define Permissions
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SHUTDOWN_SERVER, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SHOW_SYSTEMINFO, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_SERVERSETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_SET_PAUSE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CANCEL_VOTE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
|
||||
//Check if Pause exists in current GameMode
|
||||
$scriptInfos = $this->maniaControl->client->getModeScriptInfo();
|
||||
|
||||
$pauseExists = false;
|
||||
@ -98,7 +110,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_CancelVote(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CANCEL_VOTE)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -115,11 +127,19 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function setPause(array $callback) {
|
||||
$success = $this->maniaControl->client->sendModeScriptCommands(array('Command_ForceWarmUp' => True));
|
||||
if (!$success) {
|
||||
$this->maniaControl->chat->sendError("Error while setting the pause");
|
||||
public function setPause(array $callback, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_SET_PAUSE)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$this->maniaControl->client->sendModeScriptCommands(array('Command_ForceWarmUp' => True));
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> paused the Game!');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,7 +172,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SystemInfo(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_SHOW_SYSTEMINFO)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -168,7 +188,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_ShutdownServer(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_SHUTDOWN_SERVER)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -207,7 +227,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SetServerName(array $chat, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SERVERSETTINGS)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -233,7 +253,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SetPwd(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SERVERSETTINGS)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -260,7 +280,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SetSpecPwd(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SERVERSETTINGS)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -287,7 +307,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SetMaxPlayers(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SERVERSETTINGS)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -323,7 +343,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SetMaxSpectators(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SERVERSETTINGS)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
const SETTING_PERFORM_BACKUPS = 'Perform Backup before Updating';
|
||||
const SETTING_AUTO_UPDATE = 'Perform update automatically';
|
||||
const SETTING_PERMISSION_UPDATE = 'Update Core';
|
||||
const SETTING_PERMISSION_UPDATECHECK = 'Check Core Update';
|
||||
const URL_WEBSERVICE = 'http://ws.maniacontrol.com/';
|
||||
const CHANNEL_RELEASE = 'release';
|
||||
const CHANNEL_BETA = 'beta';
|
||||
@ -57,8 +58,10 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Minute', 1000 * 60);
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerJoined');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'handlePlayerDisconnected');
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_UPDATE, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
|
||||
//define Permissions
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_UPDATE, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_UPDATECHECK, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
|
||||
// Register for chat commands
|
||||
$this->maniaControl->commandManager->registerCommandListener('checkupdate', $this, 'handle_CheckUpdate', true);
|
||||
@ -104,7 +107,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
}
|
||||
// Announce available update
|
||||
$player = $callback[1];
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_UPDATE)) {
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->chat->sendInformation('New ManiaControl Version ' . $this->coreUpdateData->version . ' available!', $player->login);
|
||||
@ -152,7 +155,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handle_CheckUpdate(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_UPDATECHECK)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user