Skip to content

Commit fafda98

Browse files
committed
Fix some minor bugs
- Events not found are now handled and return HTTP 404. - Referer link shown if possible.
1 parent 57adc63 commit fafda98

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

src/controllers/EventLog/View.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ public function &run( Router &$router, ViewMVC &$view, array &$args ) {
4444

4545
}
4646

47-
$view->render($model);
47+
$view->render( $model );
48+
49+
$model->_responseCode = (
50+
$model->acl_allowed ? (
51+
$model->event ? 200 : 404
52+
) : 403
53+
);
4854

49-
$model->_responseCode = ( $model->acl_allowed ? 200 : 403 );
5055
$model->_responseHeaders['Content-Type'] = $view->getMimeType();
5156
$model->_responseTTL = 0;
5257

src/models/EventLog/View.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
class View extends Model {
88

99
public $acl_allowed;
10+
public $id;
1011
public $event;
1112
public $user;
1213

src/templates/EventLog/View.phtml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ $object_user = (
3232
!is_null( $object_user_id ) ? new User( $object_user_id ) : null
3333
);
3434

35+
if ( !$object instanceof Event ) {
36+
$title = 'Event Not Found';
37+
$description = 'The event you tried to access could not be found.';
38+
}
39+
3540
$tpl_user = (
3641
is_null( $object_user ) ? '<em>(null)</em>' :
3742
'<a href="' . $object_user->getURI() . '"><img class="avatar" src="' .
@@ -49,7 +54,7 @@ $tpl_metadata = (
4954

5055
$tpl_referer = getenv( 'HTTP_REFERER' );
5156
if ( !empty( $tpl_referer )) {
52-
$tpl_referer = '<hr/><a href="' . filter_var(
57+
$tpl_referer = '<a href="' . filter_var(
5358
$tpl_referer, FILTER_SANITIZE_FULL_SPECIAL_CHARS
5459
) . '">&lt;&lt; Back to Previous</a>';
5560
}
@@ -64,11 +69,19 @@ $this->additional_css[] = '/a/forms.css';
6469
require('./header.inc.phtml');
6570
?>
6671
<article>
67-
<?php if (!$this->getContext()->acl_allowed) { ?>
72+
<?php if ( !$this->getContext()->acl_allowed ) { ?>
6873
<header class="red"><?php echo $title; ?></header>
6974
<section class="red">
7075
<p>You are not authorized to view this page.</p>
7176
</section>
77+
<?php } else if ( is_null( $object )) { $title = 'Event Not Found' ?>
78+
<header class="red"><?php echo $title; ?></header>
79+
<section class="red">
80+
<p><?php echo $description; ?></p>
81+
<?php if ( !empty( $tpl_referer )) { ?>
82+
<p><?php echo $tpl_referer; ?></p>
83+
<?php } ?>
84+
</section>
7285
<?php } else { ?>
7386
<header><?php echo $title; ?></header>
7487
<section>
@@ -81,7 +94,10 @@ require('./header.inc.phtml');
8194
<tr><th class="right">User Account</th><td><?php echo $tpl_user; ?></td></tr>
8295
<tr><th class="right" style="vertical-align:top;">Metadata</th><td><?php echo $tpl_metadata; ?></td></tr>
8396
</tbody>
84-
</table><?php echo $tpl_referer; ?>
97+
</table>
98+
<?php if ( !empty( $tpl_referer )) { ?>
99+
<hr/><p><?php echo $tpl_referer; ?></p>
100+
<?php } ?>
85101
</section>
86102
</article>
87103
<?php } ?>

0 commit comments

Comments
 (0)