added auth level communication methods
This commit is contained in:
parent
bebd2e7353
commit
1ef9d3622a
@ -5,6 +5,9 @@ namespace ManiaControl\Admin;
|
|||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\Callbacks;
|
use ManiaControl\Callbacks\Callbacks;
|
||||||
use ManiaControl\Callbacks\EchoListener;
|
use ManiaControl\Callbacks\EchoListener;
|
||||||
|
use ManiaControl\Communication\CommunicationAnswer;
|
||||||
|
use ManiaControl\Communication\CommunicationListener;
|
||||||
|
use ManiaControl\Communication\CommunicationMethods;
|
||||||
use ManiaControl\Logger;
|
use ManiaControl\Logger;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
@ -18,7 +21,7 @@ use ManiaControl\Settings\Setting;
|
|||||||
* @copyright 2014-2015 ManiaControl Team
|
* @copyright 2014-2015 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, EchoListener {
|
class AuthenticationManager implements CallbackListener, EchoListener, CommunicationListener {
|
||||||
/*
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -75,6 +78,36 @@ class AuthenticationManager implements CallbackListener, EchoListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//Communication Listenings
|
||||||
|
$this->maniaControl->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::GRANT_AUTH_LEVEL, $this, function ($data) {
|
||||||
|
if (!is_object($data) || !property_exists($data, 'level') || !property_exists($data, 'login')) {
|
||||||
|
return new CommunicationAnswer("No valid level or player login provided!", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($data->login);
|
||||||
|
if ($player) {
|
||||||
|
$success = $this->grantAuthLevel($player, $data->level);
|
||||||
|
return new CommunicationAnswer(array("success" => $success));
|
||||||
|
} else {
|
||||||
|
return new CommunicationAnswer("Player not found!", true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->maniaControl->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::REVOKE_AUTH_LEVEL, $this, function ($data) {
|
||||||
|
if (!is_object($data) || !property_exists($data, 'login')) {
|
||||||
|
return new CommunicationAnswer("No valid player login provided!", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($data->login);
|
||||||
|
if ($player) {
|
||||||
|
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($player, self::AUTH_LEVEL_PLAYER);
|
||||||
|
return new CommunicationAnswer(array("success" => $success));
|
||||||
|
} else {
|
||||||
|
return new CommunicationAnswer("Player not found!", true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,19 @@ interface CommunicationMethods {
|
|||||||
*/
|
*/
|
||||||
const RESTART_MANIA_CONTROL = "ManiaControl.Restart";
|
const RESTART_MANIA_CONTROL = "ManiaControl.Restart";
|
||||||
|
|
||||||
|
/** Grands an Authentication Level on a Player
|
||||||
|
* Required Parameters
|
||||||
|
* - login (login of the player)
|
||||||
|
* - level (integer, 0-3 possible, @see AuthenticationManager)
|
||||||
|
*/
|
||||||
|
const GRANT_AUTH_LEVEL = "AuthenticationManager.GrandLevel";
|
||||||
|
|
||||||
|
/** Revokes an Authentication Level on a Player
|
||||||
|
* Required Parameters
|
||||||
|
* - login (login of the player)
|
||||||
|
*/
|
||||||
|
const REVOKE_AUTH_LEVEL = "AuthenticationManager.RevokeLevel";
|
||||||
|
|
||||||
/** Provides the Server Options
|
/** Provides the Server Options
|
||||||
* no Parameters
|
* no Parameters
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user