performed code formatting
This commit is contained in:
@ -51,14 +51,20 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_POSX, 156.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_POSY, -17.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_POSX, 156.);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_POSY, -17.);
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'handlePlayerJoined');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'handlePlayerJoined');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,10 +106,12 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
if (!$this->initCompleted) {
|
||||
return;
|
||||
}
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
$players = $this->maniaControl->getPlayerManager()
|
||||
->getPlayers();
|
||||
foreach ($players as $player) {
|
||||
$manialink = $this->buildMenuIconsManialink($player);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($manialink, $player->login);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->sendManialink($manialink, $player->login);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,18 +122,28 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
* @return ManiaLink
|
||||
*/
|
||||
private function buildMenuIconsManialink(Player $player) {
|
||||
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSX);
|
||||
$posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSY);
|
||||
$itemSize = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
|
||||
$shootManiaOffset = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultIconOffsetSM();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
|
||||
$posX = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_POSX);
|
||||
$posY = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_POSY);
|
||||
$itemSize = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
|
||||
$shootManiaOffset = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultIconOffsetSM();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultQuadSubstyle();
|
||||
$itemMarginFactorX = 1.3;
|
||||
$itemMarginFactorY = 1.2;
|
||||
|
||||
// If game is shootmania lower the icons position by 20
|
||||
if ($this->maniaControl->getMapManager()->getCurrentMap()
|
||||
->getGame() === 'sm'
|
||||
if ($this->maniaControl->getMapManager()
|
||||
->getCurrentMap()
|
||||
->getGame() === 'sm'
|
||||
) {
|
||||
$posY -= $shootManiaOffset;
|
||||
}
|
||||
@ -135,7 +153,9 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/*
|
||||
* Admin Menu
|
||||
*/
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
|
||||
) {
|
||||
// Admin Menu Icon Frame
|
||||
$iconFrame = new Frame();
|
||||
$manialink->add($iconFrame);
|
||||
@ -313,6 +333,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
*/
|
||||
public function handlePlayerJoined(Player $player) {
|
||||
$maniaLink = $this->buildMenuIconsManialink($player);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $player);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->sendManialink($maniaLink, $player);
|
||||
}
|
||||
}
|
||||
|
@ -46,17 +46,23 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
||||
|
||||
// Menu Entry AdminList
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_ADMIN_LIST, $this, 'openAdminList');
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_OPEN_ADMIN_LIST, $this, 'openAdminList');
|
||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Author);
|
||||
$itemQuad->setAction(self::ACTION_OPEN_ADMIN_LIST);
|
||||
$this->maniaControl->getActionsMenu()->addMenuItem($itemQuad, false, 50, 'Open AdminList');
|
||||
$this->maniaControl->getActionsMenu()
|
||||
->addMenuItem($itemQuad, false, 50, 'Open AdminList');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,11 +83,16 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
public function showAdminLists(Player $player) {
|
||||
$this->adminListShown[$player->login] = true;
|
||||
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
|
||||
// get Admins
|
||||
$admins = $this->maniaControl->getAuthenticationManager()->getAdmins();
|
||||
$admins = $this->maniaControl->getAuthenticationManager()
|
||||
->getAdmins();
|
||||
|
||||
//Create ManiaLink
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
@ -90,7 +101,9 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$script->addFeature($paging);
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
// Start offsets
|
||||
@ -98,7 +111,9 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$posY = $height / 2;
|
||||
|
||||
//Predefine description Label
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultDescriptionLabel();
|
||||
$frame->add($descriptionLabel);
|
||||
|
||||
// Headline
|
||||
@ -106,7 +121,8 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($posY - 5);
|
||||
$array = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Actions' => $posX + 120);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($headFrame, $array);
|
||||
|
||||
$index = 1;
|
||||
$posY -= 10;
|
||||
@ -134,7 +150,8 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
}
|
||||
|
||||
$array = array($index => $posX + 5, $admin->nickname => $posX + 18, $admin->login => $posX + 70);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($playerFrame, $array);
|
||||
|
||||
|
||||
// Level Quad
|
||||
@ -150,12 +167,17 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$rightLabel->setX($posX + 13.9);
|
||||
$rightLabel->setTextSize(0.8);
|
||||
$rightLabel->setZ(10);
|
||||
$rightLabel->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelAbbreviation($admin));
|
||||
$description = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin) . " " . $admin->nickname;
|
||||
$rightLabel->setText($this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelAbbreviation($admin));
|
||||
$description = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin) . " " . $admin->nickname;
|
||||
$rightLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
//Revoke Button
|
||||
if ($admin->authLevel > 0 && $this->maniaControl->getAuthenticationManager()->checkRight($player, $admin->authLevel + 1)) {
|
||||
if ($admin->authLevel > 0
|
||||
&& $this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($player, $admin->authLevel + 1)
|
||||
) {
|
||||
//Settings
|
||||
$style = Label_Text::STYLE_TextCardSmall;
|
||||
$textColor = 'FFF';
|
||||
@ -187,7 +209,8 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
}
|
||||
|
||||
// Render and display xml
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'AdminList');
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, 'AdminList');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -208,7 +231,9 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
switch ($action) {
|
||||
case self::ACTION_REVOKE_RIGHTS:
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->revokeAuthLevel($adminLogin, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->revokeAuthLevel($adminLogin, $targetLogin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -221,7 +246,8 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
public function updateWidget(Player $player) {
|
||||
foreach ($this->adminListShown as $login => $shown) {
|
||||
if ($shown) {
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
if ($player) {
|
||||
$this->showAdminLists($player);
|
||||
} else {
|
||||
|
@ -29,9 +29,12 @@ class AuthCommands implements CommandListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Commands
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin', true, 'Add Player to the AdminList as SuperAdmin.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('addadmin', $this, 'command_AddAdmin', true, 'Add Player to the AdminList as Admin.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('addmod', $this, 'command_AddModerator', true, 'Add Player to the AdminList as Moderator.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin', true, 'Add Player to the AdminList as SuperAdmin.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('addadmin', $this, 'command_AddAdmin', true, 'Add Player to the AdminList as Admin.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('addmod', $this, 'command_AddModerator', true, 'Add Player to the AdminList as Moderator.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,7 +45,8 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
public function command_AddSuperAdmin(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$text = $chatCallback[1][2];
|
||||
@ -51,18 +55,23 @@ class AuthCommands implements CommandListener {
|
||||
$this->sendAddSuperAdminUsageInfo($player);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
return;
|
||||
}
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$success = $this->maniaControl->getAuthenticationManager()
|
||||
->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error occurred.', $player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as SuperAdmin!';
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,7 +82,8 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
private function sendAddSuperAdminUsageInfo(Player $player) {
|
||||
$message = "Usage Example: '//addsuperadmin login'";
|
||||
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
return $this->maniaControl->getChat()
|
||||
->sendUsageInfo($message, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +94,8 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
public function command_AddAdmin(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$text = $chatCallback[1][2];
|
||||
@ -93,18 +104,23 @@ class AuthCommands implements CommandListener {
|
||||
$this->sendAddAdminUsageInfo($player);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
return;
|
||||
}
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$success = $this->maniaControl->getAuthenticationManager()
|
||||
->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error occurred.', $player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as Admin!';
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,7 +131,8 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
private function sendAddAdminUsageInfo(Player $player) {
|
||||
$message = "Usage Example: '//addadmin login'";
|
||||
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
return $this->maniaControl->getChat()
|
||||
->sendUsageInfo($message, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,7 +143,8 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
public function command_AddModerator(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$text = $chatCallback[1][2];
|
||||
@ -135,18 +153,23 @@ class AuthCommands implements CommandListener {
|
||||
$this->sendAddModeratorUsageInfo($player);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
return;
|
||||
}
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$success = $this->maniaControl->getAuthenticationManager()
|
||||
->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error occurred.', $player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as Moderator!';
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,6 +180,7 @@ class AuthCommands implements CommandListener {
|
||||
*/
|
||||
private function sendAddModeratorUsageInfo(Player $player) {
|
||||
$message = "Usage Example: '//addmod login'";
|
||||
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
return $this->maniaControl->getChat()
|
||||
->sendUsageInfo($message, $player);
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ class AuthenticationManager implements CallbackListener {
|
||||
$this->authCommands = new AuthCommands($maniaControl);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,14 +147,16 @@ class AuthenticationManager implements CallbackListener {
|
||||
* @return bool
|
||||
*/
|
||||
private function updateMasterAdmins() {
|
||||
$masterAdminsElements = $this->maniaControl->getConfig()->xpath('masteradmins');
|
||||
$masterAdminsElements = $this->maniaControl->getConfig()
|
||||
->xpath('masteradmins');
|
||||
if (!$masterAdminsElements) {
|
||||
Logger::logError('Missing MasterAdmins configuration!');
|
||||
return false;
|
||||
}
|
||||
$masterAdminsElement = $masterAdminsElements[0];
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
|
||||
// Remove all MasterAdmins
|
||||
$adminQuery = "UPDATE `" . PlayerManager::TABLE_PLAYERS . "`
|
||||
@ -209,7 +212,8 @@ class AuthenticationManager implements CallbackListener {
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getConnectedAdmins($authLevel = self::AUTH_LEVEL_MODERATOR) {
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
$players = $this->maniaControl->getPlayerManager()
|
||||
->getPlayers();
|
||||
$admins = array();
|
||||
foreach ($players as $player) {
|
||||
if (self::checkRight($player, $authLevel)) {
|
||||
@ -240,7 +244,8 @@ class AuthenticationManager implements CallbackListener {
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getAdmins($authLevel = self::AUTH_LEVEL_MODERATOR) {
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$query = "SELECT `login` FROM `" . PlayerManager::TABLE_PLAYERS . "`
|
||||
WHERE `authLevel` > " . $authLevel . "
|
||||
ORDER BY `authLevel` DESC;";
|
||||
@ -251,7 +256,8 @@ class AuthenticationManager implements CallbackListener {
|
||||
}
|
||||
$admins = array();
|
||||
while ($row = $result->fetch_object()) {
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($row->login, false);
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($row->login, false);
|
||||
if ($player) {
|
||||
array_push($admins, $player);
|
||||
}
|
||||
@ -276,7 +282,8 @@ class AuthenticationManager implements CallbackListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$authQuery = "INSERT INTO `" . PlayerManager::TABLE_PLAYERS . "` (
|
||||
`login`,
|
||||
`authLevel`
|
||||
@ -299,7 +306,8 @@ class AuthenticationManager implements CallbackListener {
|
||||
$authStatement->close();
|
||||
|
||||
$player->authLevel = $authLevel;
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_AUTH_LEVEL_CHANGED, $player);
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_AUTH_LEVEL_CHANGED, $player);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -314,7 +322,8 @@ class AuthenticationManager implements CallbackListener {
|
||||
if (!$player) {
|
||||
return false;
|
||||
}
|
||||
return $this->maniaControl->getChat()->sendError('You do not have the required Rights to perform this Action!', $player);
|
||||
return $this->maniaControl->getChat()
|
||||
->sendError('You do not have the required Rights to perform this Action!', $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -325,7 +334,8 @@ class AuthenticationManager implements CallbackListener {
|
||||
* @return bool
|
||||
*/
|
||||
public function checkPermission(Player $player, $rightName) {
|
||||
$right = $this->maniaControl->getSettingManager()->getSettingValue($this, $rightName);
|
||||
$right = $this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, $rightName);
|
||||
return $this->checkRight($player, $this->getAuthLevel($right));
|
||||
}
|
||||
|
||||
@ -336,7 +346,8 @@ class AuthenticationManager implements CallbackListener {
|
||||
* @param int $authLevelNeeded
|
||||
*/
|
||||
public function definePermissionLevel($rightName, $authLevelNeeded) {
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, $rightName, $this->getPermissionLevelNameArray($authLevelNeeded));
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, $rightName, $this->getPermissionLevelNameArray($authLevelNeeded));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user