adjustment for new web service

This commit is contained in:
Steffen Schröder 2014-05-30 03:17:39 +02:00
parent 897630a95c
commit 860aae811e

View File

@ -210,9 +210,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$updates = array(); $updates = array();
$pluginClasses = $this->maniaControl->pluginManager->getPluginClasses(); $pluginClasses = $this->maniaControl->pluginManager->getPluginClasses();
foreach ($pluginClasses as $pluginClass) { foreach ($pluginClasses as $pluginClass) {
/** /** @var Plugin $pluginClass */
* @var Plugin $pluginClass
*/
$pluginId = $pluginClass::getId(); $pluginId = $pluginClass::getId();
if (isset($pluginsUpdates[$pluginId])) { if (isset($pluginsUpdates[$pluginId])) {
/** @var PluginUpdateData $pluginUpdateData */ /** @var PluginUpdateData $pluginUpdateData */
@ -379,19 +377,17 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
*/ */
public function getPluginUpdate($pluginClass) { public function getPluginUpdate($pluginClass) {
$pluginClass = PluginManager::getPluginClass($pluginClass); $pluginClass = PluginManager::getPluginClass($pluginClass);
/** /** @var Plugin $pluginClass */
* @var Plugin $pluginClass $pluginId = $pluginClass::getId();
*/ $url = ManiaControl::URL_WEBSERVICE . 'plugins/' . $pluginId;
$pluginId = $pluginClass::getId(); $dataJson = FileUtil::loadFile($url);
$url = ManiaControl::URL_WEBSERVICE . 'plugins/' . $pluginId; $pluginVersion = json_decode($dataJson);
$dataJson = FileUtil::loadFile($url); if (!$pluginVersion) {
$pluginVersions = json_decode($dataJson);
if (!$pluginVersions || !isset($pluginVersions[0])) {
return false; return false;
} }
$pluginUpdateData = new PluginUpdateData($pluginVersions[0]); $pluginUpdateData = new PluginUpdateData($pluginVersion);
$pluginVersion = $pluginClass::getVersion(); $version = $pluginClass::getVersion();
if ($pluginUpdateData->isNewerThan($pluginVersion)) { if ($pluginUpdateData->isNewerThan($version)) {
return $pluginUpdateData; return $pluginUpdateData;
} }
return false; return false;