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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -223,6 +226,11 @@ 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) {
|
||||
return;
|
||||
@ -281,6 +289,11 @@ 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)) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,7 +106,7 @@ 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;
|
||||
}
|
||||
@ -140,7 +146,7 @@ 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;
|
||||
}
|
||||
@ -166,7 +172,7 @@ 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;
|
||||
}
|
||||
@ -196,7 +202,7 @@ 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;
|
||||
}
|
||||
@ -217,7 +223,7 @@ 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;
|
||||
}
|
||||
@ -238,7 +244,7 @@ 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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
@ -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