Report handlers are now parsed and displayed correctly.

This commit is contained in:
Keir 2015-12-16 16:01:19 +00:00
parent db5327d2e4
commit 3ecb4c7fb8
2 changed files with 30 additions and 11 deletions

View File

@ -6,6 +6,9 @@
/** @var String */
private $serverName;
/** @var Player|Null */
private $handler;
/** @var Player */
private $suspect;
@ -16,13 +19,15 @@
* Report constructor.
* @param Int $id
* @param String $serverName
* @param Player|Null $handler
* @param Player $suspect
* @param SplObjectStorage $reporters
*/
function Report($id, $serverName, $suspect, $reporters)
function Report($id, $serverName, $handler, $suspect, $reporters)
{
$this->id = $id;
$this->serverName = $serverName;
$this->handler = $handler;
$this->suspect = $suspect;
$this->reporters = $reporters;
}
@ -43,6 +48,14 @@
return $this->serverName;
}
/**
* @return Player|Null
*/
public function getHandler()
{
return $this->handler;
}
/**
* @return Player
*/

View File

@ -60,9 +60,10 @@ function toReport($reportData, $players)
{
$id = $reportData["id"];
$serverName = $reportData["serverName"];
$handler = array_key_exists("handler", $reportData) ? getPlayer($players, $reportData["handler"]) : null;
$suspect = getPlayer($players, $reportData["suspect"]);
$reporters = toReporters($players, $reportData["reporters"]);
return new Report($id, $serverName, $suspect, $reporters);
return new Report($id, $serverName, $handler, $suspect, $reporters);
}
/**
@ -239,20 +240,20 @@ function removeBadCharacters($input)
$messages = $snapshot->getMessages();
foreach($messages as $message):
$typeId = $message->getType();
$typeDisplayName = Message::$TYPE_DISPLAY_NAMES[$typeId];
$isPM = $typeId == Message::TYPE_PM;
$typeId = $message->getType();
$typeDisplayName = Message::$TYPE_DISPLAY_NAMES[$typeId];
$isPM = $typeId == Message::TYPE_PM;
// If this is a PM, then the "-> <recipient>" suffix will be applied.
$involved = $message->getSender()->getUsername() . ($isPM ? " -> " . $message->getRecipients()[0]->getUsername() : "");
// If this is a PM, then the "-> <recipient>" suffix will be applied.
$involved = $message->getSender()->getUsername() . ($isPM ? " -> " . $message->getRecipients()[0]->getUsername() : "");
?>
<span class="label <?php if($isPM) echo "label-primary chat pm"; else echo "label-info chat"; ?>" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"><?= $typeDisplayName ?></span>
<span class="black"><?= $involved; ?>:</span> <?= $message->getMessage(); ?>
<?php if ($message != end($messages)){ // Don't break on the last element ?>
<br>
<?php } ?>
<br>
<?php } ?>
<?php endforeach; ?>
</div>
</div>
@ -287,7 +288,12 @@ function removeBadCharacters($input)
<span class="label label-pill label-default"><?= $time ?></span><br>
<span class="label label-pill label-success">Reported by <?= $reportersString ?></span><br>
<span class="label label-pill label-danger">Suspect is <?= $report->getSuspect()->getUsername() ?></span><br>
<span class="label label-pill label-warning">Staff Member assigned is TODO</span><br><!-- TODO -->
<span class="label label-pill label-warning">
<?php
$handler = $report->getHandler();
echo $handler != null ? "Staff Member assigned is " . $handler->getUsername() : "No Staff Member assigned";
?>
</span><br><!-- TODO -->
</div>
</div>
<br>
@ -297,7 +303,7 @@ function removeBadCharacters($input)
<?php foreach($snapshot->getPlayers() as $player): ?>
<img src="http://cravatar.eu/avatar/<?= $player->getUUID() ?>/55.png" class="pull-left" />
&nbsp;&nbsp;<b class="name"><?= $player->getUsername() ?></b> <span class="label label-staff name">TODO</span><br> <!-- TODO -->
&nbsp;<code style="font-size: 11px;"><?= $player->getUUID() ?></code>
&nbsp;<code style="font-size: 11px;"><?= $player->getUUID() ?></code>
<br><br>
<?php endforeach; ?>
</div>