diff --git a/application/core/Server/Directory.php b/application/core/Server/Directory.php new file mode 100644 index 00000000..796a34cf --- /dev/null +++ b/application/core/Server/Directory.php @@ -0,0 +1,56 @@ + + * @copyright 2014 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class Directory { + + /** + * Private Properties + */ + private $maniaControl = null; + + /** + * Create new Server Directory Object + * + * @param ManiaControl $maniaControl + */ + public function __construct(ManiaControl $maniaControl) { + $this->maniaControl = $maniaControl; + } + + /** + * Retrieve the Game Data Folder Path + * + * @return string + */ + public function getGameDataFolder() { + return $this->maniaControl->client->gameDataDirectory(); + } + + /** + * Retrieve the Maps Folder Path + * + * @return string + */ + public function getMapsFolder() { + return $this->maniaControl->client->getMapsDirectory(); + } + + /** + * Retrieve the Skins Folder Path + * + * @return string + */ + public function getSkinsFolder() { + return $this->maniaControl->client->getSkinsDirectory(); + } +} diff --git a/application/core/Server/Server.php b/application/core/Server/Server.php index 005f49f2..07ffb1b8 100644 --- a/application/core/Server/Server.php +++ b/application/core/Server/Server.php @@ -34,7 +34,7 @@ class Server implements CallbackListener { public $p2pPort = -1; public $login = null; public $titleId = null; - public $dataDirectory = null; + public $directory = null; public $serverCommands = null; public $usageReporter = null; public $rankingManager = null; @@ -55,6 +55,7 @@ class Server implements CallbackListener { $this->maniaControl = $maniaControl; $this->initTables(); + $this->directory = new Directory($maniaControl); $this->serverCommands = new ServerCommands($maniaControl); $this->usageReporter = new UsageReporter($maniaControl); $this->rankingManager = new RankingManager($maniaControl); @@ -198,28 +199,6 @@ class Server implements CallbackListener { $statement->close(); } - /** - * Get Maps Directory - * - * @return string - */ - public function getMapsDirectory() { - $dataDirectory = $this->getDataDirectory(); - return $dataDirectory . 'Maps' . DIRECTORY_SEPARATOR; - } - - /** - * Get Game Data Directory - * - * @return string - */ - public function getDataDirectory() { - if (!$this->dataDirectory) { - $this->dataDirectory = $this->maniaControl->client->gameDataDirectory(); - } - return $this->dataDirectory; - } - /** * Get Server Player Info * @@ -255,7 +234,7 @@ class Server implements CallbackListener { * @return string */ public function getGhostReplay($login) { - $dataDir = $this->getDataDirectory(); + $dataDir = $this->directory->getGameDataFolder(); if (!$this->checkAccess($dataDir)) { return null; } diff --git a/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index 8fe96ab6..11ce9fbd 100644 --- a/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -989,7 +989,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene // Set ghost replay if ($record->rank <= 1) { - $dataDirectory = $this->maniaControl->server->getDataDirectory(); + $dataDirectory = $this->maniaControl->server->directory->getGameDataFolder(); if (!isset($this->dedimaniaData->directoryAccessChecked)) { $access = $this->maniaControl->server->checkAccess($dataDirectory); if (!$access) {