nightly build channel
This commit is contained in:
parent
771409b8eb
commit
16042974fd
@ -66,12 +66,11 @@ class Chat {
|
|||||||
if(!$this->maniaControl->client) {
|
if(!$this->maniaControl->client) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$client = $this->maniaControl->client;
|
|
||||||
$chatMessage = '$z$<' . $this->getPrefix($prefix) . $message . '$>$z';
|
$chatMessage = '$z$<' . $this->getPrefix($prefix) . $message . '$>$z';
|
||||||
if($login === null) {
|
if($login === null) {
|
||||||
return $client->chatSendServerMessage($chatMessage);
|
return $this->maniaControl->client->chatSendServerMessage($chatMessage);
|
||||||
}
|
}
|
||||||
return $client->chatSendServerMessage($chatMessage, $login);
|
return $this->maniaControl->client->chatSendServerMessage($chatMessage, $login);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,19 +15,19 @@ use ManiaControl\Players\PlayerManager;
|
|||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
class UpdateManager implements CallbackListener, CommandListener {
|
class UpdateManager implements CallbackListener, CommandListener {
|
||||||
/**
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const SETTING_ENABLEUPDATECHECK = 'Enable Automatic Core Update Check';
|
const SETTING_ENABLEUPDATECHECK = 'Enable Automatic Core Update Check';
|
||||||
const SETTING_UPDATECHECK_INTERVAL = 'Core Update Check Interval (Hours)';
|
const SETTING_UPDATECHECK_INTERVAL = 'Core Update Check Interval (Hours)';
|
||||||
const SETTING_UPDATECHECK_CHANNEL = 'Core Update Channel (release, beta, alpha)';
|
const SETTING_UPDATECHECK_CHANNEL = 'Core Update Channel (release, beta, nightly)';
|
||||||
const SETTING_PERFORM_BACKUPS = 'Perform Backup before Updating';
|
const SETTING_PERFORM_BACKUPS = 'Perform Backup before Updating';
|
||||||
const URL_WEBSERVICE = 'http://ws.maniacontrol.com/';
|
const URL_WEBSERVICE = 'http://ws.maniacontrol.com/';
|
||||||
const CHANNEL_RELEASE = 'release';
|
const CHANNEL_RELEASE = 'release';
|
||||||
const CHANNEL_BETA = 'beta';
|
const CHANNEL_BETA = 'beta';
|
||||||
const CHANNEL_ALPHA = 'alpha';
|
const CHANNEL_NIGHTLY = 'nightly';
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
@ -35,7 +35,7 @@ class UpdateManager implements CallbackListener, CommandListener {
|
|||||||
private $coreUpdateData = null;
|
private $coreUpdateData = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Updater
|
* Create a new Update Manager
|
||||||
*
|
*
|
||||||
* @param ManiaControl $maniaControl
|
* @param ManiaControl $maniaControl
|
||||||
*/
|
*/
|
||||||
@ -45,7 +45,7 @@ class UpdateManager implements CallbackListener, CommandListener {
|
|||||||
// Init settings
|
// Init settings
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_ENABLEUPDATECHECK, true);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_ENABLEUPDATECHECK, true);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_UPDATECHECK_INTERVAL, 24.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_UPDATECHECK_INTERVAL, 24.);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_UPDATECHECK_CHANNEL, self::CHANNEL_ALPHA);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_UPDATECHECK_CHANNEL, self::CHANNEL_RELEASE);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_PERFORM_BACKUPS, true);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_PERFORM_BACKUPS, true);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
@ -66,22 +66,15 @@ class UpdateManager implements CallbackListener, CommandListener {
|
|||||||
$updateCheckEnabled = $this->maniaControl->settingManager->getSetting($this, self::SETTING_ENABLEUPDATECHECK);
|
$updateCheckEnabled = $this->maniaControl->settingManager->getSetting($this, self::SETTING_ENABLEUPDATECHECK);
|
||||||
if (!$updateCheckEnabled) {
|
if (!$updateCheckEnabled) {
|
||||||
// Automatic update check disabled
|
// Automatic update check disabled
|
||||||
if ($this->coreUpdateData) {
|
if ($this->coreUpdateData) $this->coreUpdateData = null;
|
||||||
$this->coreUpdateData = null;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Only check once per hour
|
// Only check once per hour
|
||||||
$updateInterval = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_INTERVAL);
|
$updateInterval = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_INTERVAL);
|
||||||
if ($this->lastUpdateCheck > time() - $updateInterval * 3600.) {
|
if ($this->lastUpdateCheck > time() - $updateInterval * 3600.) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->lastUpdateCheck = time();
|
$this->lastUpdateCheck = time();
|
||||||
$updateData = $this->checkCoreUpdate();
|
$updateData = $this->checkCoreUpdate();
|
||||||
if (!$updateData) {
|
if (!$updateData) return;
|
||||||
// No update available
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->maniaControl->log('New ManiaControl Version ' . $updateData->version . ' available!');
|
$this->maniaControl->log('New ManiaControl Version ' . $updateData->version . ' available!');
|
||||||
$this->coreUpdateData = $updateData;
|
$this->coreUpdateData = $updateData;
|
||||||
}
|
}
|
||||||
@ -92,14 +85,11 @@ class UpdateManager implements CallbackListener, CommandListener {
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handlePlayerJoined(array $callback) {
|
public function handlePlayerJoined(array $callback) {
|
||||||
if (!$this->coreUpdateData) {
|
if (!$this->coreUpdateData) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Announce available update
|
// Announce available update
|
||||||
$player = $callback[1];
|
$player = $callback[1];
|
||||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) return;
|
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) return;
|
||||||
$this->maniaControl->chat->sendInformation('New ManiaControl Version ' . $this->coreUpdateData->version . ' available!',
|
$this->maniaControl->chat->sendInformation('New ManiaControl Version ' . $this->coreUpdateData->version . ' available!', $player->login);
|
||||||
$player->login);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,12 +103,42 @@ class UpdateManager implements CallbackListener, CommandListener {
|
|||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$updateData = $this->checkCoreUpdate();
|
$updateChannel = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_CHANNEL);
|
||||||
if (!$updateData) {
|
if ($updateChannel != self::CHANNEL_NIGHTLY) {
|
||||||
$this->maniaControl->chat->sendInformation('No Update available!', $player->login);
|
// Check update and send result message
|
||||||
return;
|
$updateData = $this->checkCoreUpdate();
|
||||||
|
if (!$updateData) {
|
||||||
|
$this->maniaControl->chat->sendInformation('No Update available!', $player->login);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->maniaControl->chat->sendSuccess('Update for Version ' . $updateData->version . ' available!', $player->login);
|
||||||
}
|
}
|
||||||
$this->maniaControl->chat->sendSuccess('Update for Version ' . $updateData->version . ' available!', $player->login);
|
else {
|
||||||
|
// Special nightly channel updating
|
||||||
|
$updateData = $this->checkCoreUpdate(true);
|
||||||
|
$buildDate = $this->getNightlyBuildDate();
|
||||||
|
if ($buildDate) {
|
||||||
|
$buildTime = strtotime($buildDate);
|
||||||
|
$releaseTime = strtotime($updateData->release_date);
|
||||||
|
if ($buildTime >= $releaseTime) {
|
||||||
|
$this->maniaControl->chat->sendInformation('No new Build available!', $player->login);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->maniaControl->chat->sendSuccess('New Nightly Build available!', $player->login);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Build Date of the local Nightly Build Version
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
private function getNightlyBuildDate() {
|
||||||
|
$nightlyBuildDateFile = ManiaControlDir . '/core/nightly_build.txt';
|
||||||
|
if (!file_exists($nightlyBuildDateFile)) return false;
|
||||||
|
$fileContent = file_get_contents($nightlyBuildDateFile);
|
||||||
|
return $fileContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,7 +222,7 @@ class UpdateManager implements CallbackListener, CommandListener {
|
|||||||
private function performBackup() {
|
private function performBackup() {
|
||||||
$backupFolder = ManiaControlDir . '/backup/';
|
$backupFolder = ManiaControlDir . '/backup/';
|
||||||
if (!is_dir($backupFolder)) mkdir($backupFolder);
|
if (!is_dir($backupFolder)) mkdir($backupFolder);
|
||||||
$backupFileName = $backupFolder . 'backup_' . ManiaControl::VERSION . '_' . date('y-m-d') . '.zip';
|
$backupFileName = $backupFolder . 'backup_' . ManiaControl::VERSION . '_' . date('y-m-d') . '_' . time() . '.zip';
|
||||||
$backupZip = new \ZipArchive();
|
$backupZip = new \ZipArchive();
|
||||||
if ($backupZip->open($backupFileName, \ZipArchive::CREATE) !== TRUE) {
|
if ($backupZip->open($backupFileName, \ZipArchive::CREATE) !== TRUE) {
|
||||||
trigger_error("Couldn't create Backup Zip!");
|
trigger_error("Couldn't create Backup Zip!");
|
||||||
@ -294,7 +314,7 @@ class UpdateManager implements CallbackListener, CommandListener {
|
|||||||
private function getCurrentUpdateChannelSetting() {
|
private function getCurrentUpdateChannelSetting() {
|
||||||
$updateChannel = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_CHANNEL);
|
$updateChannel = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_CHANNEL);
|
||||||
$updateChannel = strtolower($updateChannel);
|
$updateChannel = strtolower($updateChannel);
|
||||||
if (!in_array($updateChannel, array(self::CHANNEL_RELEASE, self::CHANNEL_BETA, self::CHANNEL_ALPHA))) {
|
if (!in_array($updateChannel, array(self::CHANNEL_RELEASE, self::CHANNEL_BETA, self::CHANNEL_NIGHTLY))) {
|
||||||
$updateChannel = self::CHANNEL_RELEASE;
|
$updateChannel = self::CHANNEL_RELEASE;
|
||||||
}
|
}
|
||||||
return $updateChannel;
|
return $updateChannel;
|
||||||
|
Loading…
Reference in New Issue
Block a user