diff --git a/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php b/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php index dc26b121..721b055b 100644 --- a/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php +++ b/application/core/ManiaExchange/ManiaExchangeInfoSearcher.php @@ -59,7 +59,7 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager // Save map data $saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "` SET `mxid` = ? - WHERE `index` = ?;"; + WHERE `uid` = ?;"; $saveMapStatement = $mysqli->prepare($saveMapQuery); if($mysqli->error) { trigger_error($mysqli->error); diff --git a/application/core/Maps/Map.php b/application/core/Maps/Map.php index 855a3d78..2a8b03ad 100644 --- a/application/core/Maps/Map.php +++ b/application/core/Maps/Map.php @@ -69,7 +69,7 @@ class Map { * @return bool */ 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; } else { return false; diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index dee4b3a3..49a61766 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -35,6 +35,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { * Constants */ const ACTION_ADD_MAP = 'MapList.AddMap'; + const ACTION_UPDATE_MAP = 'MapList.UpdateMap'; const ACTION_SEARCH_MAPNAME = 'MapList.SearchMapName'; const ACTION_SEARCH_AUTHOR = 'MapList.SearchAuthor'; const ACTION_GET_MAPS_FROM_AUTHOR = 'MapList.GetMapsFromAuthor'; @@ -489,6 +490,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $mxQuad->setUrl($map->mx->pageurl); $mxQuad->setZ(0.01); $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: $this->maniaControl->mapManager->addMapFromMx($mapId, $player->login); break; + case self::ACTION_UPDATE_MAP: + $mapUid = $actionArray[2]; + $this->maniaControl->mapManager->updateMap($player, $mapUid); + break; case self::ACTION_ERASE_MAP: $mapUid = $actionArray[3]; $this->maniaControl->mapManager->removeMap($player, $mapUid); diff --git a/application/core/Maps/MapManager.php b/application/core/Maps/MapManager.php index 866e9c9b..a00a667b 100644 --- a/application/core/Maps/MapManager.php +++ b/application/core/Maps/MapManager.php @@ -137,6 +137,30 @@ class MapManager implements CallbackListener { 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 *