map permission levels

This commit is contained in:
kremsy 2014-01-09 19:00:37 +01:00
parent 4ab7f8ff49
commit 5680725e66
2 changed files with 17 additions and 19 deletions

View File

@ -15,7 +15,6 @@ use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\ManiaLink; use FML\ManiaLink;
use FML\Script\Script; use FML\Script\Script;
use KarmaPlugin; use KarmaPlugin;
use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ColorUtil; use ManiaControl\ColorUtil;
@ -68,7 +67,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$this->maniaControl->callbackManager->registerCallbackListener(MapQueue::CB_MAPQUEUE_CHANGED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(MapQueue::CB_MAPQUEUE_CHANGED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_MAPS_UPDATED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_MAPS_UPDATED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_KARMA_UPDATED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_KARMA_UPDATED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_BEGINMAP, $this, 'updateWidget');
// TODO not working yet // TODO not working yet
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAPNAME, $this, 'showManiaExchangeList'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAPNAME, $this, 'showManiaExchangeList');
@ -229,8 +228,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$mxQuad->setZ(0.01); $mxQuad->setZ(0.01);
$script->addTooltip($mxQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "View " . $map->name . " on Mania-Exchange")); $script->addTooltip($mxQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "View " . $map->name . " on Mania-Exchange"));
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) { if($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
// TODO: SET as setting who can add maps Add-Map-Button
$addQuad = new Quad_Icons64x64_1(); $addQuad = new Quad_Icons64x64_1();
$mapFrame->add($addQuad); $mapFrame->add($addQuad);
$addQuad->setX($x + 59); $addQuad->setX($x + 59);
@ -475,8 +473,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// Display Maps // Display Maps
$array = array($id => $x + 5, $mxId => $x + 10, Formatter::stripDirtyCodes($map->name) => $x + 20, $map->authorNick => $x + 68); $array = array($id => $x + 5, $mxId => $x + 10, Formatter::stripDirtyCodes($map->name) => $x + 20, $map->authorNick => $x + 68);
$this->maniaControl->manialinkManager->labelLine($mapFrame, $array); $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
// TODO detailed mx info page with link to mxo // TODO action detailed map info including mx info
// TODO action detailed map info
// MapQueue Description Label // MapQueue Description Label
$descriptionLabel = clone $preDefinedDescriptionLabel; $descriptionLabel = clone $preDefinedDescriptionLabel;
@ -508,8 +505,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$script->addTooltip($queueLabel, $descriptionLabel); $script->addTooltip($queueLabel, $descriptionLabel);
} }
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) { if($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
// TODO SET as setting who can add maps
// erase map quad // erase map quad
$eraseLabel = new Label_Button(); $eraseLabel = new Label_Button();
$mapFrame->add($eraseLabel); $mapFrame->add($eraseLabel);
@ -531,8 +527,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$script->addTooltip($eraseLabel, $descriptionLabel); $script->addTooltip($eraseLabel, $descriptionLabel);
} }
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) { if($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
// TODO SET as setting who can add maps
// Switch to map // Switch to map
$switchLabel = new Label_Button(); $switchLabel = new Label_Button();
$mapFrame->add($switchLabel); $mapFrame->add($switchLabel);
@ -630,7 +625,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$confirmFrame->add($buttLabel); $confirmFrame->add($buttLabel);
$buttLabel->setPosition(3.2, 0.4, 0.2); $buttLabel->setPosition(3.2, 0.4, 0.2);
$buttLabel->setSize(3, 3); $buttLabel->setSize(3, 3);
// $buttLabel->setTextSize(1);
$buttLabel->setAlign(Control::CENTER, Control::CENTER); $buttLabel->setAlign(Control::CENTER, Control::CENTER);
if(!$mapUid) { if(!$mapUid) {

View File

@ -23,6 +23,7 @@ class MapManager implements CallbackListener {
* Constants * Constants
*/ */
const TABLE_MAPS = 'mc_maps'; const TABLE_MAPS = 'mc_maps';
const CB_BEGINMAP = 'MapManager.BeginMap';
const CB_MAPS_UPDATED = 'MapManager.MapsUpdated'; const CB_MAPS_UPDATED = 'MapManager.MapsUpdated';
const CB_KARMA_UPDATED = 'MapManager.KarmaUpdated'; const CB_KARMA_UPDATED = 'MapManager.KarmaUpdated';
const SETTING_PERMISSION_ADD_MAP = 'Add Maps'; const SETTING_PERMISSION_ADD_MAP = 'Add Maps';
@ -191,7 +192,7 @@ class MapManager implements CallbackListener {
return false; return false;
} }
$rpcMap = $this->maniaControl->client->getResponse(); $rpcMap = $this->maniaControl->client->getResponse();
if(!array_key_exists($rpcMap["UId"], $this->mapsUids)) { if(array_key_exists($rpcMap["UId"], $this->mapsUids)) {
$this->currentMap = $this->mapsUids[$rpcMap["UId"]]; $this->currentMap = $this->mapsUids[$rpcMap["UId"]];
return true; return true;
} }
@ -248,6 +249,9 @@ class MapManager implements CallbackListener {
// can this ever happen? // can this ever happen?
$this->fetchCurrentMap(); $this->fetchCurrentMap();
} }
// Trigger own BeginMap callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_BEGINMAP, array(self::CB_BEGINMAP, $this->currentMap));
} }
/** /**