Repository navigation
Expand file tree
/
Copy pathDiscordPlus.php
More file actions
65 lines (56 loc) · 1.94 KB
/
Copy pathDiscordPlus.php
File metadata and controls
65 lines (56 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/*
* This file is part of FeatherPanel.
*
* Copyright (C) 2025 MythicalSystems Studios
* Copyright (C) 2025 FeatherPanel Contributors
* Copyright (C) 2025 Cassian Gherman (aka NaysKutzu)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* See the LICENSE file or <https://www.gnu.org/licenses/>.
*/
namespace App\Addons\discordplus;
use App\Plugins\AppPlugin;
use App\Plugins\PluginEvents;
use App\Plugins\PluginSettings;
use App\Plugins\Events\Events\AppEvent;
use App\Addons\discordplus\Helpers\RouteGuard;
class DiscordPlus implements AppPlugin
{
public const IDENTIFIER = 'discordplus';
public static function processEvents(PluginEvents $event): void
{
$event->on(AppEvent::onRouterReady(), function ($payload) {
$router = is_array($payload) ? ($payload['router'] ?? null) : $payload;
if ($router !== null) {
RouteGuard::attach($router);
}
});
}
public static function pluginInstall(): void
{
$defaults = [
'require_discord_link' => 'false',
'allow_admin_bypass' => 'true',
'block_api_keys' => 'true',
'gate_message' => 'Link your Discord account to continue using this panel.',
];
foreach ($defaults as $key => $value) {
if (PluginSettings::getSetting(self::IDENTIFIER, $key) === null) {
PluginSettings::setSetting(self::IDENTIFIER, $key, $value);
}
}
}
public static function pluginUpdate(?string $oldVersion, ?string $newVersion): void
{
self::pluginInstall();
}
public static function pluginUninstall(): void
{
// Settings remain in featherpanel_addons_settings until manually cleared.
}
}