Compare commits

..

2 Commits

Author SHA1 Message Date
beu
01be9cc45f add getConfig function 2024-06-21 11:56:21 +02:00
beu
748ebb20ae add phpdoc 2024-06-21 11:28:06 +02:00

View File

@ -42,7 +42,7 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
* Constants
*/
const PLUGIN_ID = 171;
const PLUGIN_VERSION = 1.3;
const PLUGIN_VERSION = 1.4;
const PLUGIN_NAME = 'MatchManager Multiple Config Manager';
const PLUGIN_AUTHOR = 'Beu';
@ -334,6 +334,10 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
$this->saveConfig($configname, $gamemodebase, json_encode($result));
}
/**
* getSavedConfigs
* @return array
*/
public function getSavedConfigs() {
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
$query = 'SELECT `id`,`name`,`gamemodebase`,`date` FROM `' . self::DB_MATCHCONFIG . '` ORDER BY id DESC';
@ -345,7 +349,14 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
return $result->fetch_all(MYSQLI_ASSOC);
}
public function saveConfig($configname, $gamemodebase, $config) {
/**
* saveConfig
* @param string $configname
* @param string $gamemodebase
* @param string $config
* @return void
*/
public function saveConfig(string $configname, string $gamemodebase, string $config) {
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
$query = $mysqli->prepare('INSERT INTO `' . self::DB_MATCHCONFIG . '` (`name`,`gamemodebase`,`config`) VALUES (?, ?, ?);');
$query->bind_param('sss', $configname, $gamemodebase, $config);
@ -355,6 +366,21 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_SAVECONFIG, $configname);
}
/**
* getConfig
* @param string $name
* @return object|null config
*/
public function getConfig(string $name) {
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
$stmt = $mysqli->prepare('SELECT id FROM `' . self::DB_MATCHCONFIG . '` WHERE `name` = ? LIMIT 1;');
$stmt->bind_param('s', $name);
if (!$stmt->execute()) {
trigger_error('Error executing MySQL query: ' . $stmt->error);
}
return $stmt->get_result()->fetch_object();
}
/**
* Shows a ManiaLink list with the local records.
*