Changes to the attributes

- attributes in the event view now show the date when they were added / modified

- the alert e-mail now shows which attributes are new since the last commit
pull/217/head
iglocska 2014-01-13 11:39:35 +01:00
parent 5fa7759e40
commit 2114f55ddd
3 changed files with 27 additions and 6 deletions

View File

@ -921,7 +921,7 @@ class EventsController extends AppController {
if ($this->request->is('post') || $this->request->is('put')) {
// Performs all the actions required to publish an event
$result = $this->Event->publish($id);
if (Configure::read('MISP.background_jobs')) {
if (!Configure::read('MISP.background_jobs')) {
if (!is_array($result)) {
// redirect to the view event page
$this->Session->setFlash(__('Event published, but NO mail sent to any participants.', true));

View File

@ -861,7 +861,7 @@ class Event extends AppModel {
// $conditions['AND'][] = array('Event.published =' => 1);
// do not expose all the data ...
$fields = array('Event.id', 'Event.org', 'Event.date', 'Event.threat_level_id', 'Event.info', 'Event.published', 'Event.uuid', 'Event.attribute_count', 'Event.analysis', 'Event.timestamp', 'Event.distribution', 'Event.proposal_email_lock', 'Event.orgc', 'Event.user_id', 'Event.locked');
$fields = array('Event.id', 'Event.org', 'Event.date', 'Event.threat_level_id', 'Event.info', 'Event.published', 'Event.uuid', 'Event.attribute_count', 'Event.analysis', 'Event.timestamp', 'Event.distribution', 'Event.proposal_email_lock', 'Event.orgc', 'Event.user_id', 'Event.locked', 'Event.publish_timestamp');
$fieldsAtt = array('Attribute.id', 'Attribute.type', 'Attribute.category', 'Attribute.value', 'Attribute.to_ids', 'Attribute.uuid', 'Attribute.event_id', 'Attribute.distribution', 'Attribute.timestamp', 'Attribute.comment');
$fieldsShadowAtt = array('ShadowAttribute.id', 'ShadowAttribute.type', 'ShadowAttribute.category', 'ShadowAttribute.value', 'ShadowAttribute.to_ids', 'ShadowAttribute.uuid', 'ShadowAttribute.event_id', 'ShadowAttribute.old_id', 'ShadowAttribute.comment', 'ShadowAttribute.org');
@ -1033,10 +1033,13 @@ class Event extends AppModel {
}
$body .= 'Attributes :' . "\n";
$bodyTempOther = "";
if (isset($event['Attribute'])) {
foreach ($event['Attribute'] as &$attribute) {
$line = '- ' . $attribute['type'] . str_repeat(' ', $appendlen - 2 - strlen($attribute['type'])) . ': ' . $attribute['value'] . "\n";
if (isset($event['Event']['publish_timestamp']) && isset($attribute['timestamp']) && $attribute['timestamp'] > $event['Event']['publish_timestamp']) {
$line = '(NEW!)- ' . $attribute['type'] . str_repeat(' ', $appendlen - 2 - strlen($attribute['type'])) . ': ' . $attribute['value'] ."\n";
} else {
$line = '- ' . $attribute['type'] . str_repeat(' ', $appendlen - 2 - strlen($attribute['type'])) . ': ' . $attribute['value'] . "\n";
}
if ('other' == $attribute['type']) // append the 'other' attribute types to the bottom.
$bodyTempOther .= $line;
else $body .= $line;
@ -1470,8 +1473,9 @@ class Event extends AppModel {
$this->recursive = 0;
$event = $this->read(null, $id);
// update the DB to set the published flag
$fieldList = array('published', 'id', 'info');
$fieldList = array('published', 'id', 'info', 'publish_timestamp');
$event['Event']['published'] = 1;
$event['Event']['publish_timestamp'] = time();
$this->save($event, array('fieldList' => $fieldList));
$uploaded = false;
if ('true' == Configure::read('CyDefSIG.sync') && $event['Event']['distribution'] > 1) {

View File

@ -6,7 +6,6 @@ $mayPublish = ($isAclPublish && $event['Event']['orgc'] == $me['org']);
echo $this->element('side_menu', array('menuList' => 'event', 'menuItem' => 'viewEvent', 'mayModify' => $mayModify, 'mayPublish' => $mayPublish));
?>
<div class="events view">
<?php
@ -134,6 +133,7 @@ $mayPublish = ($isAclPublish && $event['Event']['orgc'] == $me['org']);
if (!empty($event['Attribute'])):?>
<table class="table table-striped table-condensed">
<tr>
<th>Date</th>
<th>Category</th>
<th>Type</th>
<th>Value</th>
@ -151,6 +151,12 @@ if (!empty($event['Attribute'])):?>
if (count($attribute['ShadowAttribute'])) $extra .= 'highlight1';
?>
<tr>
<td class= "short <?php echo $extra; ?>">
<?php
if (isset($attribute['timestamp'])) echo date('Y-m-d', $attribute['timestamp']);
else echo '&nbsp';
?>
</td>
<?php if($first): ?>
<td class= "short <?php echo $extra; ?>" title="<?php if('' != $attribute['category']) echo $categoryDefinitions[$attribute['category']]['desc'];?>">
<?php
@ -249,6 +255,12 @@ if (!empty($event['Attribute'])):?>
$extra = 'highlight2';
foreach ($attribute['ShadowAttribute'] as $shadowAttribute): ?>
<tr class="highlight2">
<td class= "short <?php echo $extra; ?>">
<?php
if (isset($event['Event']['publish_timestamp'])) echo date('Y-m-d', $shadowAttribute['timestamp']);
else echo '&nbsp';
?>
</td>
<td class="short highlight2" title="
<?php if('' != $shadowAttribute['category']) echo $categoryDefinitions[$shadowAttribute['category']]['desc'];?>
">
@ -333,6 +345,11 @@ if (!empty($event['Attribute'])):?>
//if ($remain === end($remaining)) $extra .= ' highlightBottom';
?>
<tr class="highlight2">
<td class= "short <?php echo $extra; ?>">
<?php
echo '&nbsp';
?>
</td>
<td class="highlight2" title="<?php if('' != $remain['category']) echo $categoryDefinitions[$remain['category']]['desc'];?>">
<?php
echo h($remain['category']);