fixed authentication manager

This commit is contained in:
Steffen Schröder 2014-01-09 22:13:25 +01:00
parent f9041748f6
commit 161ef44508

View File

@ -5,6 +5,8 @@ namespace ManiaControl\Admin;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
require_once __DIR__ . '/AuthCommands.php';
@ -13,7 +15,7 @@ require_once __DIR__ . '/AuthCommands.php';
*
* @author steeffeen & kremsy
*/
class AuthenticationManager {
class AuthenticationManager implements CallbackListener {
/**
* Constants
*/
@ -35,20 +37,23 @@ class AuthenticationManager {
private $maniaControl = null;
/**
* Construct authentication manager
* Construct a new Authentication Manager
*
* @param \ManiaControl\ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
$this->updateMasterAdmins();
$this->authCommands = new AuthCommands($maniaControl);
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
}
public function handleOnInit(array $callback) {
$this->updateMasterAdmins();
}
/**
* Set MasterAdmins
* Update MasterAdmins based on config
*
* @return bool
*/
@ -109,13 +114,9 @@ class AuthenticationManager {
* @return bool
*/
public function grantAuthLevel(Player &$player, $authLevel) {
if(!$player || !is_numeric($authLevel)) {
return false;
}
if (!$player || !is_numeric($authLevel)) return false;
$authLevel = (int) $authLevel;
if($authLevel >= self::AUTH_LEVEL_MASTERADMIN) {
return false;
}
if ($authLevel >= self::AUTH_LEVEL_MASTERADMIN) return false;
$mysqli = $this->maniaControl->database->mysqli;
$authQuery = "INSERT INTO `" . PlayerManager::TABLE_PLAYERS . "` (
@ -152,9 +153,7 @@ class AuthenticationManager {
* @return bool
*/
public function sendNotAllowed(Player $player) {
if(!$player) {
return false;
}
if (!$player) return false;
return $this->maniaControl->chat->sendError('You do not have the required Rights to perform this Command!', $player->login);
}
@ -191,7 +190,6 @@ class AuthenticationManager {
$this->maniaControl->settingManager->initSetting($this, $rightName, $authLevelNeeded);
}
/**
* Get Name of the Authentication Level from Level Int
*