monitoring/security: Hide delete comment action if user lacks the respective permission

This commit is contained in:
Eric Lippmann 2015-01-22 17:33:20 +01:00
parent 4226f06d5d
commit a19c155d9f
2 changed files with 7 additions and 6 deletions

View File

@ -34,10 +34,6 @@ foreach ($object->comments as $comment) {
$this->escape($comment->comment)
) : $this->escape($comment->comment);
$form = clone $delCommentForm;
$form->populate(array('comment_id' => $comment->id));
?>
<tr>
@ -46,7 +42,12 @@ foreach ($object->comments as $comment) {
<table>
<tr>
<td style="vertical-align: top;" data-base-target="_self">
<?= $form ?> (<?= ucfirst($comment->type) ?>):
<?php if (isset($delCommentForm)) { // Form is unset if the current user lacks the respective permission
$form = clone $delCommentForm;
$form->populate(array('comment_id' => $comment->id));
echo $form;
} ?>
(<?= ucfirst($comment->type) ?>):
</td>
<td style="padding-left: .5em;">
<?= str_replace(array('\r\n', '\n'), '<br>', $text) ?>

View File

@ -72,7 +72,7 @@ abstract class MonitoredObjectController extends Controller
}
}
}
if (count($this->object->comments) > 0) {
if (count($this->object->comments) > 0 && $auth->hasPermission('monitoring/command/comment/delete')) {
$delCommentForm = new DeleteCommentCommandForm();
$delCommentForm
->setObjects($this->object)