chg: [internal] Cosmetic code changes

pull/8188/head
Jakub Onderka 2022-03-03 15:59:25 +01:00
parent 09877c33f8
commit d51c052b3f
3 changed files with 42 additions and 50 deletions

View File

@ -3,6 +3,7 @@ App::uses('AppModel', 'Model');
/**
* @property EventTag $EventTag
* @property User $User
* @property AttributeTag $AttributeTag
* @property FavouriteTag $FavouriteTag
* @property Organisation $Organisation

View File

@ -15,13 +15,13 @@
</ul>
</div>
<?php
$filterParamsString = array();
$filterParamsString = [];
foreach ($passedArgsArray as $k => $v) {
$filterParamsString[] = sprintf(
'%s: %s',
h(ucfirst($k)),
h($v)
);
$filterParamsString[] = sprintf(
'%s: %s',
h(ucfirst($k)),
h($v)
);
}
$filterParamsString = implode(' & ', $filterParamsString);
$data = array(
@ -40,7 +40,7 @@
array(
'children' => array(
array(
'requirement' => count($passedArgsArray) > 0,
'requirement' => !empty($passedArgsArray),
'html' => sprintf(
'<span class="bold">%s</span>: %s',
__('Filters'),
@ -48,7 +48,7 @@
)
),
array(
'requirement' => count($passedArgsArray) > 0,
'requirement' => !empty($passedArgsArray),
'url' => $baseurl . '/servers/previewIndex/' . h($server['Server']['id']),
'title' => __('Remove filters'),
'fa-icon' => 'times'
@ -85,7 +85,7 @@
<?php
endif;
?>
<th><?php echo $this->Paginator->sort('id', null, array('direction' => 'desc'));?></th>
<th><?php echo $this->Paginator->sort('id', __('ID'), array('direction' => 'desc'));?></th>
<?php if (Configure::read('MISP.tagging')): ?>
<th class="filter"><?php echo __('Tags');?></th>
<?php endif; ?>
@ -100,35 +100,29 @@
<?php echo $this->Paginator->sort('distribution');?>
</th>
<th class="actions"><?php echo __('Actions');?></th>
</tr>
<?php if (!empty($events)) foreach ($events as $event): ?>
<tr <?php if ($event['Event']['distribution'] == 0) echo 'class = "privateRed"'?>>
<td class="short" ondblclick="document.location.href ='<?php echo $eventViewURL . h($event['Event']['id']);?>'">
<span class="icon-<?php echo ($event['Event']['published'] == 1) ? 'ok' : 'remove'; ?>" title="<?php echo __('Published');?>" aria-label="<?php echo __('Event ') . ($event['Event']['published'] == 1) ? '' : __('not ') . __('published'); ?>"></span>
<tr<?php if ($event['Event']['distribution'] == 0) echo ' class="privateRed"'?>>
<td class="short dblclickElement">
<span class="icon-<?= $event['Event']['published'] == 1 ? 'ok' : 'remove'; ?>" title="<?php echo __('Published');?>" aria-label="<?php echo __('Event ') . ($event['Event']['published'] == 1) ? '' : __('not ') . __('published'); ?>"></span>
</td>
<td class="short" ondblclick="document.location.href ='<?php echo $eventViewURL . h($event['Event']['id']);?>'">
<?php
echo h($event['Event']['Orgc']['name']);
?>
&nbsp;
<td class="short dblclickElement">
<?= h($event['Event']['Orgc']['name']); ?>
</td>
<td class="short" ondblclick="document.location.href ='<?php echo $eventViewURL . h($event['Event']['id']);?>'">
<?php
echo h($event['Event']['Org']['name']);
?>
&nbsp;
<td class="short dblclickElement">
<?= h($event['Event']['Org']['name']); ?>
</td>
<td style="width:30px;" ondblclick="document.location.href ='<?php echo $eventViewURL . h($event['Event']['id']);?>'">
<a href='<?php echo $eventViewURL . h($event['Event']['id']);?>'><?php echo $event['Event']['id'];?></a>
<td style="width:30px;" class="dblclickElement">
<a href="<?php echo $eventViewURL . h($event['Event']['id']);?>" class="dblclickActionElement"><?php echo $event['Event']['id'];?></a>
</td>
<?php if (Configure::read('MISP.tagging')): ?>
<td style = "max-width: 200px;width:10px;">
<td style="max-width: 200px;width:10px;">
<?php foreach ($event['Event']['EventTag'] as $tag):
if (empty($tag['Tag'])) continue;
$tagText = "";
if (Configure::read('MISP.full_tags_on_event_index') == 1) $tagText = $tag['Tag']['name'];
else if (Configure::read('MISP.full_tags_on_event_index') == 2) {
if (Configure::read('MISP.full_tags_on_event_index') == 1) {
$tagText = $tag['Tag']['name'];
} else if (Configure::read('MISP.full_tags_on_event_index') == 2) {
if (strpos($tag['Tag']['name'], '=')) {
$tagText = explode('=', $tag['Tag']['name']);
$tagText = h(trim(end($tagText), "\""));
@ -136,28 +130,26 @@
else $tagText = $tag['Tag']['name'];
}
?>
<span class=tag style="margin-bottom:3px;background-color:<?php echo h($tag['Tag']['colour']);?>;color:<?php echo $this->TextColour->getTextColour($tag['Tag']['colour']);?>;" title="<?php echo h($tag['Tag']['name']); ?>"><?php echo h($tagText); ?>&nbsp;</span>
<span class=tag style="margin-bottom:3px;background-color:<?= h($tag['Tag']['colour']);?>;color:<?= $this->TextColour->getTextColour($tag['Tag']['colour']);?>;" title="<?= h($tag['Tag']['name']); ?>"><?= h($tagText); ?></span>
<?php endforeach; ?>
</td>
<?php endif; ?>
<td style="width:30px;" ondblclick="document.location.href ='<?php echo $eventViewURL . h($event['Event']['id']);?>'">
<?php echo $event['Event']['attribute_count']; ?>&nbsp;
<td style="width:30px;" class="dblclickElement">
<?php echo $event['Event']['attribute_count']; ?>
</td>
<td class="short" ondblclick="document.location.href ='<?php echo $eventViewURL . h($event['Event']['id']);?>'">
<?php echo $event['Event']['date']; ?>&nbsp;
<td class="short dblclickElement">
<?php echo $event['Event']['date']; ?>
</td>
<td class="short" ondblclick="document.location.href ='<?php echo $eventViewURL . h($event['Event']['id']);?>'">
<?php
echo h($threatLevels[$event['Event']['threat_level_id']]);
?>&nbsp;
<td class="short dblclickElement">
<?= h($threatLevels[$event['Event']['threat_level_id']]); ?>
</td>
<td class="short" ondblclick="document.location.href ='<?php echo $eventViewURL . h($event['Event']['id']);?>'">
<?php echo $analysisLevels[$event['Event']['analysis']]; ?>&nbsp;
<td class="short dblclickElement">
<?php echo $analysisLevels[$event['Event']['analysis']]; ?>
</td>
<td ondblclick="document.location.href ='<?php echo $eventViewURL . h($event['Event']['id']);?>'">
<?php echo nl2br(h($event['Event']['info'])); ?>&nbsp;
<td class="dblclickElement">
<?php echo nl2br(h($event['Event']['info'])); ?>
</td>
<td class="short <?php if ($event['Event']['distribution'] == 0) echo 'privateRedText';?>" ondblclick="document.location.href ='<?php echo $eventViewURL . h($event['Event']['id']);?>'" title = "<?php echo $event['Event']['distribution'] != 3 ? $distributionLevels[$event['Event']['distribution']] : 'All';?>">
<td class="short dblclickElement <?php if ($event['Event']['distribution'] == 0) echo 'privateRedText';?>" title="<?php echo $event['Event']['distribution'] != 3 ? $distributionLevels[$event['Event']['distribution']] : 'All';?>">
<?php if ($event['Event']['distribution'] == 4):?>
<?php echo h($event['Event']['SharingGroup']['name']);?>
<?php else:
@ -167,16 +159,15 @@
</td>
<td class="short action-links">
<?php if ($event['Event']['published']) echo $this->Form->postLink('', $baseurl . '/servers/pull/' . $server['Server']['id'] . '/' . $event['Event']['id'], array('class' => 'fa fa-arrow-circle-down', 'title' => __('Fetch the event')), __('Are you sure you want to fetch and save this event on your instance?', $this->Form->value('Server.id'))); ?>
<a href='<?php echo $eventViewURL . h($event['Event']['id']);?>' class = "fa fa-eye" title = "<?php echo __('View');?>"></a>
<a href="<?php echo $eventViewURL . h($event['Event']['id']);?>" class="fa fa-eye" title="<?php echo __('View');?>"></a>
</td>
</tr>
<?php endforeach; ?>
</table>
<p>
<?php
echo $this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}'),
'model' => 'Server',
<?= $this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}'),
'model' => 'Server',
));
?>
</p>
@ -192,7 +183,7 @@
</div>
<script type="text/javascript">
var passedArgsArray = <?php echo $passedArgs; ?>;
$(document).ready(function() {
$(function() {
$('#quickFilterButton').click(function() {
runIndexQuickFilter('<?php echo '/' . h($server['Server']['id']);?>');
});

View File

@ -21,7 +21,7 @@ echo $this->element('genericElements/Form/genericForm', [
[
'field' => 'user_id',
'label' => __('Restrict tagging to user'),
'options' => $users,
'options' => $isSiteAdmin ? $users : null,
'type' => 'dropdown',
'requirements' => $isSiteAdmin,
],
@ -54,4 +54,4 @@ if (!$ajax) {
$(function() {
$('#TagColour').colorpicker();
});
</script>
</script>