applied common formatting
This commit is contained in:
parent
3857f332f7
commit
d52423b737
@ -3,6 +3,18 @@
|
||||
<component name="ProjectCodeStyleSettingsManager">
|
||||
<option name="PER_PROJECT_SETTINGS">
|
||||
<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>
|
||||
<option name="ALIGN_PHPDOC_PARAM_NAMES" value="true" />
|
||||
<option name="ALIGN_PHPDOC_COMMENTS" value="true" />
|
||||
@ -16,6 +28,11 @@
|
||||
<XML>
|
||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||
</XML>
|
||||
<codeStyleSettings language="HTML">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="PHP">
|
||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
@ -25,9 +42,10 @@
|
||||
<option name="CLASS_BRACE_STYLE" value="1" />
|
||||
<option name="METHOD_BRACE_STYLE" value="1" />
|
||||
<option name="SPECIAL_ELSE_IF_TREATMENT" value="true" />
|
||||
<option name="IF_BRACE_FORCE" value="1" />
|
||||
<option name="DOWHILE_BRACE_FORCE" value="1" />
|
||||
<option name="WHILE_BRACE_FORCE" value="1" />
|
||||
<option name="IF_BRACE_FORCE" value="3" />
|
||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||
<option name="FOR_BRACE_FORCE" value="3" />
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
|
@ -18,8 +18,8 @@ use ManiaControl\Players\PlayerManager;
|
||||
/**
|
||||
* Class managing Actions Menus
|
||||
*
|
||||
* @author steeffeen & kremsy
|
||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
@ -71,28 +71,11 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
public function addMenuItem(Control $control, $playerAction = true, $order = 0, $description = null) {
|
||||
if ($playerAction) {
|
||||
$this->addPlayerMenuItem($control, $order, $description);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$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
|
||||
*
|
||||
@ -109,30 +92,6 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
$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)
|
||||
*/
|
||||
@ -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
|
||||
*
|
||||
@ -314,4 +263,53 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
|
||||
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,8 +21,8 @@ use ManiaControl\Players\Player;
|
||||
/**
|
||||
* Widget Class listing Authorized Players
|
||||
*
|
||||
* @author kremsy
|
||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
namespace ManiaControl\Admin;
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
/**
|
||||
* Class offering Commands to grant Authorizations to Players
|
||||
*
|
||||
* @author steeffeen & kremsy
|
||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class AuthCommands implements CommandListener {
|
||||
@ -64,6 +64,17 @@ class AuthCommands implements CommandListener {
|
||||
$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
|
||||
*
|
||||
@ -95,6 +106,17 @@ class AuthCommands implements CommandListener {
|
||||
$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
|
||||
*
|
||||
@ -126,28 +148,6 @@ class AuthCommands implements CommandListener {
|
||||
$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
|
||||
*
|
||||
|
@ -11,8 +11,8 @@ use ManiaControl\Players\PlayerManager;
|
||||
/**
|
||||
* Class managing Authentication Levels
|
||||
*
|
||||
* @author steeffeen & kremsy
|
||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class AuthenticationManager implements CallbackListener {
|
||||
@ -53,6 +53,85 @@ class AuthenticationManager implements CallbackListener {
|
||||
$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
|
||||
*/
|
||||
@ -61,7 +140,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update MasterAdmins based on config
|
||||
* Update MasterAdmins based on Config
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@ -124,8 +203,7 @@ class AuthenticationManager implements CallbackListener {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
if ($authLevel < 0) {
|
||||
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "` WHERE `authLevel` > 0 ORDER BY `authLevel` DESC;";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$query = "SELECT * FROM `" . PlayerManager::TABLE_PLAYERS . "` WHERE `authLevel` = " . $authLevel . ";";
|
||||
}
|
||||
$result = $mysqli->query($query);
|
||||
@ -197,17 +275,6 @@ class AuthenticationManager implements CallbackListener {
|
||||
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
|
||||
*
|
||||
@ -220,6 +287,17 @@ class AuthenticationManager implements CallbackListener {
|
||||
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
|
||||
*
|
||||
@ -229,83 +307,4 @@ class AuthenticationManager implements CallbackListener {
|
||||
public function definePermissionLevel($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