Improve handling of circumstances whereby a report exists but no

corresponding chatsnap log on chatsnap site
This commit is contained in:
Keir Nellyer 2016-10-05 15:31:46 +01:00
parent c462282632
commit e6bb0c2d78

View File

@ -356,12 +356,13 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
}
$validId = isset($_GET['id']);
$idError = "";
$errorMsg = "";
$id = null;
$expanded = null;
$report = null;
$snapshot = null;
$messages = null;
if ($validId)
{
@ -372,11 +373,20 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
if ($report)
{
$snapshot = $report->getSnapshot();
if ($snapshot != null)
{
$messages = $snapshot->getMessages();
}
else
{
$errorMsg = 'No associated snapshot found for report.';
}
}
else
{
$validId = false;
$idError = "Invalid id.";
$errorMsg = "Invalid id.";
}
}
?>
@ -415,12 +425,15 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
</form>
</div>
<?php if (isset($_GET['id']) && !$validId && !empty($idError)): ?>
<?php if ((isset($_GET['id']) && !$validId) || !empty($errorMsg)): ?>
<div id="content" class="center-block" style="text-align: center; background-color: rgba(204, 34, 42, 0.52);">
<p class="error-oh-no" style="font-size: 60px;">What did you do?!?!?</p>
<img src="img/shaun.gif" />
<p class="error-oh-no" style="font-size: 40px;">Error: <?= $idError ?></p>
<br>
<?php if (!empty($errorMsg)): ?>
<p class="error-oh-no" style="font-size: 40px;">Error: <?= $errorMsg ?></p>
<br />
<?php endif; ?>
</div>
<?php else: ?>
<?php if (!isset($_GET['id'])) exit(); ?>
@ -440,9 +453,6 @@ WHERE snapshotMessageMap.snapshotId = snapshots.id
<div id="log">
<?php
// INITIALIZE
// Get messages and the amount that we are going to display
$messages = $snapshot->getMessages();
$messageCount = count($messages);
$displayAmount = $expanded || $messageCount <= collapsedMessageCount ? $messageCount : collapsedMessageCount;