map file erasing from browser

This commit is contained in:
steeffeen 2014-07-05 14:05:23 +02:00
parent 9fde082a71
commit 9e4f815278
2 changed files with 15 additions and 5 deletions

View File

@ -402,8 +402,6 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
// Queue requested Map
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($player, $map);
$this->showManiaLink($player);
}
/**
@ -415,7 +413,13 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
public function handleEraseFile(array $actionCallback, Player $player) {
$actionName = $actionCallback[1][2];
$fileName = substr($actionName, strlen(self::ACTION_ERASE_FILE));
// TODO: erase map
var_dump($fileName);
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
$filePath = $folderPath . $fileName;
if (@unlink($filePath)) {
$this->maniaControl->chat->sendSuccess("Erased {$fileName}!");
$this->showManiaLink($player);
} else {
$this->maniaControl->chat->sendError("Couldn't erase {$fileName}!");
}
}
}

View File

@ -713,10 +713,16 @@ class MapManager implements CallbackListener {
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDMAP, $this->currentMap);
}
/**
* Fetch a map by its file path
*
* @param string $relativeFileName
* @return Map
*/
public function fetchMapByFileName($relativeFileName) {
$mapInfo = $this->maniaControl->client->getMapInfo($relativeFileName);
if (!$mapInfo) {
return false;
return null;
}
return $this->initializeMap($mapInfo);
}