Compare commits
No commits in common. "bad5ecd70f383903d98dd299b3f748a1beca8b68" and "129053e951b3f86549278924bb7c8a6f7f3153b6" have entirely different histories.
bad5ecd70f
...
129053e951
@ -154,7 +154,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($player !== $target && $target->authLevel >= AuthenticationManager::AUTH_LEVEL_MASTERADMIN) {
|
||||
if ($target->authLevel >= AuthenticationManager::AUTH_LEVEL_MASTERADMIN) {
|
||||
$this->maniaControl->getChat()->sendError('You cannot remove rights of a MasterAdmin!', $player);
|
||||
return;
|
||||
}
|
||||
@ -164,7 +164,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($player !== $target && $player->authLevel <= $target->authLevel) {
|
||||
if ($player->authLevel <= $target->authLevel) {
|
||||
$this->maniaControl->getChat()->sendError('You cannot remove rights of a higher privileged player!', $player);
|
||||
return;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ abstract class FileUtil {
|
||||
public static function getClearedFileName($fileName) {
|
||||
$fileName = Formatter::stripCodes($fileName);
|
||||
$fileName = Formatter::utf8($fileName);
|
||||
$fileName = preg_replace('/[^0-9A-Za-z\-\+\.\_\ ]/', '', $fileName);
|
||||
$fileName = preg_replace('/[^0-9A-Za-z\-\+\.\_\ ]/', null, $fileName);
|
||||
$fileName = preg_replace('/ /', '_', $fileName);
|
||||
return $fileName;
|
||||
}
|
||||
|
@ -71,7 +71,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleManialinkPageAnswer(array $callback) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
$actionId = $callback[1][2];
|
||||
$actionArray = explode('.', $actionId);
|
||||
if (count($actionArray) <= 2) {
|
||||
@ -102,7 +101,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showListCommand(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
$this->mapListShown[$player->login] = true;
|
||||
$params = explode(' ', $chatCallback[1][2]);
|
||||
$searchString = '';
|
||||
@ -143,7 +141,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param string $searchString
|
||||
*/
|
||||
private function getMXMapsAndShowList(Player $player, $author = '', $environment = '', $searchString = '') {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
//TODO do more clean solution
|
||||
if($environment == ""){
|
||||
$titleId = $this->maniaControl->getServer()->titleId;
|
||||
@ -194,7 +191,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @internal param array $chatCallback
|
||||
*/
|
||||
private function showManiaExchangeList(array $maps, Player $player) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
// Start offsets
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
@ -344,7 +340,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param $openedWidget
|
||||
*/
|
||||
public function handleWidgetOpened(Player $player, $openedWidget) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
//unset when another main widget got opened
|
||||
if ($openedWidget !== 'ManiaExchangeList') {
|
||||
unset($this->mapListShown[$player->login]);
|
||||
@ -360,4 +355,5 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
public function closeWidget(Player $player) {
|
||||
unset($this->mapListShown[$player->login]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $enabled = true;
|
||||
private $mxIdUidVector = array();
|
||||
|
||||
/**
|
||||
@ -68,22 +67,6 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
//$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MX_KEY, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the status of the plugin
|
||||
*
|
||||
* @param bool $status
|
||||
*/
|
||||
public function setStatus(bool $status) {
|
||||
$this->enabled = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status of the plugin
|
||||
*/
|
||||
public function getStatus() {
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset Map by Mx Id
|
||||
*
|
||||
@ -101,7 +84,6 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param mixed $maps
|
||||
*/
|
||||
public function fetchManiaExchangeMapInformation($maps = null) {
|
||||
if (!$this->enabled) return;
|
||||
if ($maps) {
|
||||
// Fetch Information for a single map
|
||||
$maps = array($maps);
|
||||
@ -178,7 +160,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param string $string
|
||||
*/
|
||||
public function fetchMaplistByMixedUidIdString($string) {
|
||||
if (!$this->enabled) return;
|
||||
|
||||
// For TM2020
|
||||
if ($this->maniaControl->getServer()->titleId == "Trackmania") {
|
||||
// Get Title Prefix
|
||||
@ -235,7 +217,6 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param array $mxMapInfos
|
||||
*/
|
||||
public function updateMapObjectsWithManiaExchangeIds(array $mxMapInfos) {
|
||||
if (!$this->enabled) return;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
// Save map data
|
||||
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
|
||||
@ -288,7 +269,6 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param callable $function
|
||||
*/
|
||||
public function fetchMapInfo($mapId, callable $function) {
|
||||
if (!$this->enabled) return;
|
||||
// For TM2020
|
||||
if ($this->maniaControl->getServer()->titleId == "Trackmania") {
|
||||
// Get Title Prefix
|
||||
@ -355,7 +335,6 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @see \ManiaControl\ManiaExchange\ManiaExchangeMapSearch
|
||||
*/
|
||||
public function fetchMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $sortOrder = ManiaExchangeMapSearch::SEARCH_ORDER_UPDATED_NEWEST) {
|
||||
if (!$this->enabled) return;
|
||||
$mapSearch = new ManiaExchangeMapSearch($this->maniaControl);
|
||||
$mapSearch->setMapName($name);
|
||||
$mapSearch->setAuthorName($author);
|
||||
|
@ -140,8 +140,6 @@ class ManiaExchangeMapSearch implements UsageInformationAble {
|
||||
* @param callable $function
|
||||
*/
|
||||
public function fetchMapsAsync(callable $function) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
|
||||
// compile search URL
|
||||
$parameters = "";
|
||||
|
||||
|
@ -506,7 +506,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
|
||||
if ($filename !== null) {
|
||||
if ($isUtf8 && strpos($filename, "utf-8''") === 0 && $filename = substr($filename, strlen("utf-8''"))) {
|
||||
$filePath = $folderPath . FileUtil::getClearedFileName(rawurldecode($filename));
|
||||
$filePath = $folderPath . rawurldecode($filename);
|
||||
}
|
||||
if (substr($filename, 0, 1) === '"' && substr($filename, -1, 1) === '"') {
|
||||
$filePath = $folderPath . substr($filename, 1, -1);
|
||||
|
@ -8,7 +8,6 @@ use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
@ -50,6 +49,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
*/
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
$this->initActionsMenuButtons();
|
||||
|
||||
// Admin commands
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('nextmap', 'next', 'skip'), $this, 'command_NextMap', true, 'Skips to the next map.');
|
||||
@ -68,7 +68,6 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('xmaps', 'xlist'), $this, 'command_xList', false, 'Shows maps from ManiaExchange.');
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_XLIST, $this, 'command_xList');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_MAPLIST, $this, 'command_List');
|
||||
@ -76,22 +75,16 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SKIP_MAP, $this, 'command_NextMap');
|
||||
}
|
||||
|
||||
public function handleAfterInit() {
|
||||
$this->initActionsMenuButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all Actions Menu Buttons
|
||||
*/
|
||||
private function initActionsMenuButtons() {
|
||||
// Menu Open xList
|
||||
if ($this->maniaControl->getMapManager()->getMXManager()->getStatus()) {
|
||||
$itemQuad = new Quad();
|
||||
$itemQuad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
|
||||
$itemQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
|
||||
$itemQuad->setAction(self::ACTION_OPEN_XLIST);
|
||||
$this->maniaControl->getActionsMenu()->addPlayerMenuItem($itemQuad, 5, 'Open MX List');
|
||||
}
|
||||
$itemQuad = new Quad();
|
||||
$itemQuad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
|
||||
$itemQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
|
||||
$itemQuad->setAction(self::ACTION_OPEN_XLIST);
|
||||
$this->maniaControl->getActionsMenu()->addPlayerMenuItem($itemQuad, 5, 'Open MX List');
|
||||
|
||||
// Menu Open List
|
||||
$itemQuad = new Quad_Icons64x64_1();
|
||||
|
@ -111,8 +111,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
*/
|
||||
public function checkUpdates(array $chatCallback, Player $player) {
|
||||
// Update Mx Infos
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)) return;
|
||||
|
||||
$this->maniaControl->getMapManager()->getMXManager()->fetchManiaExchangeMapInformation();
|
||||
|
||||
// Reshow the Maplist
|
||||
@ -342,7 +340,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$description = $map->getEscapedName() . ' is on Map-Queue Position: ' . $queuedMaps[$map->uid];
|
||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
} else if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_ADD_TO_QUEUE)) {
|
||||
} else {
|
||||
// Map-Queue-Map-Button
|
||||
$queueLabel = new Label_Button();
|
||||
$mapFrame->addChild($queueLabel);
|
||||
@ -586,8 +584,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
}
|
||||
break;
|
||||
case self::ACTION_SWITCH_MAP:
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SKIP_MAP)) return;
|
||||
|
||||
// Don't queue on Map-Change
|
||||
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
|
||||
try {
|
||||
|
@ -19,8 +19,6 @@ use ManiaControl\ManiaExchange\ManiaExchangeList;
|
||||
use ManiaControl\ManiaExchange\ManiaExchangeManager;
|
||||
use ManiaControl\ManiaExchange\MXMapInfo;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Settings\Setting;
|
||||
use ManiaControl\Settings\SettingManager;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\AlreadyInListException;
|
||||
@ -58,7 +56,6 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
const SETTING_AUTOSAVE_MAPLIST = 'Autosave Maplist file';
|
||||
const SETTING_MAPLIST_FILE = 'File to write Maplist in';
|
||||
const SETTING_WRITE_OWN_MAPLIST_FILE = 'Write a own Maplist File for every Server called serverlogin.txt';
|
||||
const SETTING_ENABLE_MX = 'Enable MX features';
|
||||
|
||||
const SEARCH_BY_AUTHOR = 'Author';
|
||||
const SEARCH_BY_MAP_NAME = 'Mapname';
|
||||
@ -119,7 +116,6 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapsModified');
|
||||
|
||||
// Permissions
|
||||
@ -135,9 +131,6 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AUTOSAVE_MAPLIST, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIST_FILE, "MatchSettings/tracklist.txt");
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WRITE_OWN_MAPLIST_FILE, false);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ENABLE_MX, true);
|
||||
|
||||
$this->mxManager->setStatus($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ENABLE_MX, true));
|
||||
|
||||
//Initlaize Communication Listenings
|
||||
$this->initalizeCommunicationListenings();
|
||||
@ -195,8 +188,6 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
* @param string $uid
|
||||
*/
|
||||
public function updateMap($admin, $uid) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_ADD_MAP)) return;
|
||||
|
||||
$this->updateMapTimestamp($uid);
|
||||
|
||||
if (!isset($uid) || !isset($this->maps[$uid])) {
|
||||
@ -222,19 +213,6 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Settings
|
||||
*
|
||||
* @param ?Setting $setting
|
||||
*/
|
||||
public function updateSettings(Setting $setting = null) {
|
||||
if (!isset($setting) || !$setting->belongsToClass($this)) return;
|
||||
|
||||
if ($setting->setting === self::SETTING_ENABLE_MX) {
|
||||
$this->mxManager->setStatus($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ENABLE_MX, true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Timestamp of a Map
|
||||
*
|
||||
@ -274,8 +252,6 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
||||
* @return bool
|
||||
*/
|
||||
public function removeMap($admin, $uid, $eraseFile = false, $message = true) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_REMOVE_MAP)) return;
|
||||
|
||||
if (!isset($this->maps[$uid])) {
|
||||
if ($admin) {
|
||||
$this->maniaControl->getChat()->sendError('Map does not exist!', $admin);
|
||||
|
@ -36,7 +36,6 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
||||
const SETTING_MAPLIMIT_ADMIN = 'Maximum maps per admin (Admin+) in the Map-Queue (-1 = unlimited)';
|
||||
const SETTING_MESSAGE_FORMAT = 'Message Format';
|
||||
const SETTING_BUFFERSIZE = 'Size of the Map-Queue buffer (recently played maps)';
|
||||
const SETTING_PERMISSION_ADD_TO_QUEUE = 'Add map to queue';
|
||||
const SETTING_PERMISSION_CLEAR_MAPQUEUE = 'Clear MapQueue';
|
||||
const SETTING_PERMISSION_QUEUE_BUFFER = 'Queue maps in buffer';
|
||||
|
||||
@ -75,7 +74,6 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_BUFFERSIZE, 10);
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_ADD_TO_QUEUE, AuthenticationManager::AUTH_LEVEL_PLAYER, AuthenticationManager::AUTH_LEVEL_PLAYER);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CLEAR_MAPQUEUE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_QUEUE_BUFFER, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
|
||||
@ -285,8 +283,6 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_TO_QUEUE)) return;
|
||||
|
||||
// Check if the Player is muted
|
||||
if ($player->isMuted()) {
|
||||
$this->maniaControl->getChat()->sendError('Muted Players are not allowed to queue a map.', $player);
|
||||
@ -373,10 +369,6 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
||||
if (!isset($this->queuedMaps[$uid])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$queuer = $this->maniaControl->getMapManager()->getMapQueue()->getQueuer($uid);
|
||||
if (($queuer === null || $queuer->login !== $player->login) && !$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) return;
|
||||
|
||||
/** @var Map $map */
|
||||
$map = $this->queuedMaps[$uid][1];
|
||||
unset($this->queuedMaps[$uid]);
|
||||
|
Loading…
Reference in New Issue
Block a user