karma fix

This commit is contained in:
kremsy 2014-03-07 18:28:53 +01:00 committed by Steffen Schröder
parent 60b13c8bbc
commit 53ddea9d45

View File

@ -578,6 +578,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$query .= '&applicationIdentifier=' . urlencode($applicationIdentifier); $query .= '&applicationIdentifier=' . urlencode($applicationIdentifier);
$query .= '&testMode=' . $testMode; $query .= '&testMode=' . $testMode;
$this->mxKarma['connectionInProgress'] = true;
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use ($mxKarmaCode) { $this->maniaControl->fileReader->loadFile($query, function ($data, $error) use ($mxKarmaCode) {
if (!$error) { if (!$error) {
@ -589,11 +590,13 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$this->maniaControl->log("Error while authenticating on Mania-Exchange Karma"); $this->maniaControl->log("Error while authenticating on Mania-Exchange Karma");
//TODO remove temp trigger //TODO remove temp trigger
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message); $this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message);
$this->mxKarma['connectionInProgress'] = false;
} }
} else { } else {
$this->maniaControl->log($error); $this->maniaControl->log($error);
//TODO remove temp trigger //TODO remove temp trigger
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error); $this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error);
$this->mxKarma['connectionInProgress'] = false;
} }
}, "application/json", 1000); }, "application/json", 1000);
} }
@ -615,15 +618,18 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$data = json_decode($data); $data = json_decode($data);
if ($data->success && $data->data->activated) { if ($data->success && $data->data->activated) {
$this->maniaControl->log("Successfully authenticated on Mania-Exchange Karma"); $this->maniaControl->log("Successfully authenticated on Mania-Exchange Karma");
$this->mxKarma['connectionInProgress'] = false;
} else { } else {
$this->maniaControl->log("Error while authenticating on Mania-Exchange Karma " . $data->data->message); $this->maniaControl->log("Error while authenticating on Mania-Exchange Karma " . $data->data->message);
//TODO remove temp trigger //TODO remove temp trigger
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message . " url Query " . $query); $this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message . " url Query " . $query);
$this->mxKarma['connectionInProgress'] = false;
} }
} else { } else {
//TODO remove temp trigger //TODO remove temp trigger
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error); $this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error);
$this->maniaControl->log($error); $this->maniaControl->log($error);
$this->mxKarma['connectionInProgress'] = false;
} }
}, "application/json", 1000); }, "application/json", 1000);
} }
@ -642,7 +648,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
return; return;
} }
if (!isset($this->mxKarma['session'])) { if (!isset($this->mxKarma['session']) && isset($this->mxKarma['connectionInProgress']) && $this->mxKarma['connectionInProgress'] != true) {
$this->mxKarmaOpenSession(); $this->mxKarmaOpenSession();
return; return;
} }
@ -693,7 +699,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
return; return;
} }
if (!isset($this->mxKarma['session'])) { if (!isset($this->mxKarma['session']) && isset($this->mxKarma['connectionInProgress']) && $this->mxKarma['connectionInProgress'] != true) {
$this->mxKarmaOpenSession(); $this->mxKarmaOpenSession();
return; return;
} }
@ -715,8 +721,9 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
private function postKarmaVotes(Map $map, array $votes, $import = false) { private function postKarmaVotes(Map $map, array $votes, $import = false) {
$gameMode = $this->maniaControl->server->getGameMode(true); $gameMode = $this->maniaControl->server->getGameMode(true);
if(count($votes) == 0) if (count($votes) == 0) {
return; return;
}
$properties = array(); $properties = array();
if ($gameMode == 'Script') { if ($gameMode == 'Script') {