Compare commits
5 Commits
129053e951
...
bad5ecd70f
Author | SHA1 | Date | |
---|---|---|---|
bad5ecd70f | |||
bff16f6441 | |||
0f55bff6c2 | |||
d947337c9c | |||
0ad0d06f85 |
@ -154,7 +154,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target->authLevel >= AuthenticationManager::AUTH_LEVEL_MASTERADMIN) {
|
||||
if ($player !== $target && $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->authLevel <= $target->authLevel) {
|
||||
if ($player !== $target && $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\-\+\.\_\ ]/', null, $fileName);
|
||||
$fileName = preg_replace('/[^0-9A-Za-z\-\+\.\_\ ]/', '', $fileName);
|
||||
$fileName = preg_replace('/ /', '_', $fileName);
|
||||
return $fileName;
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ 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) {
|
||||
@ -101,6 +102,7 @@ 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 = '';
|
||||
@ -141,6 +143,7 @@ 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;
|
||||
@ -191,6 +194,7 @@ 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();
|
||||
@ -340,6 +344,7 @@ 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]);
|
||||
@ -355,5 +360,4 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
public function closeWidget(Player $player) {
|
||||
unset($this->mapListShown[$player->login]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $enabled = true;
|
||||
private $mxIdUidVector = array();
|
||||
|
||||
/**
|
||||
@ -67,6 +68,22 @@ 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
|
||||
*
|
||||
@ -84,6 +101,7 @@ 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);
|
||||
@ -160,7 +178,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
|
||||
@ -217,6 +235,7 @@ 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 . "`
|
||||
@ -269,6 +288,7 @@ 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
|
||||
@ -335,6 +355,7 @@ 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,6 +140,8 @@ 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 . rawurldecode($filename);
|
||||
$filePath = $folderPath . FileUtil::getClearedFileName(rawurldecode($filename));
|
||||
}
|
||||
if (substr($filename, 0, 1) === '"' && substr($filename, -1, 1) === '"') {
|
||||
$filePath = $folderPath . substr($filename, 1, -1);
|
||||
|
@ -8,6 +8,7 @@ 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;
|
||||
@ -49,7 +50,6 @@ 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,6 +68,7 @@ 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');
|
||||
@ -75,16 +76,22 @@ 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
|
||||
$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');
|
||||
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');
|
||||
}
|
||||
|
||||
// Menu Open List
|
||||
$itemQuad = new Quad_Icons64x64_1();
|
||||
|
@ -111,6 +111,8 @@ 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
|
||||
@ -340,7 +342,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$description = $map->getEscapedName() . ' is on Map-Queue Position: ' . $queuedMaps[$map->uid];
|
||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
} else {
|
||||
} else if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_ADD_TO_QUEUE)) {
|
||||
// Map-Queue-Map-Button
|
||||
$queueLabel = new Label_Button();
|
||||
$mapFrame->addChild($queueLabel);
|
||||
@ -584,6 +586,8 @@ 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,6 +19,8 @@ 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;
|
||||
@ -56,6 +58,7 @@ 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';
|
||||
@ -116,6 +119,7 @@ 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
|
||||
@ -131,6 +135,9 @@ 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();
|
||||
@ -188,6 +195,8 @@ 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])) {
|
||||
@ -213,6 +222,19 @@ 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
|
||||
*
|
||||
@ -252,6 +274,8 @@ 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,6 +36,7 @@ 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';
|
||||
|
||||
@ -74,6 +75,7 @@ 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);
|
||||
|
||||
@ -283,6 +285,8 @@ 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);
|
||||
@ -369,6 +373,10 @@ 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