fixed bug with mxids

This commit is contained in:
kremsy 2014-01-12 21:39:27 +01:00 committed by Steffen Schröder
parent a550ed9e0e
commit f7430dfad9
4 changed files with 32 additions and 2 deletions

View File

@ -59,7 +59,7 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager
// Save map data // Save map data
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "` $saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
SET `mxid` = ? SET `mxid` = ?
WHERE `index` = ?;"; WHERE `uid` = ?;";
$saveMapStatement = $mysqli->prepare($saveMapQuery); $saveMapStatement = $mysqli->prepare($saveMapQuery);
if($mysqli->error) { if($mysqli->error) {
trigger_error($mysqli->error); trigger_error($mysqli->error);

View File

@ -69,7 +69,7 @@ class Map {
* @return bool * @return bool
*/ */
public function updateAvailable() { public function updateAvailable() {
if($this->mx != null && ($this->lastUpdate < $this->mx->updated || $this->uid != $this->mx->uid)) { if($this->mx != null && ($this->lastUpdate < strtotime($this->mx->updated) || $this->uid != $this->mx->uid)) {
return true; return true;
} else { } else {
return false; return false;

View File

@ -35,6 +35,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
* Constants * Constants
*/ */
const ACTION_ADD_MAP = 'MapList.AddMap'; const ACTION_ADD_MAP = 'MapList.AddMap';
const ACTION_UPDATE_MAP = 'MapList.UpdateMap';
const ACTION_SEARCH_MAPNAME = 'MapList.SearchMapName'; const ACTION_SEARCH_MAPNAME = 'MapList.SearchMapName';
const ACTION_SEARCH_AUTHOR = 'MapList.SearchAuthor'; const ACTION_SEARCH_AUTHOR = 'MapList.SearchAuthor';
const ACTION_GET_MAPS_FROM_AUTHOR = 'MapList.GetMapsFromAuthor'; const ACTION_GET_MAPS_FROM_AUTHOR = 'MapList.GetMapsFromAuthor';
@ -489,6 +490,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$mxQuad->setUrl($map->mx->pageurl); $mxQuad->setUrl($map->mx->pageurl);
$mxQuad->setZ(0.01); $mxQuad->setZ(0.01);
$script->addTooltip($mxQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Update of $<" . $map->name . "$> available on Mania-Exchange")); $script->addTooltip($mxQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Update of $<" . $map->name . "$> available on Mania-Exchange"));
$mxQuad->setAction(self::ACTION_UPDATE_MAP . '.' . $map->uid);
} }
} }
@ -711,6 +713,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
case self::ACTION_ADD_MAP: case self::ACTION_ADD_MAP:
$this->maniaControl->mapManager->addMapFromMx($mapId, $player->login); $this->maniaControl->mapManager->addMapFromMx($mapId, $player->login);
break; break;
case self::ACTION_UPDATE_MAP:
$mapUid = $actionArray[2];
$this->maniaControl->mapManager->updateMap($player, $mapUid);
break;
case self::ACTION_ERASE_MAP: case self::ACTION_ERASE_MAP:
$mapUid = $actionArray[3]; $mapUid = $actionArray[3];
$this->maniaControl->mapManager->removeMap($player, $mapUid); $this->maniaControl->mapManager->removeMap($player, $mapUid);

View File

@ -137,6 +137,30 @@ class MapManager implements CallbackListener {
return true; return true;
} }
/**
* Updates a Map from Mania Exchange
*
* @param Player $admin
* @param $mxId
* @param $uid
*/
public function updateMap(Player $admin, $uid) {
return;
//TODO not finished yet
$mapsDirectory = $this->maniaControl->server->getMapsDirectory();
if(!$this->maniaControl->server->checkAccess($mapsDirectory)) {
$this->maniaControl->chat->sendError("ManiaControl doesn't have access to the maps directory.", $admin->login);
return;
}
$map = $this->maps[$uid];
/** @var Map $map */
$mxId = $map->mx->id;
$this->removeMap($admin, $uid, true);
$this->addMapFromMx($mxId, $admin->login);
}
/** /**
* Remove a Map * Remove a Map
* *