prevent sending data when sheetname is empty
This commit is contained in:
parent
5d92ce5900
commit
9fda8274b4
@ -39,7 +39,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
|||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const PLUGIN_ID = 156;
|
const PLUGIN_ID = 156;
|
||||||
const PLUGIN_VERSION = 2.2;
|
const PLUGIN_VERSION = 2.3;
|
||||||
const PLUGIN_NAME = 'MatchManager GSheet';
|
const PLUGIN_NAME = 'MatchManager GSheet';
|
||||||
const PLUGIN_AUTHOR = 'Beu';
|
const PLUGIN_AUTHOR = 'Beu';
|
||||||
|
|
||||||
@ -588,6 +588,9 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
|||||||
$spreadsheetid = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET);
|
$spreadsheetid = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET);
|
||||||
if ($spreadsheetid === "") return;
|
if ($spreadsheetid === "") return;
|
||||||
|
|
||||||
|
$sheetname = $this->getSheetName();
|
||||||
|
if ($sheetname === "") return;
|
||||||
|
|
||||||
foreach ($currentscore as $key => $score) {
|
foreach ($currentscore as $key => $score) {
|
||||||
$name = "~";
|
$name = "~";
|
||||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($score[1]);
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($score[1]);
|
||||||
@ -599,8 +602,6 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
|||||||
$matchstatus = $this->matchstatus;
|
$matchstatus = $this->matchstatus;
|
||||||
|
|
||||||
if ($this->refreshTokenIfNeeded()) {
|
if ($this->refreshTokenIfNeeded()) {
|
||||||
$sheetname = $this->getSheetName();
|
|
||||||
|
|
||||||
$data = new \stdClass;
|
$data = new \stdClass;
|
||||||
$data->valueInputOption = "RAW";
|
$data->valueInputOption = "RAW";
|
||||||
|
|
||||||
@ -748,12 +749,15 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
|||||||
$spreadsheetid = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET);
|
$spreadsheetid = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET);
|
||||||
if ($spreadsheetid === "") return;
|
if ($spreadsheetid === "") return;
|
||||||
|
|
||||||
|
$sheetname = $this->getSheetName();
|
||||||
|
if ($sheetname === "") return;
|
||||||
|
|
||||||
if ($this->refreshTokenIfNeeded()) {
|
if ($this->refreshTokenIfNeeded()) {
|
||||||
$this->matchid = $matchid;
|
$this->matchid = $matchid;
|
||||||
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://sheets.googleapis.com/v4/spreadsheets/' . $spreadsheetid);
|
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://sheets.googleapis.com/v4/spreadsheets/' . $spreadsheetid);
|
||||||
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
|
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
|
||||||
$asyncHttpRequest->setHeaders(array("Authorization: Bearer " . $this->access_token));
|
$asyncHttpRequest->setHeaders(array("Authorization: Bearer " . $this->access_token));
|
||||||
$asyncHttpRequest->setCallable(function ($json, $error) {
|
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname) {
|
||||||
if (!$json || $error) {
|
if (!$json || $error) {
|
||||||
Logger::logError('Error from Google API: ' . $error);
|
Logger::logError('Error from Google API: ' . $error);
|
||||||
$this->maniaControl->getChat()->sendErrorToAdmins('Error from Google API: ' . $error);
|
$this->maniaControl->getChat()->sendErrorToAdmins('Error from Google API: ' . $error);
|
||||||
@ -773,7 +777,6 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
|||||||
|
|
||||||
if ($data->properties->title) {
|
if ($data->properties->title) {
|
||||||
$sheetsid = array();
|
$sheetsid = array();
|
||||||
$sheetname = $this->getSheetName();
|
|
||||||
$sheetexists = false;
|
$sheetexists = false;
|
||||||
foreach($data->sheets as $value) {
|
foreach($data->sheets as $value) {
|
||||||
if ($value->properties->title == $sheetname) {
|
if ($value->properties->title == $sheetname) {
|
||||||
@ -798,6 +801,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function PrepareSheet(String $sheetname, bool $sheetexists, Array $sheetsid) {
|
private function PrepareSheet(String $sheetname, bool $sheetexists, Array $sheetsid) {
|
||||||
|
if ($sheetname === "") return;
|
||||||
$spreadsheetid = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET);
|
$spreadsheetid = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET);
|
||||||
if ($spreadsheetid === "") return;
|
if ($spreadsheetid === "") return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user