finished updatecommand
This commit is contained in:
parent
7fa6a0beda
commit
ffe3e0d2ef
@ -89,9 +89,18 @@ class ManiaExchangeManager {
|
|||||||
$saveMapStatement->close();
|
$saveMapStatement->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unset Map by Mx Id
|
||||||
|
*
|
||||||
|
* @param $mxId
|
||||||
|
*/
|
||||||
|
public function unsetMap($mxId) {
|
||||||
|
unset($this->mxIdUidVector[$mxId]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch Map Information from Mania Exchange
|
* Fetch Map Information from Mania Exchange
|
||||||
|
*
|
||||||
* @param null $map
|
* @param null $map
|
||||||
*/
|
*/
|
||||||
public function fetchManiaExchangeMapInformations($map = null) {
|
public function fetchManiaExchangeMapInformations($map = null) {
|
||||||
|
@ -108,7 +108,7 @@ class IconManager implements CallbackListener {
|
|||||||
*
|
*
|
||||||
* @param string $login
|
* @param string $login
|
||||||
*/
|
*/
|
||||||
private function preloadIcons($login = false) {
|
public function preloadIcons($login = false) {
|
||||||
$maniaLink = new ManiaLink(self::PRELOAD_MLID);
|
$maniaLink = new ManiaLink(self::PRELOAD_MLID);
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
|
@ -69,6 +69,7 @@ class Map {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function updateAvailable() {
|
public function updateAvailable() {
|
||||||
|
|
||||||
if($this->mx != null && ($this->lastUpdate < strtotime($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 {
|
||||||
|
@ -138,6 +138,32 @@ class MapManager implements CallbackListener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the Timestamp of a map
|
||||||
|
*
|
||||||
|
* @param $map
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function updateMapTimestamp($uid) {
|
||||||
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
|
$mapQuery = "UPDATE `" . self::TABLE_MAPS . "` SET mxid = 0, changed = NOW() WHERE 'uid' = ?";
|
||||||
|
|
||||||
|
$mapStatement = $mysqli->prepare($mapQuery);
|
||||||
|
if($mysqli->error) {
|
||||||
|
trigger_error($mysqli->error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$mapStatement->bind_param('s', $uid);
|
||||||
|
$mapStatement->execute();
|
||||||
|
if($mapStatement->error) {
|
||||||
|
trigger_error($mapStatement->error);
|
||||||
|
$mapStatement->close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$mapStatement->close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a Map from Mania Exchange
|
* Updates a Map from Mania Exchange
|
||||||
*
|
*
|
||||||
@ -146,8 +172,7 @@ class MapManager implements CallbackListener {
|
|||||||
* @param $uid
|
* @param $uid
|
||||||
*/
|
*/
|
||||||
public function updateMap(Player $admin, $uid) {
|
public function updateMap(Player $admin, $uid) {
|
||||||
return;
|
$this->updateMapTimestamp($uid);
|
||||||
//TODO not finished yet
|
|
||||||
|
|
||||||
$mapsDirectory = $this->maniaControl->server->getMapsDirectory();
|
$mapsDirectory = $this->maniaControl->server->getMapsDirectory();
|
||||||
if(!$this->maniaControl->server->checkAccess($mapsDirectory)) {
|
if(!$this->maniaControl->server->checkAccess($mapsDirectory)) {
|
||||||
@ -158,8 +183,8 @@ class MapManager implements CallbackListener {
|
|||||||
$map = $this->maps[$uid];
|
$map = $this->maps[$uid];
|
||||||
/** @var Map $map */
|
/** @var Map $map */
|
||||||
$mxId = $map->mx->id;
|
$mxId = $map->mx->id;
|
||||||
$this->removeMap($admin, $uid, true);
|
$this->removeMap($admin, $uid, true, false);
|
||||||
$this->addMapFromMx($mxId, $admin->login);
|
$this->addMapFromMx($mxId, $admin->login, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,10 +193,15 @@ class MapManager implements CallbackListener {
|
|||||||
* @param \ManiaControl\Players\Player $admin
|
* @param \ManiaControl\Players\Player $admin
|
||||||
* @param string $uid
|
* @param string $uid
|
||||||
* @param bool $eraseFile
|
* @param bool $eraseFile
|
||||||
|
* @param bool $message
|
||||||
*/
|
*/
|
||||||
public function removeMap(Player $admin, $uid, $eraseFile = false) { //TODO erasefile?
|
public function removeMap(Player $admin, $uid, $eraseFile = false, $message = true) { //TODO erasefile?
|
||||||
$map = $this->maps[$uid];
|
$map = $this->maps[$uid];
|
||||||
|
|
||||||
|
//Unset the Map everywhere
|
||||||
|
$this->mapQueue->removeFromMapQueue($admin->login, $map->uid);
|
||||||
|
$this->mxManager->unsetMap($map->mx->id);
|
||||||
|
|
||||||
// Remove map
|
// Remove map
|
||||||
if(!$this->maniaControl->client->query('RemoveMap', $map->fileName)) {
|
if(!$this->maniaControl->client->query('RemoveMap', $map->fileName)) {
|
||||||
trigger_error("Couldn't remove current map. " . $this->maniaControl->getClientErrorText());
|
trigger_error("Couldn't remove current map. " . $this->maniaControl->getClientErrorText());
|
||||||
@ -179,9 +209,13 @@ class MapManager implements CallbackListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Show Message
|
||||||
|
if($message) {
|
||||||
$message = '$<' . $admin->nickname . '$> removed $<' . $map->name . '$>!';
|
$message = '$<' . $admin->nickname . '$> removed $<' . $map->name . '$>!';
|
||||||
$this->maniaControl->chat->sendSuccess($message);
|
$this->maniaControl->chat->sendSuccess($message);
|
||||||
$this->maniaControl->log($message, true);
|
$this->maniaControl->log($message, true);
|
||||||
|
}
|
||||||
|
|
||||||
unset($this->maps[$uid]);
|
unset($this->maps[$uid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,8 +465,9 @@ class MapManager implements CallbackListener {
|
|||||||
*
|
*
|
||||||
* @param $mapId
|
* @param $mapId
|
||||||
* @param $login
|
* @param $login
|
||||||
|
* @param bool $update
|
||||||
*/
|
*/
|
||||||
public function addMapFromMx($mapId, $login) {
|
public function addMapFromMx($mapId, $login, $update = false) {
|
||||||
// Check if ManiaControl can even write to the maps dir
|
// Check if ManiaControl can even write to the maps dir
|
||||||
if(!$this->maniaControl->client->query('GetMapsDirectory')) {
|
if(!$this->maniaControl->client->query('GetMapsDirectory')) {
|
||||||
trigger_error("Couldn't get map directory. " . $this->maniaControl->getClientErrorText());
|
trigger_error("Couldn't get map directory. " . $this->maniaControl->getClientErrorText());
|
||||||
@ -515,15 +550,27 @@ class MapManager implements CallbackListener {
|
|||||||
$this->maniaControl->chat->sendError("Couldn't add map to match settings!", $login);
|
$this->maniaControl->chat->sendError("Couldn't add map to match settings!", $login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->maniaControl->chat->sendSuccess('Map $<' . $mapInfo->name . '$> added!');
|
|
||||||
|
|
||||||
$this->updateFullMapList();
|
$this->updateFullMapList();
|
||||||
|
|
||||||
//Update Mx MapInfo
|
//Update Mx MapInfo
|
||||||
$this->maniaControl->mapManager->mxManager->updateMapObjectsWithManiaExchangeIds($mxMapInfos);
|
$this->maniaControl->mapManager->mxManager->updateMapObjectsWithManiaExchangeIds($mxMapInfos);
|
||||||
|
|
||||||
|
//Update last updated time
|
||||||
|
$map = $this->maps[$mapInfo->uid];
|
||||||
|
/** @var Map $map */
|
||||||
|
$map->lastUpdate = time();
|
||||||
|
|
||||||
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
|
|
||||||
|
if(!$update) {
|
||||||
|
//Message
|
||||||
|
$this->maniaControl->chat->sendSuccess('$<' . $player->nickname . '$> added $<' . $mapInfo->name . '$>!');
|
||||||
// Queue requested Map
|
// Queue requested Map
|
||||||
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($login, $mapInfo->uid);
|
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($login, $mapInfo->uid);
|
||||||
|
} else {
|
||||||
|
$this->maniaControl->chat->sendSuccess('$<' . $player->nickname . '$> updated $<' . $mapInfo->name . '$>!');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO: add local map by filename
|
// TODO: add local map by filename
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user