applied common formatting
This commit is contained in:
parent
3857f332f7
commit
d52423b737
@ -3,6 +3,18 @@
|
|||||||
<component name="ProjectCodeStyleSettingsManager">
|
<component name="ProjectCodeStyleSettingsManager">
|
||||||
<option name="PER_PROJECT_SETTINGS">
|
<option name="PER_PROJECT_SETTINGS">
|
||||||
<value>
|
<value>
|
||||||
|
<option name="OTHER_INDENT_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="INDENT_SIZE" value="4" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||||
|
<option name="TAB_SIZE" value="4" />
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="false" />
|
||||||
|
<option name="LABEL_INDENT_SIZE" value="0" />
|
||||||
|
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
|
||||||
|
<option name="USE_RELATIVE_INDENTS" value="false" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
<PHPCodeStyleSettings>
|
<PHPCodeStyleSettings>
|
||||||
<option name="ALIGN_PHPDOC_PARAM_NAMES" value="true" />
|
<option name="ALIGN_PHPDOC_PARAM_NAMES" value="true" />
|
||||||
<option name="ALIGN_PHPDOC_COMMENTS" value="true" />
|
<option name="ALIGN_PHPDOC_COMMENTS" value="true" />
|
||||||
@ -16,6 +28,11 @@
|
|||||||
<XML>
|
<XML>
|
||||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||||
</XML>
|
</XML>
|
||||||
|
<codeStyleSettings language="HTML">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
<codeStyleSettings language="PHP">
|
<codeStyleSettings language="PHP">
|
||||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||||
@ -25,9 +42,10 @@
|
|||||||
<option name="CLASS_BRACE_STYLE" value="1" />
|
<option name="CLASS_BRACE_STYLE" value="1" />
|
||||||
<option name="METHOD_BRACE_STYLE" value="1" />
|
<option name="METHOD_BRACE_STYLE" value="1" />
|
||||||
<option name="SPECIAL_ELSE_IF_TREATMENT" value="true" />
|
<option name="SPECIAL_ELSE_IF_TREATMENT" value="true" />
|
||||||
<option name="IF_BRACE_FORCE" value="1" />
|
<option name="IF_BRACE_FORCE" value="3" />
|
||||||
<option name="DOWHILE_BRACE_FORCE" value="1" />
|
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||||
<option name="WHILE_BRACE_FORCE" value="1" />
|
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||||
|
<option name="FOR_BRACE_FORCE" value="3" />
|
||||||
<indentOptions>
|
<indentOptions>
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
</indentOptions>
|
</indentOptions>
|
||||||
|
@ -18,19 +18,19 @@ use ManiaControl\Players\PlayerManager;
|
|||||||
/**
|
/**
|
||||||
* Class managing Actions Menus
|
* Class managing Actions Menus
|
||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||||
/*
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const MLID_MENU = 'ActionsMenu.MLID';
|
const MLID_MENU = 'ActionsMenu.MLID';
|
||||||
const SETTING_MENU_POSX = 'Menu Position: X';
|
const SETTING_MENU_POSX = 'Menu Position: X';
|
||||||
const SETTING_MENU_POSY = 'Menu Position: Y';
|
const SETTING_MENU_POSY = 'Menu Position: Y';
|
||||||
const SETTING_MENU_ITEMSIZE = 'Menu Item Size';
|
const SETTING_MENU_ITEMSIZE = 'Menu Item Size';
|
||||||
const ACTION_OPEN_ADMIN_MENU = 'ActionsMenu.OpenAdminMenu';
|
const ACTION_OPEN_ADMIN_MENU = 'ActionsMenu.OpenAdminMenu';
|
||||||
const ACTION_OPEN_PLAYER_MENU = 'ActionsMenu.OpenPlayerMenu';
|
const ACTION_OPEN_PLAYER_MENU = 'ActionsMenu.OpenPlayerMenu';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -64,41 +64,24 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
* Add a new Menu Item
|
* Add a new Menu Item
|
||||||
*
|
*
|
||||||
* @param Control $control
|
* @param Control $control
|
||||||
* @param bool $playerAction
|
* @param bool $playerAction
|
||||||
* @param int $order
|
* @param int $order
|
||||||
* @param string $description
|
* @param string $description
|
||||||
*/
|
*/
|
||||||
public function addMenuItem(Control $control, $playerAction = true, $order = 0, $description = null) {
|
public function addMenuItem(Control $control, $playerAction = true, $order = 0, $description = null) {
|
||||||
if ($playerAction) {
|
if ($playerAction) {
|
||||||
$this->addPlayerMenuItem($control, $order, $description);
|
$this->addPlayerMenuItem($control, $order, $description);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$this->addAdminMenuItem($control, $order, $description);
|
$this->addAdminMenuItem($control, $order, $description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a Menu Item
|
|
||||||
*
|
|
||||||
* @param $order
|
|
||||||
* @param bool $playerAction
|
|
||||||
*/
|
|
||||||
public function removeMenuItem($order, $playerAction = true) {
|
|
||||||
if ($playerAction) {
|
|
||||||
unset($this->playerMenuItems[$order]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
unset($this->adminMenuItems[$order]);
|
|
||||||
}
|
|
||||||
$this->rebuildAndShowMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Player Menu Item
|
* Add a new Player Menu Item
|
||||||
*
|
*
|
||||||
* @param Control $control
|
* @param Control $control
|
||||||
* @param int $order
|
* @param int $order
|
||||||
* @param string $description
|
* @param string $description
|
||||||
*/
|
*/
|
||||||
public function addPlayerMenuItem(Control $control, $order = 0, $description = null) {
|
public function addPlayerMenuItem(Control $control, $order = 0, $description = null) {
|
||||||
if (!isset($this->playerMenuItems[$order])) {
|
if (!isset($this->playerMenuItems[$order])) {
|
||||||
@ -109,30 +92,6 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
$this->rebuildAndShowMenu();
|
$this->rebuildAndShowMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new Admin Menu Item
|
|
||||||
*
|
|
||||||
* @param Control $control
|
|
||||||
* @param int $order
|
|
||||||
* @param string $description
|
|
||||||
*/
|
|
||||||
public function addAdminMenuItem(Control $control, $order = 0, $description = null) {
|
|
||||||
if (!isset($this->adminMenuItems[$order])) {
|
|
||||||
$this->adminMenuItems[$order] = array();
|
|
||||||
}
|
|
||||||
array_push($this->adminMenuItems[$order], array($control, $description));
|
|
||||||
krsort($this->adminMenuItems);
|
|
||||||
$this->rebuildAndShowMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle ManiaControl AfterInit callback
|
|
||||||
*/
|
|
||||||
public function handleAfterInit() {
|
|
||||||
$this->initCompleted = true;
|
|
||||||
$this->rebuildAndShowMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build and show the menus to everyone (if a menu get made after the init)
|
* Build and show the menus to everyone (if a menu get made after the init)
|
||||||
*/
|
*/
|
||||||
@ -147,16 +106,6 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle PlayerJoined callback
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
*/
|
|
||||||
public function handlePlayerJoined(Player $player) {
|
|
||||||
$maniaLink = $this->buildMenuIconsManialink($player);
|
|
||||||
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $player->login);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the Manialink
|
* Builds the Manialink
|
||||||
*
|
*
|
||||||
@ -164,12 +113,12 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
* @return ManiaLink
|
* @return ManiaLink
|
||||||
*/
|
*/
|
||||||
private function buildMenuIconsManialink(Player $player) {
|
private function buildMenuIconsManialink(Player $player) {
|
||||||
$posX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSX);
|
$posX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSX);
|
||||||
$posY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSY);
|
$posY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSY);
|
||||||
$itemSize = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_ITEMSIZE);
|
$itemSize = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_ITEMSIZE);
|
||||||
$shootManiaOffset = $this->maniaControl->manialinkManager->styleManager->getDefaultIconOffsetSM();
|
$shootManiaOffset = $this->maniaControl->manialinkManager->styleManager->getDefaultIconOffsetSM();
|
||||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
|
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
|
||||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
|
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
|
||||||
$itemMarginFactorX = 1.3;
|
$itemMarginFactorX = 1.3;
|
||||||
$itemMarginFactorY = 1.2;
|
$itemMarginFactorY = 1.2;
|
||||||
|
|
||||||
@ -314,4 +263,53 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
|
|
||||||
return $manialink;
|
return $manialink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new Admin Menu Item
|
||||||
|
*
|
||||||
|
* @param Control $control
|
||||||
|
* @param int $order
|
||||||
|
* @param string $description
|
||||||
|
*/
|
||||||
|
public function addAdminMenuItem(Control $control, $order = 0, $description = null) {
|
||||||
|
if (!isset($this->adminMenuItems[$order])) {
|
||||||
|
$this->adminMenuItems[$order] = array();
|
||||||
|
}
|
||||||
|
array_push($this->adminMenuItems[$order], array($control, $description));
|
||||||
|
krsort($this->adminMenuItems);
|
||||||
|
$this->rebuildAndShowMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a Menu Item
|
||||||
|
*
|
||||||
|
* @param $order
|
||||||
|
* @param bool $playerAction
|
||||||
|
*/
|
||||||
|
public function removeMenuItem($order, $playerAction = true) {
|
||||||
|
if ($playerAction) {
|
||||||
|
unset($this->playerMenuItems[$order]);
|
||||||
|
} else {
|
||||||
|
unset($this->adminMenuItems[$order]);
|
||||||
|
}
|
||||||
|
$this->rebuildAndShowMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle ManiaControl AfterInit callback
|
||||||
|
*/
|
||||||
|
public function handleAfterInit() {
|
||||||
|
$this->initCompleted = true;
|
||||||
|
$this->rebuildAndShowMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle PlayerJoined callback
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
*/
|
||||||
|
public function handlePlayerJoined(Player $player) {
|
||||||
|
$maniaLink = $this->buildMenuIconsManialink($player);
|
||||||
|
$this->maniaControl->manialinkManager->sendManialink($maniaLink, $player->login);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@ use ManiaControl\Players\Player;
|
|||||||
/**
|
/**
|
||||||
* Widget Class listing Authorized Players
|
* Widget Class listing Authorized Players
|
||||||
*
|
*
|
||||||
* @author kremsy
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||||
/*
|
/*
|
||||||
@ -62,7 +62,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Open Admin List Action
|
* Open Admin List Action
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param array $callback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function openAdminList(array $callback, Player $player) {
|
public function openAdminList(array $callback, Player $player) {
|
||||||
@ -90,8 +90,8 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
//Create ManiaLink
|
//Create ManiaLink
|
||||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||||
$script = $maniaLink->getScript();
|
$script = $maniaLink->getScript();
|
||||||
$paging = new Paging();
|
$paging = new Paging();
|
||||||
$script->addFeature($paging);
|
$script->addFeature($paging);
|
||||||
|
|
||||||
// Main frame
|
// Main frame
|
||||||
$frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script, $pagesId);
|
$frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script, $pagesId);
|
||||||
@ -115,7 +115,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$i = 1;
|
$i = 1;
|
||||||
$y = $y - 10;
|
$y = $y - 10;
|
||||||
$pageFrames = array();
|
$pageFrames = array();
|
||||||
foreach($admins as $admin) {
|
foreach ($admins as $admin) {
|
||||||
if (!isset($pageFrame)) {
|
if (!isset($pageFrame)) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
@ -124,7 +124,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
array_push($pageFrames, $pageFrame);
|
array_push($pageFrames, $pageFrame);
|
||||||
$y = $height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -158,8 +158,8 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$rightLabel->setTextSize(0.8);
|
$rightLabel->setTextSize(0.8);
|
||||||
$rightLabel->setZ(10);
|
$rightLabel->setZ(10);
|
||||||
$rightLabel->setText($this->maniaControl->authenticationManager->getAuthLevelAbbreviation($admin));
|
$rightLabel->setText($this->maniaControl->authenticationManager->getAuthLevelAbbreviation($admin));
|
||||||
$description = $this->maniaControl->authenticationManager->getAuthLevelName($admin) . " " . $admin->nickname;
|
$description = $this->maniaControl->authenticationManager->getAuthLevelName($admin) . " " . $admin->nickname;
|
||||||
$rightLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
$rightLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||||
|
|
||||||
//Revoke Button
|
//Revoke Button
|
||||||
if ($admin->authLevel > 0 && $this->maniaControl->authenticationManager->checkRight($player, $admin->authLevel + 1)) {
|
if ($admin->authLevel > 0 && $this->maniaControl->authenticationManager->checkRight($player, $admin->authLevel + 1)) {
|
||||||
@ -217,7 +217,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$adminLogin = $callback[1][1];
|
$adminLogin = $callback[1][1];
|
||||||
$targetLogin = $actionArray[2];
|
$targetLogin = $actionArray[2];
|
||||||
|
|
||||||
switch($action) {
|
switch ($action) {
|
||||||
case self::ACTION_REVOKE_RIGHTS:
|
case self::ACTION_REVOKE_RIGHTS:
|
||||||
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);
|
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);
|
||||||
break;
|
break;
|
||||||
@ -230,7 +230,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function updateWidget(Player $player) {
|
public function updateWidget(Player $player) {
|
||||||
foreach($this->adminListShown as $login => $shown) {
|
foreach ($this->adminListShown as $login => $shown) {
|
||||||
if ($shown) {
|
if ($shown) {
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
if ($player) {
|
if ($player) {
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
namespace ManiaControl\Admin;
|
namespace ManiaControl\Admin;
|
||||||
|
|
||||||
use ManiaControl\ManiaControl;
|
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class offering Commands to grant Authorizations to Players
|
* Class offering Commands to grant Authorizations to Players
|
||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class AuthCommands implements CommandListener {
|
class AuthCommands implements CommandListener {
|
||||||
/*
|
/*
|
||||||
@ -28,15 +28,15 @@ class AuthCommands implements CommandListener {
|
|||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
// Register for commands
|
// Register for commands
|
||||||
$this->maniaControl->commandManager->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin',true, 'Add Player to the AdminList as SuperAdmin.');
|
$this->maniaControl->commandManager->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin', true, 'Add Player to the AdminList as SuperAdmin.');
|
||||||
$this->maniaControl->commandManager->registerCommandListener('addadmin', $this, 'command_AddAdmin',true, 'Add Player to the AdminList as Admin.');
|
$this->maniaControl->commandManager->registerCommandListener('addadmin', $this, 'command_AddAdmin', true, 'Add Player to the AdminList as Admin.');
|
||||||
$this->maniaControl->commandManager->registerCommandListener('addmod', $this, 'command_AddModerator',true, 'Add Player to the AdminList as Moderator.');
|
$this->maniaControl->commandManager->registerCommandListener('addmod', $this, 'command_AddModerator', true, 'Add Player to the AdminList as Moderator.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle //addsuperadmin command
|
* Handle //addsuperadmin command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_AddSuperAdmin(array $chatCallback, Player $player) {
|
public function command_AddSuperAdmin(array $chatCallback, Player $player) {
|
||||||
@ -44,7 +44,7 @@ class AuthCommands implements CommandListener {
|
|||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$text = $chatCallback[1][2];
|
$text = $chatCallback[1][2];
|
||||||
$commandParts = explode(' ', $text);
|
$commandParts = explode(' ', $text);
|
||||||
if (!array_key_exists(1, $commandParts)) {
|
if (!array_key_exists(1, $commandParts)) {
|
||||||
$this->sendAddSuperAdminUsageInfo($player);
|
$this->sendAddSuperAdminUsageInfo($player);
|
||||||
@ -64,10 +64,21 @@ class AuthCommands implements CommandListener {
|
|||||||
$this->maniaControl->chat->sendSuccess($message);
|
$this->maniaControl->chat->sendSuccess($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send usage example for //addsuperadmin command
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function sendAddSuperAdminUsageInfo(Player $player) {
|
||||||
|
$message = "Usage Example: '//addsuperadmin login'";
|
||||||
|
return $this->maniaControl->chat->sendUsageInfo($message, $player->login);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle //addadmin command
|
* Handle //addadmin command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_AddAdmin(array $chatCallback, Player $player) {
|
public function command_AddAdmin(array $chatCallback, Player $player) {
|
||||||
@ -75,7 +86,7 @@ class AuthCommands implements CommandListener {
|
|||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$text = $chatCallback[1][2];
|
$text = $chatCallback[1][2];
|
||||||
$commandParts = explode(' ', $text);
|
$commandParts = explode(' ', $text);
|
||||||
if (!array_key_exists(1, $commandParts)) {
|
if (!array_key_exists(1, $commandParts)) {
|
||||||
$this->sendAddAdminUsageInfo($player);
|
$this->sendAddAdminUsageInfo($player);
|
||||||
@ -95,10 +106,21 @@ class AuthCommands implements CommandListener {
|
|||||||
$this->maniaControl->chat->sendSuccess($message);
|
$this->maniaControl->chat->sendSuccess($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send usage example for //addadmin command
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function sendAddAdminUsageInfo(Player $player) {
|
||||||
|
$message = "Usage Example: '//addadmin login'";
|
||||||
|
return $this->maniaControl->chat->sendUsageInfo($message, $player->login);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle //addmod command
|
* Handle //addmod command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_AddModerator(array $chatCallback, Player $player) {
|
public function command_AddModerator(array $chatCallback, Player $player) {
|
||||||
@ -106,7 +128,7 @@ class AuthCommands implements CommandListener {
|
|||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$text = $chatCallback[1][2];
|
$text = $chatCallback[1][2];
|
||||||
$commandParts = explode(' ', $text);
|
$commandParts = explode(' ', $text);
|
||||||
if (!array_key_exists(1, $commandParts)) {
|
if (!array_key_exists(1, $commandParts)) {
|
||||||
$this->sendAddModeratorUsageInfo($player);
|
$this->sendAddModeratorUsageInfo($player);
|
||||||
@ -126,28 +148,6 @@ class AuthCommands implements CommandListener {
|
|||||||
$this->maniaControl->chat->sendSuccess($message);
|
$this->maniaControl->chat->sendSuccess($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send usage example for //addsuperadmin command
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function sendAddSuperAdminUsageInfo(Player $player) {
|
|
||||||
$message = "Usage Example: '//addsuperadmin login'";
|
|
||||||
return $this->maniaControl->chat->sendUsageInfo($message, $player->login);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send usage example for //addadmin command
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function sendAddAdminUsageInfo(Player $player) {
|
|
||||||
$message = "Usage Example: '//addadmin login'";
|
|
||||||
return $this->maniaControl->chat->sendUsageInfo($message, $player->login);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send usage example for //addop command
|
* Send usage example for //addop command
|
||||||
*
|
*
|
||||||
|
@ -11,25 +11,25 @@ use ManiaControl\Players\PlayerManager;
|
|||||||
/**
|
/**
|
||||||
* Class managing Authentication Levels
|
* Class managing Authentication Levels
|
||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
* @copyright 2014 ManiaControl Team
|
||||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
class AuthenticationManager implements CallbackListener {
|
class AuthenticationManager implements CallbackListener {
|
||||||
/*
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const AUTH_LEVEL_PLAYER = 0;
|
const AUTH_LEVEL_PLAYER = 0;
|
||||||
const AUTH_LEVEL_MODERATOR = 1;
|
const AUTH_LEVEL_MODERATOR = 1;
|
||||||
const AUTH_LEVEL_ADMIN = 2;
|
const AUTH_LEVEL_ADMIN = 2;
|
||||||
const AUTH_LEVEL_SUPERADMIN = 3;
|
const AUTH_LEVEL_SUPERADMIN = 3;
|
||||||
const AUTH_LEVEL_MASTERADMIN = 4;
|
const AUTH_LEVEL_MASTERADMIN = 4;
|
||||||
const AUTH_NAME_PLAYER = 'Player';
|
const AUTH_NAME_PLAYER = 'Player';
|
||||||
const AUTH_NAME_MODERATOR = 'Moderator';
|
const AUTH_NAME_MODERATOR = 'Moderator';
|
||||||
const AUTH_NAME_ADMIN = 'Admin';
|
const AUTH_NAME_ADMIN = 'Admin';
|
||||||
const AUTH_NAME_SUPERADMIN = 'SuperAdmin';
|
const AUTH_NAME_SUPERADMIN = 'SuperAdmin';
|
||||||
const AUTH_NAME_MASTERADMIN = 'MasterAdmin';
|
const AUTH_NAME_MASTERADMIN = 'MasterAdmin';
|
||||||
const CB_AUTH_LEVEL_CHANGED = 'AuthenticationManager.AuthLevelChanged';
|
const CB_AUTH_LEVEL_CHANGED = 'AuthenticationManager.AuthLevelChanged';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public Properties
|
* Public Properties
|
||||||
@ -53,6 +53,85 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'handleOnInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'handleOnInit');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Name of the Authentication Level from Level Int
|
||||||
|
*
|
||||||
|
* @param mixed $authLevelInt
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getAuthLevelName($authLevelInt) {
|
||||||
|
$authLevelInt = self::getAuthLevelInt($authLevelInt);
|
||||||
|
switch ($authLevelInt) {
|
||||||
|
case self::AUTH_LEVEL_MASTERADMIN:
|
||||||
|
return self::AUTH_NAME_MASTERADMIN;
|
||||||
|
case self::AUTH_LEVEL_SUPERADMIN:
|
||||||
|
return self::AUTH_NAME_SUPERADMIN;
|
||||||
|
case self::AUTH_LEVEL_ADMIN:
|
||||||
|
return self::AUTH_NAME_ADMIN;
|
||||||
|
case self::AUTH_LEVEL_MODERATOR:
|
||||||
|
return self::AUTH_NAME_MODERATOR;
|
||||||
|
}
|
||||||
|
return self::AUTH_NAME_PLAYER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Authentication Level Int from the given Param
|
||||||
|
*
|
||||||
|
* @param mixed $authLevelParam
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getAuthLevelInt($authLevelParam) {
|
||||||
|
if (is_object($authLevelParam) && property_exists($authLevelParam, 'authLevel')) {
|
||||||
|
return (int)$authLevelParam->authLevel;
|
||||||
|
}
|
||||||
|
if (is_string($authLevelParam)) {
|
||||||
|
return self::getAuthLevel($authLevelParam);
|
||||||
|
}
|
||||||
|
return (int)$authLevelParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Authentication Level Int from Level Name
|
||||||
|
*
|
||||||
|
* @param string $authLevelName
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getAuthLevel($authLevelName) {
|
||||||
|
$authLevelName = (string)$authLevelName;
|
||||||
|
switch ($authLevelName) {
|
||||||
|
case self::AUTH_NAME_MASTERADMIN:
|
||||||
|
return self::AUTH_LEVEL_MASTERADMIN;
|
||||||
|
case self::AUTH_NAME_SUPERADMIN:
|
||||||
|
return self::AUTH_LEVEL_SUPERADMIN;
|
||||||
|
case self::AUTH_NAME_ADMIN:
|
||||||
|
return self::AUTH_LEVEL_ADMIN;
|
||||||
|
case self::AUTH_NAME_MODERATOR:
|
||||||
|
return self::AUTH_LEVEL_MODERATOR;
|
||||||
|
}
|
||||||
|
return self::AUTH_LEVEL_PLAYER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Abbreviation of the Authentication Level from Level Int
|
||||||
|
*
|
||||||
|
* @param mixed $authLevelInt
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getAuthLevelAbbreviation($authLevelInt) {
|
||||||
|
$authLevelInt = self::getAuthLevelInt($authLevelInt);
|
||||||
|
switch ($authLevelInt) {
|
||||||
|
case self::AUTH_LEVEL_MASTERADMIN:
|
||||||
|
return 'MA';
|
||||||
|
case self::AUTH_LEVEL_SUPERADMIN:
|
||||||
|
return 'SA';
|
||||||
|
case self::AUTH_LEVEL_ADMIN:
|
||||||
|
return 'AD';
|
||||||
|
case self::AUTH_LEVEL_MODERATOR:
|
||||||
|
return 'MOD';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle ManiaControl OnInit Callback
|
* Handle ManiaControl OnInit Callback
|
||||||
*/
|
*/
|
||||||
@ -61,7 +140,7 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update MasterAdmins based on config
|
* Update MasterAdmins based on Config
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@ -69,7 +148,7 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
|
|
||||||
// Remove all MasterAdmins
|
// Remove all MasterAdmins
|
||||||
$adminQuery = "UPDATE `" . PlayerManager::TABLE_PLAYERS . "`
|
$adminQuery = "UPDATE `" . PlayerManager::TABLE_PLAYERS . "`
|
||||||
SET `authLevel` = ?
|
SET `authLevel` = ?
|
||||||
WHERE `authLevel` = ?;";
|
WHERE `authLevel` = ?;";
|
||||||
$adminStatement = $mysqli->prepare($adminQuery);
|
$adminStatement = $mysqli->prepare($adminQuery);
|
||||||
@ -77,7 +156,7 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
trigger_error($mysqli->error, E_USER_ERROR);
|
trigger_error($mysqli->error, E_USER_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$adminLevel = self::AUTH_LEVEL_SUPERADMIN;
|
$adminLevel = self::AUTH_LEVEL_SUPERADMIN;
|
||||||
$masterAdminLevel = self::AUTH_LEVEL_MASTERADMIN;
|
$masterAdminLevel = self::AUTH_LEVEL_MASTERADMIN;
|
||||||
$adminStatement->bind_param('ii', $adminLevel, $masterAdminLevel);
|
$adminStatement->bind_param('ii', $adminLevel, $masterAdminLevel);
|
||||||
$adminStatement->execute();
|
$adminStatement->execute();
|
||||||
@ -87,8 +166,8 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
$adminStatement->close();
|
$adminStatement->close();
|
||||||
|
|
||||||
// Set MasterAdmins
|
// Set MasterAdmins
|
||||||
$masterAdmins = $this->maniaControl->config->masteradmins->xpath('login');
|
$masterAdmins = $this->maniaControl->config->masteradmins->xpath('login');
|
||||||
$adminQuery = "INSERT INTO `" . PlayerManager::TABLE_PLAYERS . "` (
|
$adminQuery = "INSERT INTO `" . PlayerManager::TABLE_PLAYERS . "` (
|
||||||
`login`,
|
`login`,
|
||||||
`authLevel`
|
`authLevel`
|
||||||
) VALUES (
|
) VALUES (
|
||||||
@ -102,7 +181,7 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
$success = true;
|
$success = true;
|
||||||
foreach ($masterAdmins as $masterAdmin) {
|
foreach ($masterAdmins as $masterAdmin) {
|
||||||
$login = (string) $masterAdmin;
|
$login = (string)$masterAdmin;
|
||||||
$adminStatement->bind_param('si', $login, $masterAdminLevel);
|
$adminStatement->bind_param('si', $login, $masterAdminLevel);
|
||||||
$adminStatement->execute();
|
$adminStatement->execute();
|
||||||
if ($adminStatement->error) {
|
if ($adminStatement->error) {
|
||||||
@ -124,8 +203,7 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
if ($authLevel < 0) {
|
if ($authLevel < 0) {
|
||||||
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "` WHERE `authLevel` > 0 ORDER BY `authLevel` DESC;";
|
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "` WHERE `authLevel` > 0 ORDER BY `authLevel` DESC;";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "` WHERE `authLevel` = " . $authLevel . ";";
|
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "` WHERE `authLevel` = " . $authLevel . ";";
|
||||||
}
|
}
|
||||||
$result = $mysqli->query($query);
|
$result = $mysqli->query($query);
|
||||||
@ -144,20 +222,20 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
* Grant the Auth Level to the Player
|
* Grant the Auth Level to the Player
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param int $authLevel
|
* @param int $authLevel
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function grantAuthLevel(Player &$player, $authLevel) {
|
public function grantAuthLevel(Player &$player, $authLevel) {
|
||||||
if (!$player || !is_numeric($authLevel)) {
|
if (!$player || !is_numeric($authLevel)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$authLevel = (int) $authLevel;
|
$authLevel = (int)$authLevel;
|
||||||
if ($authLevel >= self::AUTH_LEVEL_MASTERADMIN) {
|
if ($authLevel >= self::AUTH_LEVEL_MASTERADMIN) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
$authQuery = "INSERT INTO `" . PlayerManager::TABLE_PLAYERS . "` (
|
$authQuery = "INSERT INTO `" . PlayerManager::TABLE_PLAYERS . "` (
|
||||||
`login`,
|
`login`,
|
||||||
`authLevel`
|
`authLevel`
|
||||||
) VALUES (
|
) VALUES (
|
||||||
@ -197,22 +275,11 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
return $this->maniaControl->chat->sendError('You do not have the required Rights to perform this Action!', $player->login);
|
return $this->maniaControl->chat->sendError('You do not have the required Rights to perform this Action!', $player->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the Player has enough Rights
|
|
||||||
*
|
|
||||||
* @param Player $player
|
|
||||||
* @param int $neededAuthLevel
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function checkRight(Player $player, $neededAuthLevel) {
|
|
||||||
return ($player->authLevel >= $neededAuthLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the permission by a right name
|
* Checks the permission by a right name
|
||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param $rightName
|
* @param $rightName
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function checkPermission(Player $player, $rightName) {
|
public function checkPermission(Player $player, $rightName) {
|
||||||
@ -220,6 +287,17 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
return $this->checkRight($player, $right);
|
return $this->checkRight($player, $right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the Player has enough Rights
|
||||||
|
*
|
||||||
|
* @param Player $player
|
||||||
|
* @param int $neededAuthLevel
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function checkRight(Player $player, $neededAuthLevel) {
|
||||||
|
return ($player->authLevel >= $neededAuthLevel);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a Minimum Right Level needed for an action
|
* Defines a Minimum Right Level needed for an action
|
||||||
*
|
*
|
||||||
@ -229,83 +307,4 @@ class AuthenticationManager implements CallbackListener {
|
|||||||
public function definePermissionLevel($rightName, $authLevelNeeded) {
|
public function definePermissionLevel($rightName, $authLevelNeeded) {
|
||||||
$this->maniaControl->settingManager->initSetting($this, $rightName, $authLevelNeeded);
|
$this->maniaControl->settingManager->initSetting($this, $rightName, $authLevelNeeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Name of the Authentication Level from Level Int
|
|
||||||
*
|
|
||||||
* @param mixed $authLevelInt
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getAuthLevelName($authLevelInt) {
|
|
||||||
$authLevelInt = self::getAuthLevelInt($authLevelInt);
|
|
||||||
switch ($authLevelInt) {
|
|
||||||
case self::AUTH_LEVEL_MASTERADMIN:
|
|
||||||
return self::AUTH_NAME_MASTERADMIN;
|
|
||||||
case self::AUTH_LEVEL_SUPERADMIN:
|
|
||||||
return self::AUTH_NAME_SUPERADMIN;
|
|
||||||
case self::AUTH_LEVEL_ADMIN:
|
|
||||||
return self::AUTH_NAME_ADMIN;
|
|
||||||
case self::AUTH_LEVEL_MODERATOR:
|
|
||||||
return self::AUTH_NAME_MODERATOR;
|
|
||||||
}
|
|
||||||
return self::AUTH_NAME_PLAYER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Abbreviation of the Authentication Level from Level Int
|
|
||||||
*
|
|
||||||
* @param mixed $authLevelInt
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getAuthLevelAbbreviation($authLevelInt) {
|
|
||||||
$authLevelInt = self::getAuthLevelInt($authLevelInt);
|
|
||||||
switch ($authLevelInt) {
|
|
||||||
case self::AUTH_LEVEL_MASTERADMIN:
|
|
||||||
return 'MA';
|
|
||||||
case self::AUTH_LEVEL_SUPERADMIN:
|
|
||||||
return 'SA';
|
|
||||||
case self::AUTH_LEVEL_ADMIN:
|
|
||||||
return 'AD';
|
|
||||||
case self::AUTH_LEVEL_MODERATOR:
|
|
||||||
return 'MOD';
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Authentication Level Int from Level Name
|
|
||||||
*
|
|
||||||
* @param string $authLevelName
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public static function getAuthLevel($authLevelName) {
|
|
||||||
$authLevelName = (string) $authLevelName;
|
|
||||||
switch ($authLevelName) {
|
|
||||||
case self::AUTH_NAME_MASTERADMIN:
|
|
||||||
return self::AUTH_LEVEL_MASTERADMIN;
|
|
||||||
case self::AUTH_NAME_SUPERADMIN:
|
|
||||||
return self::AUTH_LEVEL_SUPERADMIN;
|
|
||||||
case self::AUTH_NAME_ADMIN:
|
|
||||||
return self::AUTH_LEVEL_ADMIN;
|
|
||||||
case self::AUTH_NAME_MODERATOR:
|
|
||||||
return self::AUTH_LEVEL_MODERATOR;
|
|
||||||
}
|
|
||||||
return self::AUTH_LEVEL_PLAYER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Authentication Level Int from the given Param
|
|
||||||
*
|
|
||||||
* @param mixed $authLevelParam
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public static function getAuthLevelInt($authLevelParam) {
|
|
||||||
if (is_object($authLevelParam) && property_exists($authLevelParam, 'authLevel')) {
|
|
||||||
return (int) $authLevelParam->authLevel;
|
|
||||||
}
|
|
||||||
if (is_string($authLevelParam)) {
|
|
||||||
return self::getAuthLevel($authLevelParam);
|
|
||||||
}
|
|
||||||
return (int) $authLevelParam;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user