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

View File

@ -60,9 +60,10 @@ function toReport($reportData, $players)
{ {
$id = $reportData["id"]; $id = $reportData["id"];
$serverName = $reportData["serverName"]; $serverName = $reportData["serverName"];
$handler = array_key_exists("handler", $reportData) ? getPlayer($players, $reportData["handler"]) : null;
$suspect = getPlayer($players, $reportData["suspect"]); $suspect = getPlayer($players, $reportData["suspect"]);
$reporters = toReporters($players, $reportData["reporters"]); $reporters = toReporters($players, $reportData["reporters"]);
return new Report($id, $serverName, $suspect, $reporters); return new Report($id, $serverName, $handler, $suspect, $reporters);
} }
/** /**
@ -287,7 +288,12 @@ function removeBadCharacters($input)
<span class="label label-pill label-default"><?= $time ?></span><br> <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-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-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>
</div> </div>
<br> <br>