Skip to content

Commit 5fd054b

Browse files
committed
Allow Discord webpage to be disabled by admin
1 parent 608f8ed commit 5fd054b

File tree

6 files changed

+13
-1
lines changed

6 files changed

+13
-1
lines changed

etc/config.sample.json

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
}
5454
},
5555
"discord": {
56+
"enabled": true,
5657
"forward_event_log": {
5758
"enabled": false,
5859
"exclude_meta_data": false,

src/controllers/Discord.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ public function &run(Router &$router, View &$view, array &$args) {
1919
$model->discord_url = 'https://discord.gg/';
2020
$model->discord_url .= Common::$config->discord->invite_code;
2121
$model->discord_server_id = Common::$config->discord->server_id;
22+
$model->enabled = Common::$config->discord->enabled;
2223

2324
$view->render($model);
24-
$model->_responseCode = 200;
25+
$model->_responseCode = ($model->enabled ? 200 : 503);
2526
return $model;
2627
}
2728
}

src/models/Discord.php

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
class Discord extends Model {
88

9+
public $discord_server_id;
910
public $discord_url;
11+
public $enabled;
1012

1113
}

src/templates/Discord.phtml

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ $this->additional_css[] = "/a/forms.css";
1515
require( './header.inc.phtml' );
1616
?>
1717
<article>
18+
<?php if (!$this->getContext()->enabled) { ?>
19+
<header class="red">Discord</header>
20+
<section class="red"><p>Sorry, but this page is currently not available. Try again later.</p></section>
21+
<?php } else { ?>
1822
<header>Discord</header>
1923
<section>
2024
<h2>Who's Online</h2><br/>
@@ -27,5 +31,6 @@ require( './header.inc.phtml' );
2731
<p style="text-align:center;"><a class="button" href="<?php echo Common::relativeUrlToAbsolute( $this->getContext()->discord_url ); ?>">Click this invite link</a></p>
2832
<p><strong><a href="<?php echo Common::relativeUrlToAbsolute( $this->getContext()->discord_url ); ?>">Join our Discord</a></strong> and chat with other gamers like you! Our community is open to the public and we welcome new users.</p>
2933
</section>
34+
<?php } ?>
3035
</article>
3136
<?php require( './footer.inc.phtml' ); ?>

src/templates/header.inc.phtml

+2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ $_campaign_vultr = (
105105
<a>Info Hub</a>
106106
<a href="<?php echo Common::relativeUrlToAbsolute("/welcome"); ?>">Welcome</a>
107107
<a href="<?php echo Common::relativeUrlToAbsolute("/credits"); ?>">Contributors</a>
108+
<?php if (Common::$config->discord->enabled) { ?>
108109
<a href="<?php echo Common::relativeUrlToAbsolute("/discord"); ?>">Discord</a>
110+
<?php } ?>
109111
<a href="<?php echo Common::relativeUrlToAbsolute("/donate"); ?>">Donate</a>
110112
<a href="<?php echo Common::relativeUrlToAbsolute("/user/index"); ?>">Members</a>
111113
<a href="<?php echo Common::relativeUrlToAbsolute("/news"); ?>">News</a>

src/views/DiscordHtml.php

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BNETDocs\Views;
44

55
use \BNETDocs\Models\Discord as DiscordModel;
6+
67
use \CarlBennett\MVC\Libraries\Exceptions\IncorrectModelException;
78
use \CarlBennett\MVC\Libraries\Model;
89
use \CarlBennett\MVC\Libraries\Template;

0 commit comments

Comments
 (0)