Skip to content

Commit

Permalink
feat: block users from market
Browse files Browse the repository at this point in the history
  • Loading branch information
T1Il committed Aug 24, 2023
1 parent bab6ef0 commit 54357a0
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 11 deletions.
11 changes: 7 additions & 4 deletions assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ body {
padding: 10px 10px;
}

.user-status.angenommen {
.angenommen {
color: #43b581;
}

.user-status.abgelehnt {
.abgelehnt {
color: #f04747;
}

.user-status.unprocessed {
.unprocessed {
color: #e7effd;
}

Expand Down Expand Up @@ -137,14 +137,17 @@ body {
}

.accept-button, .reject-button {
padding: 10px 20px;
font-size: 16px;
border: none;
border-radius: 5px;
cursor: pointer;
margin: 0 10px;
}

.accept-button .offset, .reject-button .offset {
padding: 10px 20px;
}

.accept-button {
background-color: #43b581;
color: #e3eaf7;
Expand Down
12 changes: 9 additions & 3 deletions case.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function getContrastColor($hexColor)
<img src="<?php echo $as->getAvatarURL(); ?>" alt="User Avatar">
</div>
<div class="user-details">
<div class="user-name accent"><?php echo $as->getUsername(); ?></div>
<div class="user-name accent"><?php echo $as->getUsername(); if($as->isModerator()) { ?> <span class="angenommen">(Moderator)</span> <?php } ?> </div>
<br>
<div class="user-discord-id"><span class="accent">Discord-ID:</span> <?php echo $as->getDiscordId(); ?>
</div>
Expand All @@ -156,6 +156,12 @@ class="accent">Everyone-Ping:</span> <?php echo $request->pingsEveryone() ? "Ja"
</div>
<div class="user-status <?php echo testInput($sta[0]); ?>"><span
class="accent">Status:</span> <?php echo testInput($sta[0]); ?></div>
<div class="user-status" <?php echo testInput($sta[0]); ?>><span class="accent">Nutzer-Status: </span><?php echo $as->isBlocked() ? "blockiert " : "nicht blockiert "; ?>
<?php if(!$as->isModerator()) { ?><button onclick="window.location.href='user.php?block_user=<?php echo $as->getDiscordId(); ?>&from=<?php echo $request->getRequestId();?>';"
class="<?php echo $as->isBlocked() ? "reject" : "accept"; ?>-button"><?php echo $as->isBlocked() ? "Freigeben" : "Blockieren"; ?>
</button>
<?php } ?>
</div>
</div>
</div>
<div class="big-box">
Expand All @@ -175,10 +181,10 @@ class="accent">Status:</span> <?php echo testInput($sta[0]); ?></div>

<div class="button-container">
<button onclick="window.location.href='process.php?action=accept&req_id=<?php echo $request->getRequestId(); ?>';"
class="accept-button">Annehmen
class="accept-button offset">Annehmen
</button>
<button onclick="window.location.href='process.php?action=decline&req_id=<?php echo $request->getRequestId(); ?>';"
class="reject-button">Ablehnen
class="reject-button offset">Ablehnen
</button>
</div>
</div>
Expand Down
13 changes: 9 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
$base_url = getenv("BOT_BASE_URI");
$discordInvite = getenv('GUILD_INVITE');
?><!DOCTYPE HTML>

<html lang="de">

<head>

<title>DevCord - Devmarkt</title>
Expand Down Expand Up @@ -69,16 +67,23 @@
$unresolvedRequests = $devmarkt->getUnresolvedRequests();
$uRS = "";

if(sizeof($unresolvedRequests) > 0) {
?>
<h5>Nicht bearbeitete Anfragen:</h5>
<?php
}

?>

<h5>Nicht bearbeitete Anfragen:</h5>
<?php

foreach($unresolvedRequests as $request) {

$request = new DevmarktRequest($request['req_id']);
if($request->getApplicant()->inBotGuild()) {
$uRS .= "<a href=case.php?req_id=" . htmlentities($request->getRequestId()) . ">" . htmlentities($request->getTitle()) . "</a><br> ";
} else {
$uRS .= "<a style='color: grey;' href=case.php?req_id=" . htmlentities($request->getRequestId()) . ">" . htmlentities($request->getTitle()) . "</a><br> ";
}
}

Expand All @@ -99,7 +104,7 @@

?>

<h4>Der Devmarkt ist zurzeit leider nicht für dich verfügbar. //</h4>
<h4>Der Devmarkt ist zurzeit leider nicht für dich verfügbar. Wende dich bei Fragen oder Problemen im Discord an das Administrations-Team oder schreibe uns eine <a href="impressum.html">E-Mail.</a></h4>

<?php

Expand Down
24 changes: 24 additions & 0 deletions php/login.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,30 @@ public function isBlocked(): bool
return $this->isBlocked;
}

public function switchBlockState(): bool {

if(!$this->exists) {
return false;
}

if($this->isModerator()) {
return false;
}

$mysql = new MySQL();
$pdo = $mysql->getPDO();

$stmt = "UPDATE `dc_users` SET `blocked`=" . ($this->isBlocked ? "0" : "1") . " WHERE `discord_id`=:id";
$qry = $pdo->prepare($stmt);
$qry->bindParam(":id", $this->discordId);
$qry->execute();

$this->isBlocked = !$this->isBlocked;

return $this->isBlocked;

}

public function getLastAcceptedEntry()
{

Expand Down
20 changes: 20 additions & 0 deletions user.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@
$token = new UserTokenHandler($_SESSION['token']);
$login = new User($token->getDiscordID());

if(isset($_GET['block_user'])) {

if($login->isModerator()) {

$blockID = testInput($_GET['block_user']);
$blockUser = new User($blockID);

$blockUser->switchBlockState();

if(isset($_GET['from'])) {

header('Location: case.php?req_id=' . $_GET['from']);
return;

}

}

}

} else {
(isset($_GET['user_id'])) ? header('Location: login.php?redirect=' . getenv("BOT_BASE_URI") . '/user.php?user_id=' . $_GET['user_id']) : header('Location: login.php');
}
Expand Down

0 comments on commit 54357a0

Please sign in to comment.